Integrating Shaders

Started by
3 comments, last by Direct 19 years, 11 months ago
I''ve found a large number of resources on writing vertex and pixel shaders, but most seem to be ''load up rendermonkey, do this and start playing around...'' At the moment I am attempting to edit our current engine to use shaders in order to give everyone more flexibility...so, I have a standard fixed function pipeline current, and my question is...where do I fit it all in. How do I integrate effect files (since they seem to be a boon to the process) with the rest of it? Currently the engine defines lights with the fixed function pipeline...do I yank this out entirely and use some kind of light structure of my own and feed this into the shaders somehow for the lighting passes? How do you deal with needing an unknown number of lights to be handled at any given frame, when you have to specify the inputs? Basically, how much do I chuck and how does one go about taking a fixed function pipeline and turning it into a programmable one? And...is it possible to allow for the fixed function pipeline to be used for some things in order to better ease the transition?
David Clifton
Advertisement
You can switch back and forth without much of an issue (just check any of the SDK demos that have text on screen; they use FVF for the text rendering).

The rest is a bit more complex.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

Here is a great thread on the topic. If you aren''t already, try out using the ID3DXEffect interface.

As far as the light issue goes, you can simply set each light structure using ID3DXEffect::SetValue(). Also, the number of lights you''re dealing with should not be unknown. You should have a maximum limit (ie 8) active lights at a time. Actually, HL2 only uses the 2 closest lights for dynamic lighting (it does use additional sources, though). Then, just set an integer constant in the shader for how many lights are currently activated.

This is a pretty tough subject, but it''s good you''re dealing with it now. Eventually, the FFP will be completely phased out, and you will need to know this.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Thanks for the responses, I''ll review the thread you mentioned.
David Clifton
I gave that thread a read...I feel that I''ll probably need to give it far more than one to truly understand all of the concepts, however...it was obviously generalized to other possible rendering schemes. I noticed some of the functionality implemented in the proposed system is already encapsulated in the effect framework from DirectX, like handling multiple passes to achieve the effect class, and associating those passes with each other easily in the overall system. I think a hybrid of Yann''s approach, but making use of the facilities provided by the D3DX effect framework, will be pretty clean overall...
Thank you very much for your help.
David Clifton

This topic is closed to new replies.

Advertisement