浏览代码

post merge: update shadow code

/main
Filip Iliescu 7 年前
当前提交
41b0ab25
共有 3 个文件被更改,包括 14 次插入9 次删除
  1. 11
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/OnTileDeferredRenderPipeline.cs
  2. 8
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/LightingTemplate.hlsl
  3. 4
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/UnityStandardForwardMobile.cginc

11
Assets/ScriptableRenderPipeline/MobileRenderPipeline/OnTileDeferredRenderPipeline.cs


};
// binding code. This needs to be in sync with ShadowContext.hlsl
ShadowContext.BindDel binder = (ShadowContext sc, CommandBuffer cb) =>
ShadowContext.BindDel binder = (ShadowContext sc, CommandBuffer cb, ComputeShader computeShader, int computeKernel) =>
{
// bind buffers
cb.SetGlobalBuffer("_ShadowDatasExp", s_ShadowDataBuffer);

UpdateShadowConstants (camera, cullResults);
m_ShadowMgr.RenderShadows( m_FrameId, loop, cullResults, cullResults.visibleLights );
CommandBuffer cmdShadow = CommandBufferPool.Get();
m_ShadowMgr.RenderShadows( m_FrameId, loop, cmdShadow, cullResults, cullResults.visibleLights );
m_ShadowMgr.BindResources( loop );
m_ShadowMgr.BindResources( cmdShadow, null, 0 );
loop.ExecuteCommandBuffer(cmdShadow);
CommandBufferPool.Release(cmdShadow);
loop.SetupCameraProperties(camera);
RenderGBuffer(cullResults, camera, loop);

uint shadowRequestCount = (uint)m_ShadowRequests.Count;
int[] shadowRequests = m_ShadowRequests.ToArray();
int[] shadowDataIndices;
m_ShadowMgr.ProcessShadowRequests(m_FrameId, inputs, camera, inputs.visibleLights,
m_ShadowMgr.ProcessShadowRequests(m_FrameId, inputs, camera, false, inputs.visibleLights,
ref shadowRequestCount, shadowRequests, out shadowDataIndices);
// update the visibleLights with the shadow information

8
Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/LightingTemplate.hlsl


#if defined (SPOT)
float3 tolight = _LightPos.xyz - wpos;
half3 lightDir = normalize (tolight);
float dist = length(tolight);
float4 uvCookie = mul (unity_WorldToLight, float4(wpos,1));
colorCookie = tex2Dlod (_LightTexture0, float4(uvCookie.xy / uvCookie.w, 0, 0));
[branch]if (_useLegacyCookies) {

atten *= tex2D (_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL;
if (_LightIndexForShadowMatrixArray >= 0)
atten *= GetPunctualShadowAttenuation(shadowContext, wpos, 0.0.xxx, _LightIndexForShadowMatrixArray, 0.0.xxx);
atten *= GetPunctualShadowAttenuation(shadowContext, wpos, 0.0.xxx, _LightIndexForShadowMatrixArray, float4(lightDir, dist));
// directional light case
#elif defined (DIRECTIONAL) || defined (DIRECTIONAL_COOKIE)

// point light case
#elif defined (POINT) || defined (POINT_COOKIE)
float3 tolight = wpos - _LightPos.xyz;
float dist = length(tolight);
half3 lightDir = -normalize (tolight);
float att = dot(tolight, tolight) * _LightPos.w;

atten *= GetPunctualShadowAttenuation(shadowContext, wpos, 0.0.xxx, _LightIndexForShadowMatrixArray, lightDir);
atten *= GetPunctualShadowAttenuation(shadowContext, wpos, 0.0.xxx, _LightIndexForShadowMatrixArray, float4(lightDir, dist));
#if defined (POINT_COOKIE)
colorCookie = texCUBElod(_LightTexture0, float4(mul(unity_WorldToLight, float4(wpos,1)).xyz, 0));

4
Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/UnityStandardForwardMobile.cginc


[branch]
if (shadowIdx >= 0 && _transparencyShadows)
{
float shadow = GetPunctualShadowAttenuation(shadowContext, vPw, 0.0.xxx, shadowIdx, vLw);
float shadow = GetPunctualShadowAttenuation(shadowContext, vPw, 0.0.xxx, shadowIdx, float4(vLw, dist));
atten *= shadow;
}

[branch]
if (shadowIdx >= 0 && _transparencyShadows)
{
float shadow = GetPunctualShadowAttenuation(shadowContext, vPw, 0.0.xxx, shadowIdx, 0.0.xxx);
float shadow = GetPunctualShadowAttenuation(shadowContext, vPw, 0.0.xxx, shadowIdx, float4(vLw, dist));
atten *= shadow;
}

正在加载...
取消
保存