浏览代码

Use the sampler to clamp the directional light cookie to border

/asmdef
Evgenii Golubev 7 年前
当前提交
c011fcdd
共有 1 个文件被更改,包括 5 次插入7 次删除
  1. 12
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

12
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


float3 positionLS = mul(lighToSample, transpose(lightToWorld));
float2 positionCS = positionLS.xy;
// Tile the texture if the 'repeat' wrap mode is enabled.
bool isInBounds = lightData.tileCookie || max(abs(positionCS.x), abs(positionCS.y)) <= 1.0;
float2 positionNDC = frac(positionCS * 0.5 + 0.5);
float2 positionNDC = positionCS * 0.5 + 0.5;
// Tile the texture if the 'repeat' wrap mode is enabled.
positionNDC = lightData.tileCookie ? frac(positionNDC) : positionNDC;
cookie.a = isInBounds ? cookie.a : 0;
return cookie;
}

// Remap the texture coordinates from [-1, 1]^2 to [0, 1]^2.
float2 positionNDC = positionCS * 0.5 + 0.5;
// We let the sampler handle clamping to border.
// Manually clamp to border (black).
cookie = SampleCookie2D(lightLoopContext, positionNDC, lightData.cookieIndex);
cookie.a = isInBounds ? cookie.a : 0;
}

正在加载...
取消
保存