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.


Deferred shadow mapping using the hw-depth?


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
No replies to this topic

#1 lipsryme   Members   -  Reputation: 1043

Like
0Likes
Like

Posted 17 November 2012 - 05:12 PM

I was thinking if I already have a depth buffer of my camera. Is it not possible to transform this depth to the light's projection space somehow ?
Is there a way to do this ? Or do I still need to render the entire geometry again for shadows ?
I imagine I could retrieve the world position of the vertices somehow and then transform them again with my light's view projection matrix...but is there no easier/faster way?

I've tried something like:


float LinearDepth(in float zw)
{
    return Projection._43 / (zw - Projection._33) / farClip;
}



VSO VS(VSI input)
{
    VSO output = (VSO)0;
    output.Position = float4(input.Position.xy, 1.0f, 1.0f);
    output.UV = input.UV;
    float3 ViewPosition = mul(float4(input.Position.xyz, 1.0f), InvProjection);
    output.ViewRay = float3(ViewPosition.xy / ViewPosition.z, 1.0f);
    return output;
}

float4 PS(VSO input) : SV_TARGET0
{
    float4 output = float4(0.0f, 0.0f, 0.0f, 1.0f);
    float3 ViewRay = normalize(input.ViewRay);
    float depth = DepthBuffer.Sample(PointSampler, input.UV).r;
    depth = LinearDepth(depth);
    float ViewZDist = dot(CamTarget, ViewRay);
    float3 worldPos = CamPosition + ViewRay * (depth / ViewZDist);

    // Construct view matrix of light
    float4x4 LightViewMatrix = CreateLightViewMatrix();
    float4x4 LightProjMatrix = CreateLightProjMatrix();
    float4 LightPosition = mul(float4(worldPos, 1.0f), LightViewMatrix);
    LightPosition = mul(LightPosition, LightProjMatrix);
    return LightPosition.z;
}



update: yea I've figured out that it's not possible to do :P..too bad

Edited by lipsryme, 20 November 2012 - 08:24 AM.


Sponsor:



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