浏览代码

insert early out in shadow code for finite lights

insert early out in shadow code for finite lights
/main
mmikk 8 年前
当前提交
5a3b035e
共有 3 个文件被更改,包括 17 次插入5 次删除
  1. 3
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  2. 18
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
  3. 1
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs

3
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


shadowLightIndex++;
bool bHasCookie = cl.light.cookie != null;
bool bHasShadow = cl.light.shadows != LightShadows.None;
if (cl.lightType == LightType.Spot)
{

lightData[i].flags |= (bIsCircularSpot ? LightDefinitions.IS_CIRCULAR_SPOT_SHAPE : 0);
lightData[i].flags |= (bHasCookie ? LightDefinitions.HAS_COOKIE_TEXTURE : 0);
lightData[i].flags |= (bHasShadow ? LightDefinitions.HAS_SHADOW : 0);
}
else if (cl.lightType == LightType.Point)
{

lightData[i].fSphRadiusSq = range * range;
lightData[i].flags |= (bHasCookie ? LightDefinitions.HAS_COOKIE_TEXTURE : 0);
lightData[i].flags |= (bHasShadow ? LightDefinitions.HAS_SHADOW : 0);
}
else
{

18
Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader


angularAtt = UNITY_SAMPLE_TEX2DARRAY_LOD(_spotCookieTextures, float3(cookCoord, lgtDat.iSliceIndex), 0.0).w;
}
atten *= angularAtt*(fProjVec>0.0); // finally apply this to the dist att.
float shadowScalar = SampleShadow(SPOT_LIGHT, vPositionWs, 0, lgtDat.uShadowLightIndex);
atten *= shadowScalar;
const bool bHasShadow = (lgtDat.flags&HAS_SHADOW)!=0;
[branch]if(bHasShadow)
{
float shadowScalar = SampleShadow(SPOT_LIGHT, vPositionWs, 0, lgtDat.uShadowLightIndex);
atten *= shadowScalar;
}
UnityLight light;
light.color.xyz = lgtDat.vCol.xyz*atten;

atten *= UNITY_SAMPLE_TEXCUBEARRAY_LOD(_pointCookieTextures, float4(-vLw, lgtDat.iSliceIndex), 0.0).w;
}
float shadowScalar = SampleShadow(SPHERE_LIGHT, vPositionWs, vLw, lgtDat.uShadowLightIndex);
atten *= shadowScalar;
const bool bHasShadow = (lgtDat.flags&HAS_SHADOW)!=0;
[branch]if(bHasShadow)
{
float shadowScalar = SampleShadow(SPHERE_LIGHT, vPositionWs, vLw, lgtDat.uShadowLightIndex);
atten *= shadowScalar;
}
UnityLight light;
light.color.xyz = lgtDat.vCol.xyz*atten;

1
Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs


public static int IS_CIRCULAR_SPOT_SHAPE = 1;
public static int HAS_COOKIE_TEXTURE = 2;
public static int IS_BOX_PROJECTED = 4;
public static int HAS_SHADOW = 8;
// types

正在加载...
取消
保存