Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Projective Texturing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Telanor   Members   -  Reputation: 1351

Like
1Likes
Like

Posted 16 April 2013 - 11:20 PM

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, 16 April 2013 - 11:23 PM.


Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7872

Like
1Likes
Like

Posted 17 April 2013 - 12:13 AM

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.



#3 Telanor   Members   -  Reputation: 1351

Like
1Likes
Like

Posted 17 April 2013 - 12:36 AM

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;


#4 VladR   Members   -  Reputation: 722

Like
1Likes
Like

Posted 17 April 2013 - 11:28 AM

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.


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#5 Telanor   Members   -  Reputation: 1351

Like
1Likes
Like

Posted 17 April 2013 - 05:43 PM

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.

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, 17 April 2013 - 05:47 PM.


#6 riuthamus   Moderators   -  Reputation: 5653

Like
0Likes
Like

Posted 24 April 2013 - 10:40 PM

Yeah that certainly does look off. Anybody else got any ideas on this?



#7 riuthamus   Moderators   -  Reputation: 5653

Like
0Likes
Like

Posted 28 May 2013 - 08:07 PM

One last shameless bump... we still do not have this figured out.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS