   SetRenderStage & Shader...
  Hi all,Sorry, maybe this is a stupid question, but i'm trying to really figuring out how shaders are working.I think i have once seen, (dont remember where, its make a while) that SetRenderState is "obsolete" when using shaders. And i think this is probably true since SetRenderState is for the Fixed Pipeline. (Correct me if im wrong)And if not, what are the methods that are made "obsolete" when using shaders. I know one: SetTextureStage. Probably others...Thanks all,Jonathan   
  There are two distinctions here. Using Shaders, and using the Effect Framework.For shaders, many of the renderstates still apply. For example, Z-buffering, Alpha-Blending, and Alpha-Testing occur when using shaders just as they would if you're not using them. The RenderStates associated with these would still apply.On the other hand, when you enable shaders, you disable parts of the pipeline that are only used in the FFP, such as lighting calculations. This means that the lighting states no longer have any effect. The call to SetRenderState still sets the state, it is just never used when drawing. If you later go back to the FFP, the setting will be used with the value set.On to the Effect Framework. This allows you to both compile and use HLSL shaders, as well as set RenderStates related to these shaders, in a single process. This means that the Effect Framework allows you to not need to use any SetRenderState calls. The calls still work, and if called after Effect.Begin would have the full effect you would expect them to. If you call Effect.Begin after the SetRenderState, it might be overriden, depending on which states are set in the .fx file.In any case, the call to SetRenderState is never "obsolete". As for SetTextureStage, this too is in fact changed, but doesn't have any effect. The call still changes the Texture Stage settings, it's just that these values are ignored while you use shaders. When you go back to using the FFP, these settings will resume their effectiveness.Hope this helps.   ;  Hummm, i will try to resume this to make sure i understand it properly.When using Shaders all not related FFP RenderState will still works as they are suppose to... All others will works (the call will not fail) but they will have no effect on the rendering until i switch back to using the FFP?For shaders, you said lighting calculations will not work... Are you talking about the SetLight method and/or the lighting related RenderState? Regarding this, when using shaders, i know i must pass the transform matrix as a parameter, its the same for the lights?For the effect framework, its seem to me that this is build on the top of shaders. So all the restrictions that applies to shaders still applies for the effect framework. Plus, since its a framework, .fx will take care about any RenderState even if they are not related to the FFP?I think this is it, thanks again,Jonathan   ;Quote:Original post by LowRadHummm, i will try to resume this to make sure i understand it properly.When using Shaders all not related FFP RenderState will still works as they are suppose to... All others will works (the call will not fail) but they will have no effect on the rendering until i switch back to using the FFP?Exactly.Quote:Original post by LowRadFor shaders, you said lighting calculations will not work... Are you talking about the SetLight method and/or the lighting related RenderState? Regarding this, when using shaders, i know i must pass the transform matrix as a parameter, its the same for the lights?When using shaders, all lighting calculations need to be done by the shader "manually". You'll need to write the code to do the lighting calculations, and you will need to pass in any light(s) by setting the values to global registers.The calls themselves, like with SetRenderState, still work, but have no effect on anything rendered in the Programmable Pipeline.As for the Effect Framework, it isn't specifically for shaders, though it is highly directed towards that use. It can be used with the FFP just the same, but it loses a lot of it's advantages, since most of the useful functionality doesn't apply.Lastly, the Effect Framework doesn't really take care of anything for you. Think of it this way, a part of an .FX file contains a list of renderstates and values that the effect requires. When you "Apply" the effect (by calling Effect.Begin and Effect.BeginPass), DX just goes through this list and calls SetRenderState for you. This would override anything previously set, but any setting that doesn't appear in the list will remain exactly what it was before.Hope this helps :).   ;Quote:Original post by sirobHope this helps :).Dont hope... ITS HELP :PThanks again! Its much more clear in my head now. Thanks for sharing your knowledge with me.Jonathan