XNA Game Development Forums
2012/05/21 20:45:33 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Playing with lighting : intermediate shader techniques?  (Read 2308 times)
5parrowhawk
Newbie
*
Offline Offline

Posts: 7


View Profile
« on: 2009/01/29 18:14:37 »

Hi all,

(1) I just started implementing a dynamic lighting solution in my modified engine, and things are getting messy. I'm attempting to target SM2.0, but the dynamic FOR loop controlling the lighting solution spits out way too many instructions and uses up too many constant registers, even when I try to limit the number of lights to 3 or 4. It doesn't help that the vertex program in the same shader also uses a FOR loop, this time for bone transformations. (That one is a fixed, unrollable one though.)

I hear that most people do it by running multiple lighting passes with a couple of lights in each pass: how does that work? Anyone got sample code? And how would that interact with Mike's solution of doing 2 passes to render alpha'd objects?

Is there a way to convert HLSL to assembly and then hand-optimize it, using the standard XNA dev toolkit? I'm not sure how to do that.

Or should I just say "screw it" and target SM3.0 instead?

(2) An idea just came to mind. Would it be possible to implement a "ghetto" radiosity solution for small scenes by using the following technique?

- render the entire scene (a box containing all objects) to a 3D monochrome texture, where 1 indicates the point is outside an object and 2 indicates it's inside
- perform a post-processing blur and brightening on the 3D texture
- apply the texture to all the scene objects as a lightmap

Has anyone already tried this, and what was the performance like? (Is it even possible to do a volumetric-ish rendering like the one described above?)

Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #1 on: 2009/02/16 11:34:28 »

The volumetricish lighting you mentioned seems pretty interesting as a possible solution. Have you tried it yet? If so, how did it turn out?
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #2 on: 2009/02/17 05:08:47 »

DaphydTheBard has been doing some funky stuff like that in his Anarchy engine, will see if he can come on here and explain what he is doing..
Logged
Chr0n1x
Global Moderator
Sr. Member
*****
Offline Offline

Posts: 307


View Profile WWW
« Reply #3 on: 2009/03/18 23:04:27 »

Sorry for the late reply, if you want to go for more than a couple of lights and still keep performance, you want to look into Deferred Shading. This (when implemented correctly) allows you to have an extremely high number of dynamic lights in the scene, and you only have to draw the scene once, because the lighting is done as a post-processing effect.

It currently is a popular topic at the moment, so there should be no shortage of resources on it and improvements. This is what DaphydTheBard has been doing in fact.

You can convert HLSL to assembly using fxc.exe which comes with XNA and the DirectX SDK, however not sure if you can put that assembly code back into the content pipeline. I have noticed that fxc generates pretty efficient code, so make sure you unroll your appropriate loops or simplify your lighting model. You in general cannot do over 3 lights per pass before you kill your framerate. Multipass lighting is a solution, or you can bake static lighting into a lightmap and apply that when rendering.
Logged

Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Shader compiler General Discussion endre 2 2368 Last post 2006/08/12 01:24:40
by Chr0n1x
Shader implemented fixed function Hazy Mind XNA Engine mikeschuld 2 2359 Last post 2006/11/07 02:07:22
by mikeschuld
Shader tutorials General Discussion endre 2 2242 Last post 2006/12/22 18:12:48
by mikeschuld
My Shader Hell... General Discussion « 1 2 » Nemo Krad 17 5368 Last post 2007/02/09 21:12:14
by Chr0n1x
What's wrong with my shader? :'( Hazy Mind XNA Engine EclipsE 6 2640 Last post 2007/03/06 15:43:17
by EclipsE
Bumpmap Shader General Discussion « 1 2 3 4 5 » Nemo Krad 70 21691 Last post 2007/09/06 13:15:22
by Nemo Krad
Point Light Shader General Discussion Nemo Krad 0 2040 Last post 2007/03/18 07:18:13
by Nemo Krad
Model & Shader Problems Hazy Mind XNA Engine Themodem 5 2070 Last post 2007/03/26 11:12:53
by Tiago
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.107 seconds with 18 queries.