Jump to content
  • Advertisement
Sign in to follow this  
Telanor

DX11 Projective Texturing

This topic is 2025 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'm trying to implement projective texturing but I'm having some trouble getting it to a usable state. Right now it works but it projects to infinity (or more specifically, to the far plane). I can't just pull back the far plane because it could result in the texture being cut off on steep surfaces, and wouldn't solve the problem of projecting through surfaces. I've tried to mimic a sort of spotlight shadow technique but wasn't able to get that to work since there are pretty much no tutorials on shadows for deferred shading pipelines. So, my question: How do you get a projective texture to stop at the first surface it hits?


Edit: I forgot to add tags. I'm using DX11 & sharpdx Edited by Telanor

Share this post


Link to post
Share on other sites
Advertisement

I've tried to mimic a sort of spotlight shadow technique but wasn't able to get that to work since there are pretty much no tutorials on shadows for deferred shading pipelines.

I fear, that you need a shadow mapping approach to solve this problem.The benefit of projective textures is, that you often don't need a shadow mapping approach (which makes it a lot slower), therefor my first tip would be, to accept the artefact and restrict the projection range (quantity vs quality). You've already implemented CSM and point light shadows, the principle is all the same:

 

Reconstruct the point in camera space and reproject it into the projection (shadow camera) space, then get the shadow value, if it is in shadow, discard the pixel. If it is not in shadow, use the xy shadowmap coord to access the projection texture.

Share this post


Link to post
Share on other sites
That's what I figured but I wasn't able to get it to work. It just considers everything to be out of the shadow.
float4 position = //bunch of code to reconstruct world space position from log depth

float4 decalPos = mul(position, DecalViewProjection);

float shadowDepth = ProjectorDepthMap.Sample(pointSampler, decalTexCoord.xy);

if(shadowDepth < decalPos.z / decalPos.w)
	discard;

Share this post


Link to post
Share on other sites

I agree that a Shadow-Mapping approach for Projective texturing is easier to get up&running faster. Plus, you will then be able to reuse parts of the pipeline for other stuff.

 

Before we had SM HW, we had to do projective texturing manually and it is truly a PITA to implement correctly and generally enough.

Share this post


Link to post
Share on other sites
I found part of the problem was from me using the ViewProjection matrix from the wrong camera but now there seems to be an issue with the sampling coordinates for the projection depth map being wrong.

[attachment=14956:RuinValor 2013-04-17 19-33-24-01.png]

The projector camera is positioned approximately where the cursor is and is looking straight downwards. Ive changed the code from before slightly
float4 decalPos = mul(position, DecalViewProjection);
decalPos /= decalPos.w;
decalPos.xy = float2(decalPos.x, -decalPos.y) / 2.0f + 0.5f;

float shadowDepth = ProjectorDepthMap.Sample(pointSampler, decalPos.xy);

return float4(shadowDepth.rrr, 1);
Edited by Telanor

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!