浏览代码

Add additional shader passes + clean-up

/sample_game
Evgenii Golubev 7 年前
当前提交
9ce510e5
共有 7 个文件被更改,包括 23 次插入13 次删除
  1. 11
      Assets/ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl
  2. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Deferred.compute
  3. 12
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  4. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.compute
  5. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.shader
  6. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPass.cs
  7. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl

11
Assets/ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl


return positionVS.xyz / positionVS.w;
}
float3 ComputeWorldSpacePosition(float2 positionSS, float depthRaw, float4x4 invViewProjMatrix)
{
float4 positionCS = ComputeClipSpacePosition(positionSS, depthRaw);
float4 hpositionWS = mul(invViewProjMatrix, positionCS);
return hpositionWS.xyz / hpositionWS.w;
}
// From deferred or compute shader
// depth must be the depth from the raw depth buffer. This allow to handle all kind of depth automatically with the inverse view projection matrix.
// For information. In Unity Depth is always in range 0..1 (even on OpenGL) but can be reversed.

float4 positionCS = ComputeClipSpacePosition(posInput.positionSS, depthRaw);
float4 hpositionWS = mul(invViewProjMatrix, positionCS);
posInput.positionWS = hpositionWS.xyz / hpositionWS.w;
posInput.positionWS = ComputeWorldSpacePosition(posInput.positionSS, depthRaw, invViewProjMatrix);
// The compiler should optimize this (less expensive than reconstruct depth VS from depth buffer)
posInput.depthVS = mul(viewProjMatrix, float4(posInput.positionWS, 1.0)).w;

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Deferred.compute


// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),
// the deferred shader will require to use multicompile.
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "../../ShaderConfig.cs.hlsl"
#include "../../ShaderVariables.hlsl"
#include "../../Lighting/Lighting.hlsl" // This include Material.hlsl

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


bool performPostScatterTexturing = IsBitSet(_TexturingModeFlags, subsurfaceProfile);
bool enableSssAndTransmission = true;
enableSssAndTransmission = false;
#elif (SSS_PASS == 0)
enableSssAndTransmission = _EnableSSSAndTransmission != 0;
bool enableSssAndTransmission = false;
#elif defined(SHADERPASS) && (SHADERPASS == SHADERPASS_SUBSURFACE_SCATTERING)
bool enableSssAndTransmission = true;
#else
bool enableSssAndTransmission = _EnableSSSAndTransmission != 0;
#endif
if (enableSssAndTransmission) // If we globally disable SSS effect, don't modify diffuseColor

{
#ifndef SSS_PASS
#if !defined(SHADERPASS) || (SHADERPASS != SHADERPASS_SUBSURFACE_SCATTERING)
bsdfData.diffuseColor = float3(1.0, 1.0, 1.0);
#endif
}

3
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.compute


#define SSS_DEBUG_NORMAL_VS 0
// Do not modify these.
#define SSS_PASS 1
#include "../../../ShaderPass/ShaderPass.cs.hlsl"
#define SHADERPASS SHADERPASS_SUBSURFACE_SCATTERING
#define MILLIMETERS_PER_METER 1000
#define CENTIMETERS_PER_METER 100
#define GROUP_SIZE_1D 16

3
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.shader


#pragma multi_compile _ SSS_FILTER_HORIZONTAL_AND_COMBINE
// Do not modify these.
#define SSS_PASS 1
#include "../../../ShaderPass/ShaderPass.cs.hlsl"
#define SHADERPASS SHADERPASS_SUBSURFACE_SCATTERING
#define MILLIMETERS_PER_METER 1000
#define CENTIMETERS_PER_METER 100

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPass.cs


Velocity,
Distortion,
LightTransport,
Shadows
Shadows,
SubsurfaceScattering,
VolumetricLighting
}
}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl


#define SHADERPASS_DISTORTION (5)
#define SHADERPASS_LIGHT_TRANSPORT (6)
#define SHADERPASS_SHADOWS (7)
#define SHADERPASS_SUBSURFACE_SCATTERING (8)
#define SHADERPASS_VOLUMETRIC_LIGHTING (9)
#endif
正在加载...
取消
保存