   MRT and Shadow Mapping
  Hi,In relation to the architectural work in my journal, I've been contemplating how I might be able to take advantage of longer SM3 shaders to reduce the workload.A few important points:1. This is to be used in conjunction with HDRI2. Arbitrary number of lights - but point and directional only3. Basic shadow mapping - it's not the focus of the work I'm doing, just adding it  "because I can"...I've read a few articles about using SM3's longer shaders to allow for multiple lights to be rendered in a single pass. One of FarCry's patches (1.2?) implemented SM3 shaders simply as an optimization where it could reduce the number of drawing calls and general workload by combining multiple lights per pass.To get to the point... I was wondering if anyone here had any experience of combining MRT (Multiple Render Targets) in Direct3D9 with shadow mapping. From the caps database, it seem that SM3 hardware supports 4 MRT's - so I'm thinking it'd be possible to do 4 directional lights in one pass...BUT, I'm wondering if the only advantage is offloading it to the GPU and having 1 DIP() instead of 4 DIP() calls. The shader would still have to transform the geometry for each light source, and I've not found an answer to MRT's and multiple DST's.Anybody able to comment?Obviously, it makes my source code easier if I only use a lowest-common-denominator codepath [wink]Cheers,Jack   
  You mean generate the SMs for the directional lights in one pass? Hmm...I doubt that'd you be able to do that effectively because the same geometry is passed to each RT, from the same point of view. If you mean rendering the light result, including shadow term, into the scene, you'd be better off concatenating the 4 passes on the pixel shader into one large one (by taking advantage of SM3's longer instruction count). I certainly don't understand how using MRTs would be all that effective.For FC's SM3 implementation, the draw call reduction they did was in the form of instancing, i.e. rendering many bushes and trees that are identical but just have different world mats in a single DP/DIP call. Multiple lights were lumped together using the method I suggested above. One thing that they found, and is something you'll have to consider, is that proper looping in shaders can only be done on vertex inputs, not on constants. As a result, you'll need seperate shaders for n number of lights (they capped it at 4 I think).   ;  Thanks for the reply [smile]In light of what you've said I think I might have thought too much of D3D9's capabilities. Must be getting them confused with something else [headshake]I'll go back to my drawing board and work on my altogether more sensible, original, idea.Jack   ;  Hey Jack,Quote:Original post by jollyjeffersTo get to the point... I was wondering if anyone here had any experience of combining MRT (Multiple Render Targets) in Direct3D9 with shadow mapping. From the caps database, it seem that SM3 hardware supports 4 MRT's - so I'm thinking it'd be possible to do 4 directional lights in one pass...Note that SM2 hardware also supports 4 MRT's.  Whether or not those MRT's can be floating point targets is dependent on the actual hardware.Quote:Original post by jollyjeffersBUT, I'm wondering if the only advantage is offloading it to the GPU and having 1 DIP() instead of 4 DIP() calls. The shader would still have to transform the geometry for each light source, and I've not found an answer to MRT's and multiple DST's.My accronym deciphering skills aren't as good as I had hoped so I don't know what you mean by DST, but in any case, I believe main advantage to this would be just limiting the number of DIP calls.I attempted to do something similar to this on SM2 hardware and found that it was a better use of resources to do just a single pass per light and add up the results.  This was mainly due to instruction count limitations, however.neneboricua   ;  (sorry no help) but im wondering in what situation are u using 4 directional lights?   ;Quote:Note that SM2 hardware also supports 4 MRT's. Whether or not those MRT's can be floating point targets is dependent on the actual hardware.The GeForce 5 series cards don't support MRT.   ;Quote:Original post by Cypher19Quote:Note that SM2 hardware also supports 4 MRT's. Whether or not those MRT's can be floating point targets is dependent on the actual hardware.The GeForce 5 series cards don't support MRT.Ahh that's right.  They support MET's instead.  Forgot about that.  *sigh* the snafu that was the GeForceFX.  We'll all be dealing with that one for years to come, just like the GeForceMX cards...neneboricua   ;  Thanks for the posts everyone - greatly appreciated!Quote:Original post by neneboricua19Quote:Original post by Cypher19Quote:Note that SM2 hardware also supports 4 MRT's. Whether or not those MRT's can be floating point targets is dependent on the actual hardware.The GeForce 5 series cards don't support MRT.Ahh that's right.  They support MET's instead.  Forgot about that.  *sigh* the snafu that was the GeForceFX.  We'll all be dealing with that one for years to come, just like the GeForceMX cards...neneboricuaI'm just glad the Voodoo3's are gone now [lol] they were an absolute pain during early development of my engine (yes, it's that old).Cheers,Jack   