Jump to content
  • Advertisement
Sign in to follow this  
JDX_John

Shaders - use z to modify x/y?

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

This is a bit hard to describe but conceptually what I am interested in is rendering a slice of a scene as the camera looks through it.

If I am rendering with z-test off, I basically want the z-coord of pixels to become (with scaling) the y-coord... in other words the camera is rendering a 1px wide slice of the scene so all pixels have the same y-value and normally this would give me an output of one line... but as the pixel shader looks at each pixel, it uses z as y and therefore we still get a 2D image, looking 'down' the camera's look-axis.

Sorry that's probably a terrible explanation but the aim is something a bit like ultrasound or scanning underground - sort of like ray-tracing but using shaders.

My questions would then be:
  1. Did I explain this enough to understand?
  2. Is it possible? It's easy to make shader only accept pixels in a narrow slice of space but what about flipping y/z?
  3. What shader model is needed to do things like modify x/y coord?

Thanks for any input, even telling me what this might be called in shader terminology!

Share this post


Link to post
Share on other sites
Advertisement

This is a bit hard to describe but conceptually what I am interested in is rendering a slice of a scene as the camera looks through it.

If I am rendering with z-test off, I basically want the z-coord of pixels to become (with scaling) the y-coord... in other words the camera is rendering a 1px wide slice of the scene so all pixels have the same y-value and normally this would give me an output of one line... but as the pixel shader looks at each pixel, it uses z as y and therefore we still get a 2D image, looking 'down' the camera's look-axis.

Sorry that's probably a terrible explanation but the aim is something a bit like ultrasound or scanning underground - sort of like ray-tracing but using shaders.

My questions would then be:
  1. Did I explain this enough to understand?
  2. Is it possible? It's easy to make shader only accept pixels in a narrow slice of space but what about flipping y/z?
  3. What shader model is needed to do things like modify x/y coord?

Thanks for any input, even telling me what this might be called in shader terminology!


So why not just change camera position to look in the direction you actually want to see (original camera zy) and use clip planes to take your slice?

Share this post


Link to post
Share on other sites
A couple of reasons...
  • I don't believe you can reliably set clip planes such a tiny distance apart (let's say 1mm in real-world units), especially on older hardware
  • If a polygon is edge-on it will not get rendered properly whereas if you're shooting a ray (my approach is a bit like ray-tracing I suppose) it would hit
    These may or may not be good reasons - but I'm still interested if my approach is technically possible and how one would do it.

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!