浏览代码

HDRenderPipeline: Re-introduce repeat mode for cookie for directional light and simplify code

/RenderPassXR_Sandbox
sebastienlagarde 8 年前
当前提交
974a44f0
共有 5 个文件被更改,包括 41 次插入40 次删除
  1. 2
      Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs.hlsl
  2. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/AdditionalData/HDAdditionalLightData.cs
  3. 6
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl
  4. 69
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  5. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

2
Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderPipeline/core/Shadow/ShadowBase.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs. Please don't edit by hand.
//
#ifndef SHADOWBASE_CS_HLSL

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/AdditionalData/HDAdditionalLightData.cs


public bool affectSpecular = true;
public LightArchetype archetype = LightArchetype.Punctual;
public SpotLightShape spotLightShape = SpotLightShape.Cone;
public SpotLightShape spotLightShape = SpotLightShape.Cone; // Note: Only for Spotlight, should be hide for other light
[Range(0.0f, 20.0f)]
public float lightLength = 0.0f; // Area & projector lights

6
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl


struct DirectionalLightData
{
float3 positionWS;
float unused;
bool tileCookie;
float3 color;
int shadowIndex;
float3 forward;

{
return value.positionWS;
}
float GetUnused(DirectionalLightData value)
bool GetTileCookie(DirectionalLightData value)
return value.unused;
return value.tileCookie;
}
float3 GetColor(DirectionalLightData value)
{

69
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


// binding code. This needs to be in sync with ShadowContext.hlsl
ShadowContext.BindDel binder = (ShadowContext sc, CommandBuffer cb, ComputeShader computeShader, int computeKernel) =>
{
{
if(computeShader)
{
// bind buffers
cb.SetComputeBufferParam(computeShader, computeKernel, "_ShadowDatasExp", s_ShadowDataBuffer);
cb.SetComputeBufferParam(computeShader, computeKernel, "_ShadowPayloads", s_ShadowPayloadBuffer);
// bind textures
cb.SetComputeTextureParam(computeShader, computeKernel, "_ShadowmapExp_VSM_0", tex[0]);
cb.SetComputeTextureParam(computeShader, computeKernel, "_ShadowmapExp_VSM_1", tex[1]);
cb.SetComputeTextureParam(computeShader, computeKernel, "_ShadowmapExp_VSM_2", tex[2]);
cb.SetComputeTextureParam(computeShader, computeKernel, "_ShadowmapExp_PCF", tex[3]);
if(computeShader)
{
// bind buffers
cb.SetComputeBufferParam(computeShader, computeKernel, "_ShadowDatasExp", s_ShadowDataBuffer);
cb.SetComputeBufferParam(computeShader, computeKernel, "_ShadowPayloads", s_ShadowPayloadBuffer);
// bind textures
cb.SetComputeTextureParam(computeShader, computeKernel, "_ShadowmapExp_VSM_0", tex[0]);
cb.SetComputeTextureParam(computeShader, computeKernel, "_ShadowmapExp_VSM_1", tex[1]);
cb.SetComputeTextureParam(computeShader, computeKernel, "_ShadowmapExp_VSM_2", tex[2]);
cb.SetComputeTextureParam(computeShader, computeKernel, "_ShadowmapExp_PCF", tex[3]);
else
{
// bind buffers
cb.SetGlobalBuffer("_ShadowDatasExp", s_ShadowDataBuffer);
cb.SetGlobalBuffer("_ShadowPayloads", s_ShadowPayloadBuffer);
// bind textures
cb.SetGlobalTexture("_ShadowmapExp_VSM_0", tex[0]);
cb.SetGlobalTexture("_ShadowmapExp_VSM_1", tex[1]);
cb.SetGlobalTexture("_ShadowmapExp_VSM_2", tex[2]);
cb.SetGlobalTexture("_ShadowmapExp_PCF", tex[3]);
else
{
// bind buffers
cb.SetGlobalBuffer("_ShadowDatasExp", s_ShadowDataBuffer);
cb.SetGlobalBuffer("_ShadowPayloads", s_ShadowPayloadBuffer);
// bind textures
cb.SetGlobalTexture("_ShadowmapExp_VSM_0", tex[0]);
cb.SetGlobalTexture("_ShadowmapExp_VSM_1", tex[1]);
cb.SetGlobalTexture("_ShadowmapExp_VSM_2", tex[2]);
cb.SetGlobalTexture("_ShadowmapExp_PCF", tex[3]);
// TODO: Currently samplers are hard coded in ShadowContext.hlsl, so we can't really set them here
};

if (light.light.cookie != null)
{
directionalLightData.tileCookie = light.light.cookie.wrapMode == TextureWrapMode.Repeat;
directionalLightData.cookieIndex = m_CookieTexArray.FetchSlice(light.light.cookie);
}
// fix up shadow information

if (m_TileSettings.enableComputeLightEvaluation && outputSplitLighting)
{
// The CS is always in the MRT mode. Do not execute the same shader twice.
return;
// The CS is always in the MRT mode. Do not execute the same shader twice.
return;
}
// TODO: To reduce GC pressure don't do concat string here

cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_SkyTexture", skyTexture ? skyTexture : m_DefaultTexture2DArray);
// Set SSS parameters.
cmd.SetComputeIntParam( shadeOpaqueShader, "_EnableSSSAndTransmission", Shader.GetGlobalInt( "_EnableSSSAndTransmission"));
cmd.SetComputeIntParam( shadeOpaqueShader, "_TexturingModeFlags", Shader.GetGlobalInt( "_TexturingModeFlags"));
cmd.SetComputeIntParam( shadeOpaqueShader, "_TransmissionFlags", Shader.GetGlobalInt( "_TransmissionFlags"));
cmd.SetComputeFloatParams(shadeOpaqueShader, "_ThicknessRemaps", Shader.GetGlobalFloatArray("_ThicknessRemaps"));
// We are currently supporting two different SSS mode: Jimenez (with 2-Gaussian profile) and Disney
// We have added the ability to switch between each other for subsurface scattering, but for transmittance this is more tricky as we need to add
// shader variant for forward, gbuffer and deferred shader. We want to avoid this.
// So for transmittance we use Disney profile formulation (that we know is more correct) in both case, and in the case of Jimenez we hack the parameters with 2-Gaussian parameters (Ideally we should fit but haven't find good fit) so it approximately match.
// Note: Jimenez SSS is in cm unit whereas Disney is in mm unit making an inconsistency here to compare model side by side
cmd.SetComputeVectorArrayParam(shadeOpaqueShader, "_ShapeParams", Shader.GetGlobalVectorArray("_ShapeParams"));
cmd.SetComputeIntParam( shadeOpaqueShader, "_EnableSSSAndTransmission", Shader.GetGlobalInt( "_EnableSSSAndTransmission"));
cmd.SetComputeIntParam( shadeOpaqueShader, "_TexturingModeFlags", Shader.GetGlobalInt( "_TexturingModeFlags"));
cmd.SetComputeIntParam( shadeOpaqueShader, "_TransmissionFlags", Shader.GetGlobalInt( "_TransmissionFlags"));
cmd.SetComputeFloatParams(shadeOpaqueShader, "_ThicknessRemaps", Shader.GetGlobalFloatArray("_ThicknessRemaps"));
// We are currently supporting two different SSS mode: Jimenez (with 2-Gaussian profile) and Disney
// We have added the ability to switch between each other for subsurface scattering, but for transmittance this is more tricky as we need to add
// shader variant for forward, gbuffer and deferred shader. We want to avoid this.
// So for transmittance we use Disney profile formulation (that we know is more correct) in both case, and in the case of Jimenez we hack the parameters with 2-Gaussian parameters (Ideally we should fit but haven't find good fit) so it approximately match.
// Note: Jimenez SSS is in cm unit whereas Disney is in mm unit making an inconsistency here to compare model side by side
cmd.SetComputeVectorArrayParam(shadeOpaqueShader, "_ShapeParams", Shader.GetGlobalVectorArray("_ShapeParams"));
cmd.SetComputeVectorArrayParam(shadeOpaqueShader, "_TransmissionTints", Shader.GetGlobalVectorArray("_TransmissionTints"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "specularLightingUAV", colorBuffers[0]);

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


// (we reuse the illumination) with the reversed normal of the current sample.
// We apply wrapped lighting instead of the regular Lambertian diffuse
// to compensate for these approximations.
illuminance = ComputeWrappedDiffuseLighting(NdotL, SSS_WRAP_LIGHT) * attenuation;
illuminance = ComputeWrappedDiffuseLighting(NdotL, SSS_WRAP_LIGHT);
// For low thickness, we can reuse the shadowing status for the back of the object.
shadow = bsdfData.useThinObjectMode ? shadow : 1;

正在加载...
取消
保存