If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
![]() |
|
|
#1 |
|
Junior Member
Join Date: Oct 2004
Posts: 25
|
Dear all,
I want to get each vertex's color combing with the vertex color itself, the texture color, the fog color, the light color..... As we knew, in the PS, we just find the fragment. We can not tell which fragment is the source vertex of the model. So, One way for this problem is to distincting each vertex's and other interpolating pixels in the PS and get the final color of each vertex. But how to do it??? Another method maybe to bring all the texture operation and fog.. blending into the VS. Is it feasible? Could anyone help me to solve this porblem? Thanks a lot!!! |
|
|
|
|
|
#2 |
|
Member
Join Date: Nov 2007
Posts: 996
|
Fog can be either calculated in vertex or pixel shader.
Fog calculation in vertex shader: - In vertex shader calculate distance from vertex to camera point (length of the vertex position vector when transformed to view space). - Calculate fog amount according to distance (subtract fog start distance, divide result by fog length) - Pass this value to the pixel shader, and the HW raster conversion smoothly interpolates the fog value for the whole triangle area. - In pixel shader lerp the final color with the fog color (using fog amount) Fog calculation in pixel shader: - In vertex shader calculate distance from vertex to camera point (length of the vertex position vector when transformed to view space). - Pass this value to the pixel shader, and the HW raster conversion smoothly interpolates the fog value for the whole triangle area. - In pixel shader calculate fog amount according to distance (subtract fog start distance, divide result by fog length) - Lerp the final color with the fog color (using fog amount) |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2004
Posts: 25
|
Thanks your reply! The fog can be caluated in the VS.
Unfortunately, to get the texture color of each vertex maybe not feasible. I have tried the "texture2D ()"" function in the vertex shader and it did not work actually. DO anyone have good idea about how to get the texture color in the VS ? I am eager to know the answer. Thanks in advance! |
|
|
|
|
|
#4 |
|
Member
Join Date: Nov 2007
Posts: 996
|
Better to store the vertex colors inside the vertex structure if you want to achieve vertex coloring. Sampling textures inside the vertex shader is not that fast and has limited texture format support (on all DirectX 9 hardware).
|
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Oct 2004
Posts: 25
|
Thanks!
I have tried the TEX2D() in the new machine with nvdia geforce 6.0 , fortuantely, it works. While I can get the vertex's texture color right now. However, I do not have idea to fetch it from VS and send to Opengl Application. Someone can give me good idea? THANKS! |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|