cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

giuseppe500
Journeyman III

cg shader for lights

Hy.
I would create a light phong shader with more than one light in cg.
For each light , from 1 to 8 i must send to shader the position, direction , color ecc... via constant buffer.
I think to use a matrix for send to the shader what are the lights that are active
,and in the shader i have an if else chain for get the color of pixel for the corrispondent light and type of light.
Then I can disable/enable the light information , and send the information of the light to the shader only if exist(via costant buffer).

Is a good solution?
what advice to me if not?
thanks

0 Likes
1 Reply
pboudier
Staff

this should work  

branching in the HW is mostly free if you have enough work inside the condition; otherwise it is faster to just compute the value into a temporary and lerp it into the final variable.

regards,

Pierre B.

0 Likes