Jump to content

  • Log In with Google      Sign In   
  • Create Account


light processing should be done in vertex or pixel shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 17 June 2013 - 01:37 AM

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



Sponsor:

#2 Hornsj3   Members   -  Reputation: 191

Like
0Likes
Like

Posted 17 June 2013 - 03:48 AM

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.



#3 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 17 June 2013 - 05:57 AM

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



#4 mhagain   Crossbones+   -  Reputation: 7833

Like
0Likes
Like

Posted 17 June 2013 - 07:07 AM

 

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).


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 17 June 2013 - 08:12 AM

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



#6 the_prodigy   Members   -  Reputation: 346

Like
0Likes
Like

Posted 17 June 2013 - 09:39 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS