Jump to content
  • Advertisement
Sign in to follow this  
Axiverse

Lighting + Shaders

This topic is 4651 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

In an engine that is based solely on shaders, does the IDirect3DDevice9::SetLight method serve any function, or do you have to implement lighting in your shaders and put light parameters in shader variables?

Share this post


Link to post
Share on other sites
Advertisement
You'll have to implement your own lighting in shaders. The SetLight function is only for the fixed function pipeline. If you're using shaders, you need to implement lighting inside the shaders.

neneboricua

Share this post


Link to post
Share on other sites
You actually answered your own questions. [grin]
SetLight() is a fixed function method, so it does not have any effect when using shaders, like you assumed. And yes, you have to implement your own lighting (either per-vertex or per-pixel).

EDIT: Beaten.

Share this post


Link to post
Share on other sites
Yes, matrices are still used, but you have to calculate transformations manually in vertex shaders. So you can't use IDirect3DDevice9::SetTransform() to do transformations.

EDIT: Beaten. Again.

Share this post


Link to post
Share on other sites
What do you mean calculate? Do you mean move from model space to view space? And do i have to use the setshaderconsts to pass matricies or can the shader retrieve matricies that i pass through settransform?

Share this post


Link to post
Share on other sites
If you use a purely shader driven system you will be using NOTHING in the fixed function pipeline. So no, shaders can not retrieve matricies from SetTransform. You have to use SetShaderConstants (for assembly shaders... I'd say use HLSL) or set an effect parameter on an HLSL shader using the D3DX framework.

Share this post


Link to post
Share on other sites
So, in effect, you can use less matricies then before (256 world matricies in fixed), only 256 floats in vertex shader... = 16 matricies..., and that is without any lights or anything!?

Share this post


Link to post
Share on other sites
Quote:
Original post by Axiverse
So, in effect, you can use less matricies then before (256 world matricies in fixed), only 256 floats in vertex shader... = 16 matricies..., and that is without any lights or anything!?

Not quite. This depends on the capabilites of the particular graphics card. If you're refering to vertex blending (i.e. skinning), the maximum number of matrices that can be handled by the fixed function pipeline is specified by the "MaxVertexBlendMatrixIndex" member of the D3DCAPS9 structure. The value is 256 when software vertex processing is used. Otherwise, you have to check this value. For example, the value of this cap on the Radeon 9800XT that I have at home is only 37.

Now compare that to a graphics card which supports the vertex shader 2.0 spec (like the previously mentioned Radeon 9800XT). A card with that supports this shader spec can handle at least 256 floating-point constant registers. Each register contains 4 floating point variables. If you were to store 4x4 matrices, you could store 64 matrices in the shader constants.

neneboricua

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!