Sign in to follow this  

HLSL fragments VS techniques and globals (Update)

This topic is 4194 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am perusing the FragmentLinker sample program in the SDK. So, although I can see this method being good for situations where you have a LOT of possible combinations of vertex and pixel shaders that you would want to make available for a game, I don't see how this would end up being different than puting the various vertex and pixel shader functions into a .fx file and then creating techniques to select which vertex and pixel function to use for various effects if you don't have a huge number of them. One thing I cannot figure out is if it is possible to have different globals defined for different techniques or fragments. Like lets say I want to have the following only used when I am rendering a skinned mesh: uniform extern float4x4 g_BonePalette[40]; uniform extern int g_NumBones; and only the following when rendering with shader instancing: uniform extern float3 g_InstancCol1[30]; uniform extern float3 g_InstancCol2[30]; uniform extern float3 g_InstancCol3[30]; uniform extern float4 g_InstancColor[30]; There doesn't seem to be a way to have these globals only get put into constants on the graphic card when I am using a certain technique or shader fragment. Since my effect file currently supports unskinned meshes with just the usual position/normal/texture0 vertex elements, I would like to not have the above globals use up space when rendering them. Would the only way to solve this be to have separate effect.fx files for such situations? As I add effects options to my mesh modeling program, the number of uniform globals needed will grow. So, I am thinking now that I need to figure out how to manage this. Thanks for any info you have on this. [Edited by - DXnut on June 20, 2006 11:04:25 PM]

Share this post


Link to post
Share on other sites
I now have three separate .fx files. One for nonskinned meshes, 1 for skinned, and 1 more for doing instancing. I am only using the first two now. Instead of having one technique with 8 passes, I now have a different technique defined that would be used for one subset draw. So, I have techniques now for the combinations of Blinn or Phong lighting with the three possible texture modes wrap/clamp/mirror.

For skinned meshes I am using around 188 constant registers for the global data. My ATI X800 XT says it can handle 256 in the D3DCAPS9 structure. I have no idea what other cards that support VS_2_0 and PS_2_0 can do. It must be really hard to design a shader not knowing how many constants you can use and support all the graphics cards.

I think it is slower now than it was when I did the same thing with multiple passes instead of techniques. So the Begin and SetTechnique instructions must be expensive, whereas doing many BeginPass calls is not.

Also, it is not working for skinned meshes. So, I am now wondering if setting the bone palette array before the Begin statement works. Does the setting of global constants survive a Begin or SetTechnique call? Or should the setting of globals always be done between the Begin/End calls?

TIA

Share this post


Link to post
Share on other sites

This topic is 4194 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this