Jump to content
  • Advertisement
Sign in to follow this  

Normal offsets in view space?

This topic is 1229 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 apply normal offsets as per http://www.dissidentlogic.com/old/images/NormalOffsetShadows/GDC_Poster_NormalOffset.png


I'm working in view space though and the offsets causes the shadows to slightly move around as the camera moves.

static const float gNormalOffset = 4.5;
static const float gBias = 1;

float3 ShadowAcneNormalOffset(in float3 normal, in float normalLightAngle, in float shadowmapSize)
    const float texelSize = 2.0 / shadowmapSize;
    const float normalOffsetScale = saturate(1.0 - normalLightAngle);

    float3 ret = normal * gNormalOffset * normalOffsetScale * texelSize;
    ret.z += texelSize * gBias;

    return ret;

viewPosition.xyz += ShadowAcneNormalOffset(viewNormal, normalLightAngle, gShadowmapSize);

Both the position and normals are in view space. Does this impact the alghorithm at all?

Share this post

Link to post
Share on other sites
There should be no difference between doing this in world space or view space, provided that everything you're working with is in the same coordinate space. I would suspect that you have something in world space that hasn't been converted to view space.

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!