Jump to content
  • Advertisement
Sign in to follow this  
jdaniel

Vertex / Fragment Shader - Graphics Pipeline Question

This topic is 4463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a couple of questions regarding vertex and fragment programs and how they relate to the fixed function graphics pipeline in general. The first question is this: Is the Interpolator & Rasterizer expecting normalized device coordinates from the vertex shader. Stated differently, in a vertex shader that is mimicking the fixed function vertex path, should I be doing the perspective division inside the vertex shader or does the Interpolator take care of this? Here I do the perpective division in the vertex shader:
Out.Pos = mul( float4 (inPos, 1.f ), g_mWorldViewProj );
Out.Pos /= Out.Pos.w;
return Out;

Here I pass along the position without applying perspective divide:
Out.Pos = mul( float4 (inPos, 1.f ), g_mWorldViewProj );
return Out;

Which appropriately mimics the fixed function path? The second question has to do with the fragment shaders. Simply stated, is there an implicit depth value associated with a color output? What if I am using the default LESS_THAN depth test and I am only returning :COLOR in my shader? How does the raster operator update the pixel in the framebuffer? What depth would it use? for example, say I have depth testing turned on and I have a simple passthrough fragment shader:
void passthrough(float4 color : COLOR, out float4 ocolor: COLOR)
{
ocolor = color;
}   

What if there is already a pixel in the framebuffer with an associated depth? What happens to my depth test? Is there an implicit depth associated with fragments output from the fragment shader or must the programmer always explicitly output depth information along with fragment? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
1. The perspective divide is done for you.

2. Fragments can drive the depth test (ps1.4 upwards). If you do not output a depth from your shader program the already calculated depth will be used.

Hope that helps.

You can find out more with a simple google for 'shader pipeline'.

- Al

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!