浏览代码

Orthographic support

/main
John 7 年前
当前提交
c3c11ecf
共有 2 个文件被更改,包括 37 次插入6 次删除
  1. 2
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
  2. 41
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


if (LightweightUtils.HasFlag(frameRenderingConfiguration, FrameRenderingConfiguration.DepthPrePass))
{
DepthPass(ref context);
if(m_RequireScreenSpaceShadows) //NOTE: Should this be added to the FrameRenderingConfiguration?
if(m_RequireScreenSpaceShadows)
ShadowCollectPass(ref context, visibleLights, ref lightData);
}

41
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader


struct Interpolators
{
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
float3 ray : TEXCOORD1;
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
//Perspective Case
float3 ray : TEXCOORD1;
//Orthographic Case
float3 orthoPosNear : TEXCOORD2;
float3 orthoPosFar : TEXCOORD3;
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.uv);
return i.ray * Linear01Depth(depth, _ZBufferParams);
float zDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.uv);
float depth = Linear01Depth(zDepth, _ZBufferParams);
#ifdef UNITY_REVERSED_Z
zDepth = 1 - zDepth;
#endif
//Perspective Case
float3 vposPersp = i.ray * depth;
//Orthographics Case
float3 vposOrtho = lerp(i.orthoPosNear, i.orthoPosFar, zDepth);
return lerp(vposPersp, vposOrtho, unity_OrthoParams.w);
}
Interpolators Vertex(VertexInput i)

o.uv = i.uv;
//Perspective Case
//Orthographic Case
float4 clipPos = o.pos;
clipPos.y *= _ProjectionParams.x;
float3 orthoPosNear = mul(unity_CameraInvProjection, float4(clipPos.x, clipPos.y, -1, 1)).xyz;
float3 orthoPosFar = mul(unity_CameraInvProjection, float4(clipPos.x, clipPos.y, 1, 1)).xyz;
orthoPosNear.z *= -1;
orthoPosFar.z *= -1;
o.orthoPosNear = orthoPosNear;
o.orthoPosFar = orthoPosFar;
return o;
}

正在加载...
取消
保存