浏览代码

Apply SSAO term to LW Standard

/projects-TheLastStand
John Parsaie 6 年前
当前提交
4d394a7e
共有 3 个文件被更改,包括 15 次插入1 次删除
  1. 9
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Core.hlsl
  2. 5
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Input.hlsl
  3. 2
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl

9
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Core.hlsl


ApplyFogColor(color, unity_FogColor.rgb, fogFactor);
}
void ApplySSAO(inout half occlusion, float4 texcoord)
{
half ssao = 1.0 - SAMPLE_TEXTURE2D(_AmbientOcclusion, sampler_AmbientOcclusion, texcoord.xy / texcoord.w);
//TODO: The occlusion term is only a half, breaking colored AO.
//TODO: Find better occlusion mix method.
occlusion *= lerp(_AmbientOcclusionParam.rgb, float3(1.0, 1.0, 1.0), ssao);
}
// Stereo-related bits
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
#define SCREENSPACE_TEXTURE TEXTURE2D_ARRAY

5
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Input.hlsl


half4 _AdditionalLightDistanceAttenuation[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightSpotDir[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightSpotAttenuation[MAX_VISIBLE_LIGHTS];
half4 _AmbientOcclusionParam;
TEXTURE2D(_AmbientOcclusion);
SAMPLER(sampler_AmbientOcclusion);
#define UNITY_MATRIX_M unity_ObjectToWorld
#define UNITY_MATRIX_I_M unity_WorldToObject

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl


SurfaceData surfaceData;
InitializeStandardLitSurfaceData(IN.uv, surfaceData);
ApplySSAO(surfaceData.occlusion, IN.shadowCoord); //The shadowcoord is the screen space position.
half4 color = LightweightFragmentPBR(inputData, surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.occlusion, surfaceData.emission, surfaceData.alpha);

正在加载...
取消
保存