浏览代码

Add support for legacy grayscale cookies as a checkbox in the asset. Turning this on makes default spot attenutation mirror builtin

/classicDeferredMobile
Filip Iliescu 8 年前
当前提交
20347583
共有 4 个文件被更改,包括 21 次插入0 次删除
  1. 4
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ClassicDeferredPipeline.cs
  2. 11
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/LightingTemplate.hlsl
  3. 5
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/UnityStandardForwardMobile.cginc
  4. 1
      Assets/TestScenes/MobileDeferredTest/ClassicDeferredPipeline.asset

4
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ClassicDeferredPipeline.cs


[SerializeField]
TextureSettings m_TextureSettings = TextureSettings.Default;
public bool UseLegacyCookies;
public Mesh m_PointLightMesh;
public float PointLightMeshScaleFactor = 2.0f;
public Mesh m_SpotLightMesh;

int shadowIdx;
float lightShadowNDXOrNot = m_ShadowIndices.TryGetValue( (int) lightNum, out shadowIdx ) ? (float) shadowIdx : -1.0f;
props.SetFloat ("_LightIndexForShadowMatrixArray", lightShadowNDXOrNot);
props.SetFloat ("_useLegacyCookies", UseLegacyCookies?1.0f:0.0f);
Texture cookie = light.light.cookie;
if (cookie != null)

cmd.SetGlobalTexture("_reflRootCubeTexture", topCube);
cmd.SetGlobalFloat("_reflRootHdrDecodeMult", defdecode.x);
cmd.SetGlobalFloat("_reflRootHdrDecodeExp", defdecode.y);
cmd.SetGlobalFloat ("_useLegacyCookies", UseLegacyCookies?1.0f:0.0f);
context.ExecuteCommandBuffer(cmd);
cmd.Dispose();

11
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/LightingTemplate.hlsl


static float4 debugLighting;
int _LightIndexForShadowMatrixArray;
int _useLegacyCookies;
void OnChipDeferredCalculateLightParams (
unity_v2f_deferred i,

float4 uvCookie = mul (unity_WorldToLight, float4(wpos,1));
colorCookie = tex2Dlod (_LightTexture0, float4(uvCookie.xy / uvCookie.w, 0, 0));
[branch]if (_useLegacyCookies) {
colorCookie.xyz = 1;
}
float atten = colorCookie.w;
atten *= uvCookie.w < 0;

#if defined (DIRECTIONAL_COOKIE)
colorCookie = tex2Dlod (_LightTexture0, float4(mul(unity_WorldToLight, half4(wpos,1)).xy, 0, 0));
[branch]if (_useLegacyCookies) {
colorCookie.xyz = 1;
}
atten *= colorCookie.w;
#endif //DIRECTIONAL_COOKIE

#if defined (POINT_COOKIE)
colorCookie = texCUBElod(_LightTexture0, float4(mul(unity_WorldToLight, float4(wpos,1)).xyz, 0));
[branch]if (_useLegacyCookies) {
colorCookie.xyz = 1;
}
atten *= colorCookie.w;
#endif //POINT_COOKIE
#else

5
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/UnityStandardForwardMobile.cginc


int g_numLights;
int g_numReflectionProbes;
int _useLegacyCookies;
float4x4 g_mViewToWorld;
float4x4 g_mWorldToView; // used for reflection only

[branch]if(bHasCookie)
{
angularAtt = UNITY_SAMPLE_TEX2DARRAY_LOD(_spotCookieTextures, float3(cookCoord, gPerLightData[lightIndex].z), 0.0);
}
[branch]if(_useLegacyCookies)
{
angularAtt.xyz = 1;
}
atten *= angularAtt.w*(-uvCookie.w>0.0); // finally apply this to the dist att.

1
Assets/TestScenes/MobileDeferredTest/ClassicDeferredPipeline.asset


spotCookieSize: 512
pointCookieSize: 128
reflectionCubemapSize: 128
UseLegacyCookies: 1
m_PointLightMesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
PointLightMeshScaleFactor: 2
m_SpotLightMesh: {fileID: 4300000, guid: 93e85ba57f65145538a8ac97bd005d40, type: 3}

正在加载...
取消
保存