Advanced Ambient occlusion method implementation for your look-dev

Advanced Ambient occlusion method implementation for your look-dev.

Advanced Ambient occlusion


AO handling of shaders When you guys usually using URP or basic mobile hardware is very simple. When using HDRP, more sophisticated specular shielding and environment reflection shielding are performed using the AO calculation formula using bent normal. A similar effect is to create a Micro Shadow with AO effect to be used on mobile hardware using the simple formula used in Uncharted2.

着色器的 AO 处理当你们通常使用 URP 或基本移动硬件时非常简单。 使用 HDRP 时,使用弯曲法线的 AO 计算公式执行更复杂的镜面反射屏蔽和环境反射屏蔽。 类似的效果是使用 Uncharted2 中使用的简单公式创建一个带有 AO 效果的微阴影,用于移动硬件。

Shader Property.

RS Lit.shader

[Header(__ SHADE PARAM __)]
[Gamma] _Metallic ("Metallic", Range(0, 1)) = 0
_Smoothness ("Smoothness", Range(0, 1)) = 0.5
_OcclusionStrength("Occlusion", Range(0,1)) = 0.75
_MicroShadowStrength("MicroShadow", Range(0,1)) = 0.8

Uniform value

RS Lit.shader

uniform half _MicroShadowStrength;


//Fragment shader
half occlusion = RS_Occlusion(OcclusionMap , ndotl , _MicroShadowStrength );



// THis code motivated from Uncharted3 Alexander Maximove Micro Shadow occlusion function.
half RS_Occlusion( half occlusionTex , half NdotL, half Strength )
	#if (SHADER_TARGET < 30)
	return occlusionTex;			    // SM20: instruction count limitation
	half occ = occlusionTex;
	occ = LerpOneTo (occ, _OcclusionStrength);
	float aperture = 2.0 * occ * occ;
	float microshadow = saturate(NdotL + aperture - 1.0);
	return lerp(1.0, microshadow, Strength);

Need to know more?

Getting project.

Advanced Ambient occlusion method Example Project. | JP Lee on Patreon

Liked it? Take a second to support leegoonz on Patreon!

댓글 남기기