浏览代码

Refactor SSAO apply

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

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


ApplyFogColor(color, unity_FogColor.rgb, fogFactor);
}
void ApplySSAO(inout half3 occlusion, float4 texcoord)
half3 SSAO(float4 texcoord)
//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);
return lerp(_AmbientOcclusionParam.rgb, float3(1.0, 1.0, 1.0), ssao);
}
// Stereo-related bits

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


SurfaceData surfaceData;
InitializeStandardLitSurfaceData(IN.uv, surfaceData);
ApplySSAO(surfaceData.occlusion, IN.shadowCoord); //The shadowcoord is the screen space position.
InputData inputData;
InitializeInputData(IN, surfaceData.normalTS, inputData);

ApplyFog(color.rgb, inputData.fogCoord);
return color;
return half4(color.rgb * SSAO(IN.shadowCoord), color.a);
}
// Used for Standard shader

#elif defined(_DEBUG_SMOOTHNESS)
debug = surfaceData.smoothness;
#elif defined(_DEBUG_OCCLUSION)
ApplySSAO(surfaceData.occlusion, IN.shadowCoord);
debug = surfaceData.occlusion;
debug = surfaceData.occlusion * SSAO(IN.shadowCoord);
#elif defined(_DEBUG_SHADOWS)
debug = RealtimeShadowAttenuation(IN.shadowCoord);
#endif

3
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/Subsurface/LightweightPassLit.hlsl


SurfaceData surfaceData;
InitializeStandardLitSurfaceData(IN.uv, surfaceData);
ApplySSAO(surfaceData.occlusion, IN.shadowCoord);
InputData inputData;
InitializeInputData(IN, surfaceData.normalTS, inputData);

half4 color = LightweightFragmentPBR(inputData, surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.occlusion, surfaceData.emission, surfaceData.alpha, curvature);
ApplyFog(color.rgb, inputData.fogCoord);
return color;
return half4(color.rgb * SSAO(IN.shadowCoord), color.a);
}
// Used for Standard shader

正在加载...
取消
保存