• Advertisement
Sign in to follow this  

Finding pixel offset for silhouette shadow mapping

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

I've looked around but I can't figure out if D3D will give me what I need. I want to create a silhouette map to implement this paper. What I need is an x-y offset of a line relative to the center of the pixel. That is, when a wireframe model is rendered D3D picks the closest pixel to the line and draws it. I want to know where exactly the line cuts through the pixel. This will be the value stored in my silhouette map. Is there any way to get this in D3D11? The x-y values of POSITION are just the pixel index plus 0.5. Do I have to do this on the cpu or use a compute shader or is there an easier way? From the attached image I want to find point O. The paper passes in the endpoints of the line segments but it would be a lot easier if D3D gave me access to some of the values that it computes at the rasterization state. Thanks.

Share this post


Link to post
Share on other sites
Advertisement

I can't think of any automatic ways that this can be done through a pipeline feature or anything like that.  The closest thing you will get is the pixel location in the pixel shader, but that will give you the address of the center of the pixel and not the central point of your line within that pixel.

 

If you pass the two endpoints as vertex attributes though, then you should be able to get a linearly interpolated approximation of the value.  Unfortunately the interpolation is performed for the pixel (and not the line) so it would again be with respect to the center of the pixel...

 

However, you are essentially just doing line intersection tests within the boundary of the pixel, which should be fairly fast operation and the lines are always oriented in the same way with respect to the pixel center.  That should let you optimize the process a bit and help you determine which of the four cases you have in your pixel shader.  I would say to give it a shot and see if you can implement it yourself - I think it should be possible to get working in an efficient manner.

 

By the way, have you considered using multi-sampling?  I assume not, since this is an anti-aliasing technique, but it would give you access to the sample coverage information if you are using it.

Share this post


Link to post
Share on other sites

Thanks! I'm trying to pass the other two vertices of a triangle in as vertex attributes. Then I'll pass all three to the pixel shader and compute the intersections. It may be possible to do this in the geometry shader before rasterization but I am not familiar enough to know. I'm still going to render in wireframe mode to reduce the number of pixel threads.

 

I'm also not familiar with how multi-sampling works below the covers.

Share this post


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

  • Advertisement