reze-engine 0.3.10 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/engine.ts CHANGED
@@ -366,12 +366,12 @@ export class Engine {
366
366
 
367
367
  let lightAccum = light.ambientColor;
368
368
 
369
- // Rim light calculation
369
+ // Rim light calculation - proper Fresnel for edge-only highlights
370
370
  let viewDir = normalize(camera.viewPos - input.worldPos);
371
- var rimFactor = 1.0 - max(dot(n, viewDir), 0.0);
372
- rimFactor = rimFactor * rimFactor; // Optimized: direct multiply instead of pow(x, 2.0)
371
+ let fresnel = 1.0 - abs(dot(n, viewDir));
372
+ let rimFactor = pow(fresnel, 4.0); // Higher power for sharper edge-only effect
373
373
  let rimLight = material.rimColor * material.rimIntensity * rimFactor;
374
-
374
+
375
375
  let color = albedo * lightAccum + rimLight;
376
376
 
377
377
  return vec4f(color, finalAlpha);