[Mobile shader] Dual Lobe GGX works

Unity3D URP

Dual Lobe GGX works

preview

Dual Lobe Debug view.

preview

Single Lobe GGX.

preview
Dual Lobe GGX.

// Specular term
	half perceptualRoughness = SmoothnessToPerceptualRoughness(smoothness);
	half roughness = PerceptualRoughnessToRoughness(perceptualRoughness);

	half a = roughness;
	half a2 = a*a;

	half d = nh * nh * (a2 - 1.h) + 1.00001h;
	half specularTerm = a2 / (max(0.1h, lh*lh) * (roughness + 0.5h) * (d * d) * 4);
	
	float Lobe0Roughness = max(saturate(specularTerm ), 0.002f);
	float Lobe1Roughness = clamp(specularTerm, 0.0, 100.0) *  _LobeWeight;
	
#if defined(DUAL_LOBE_GGX)
    float sAO = saturate(-0.3f + nv * nv);
    sAO =  lerp(pow(ao, 8.00f), 1.0f, sAO);
	half SpecularOcclusion = sAO;
	specularTerm = (Lobe0Roughness / 2 + Lobe1Roughness) * SpecularOcclusion ;
	return half4(specularTerm.xxx,1);
#else
	specularTerm = clamp(specularTerm, 0.0, 100.0); // Prevent FP16 overflow on mobiles
#endif

Categories: shader

Tagged as: , ,

1 reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s