Sign in to follow this  
littlekid

Small Shader Question

Recommended Posts

I have just recently started on to shaders. In the fixed pipeling, before rendering, we always, specify the material, lighting, vertex buffer, index buffer, then we render. However how do i specify the material and lighting in a shader. As in is there a way to write the material and shader into the shader, or must i use the D3DMATERIAL9 structure and D3DLIGHT9 structure.

Share this post


Link to post
Share on other sites
Materials and lighting parameters are passed to the shader by means of setting a number of constants. These constants are basically global variables inside the shader. You can set them by using either the ID3DXEffect::Set* methods or the ID3DXConstantTable::Set* methods.

Take a look at the BasicHLSL sample that comes with the SDK. It shows how to set a number of shader constants and render a model

neneboricua

Share this post


Link to post
Share on other sites
The bottom line to using the new shader models is that you aren't in a realm where D3D is doing anything for you any more. You have to understand matrix/vector math in order to get your lighting working properly. However, the flip side to this is that you have an extreme amount of flexibility in how you want things to render - simply code the lighting/shading/rendering model that you want. Considerations for the target hardware become very important, as you can lose entire shader effects and must provide fallbacks if the hardware doesn't support what you want, ideally.

- Pfhoenix

Share this post


Link to post
Share on other sites

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