Jump to content
  • Advertisement
Sign in to follow this  
GhostAce

Shader pass over fixed pass in Cg.

This topic is 4833 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

Hello. I want to render object in two passes. First one is just a texture pass (without shaders) and second one has vertex and fragment program (lighting pass). My problem is that i see z-fighting artifacts. Is there a way to mix that passes so that there wouldn't be z-fight? I tried cgGLSetStateMatrixParameter and cgGLSetMatrixParameterfc with explicitly calculated ModelViewProj but the result is the same.

Share this post


Link to post
Share on other sites
Advertisement
I think for the second pass you just need to change your depth function for passing a fragment. Make sure it now includes equality.

Share this post


Link to post
Share on other sites
But thats the point. I already have equal depth func.
The problem is that fixed pipeline ModelViewProj transformation produces different output vertex position than my vertex program.

I think the reason lies in precision. I didn't see 'double4x4' in cg manual matrix type - so I have to use float4x4. I think opengl internal calculations are done on 'doubles', and that results in z-fighting.

any ideas?


Share this post


Link to post
Share on other sites
Make sure you are doing everything it mentions in the "Vertex Program Profiles - Position Invariance" section of the Cg spec. That is...
 - Compile the program with a proper compiler option indicating position invariance
- Compute the position as OUT_POSITION = mul(MVP, IN_POSITION)
For more info consult the spec. Hope that solves your problem.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!