HLSL warning when using shadow maps

Description of the problem

I was working on my project today when suddenly it stop working. Checking the console log I got this message:
“three.js:18057 THREE.WebGLProgram: gl.getProgramInfoLog() C:\fakepath(309,8-98): warning X4121: gradient-based operations must be moved out of flow control to prevent divergence. Performance may improve by using a non-gradient operation”
I realised that the problem was associated with the shadow map.

Demo: https://codepen.io/FilipeNowicki/pen/vryBRe

Three.js version
  • Dev
  • r93
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

1 thought on “HLSL warning when using shadow maps

  1. Your shadow map has 0.25 trillion pixels.

    Make all of the following changes to your code.

    dirLight.shadow.mapSize.width = 1024; // was 500000;
    dirLight.shadow.mapSize.height = 1024; // was 500000;
    var d = was 500; // 5000
    
    var floorMaterial = new THREE.MeshPhongMaterial( { color: 0x006600  ); // was Lambert
    var floorGeometry = new THREE.PlaneGeometry( 7000, 7000, 1, 1 ); was tessellated

Comments are closed.