[code] d3d effect (.fx shader) instances
category: general [glöplog]
hi! does anyone have some suggestions on how to best deal with several meshes sharing 1 shader? I see two alternatives:
1.) load the d3d effect file once, and when loading meshes use d3deffect->clone() and setting all runtime-invariant parameters (textures, constants, etc.). so at render-time i only have to set the non-constant parameters.
2.) instead of using clone() one could simply store a pointer to the loaded effect/shader. but then one has to set _all_ parameters (even most constant ones), most notably re-setting textures, everytime when rendering those meshes (each mesh can have different textures/parameters but use same shader)...
which one is faster/better?
thanks for your help!
1.) load the d3d effect file once, and when loading meshes use d3deffect->clone() and setting all runtime-invariant parameters (textures, constants, etc.). so at render-time i only have to set the non-constant parameters.
2.) instead of using clone() one could simply store a pointer to the loaded effect/shader. but then one has to set _all_ parameters (even most constant ones), most notably re-setting textures, everytime when rendering those meshes (each mesh can have different textures/parameters but use same shader)...
which one is faster/better?
thanks for your help!
You would have to set _all_ parameters every time you render something anyway. The only difference is that the effect framework may abstract this from you.