summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--math.cginc7
-rw-r--r--pbr.cginc4
-rw-r--r--tooner_lighting.cginc8
3 files changed, 11 insertions, 8 deletions
diff --git a/math.cginc b/math.cginc
index 41d9987..2a384fb 100644
--- a/math.cginc
+++ b/math.cginc
@@ -300,5 +300,12 @@ uint gcd(uint a, uint b)
return 1;
}
+float wrapNoL(float NoL, float factor) {
+ // Apply wrapped lighting correction
+ // https://www.iro.umontreal.ca/~derek/files/jgt_wrap_final.pdf
+ //float4 wrapped = (NoL + 1) * (NoL + 1) * .25;
+ return pow(max(1E-4, (NoL + factor) / (1 + factor)), 1 + factor);
+}
+
#endif // __MATH_INC
diff --git a/pbr.cginc b/pbr.cginc
index c9b6e28..824647f 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -4,6 +4,7 @@
#include "filament_math.cginc"
#include "globals.cginc"
#include "interpolators.cginc"
+#include "math.cginc"
#include "MochieStandardBRDF.cginc"
#include "poi.cginc"
#include "tone.cginc"
@@ -432,6 +433,7 @@ float4 getLitColor(
/*smoothness=*/1 - cc_roughness,
/*metallic=*/0,
worldPos);
+ // Indirect specular
{
// TODO fold this into the full BRDF and apply the brightness corrections
// described in the filament whitepaper:
@@ -449,7 +451,7 @@ float4 getLitColor(
LoH,
h,
Fc);
- pbr.rgb += cc_term * cc_indirect_specular * cc_mask;
+ pbr.rgb += cc_term * (indirect_light.specular + indirect_light.diffuse) * cc_mask;
}
// Direct
{
diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc
index f8c3b52..eef6862 100644
--- a/tooner_lighting.cginc
+++ b/tooner_lighting.cginc
@@ -37,7 +37,6 @@ float3 Shade4PointLightsWrapped(
float3 pos, float3 normal,
float wrapFactor)
{
- // Compute the difference between the vertex position and light positions
float4 toLightX = lightPosX - pos.x;
float4 toLightY = lightPosY - pos.y;
float4 toLightZ = lightPosZ - pos.z;
@@ -53,18 +52,13 @@ float3 Shade4PointLightsWrapped(
ndotl += toLightZ * normal.z;
// Apply wrapped lighting correction
- // https://www.iro.umontreal.ca/~derek/files/jgt_wrap_final.pdf
- //float4 wrapped = (ndotl + 1) * (ndotl + 1) * .25;
- float4 wrapped = pow(max(1E-4, (ndotl + wrapFactor) / (1 + wrapFactor)), 1 + wrapFactor);
- //float4 wrapped = pow((ndotl + 1) / (2), 2);
+ float4 wrapped = wrapNoL(ndotl, wrapFactor);
float4 corr = rsqrt(lengthSq);
ndotl = max(0, wrapped) * corr;
- // Compute attenuation
float4 atten = 1.0 / (1.0 + lengthSq * lightAttenSq);
float4 diff = ndotl * atten;
- // Compute final color
return diff.x * lightColor0 +
diff.y * lightColor1 +
diff.z * lightColor2 +