Jump to content
  • Advertisement
Sign in to follow this  
coorn

Cg questions

This topic is 4815 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 have just started learning Cg. I have read a book on the subject and browsed a few tutorials. But there are some questions that I never get answered... 1. I assume that in a fragment program the pixel position on the screen is already calculated…? Is there a way to get this position inside the fragment program? And is there a way to get the color of the pixel stored in the frame buffer for this position? (the pixel we are about to overwrite) 2. How do I create image effects like heat haze and other pixel shifting effects on the GPU? 3. Is there a point rendering a surface in several passes with Cg? I have nerver seen a tutorial do this... What if you would like 20 projective textures on to a surface, then it has to be done in several passes right?

Share this post


Link to post
Share on other sites
Advertisement
1. You can output the 3D position as a texture coordinate from your vertex shader. This will give you the interpolated 3D positions at every pixel in your pixel shader program.

2. I think you are talking about refraction. The idea is simple. Compute view vector (say unit size). Project and calculate texture coordinates which you can use to index into a background texture. Perturb the texture coordinates to achieve the "shift" effect.

3. Look up render to texture. In directx they are called render targets.

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!