light processing should be done in vertex or pixel shader

Started by
4 comments, last by the_prodigy 10 years, 10 months ago

it is easy to be done in vertex shader

if done in pixel shader, i make vertex shader output 'TEXCOORD' including the normal and position info and then take it as the input of pixel shader, is this the standard way or any other way

Advertisement

If you want per-pixel lighting you have to do it in the pixel shader.

To do this you need at least the pixel normal and light direction vector for each light used. You can calculate the light vector if you pass position and have the light positions as a uniform, and you must pass the normal vector as input as well.

Yes, what you describe is the standard way.

If you want per-pixel lighting you have to do it in the pixel shader.

To do this you need at least the pixel normal and light direction vector for each light used. You can calculate the light vector if you pass position and have the light positions as a uniform, and you must pass the normal vector as input as well.

Yes, what you describe is the standard way.

it is strange pixel shader use 'TEXCOORD' for non-texture usage, why not define another general input semantics

If you want per-pixel lighting you have to do it in the pixel shader.

To do this you need at least the pixel normal and light direction vector for each light used. You can calculate the light vector if you pass position and have the light positions as a uniform, and you must pass the normal vector as input as well.

Yes, what you describe is the standard way.

it is strange pixel shader use 'TEXCOORD' for non-texture usage, why not define another general input semantics

In D3D9 you can't - you're stuck with the semantics defined by the API. Which is a slightly odd state of affairs, but no more odd than having to do the same in - say - ARB assembly (and remember that the original design of D3D9 dates to a similar time).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

If you want per-pixel lighting you have to do it in the pixel shader.

To do this you need at least the pixel normal and light direction vector for each light used. You can calculate the light vector if you pass position and have the light positions as a uniform, and you must pass the normal vector as input as well.

Yes, what you describe is the standard way.

by the way, what is per-pixel lighting, does it exactly mean processing light in pixel shader

i find doing this way does not need to subdivide vertex triangles any more, so cpu usage lowers a lot

Per pixel lightning mean that you calculate the light illumination per pixel and not f.e. like gourad shading does per vertex and interpolate the color across the triangle. The vertex shader is optimized for per vertex operations and the pixel shader is optimized for per pixel operations that's why it is more suitable to do the matrix calulations on the vertexshader and lightning on the pixel shader.

This topic is closed to new replies.

Advertisement