if ( enableFeatureVariants )
numVariants = LightDefinitions . s_NumFeatureVariants ;
int debugViewMaterial = Shader . GetGlobalInt ( "_DebugViewMaterial" ) ;
Vector4 debugLightingAlbedo = Shader . GetGlobalVector ( "_DebugLightingAlbedo" ) ;
Vector4 debugLightingSmoothness = Shader . GetGlobalVector ( "_DebugLightingSmoothness" ) ;
int gbufferTexture0 = Shader . PropertyToID ( "_GBufferTexture0" ) ;
int gbufferTexture1 = Shader . PropertyToID ( "_GBufferTexture1" ) ;
int gbufferTexture2 = Shader . PropertyToID ( "_GBufferTexture2" ) ;
int gbufferTexture3 = Shader . PropertyToID ( "_GBufferTexture3" ) ;
int ambientOcclusionTexture = Shader . PropertyToID ( "_AmbientOcclusionTexture" ) ;
Texture ltcData = Shader . GetGlobalTexture ( Shader . PropertyToID ( "_LtcData" ) ) ;
Texture preIntegratedFGD = Shader . GetGlobalTexture ( "_PreIntegratedFGD" ) ;
Texture ltcGGXMatrix = Shader . GetGlobalTexture ( "_LtcGGXMatrix" ) ;
Texture ltcDisneyDiffuseMatrix = Shader . GetGlobalTexture ( "_LtcDisneyDiffuseMatrix" ) ;
Texture ltcMultiGGXFresnelDisneyDiffuse = Shader . GetGlobalTexture ( "_LtcMultiGGXFresnelDisneyDiffuse" ) ;
Matrix4x4 invScrProjection = Shader . GetGlobalMatrix ( "g_mInvScrProjection" ) ;
int useTileLightList = Shader . GetGlobalInt ( "_UseTileLightList" ) ;
Vector4 time = Shader . GetGlobalVector ( "_Time" ) ;
Vector4 sinTime = Shader . GetGlobalVector ( "_SinTime" ) ;
Vector4 cosTime = Shader . GetGlobalVector ( "_CosTime" ) ;
Vector4 unity_DeltaTime = Shader . GetGlobalVector ( "unity_DeltaTime" ) ;
Vector4 worldSpaceCameraPos = Shader . GetGlobalVector ( "_WorldSpaceCameraPos" ) ;
Vector4 projectionParams = Shader . GetGlobalVector ( "_ProjectionParams" ) ;
Vector4 screenParams = Shader . GetGlobalVector ( "_ScreenParams" ) ;
Vector4 zbufferParams = Shader . GetGlobalVector ( "_ZBufferParams" ) ;
Vector4 unity_OrthoParams = Shader . GetGlobalVector ( "unity_OrthoParams" ) ;
int envLightSkyEnabled = Shader . GetGlobalInt ( "_EnvLightSkyEnabled" ) ;
int enableSSSAndTransmission = Shader . GetGlobalInt ( "_EnableSSSAndTransmission" ) ;
int texturingModeFlags = Shader . GetGlobalInt ( "_TexturingModeFlags" ) ;
int transmissionFlags = Shader . GetGlobalInt ( "_TransmissionFlags" ) ;
float [ ] thicknessRemaps = Shader . GetGlobalFloatArray ( "_ThicknessRemaps" ) ;
Vector4 [ ] shapeParams = Shader . GetGlobalVectorArray ( "_ShapeParams" ) ;
Vector4 [ ] transmissionTints = Shader . GetGlobalVectorArray ( "_TransmissionTints" ) ;
for ( int variant = 0 ; variant < numVariants ; variant + + )
{
int kernel ;
hdCamera . SetupComputeShader ( shadeOpaqueShader , cmd ) ;
// TODO: Update value like in ApplyDebugDisplaySettings() call. Sadly it is high likely that this will not be keep in sync. we really need to get rid of this by making global parameters visible to compute shaders
cmd . SetComputeIntParam ( shadeOpaqueShader , "_DebugViewMaterial" , Sha der . GetGlobalInt ( "_De bugViewMaterial" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_DebugLightingAlbedo" , Sha der . GetGlobalVector ( "_De bugLightingAlbedo" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_DebugLightingSmoothness" , Sha der . GetGlobalVector ( "_De bugLightingSmoothness" ) ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_DebugViewMaterial" , debugViewMaterial ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_DebugLightingAlbedo" , debugLightingAlbedo ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_DebugLightingSmoothness" , debugLightingSmoothness ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_GBufferTexture0" , Shader . PropertyToID ( "_GBufferTexture0" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_GBufferTexture1" , Shader . PropertyToID ( "_GBufferTexture1" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_GBufferTexture2" , Shader . PropertyToID ( "_GBufferTexture2" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_GBufferTexture3" , Shader . PropertyToID ( "_GBufferTexture3" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_AmbientOcclusionTexture" , Sh ader . PropertyToID ( "_A mbientOcclusionTexture" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_GBufferTexture0" , gbufferTexture0 ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_GBufferTexture1" , gbufferTexture1 ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_GBufferTexture2" , gbufferTexture2 ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_GBufferTexture3" , gbufferTexture3 ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_AmbientOcclusionTexture" , ambientOcclusionTexture ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_LtcData" , Shader . GetGlobalTexture ( Shader . PropertyToID ( "_L tcData" ) ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_PreIntegratedFGD" , Shader . GetGlobalTexture ( "_PreIntegratedFGD" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_LtcGGXMatrix" , Shader . GetGlobalTexture ( "_L tcGGXMatrix" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_LtcDisneyDiffuseMatrix" , Shader . GetGlobalTexture ( "_L tcDisneyDiffuseMatrix" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_LtcMultiGGXFresnelDisneyDiffuse" , Shader . GetGlobalTexture ( "_L tcMultiGGXFresnelDisneyDiffuse" ) ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_LtcData" , ltcData ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_PreIntegratedFGD" , preIntegratedFGD ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_LtcGGXMatrix" , ltcGGXMatrix ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_LtcDisneyDiffuseMatrix" , ltcDisneyDiffuseMatrix ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "_LtcMultiGGXFresnelDisneyDiffuse" , ltcMultiGGXFresnelDisneyDiffuse ) ;
cmd . SetComputeMatrixParam ( shadeOpaqueShader , "g_mInvScrProjection" , Shader . GetGlobalMatr ix ( "g_mI nvScrProjection" ) ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_UseTileLightList" , Shader . GetGlobalInt ( "_UseTileLightList" ) ) ;
cmd . SetComputeMatrixParam ( shadeOpaqueShader , "g_mInvScrProjection" , invScrProjection ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_UseTileLightList" , useTileLightList ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_Time" , Shader . Ge tGlobalVector ( "_T ime" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_SinTime" , Shader . GetGlobalVector ( "_SinTime" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_CosTime" , Shader . GetGlobalVector ( "_C osTime" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "unity_DeltaTime" , Shader . GetGlobalVector ( " unity_DeltaTime" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_WorldSpaceCameraPos" , Shader . GetGlobalVector ( "_WorldSpaceCameraPos" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_ProjectionParams" , Shader . GetGlobalVector ( "_ProjectionParams" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_ScreenParams" , Shader . GetGlobalVector ( "_ScreenParams" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_ZBufferParams" , Shader . GetGlobalVector ( "_ZBufferParams" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "unity_OrthoParams" , Shader . GetGlobalVector ( " unity_OrthoParams" ) ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_EnvLightSkyEnabled" , Shad er . GetGlobalInt ( "_E nvLightSkyEnabled" ) ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_Time" , time ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_SinTime" , sinTime ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_CosTime" , cosTime ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "unity_DeltaTime" , unity_DeltaTime ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_WorldSpaceCameraPos" , worldSpaceCameraPos ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_ProjectionParams" , projectionParams ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_ScreenParams" , screenParams ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "_ZBufferParams" , zbufferParams ) ;
cmd . SetComputeVectorParam ( shadeOpaqueShader , "unity_OrthoParams" , unity_OrthoParams ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_EnvLightSkyEnabled" , envLightSkyEnabled ) ;
Texture skyTexture = Shader . GetGlobalTexture ( "_SkyTexture" ) ;
Texture IESArrayTexture = Shader . GetGlobalTexture ( "_IESArray" ) ;
// Set SSS parameters.
cmd . SetComputeIntParam ( shadeOpaqueShader , "_EnableSSSAndTransmission" , Shad er . GetGlobalInt ( "_E nableSSSAndTransmission" ) ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_TexturingModeFlags" , Shader . Ge tGlobalInt ( "_T exturingModeFlags" ) ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_TransmissionFlags" , Shader . Ge tGlobalInt ( "_T ransmissionFlags" ) ) ;
cmd . SetComputeFloatParams ( shadeOpaqueShader , "_ThicknessRemaps" , Shader . Ge tGlobalFloatArray ( "_T hicknessRemaps" ) ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_EnableSSSAndTransmission" , enableSSSAndTransmission ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_TexturingModeFlags" , texturingModeFlags ) ;
cmd . SetComputeIntParam ( shadeOpaqueShader , "_TransmissionFlags" , transmissionFlags ) ;
cmd . SetComputeFloatParams ( shadeOpaqueShader , "_ThicknessRemaps" , thicknessRemaps ) ;
cmd . SetComputeVectorArrayParam ( shadeOpaqueShader , "_ShapeParams" , Shader . GetGlobalVectorArray ( "_ShapeParams" ) ) ;
cmd . SetComputeVectorArrayParam ( shadeOpaqueShader , "_TransmissionTints" , Shader . Ge tGlobalVectorArray ( "_T ransmissionTints" ) ) ;
cmd . SetComputeVectorArrayParam ( shadeOpaqueShader , "_ShapeParams" , shapeParams ) ;
cmd . SetComputeVectorArrayParam ( shadeOpaqueShader , "_TransmissionTints" , transmissionTints ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "specularLightingUAV" , colorBuffers [ 0 ] ) ;
cmd . SetComputeTextureParam ( shadeOpaqueShader , kernel , "diffuseLightingUAV" , colorBuffers [ 1 ] ) ;