Jump to content
  • Advertisement
Sign in to follow this  

CG - Writing Distance to a Map

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

So I'm working on a shadow mapping cg shader right now. My question is: can I store a 32bit floating number... or at least a 24bit floating point number within a texture, later to be used as a depth map when creating shadows? The idea is to get the distance from two points in world space and then store it to the corresponding point on the frame buffer that is later exported out as a texture for depth testing. Could I store the entire 32bit number as the pixel's color? A single channel will allow 8bits of percision... not much. Would the following statement result in what I want?
 color= distance(lightPos, inPosition.xyz); 
If it does, how do I read it out later? The function tex2d seems to spit out a float4. This is obviously not what I want. But I could assign it to a float. But then it gives me an implicit cast error. What the heck is it actually casting to. Just a single channel or what? Anyone ever try anything like this? Also, I'm obviously open to any other suggestions of doing accurate shadow maps

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!