Welcome, Unregistered.

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.

Reply
Old 30-Oct-2008, 08:18   #1
vrmm
Junior Member
 
Join Date: Oct 2004
Posts: 25
Icon Frown can I bring the texture operation and fog ... into VS?

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!!!
vrmm is offline   Reply With Quote
Old 31-Oct-2008, 10:33   #2
sebbbi
Member
 
Join Date: Nov 2007
Posts: 996
Default

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)
sebbbi is offline   Reply With Quote
Old 02-Nov-2008, 06:15   #3
vrmm
Junior Member
 
Join Date: Oct 2004
Posts: 25
Default

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!
vrmm is offline   Reply With Quote
Old 03-Nov-2008, 12:05   #4
sebbbi
Member
 
Join Date: Nov 2007
Posts: 996
Default

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).
sebbbi is offline   Reply With Quote
Old 05-Nov-2008, 07:32   #5
vrmm
Junior Member
 
Join Date: Oct 2004
Posts: 25
Default

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!
vrmm is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:45.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.