Skip to content

Commit

Permalink
Fix AO
Browse files Browse the repository at this point in the history
- AO should not be used in punctual lights

Closes #416
  • Loading branch information
kanerogers committed Mar 3, 2023
1 parent 893f1a2 commit 39e684a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions hotham/src/shaders/pbr.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ f16vec3 getIBLContribution(f16vec3 F0, float16_t perceptualRoughness, f16vec3 di
return diffuse + specular;
}

f16vec3 getLightContribution(f16vec3 f0, float16_t alphaRoughness, f16vec3 diffuseColor, float16_t NdotV, Light light, float16_t ao) {
f16vec3 getLightContribution(f16vec3 f0, float16_t alphaRoughness, f16vec3 diffuseColor, float16_t NdotV, Light light) {
// Get a vector between this point and the light.
vec3 pointToLight;
if (light.type != LightType_Directional) {
Expand All @@ -87,7 +87,7 @@ f16vec3 getLightContribution(f16vec3 f0, float16_t alphaRoughness, f16vec3 diffu
f16vec3 specContrib = BRDF_specular(f0, alphaRoughness, V16(h), V16(n), NdotV, NdotL, NdotH, LdotH);

// Finally, combine the diffuse and specular contributions
color = (diffuseContrib + specContrib) * (F16(light.intensity) * attenuation * NdotL * ao);
color = (diffuseContrib + specContrib) * (F16(light.intensity) * attenuation * NdotL);
}

return color;
Expand Down Expand Up @@ -148,16 +148,16 @@ f16vec3 getPBRMetallicRoughnessColor(f16vec3 baseColor) {
// Qualcomm's documentation suggests that loops are undesirable, so we do branches instead.
// Since these values are uniform, they shouldn't have too high of a penalty.
if (sceneData.lights[0].type != NOT_PRESENT) {
color += getLightContribution(f0, alphaRoughness, diffuseColor, NdotV, sceneData.lights[0], ao);
color += getLightContribution(f0, alphaRoughness, diffuseColor, NdotV, sceneData.lights[0]);
}
if (sceneData.lights[1].type != NOT_PRESENT) {
color += getLightContribution(f0, alphaRoughness, diffuseColor, NdotV, sceneData.lights[1], ao);
color += getLightContribution(f0, alphaRoughness, diffuseColor, NdotV, sceneData.lights[1]);
}
if (sceneData.lights[2].type != NOT_PRESENT) {
color += getLightContribution(f0, alphaRoughness, diffuseColor, NdotV, sceneData.lights[2], ao);
color += getLightContribution(f0, alphaRoughness, diffuseColor, NdotV, sceneData.lights[2]);
}
if (sceneData.lights[3].type != NOT_PRESENT) {
color += getLightContribution(f0, alphaRoughness, diffuseColor, NdotV, sceneData.lights[3], ao);
color += getLightContribution(f0, alphaRoughness, diffuseColor, NdotV, sceneData.lights[3]);
}

// Add emission, if present
Expand Down

0 comments on commit 39e684a

Please sign in to comment.