Three.js: HLSL warning when using shadow maps

Created on 21 Jun 2018  路  5Comments  路  Source: mrdoob/three.js

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
  • [X] r93
  • [ ] ...
Browser
  • [x] All of them
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [ ] All of them
  • [X] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Hardware Requirements (graphics card, VR Device, ...)

Most helpful comment

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

All 5 comments

I'm unable to reproduce the error with your demo. When i enable shadow mapping, the result looks fine without any messages in the console. Tested with macOS with Chrome.

image

AFAIK, X4121 is a HLSL warning. So I guess this issue is Windows exclusive.

@Age-of-the-Witch-Hunt Does the shadow map still render? Do you see any visual errors because of this warning?

erro
When I enable the shadowMap that's what I get. I've tried in chrome and firefox and got the same error. I use windows.

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

Thank you, WestLangley! It's on again

The following not appear to be a sufficiently-limiting constraint:

_shadowMapSize.min( _maxShadowMapSize );

...especially, in the case of PointLight, where _shadowMapSize is then increased by a factor of 4.

In fact, even for SpotLight, setting the shadow map size to the so-called "maximum" crashes my machine.

Was this page helpful?
0 / 5 - 0 ratings