• Advertisement
Sign in to follow this  

fragment program: pixel position in worldspace

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

how can i get the pixel position in worldspace coordinates to do pointlight attenuation based in distance from the pixel to lightsource

Share this post


Link to post
Share on other sites
Advertisement
Just use a vertex shader,and use one texture coordinate set to store the worldspace position as a vector(not normalized).It will be interpolated and you can retrieve it in the fragment program.Just as you do for the light vector,for instance.Actually,just the lightvector is enought for attenuation purposes.Just don't normalize it in the vertex program,but only in the fragment program when needed(for DOT3 operations).

Share this post


Link to post
Share on other sites
ok thx a lot

i think i have cleared everything now so i can start implementing my renderer now :)

Share this post


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

  • Advertisement