Three.js: NodeMaterial: Incorrect RectAreaLight specular highlight

Created on 2 May 2019  路  9Comments  路  Source: mrdoob/three.js

I know that RectAreaLight can't cast shadows, and that's ok... but I have this problem

A scene with a single spotlight and a single area light (you can see its highlight on the floor)
image

The same scene with shadow casting enabled for the spotlight
image

what's wrong?

Three.js version
  • [x] Dev
Bug

All 9 comments

It is best to redirect your question to the three.js forum.

If you can provide a _live example_ demonstrating a bug in the _current three.js revision_, you may reopen this issue.

I've planned to update Three in a month, it's a bit complex since there are many changes I've to take care.

But if you are redirecting me to the forum, you say it isn't a bug.. maybe with the update the problem is already resolved.
Sorry, could you confirm me that the RectAreaLight can't and should not conflict with another light even if that one is casting shadows?
Because here when I runtime switch on the spotlight.castShadow to "true" the RectAreaLight become as you see

But if you are redirecting me to the forum, you say it isn't a bug.

I did not say that. I don't know if it is a bug.

I do know it is something I was not able to reproduce.

Sorry, could you confirm me that the RectAreaLight can't and should not conflict with another light even if that one is casting shadows?

I would not expect such a conflict to occur.

Hi @WestLangley
Here your Fiddle!

https://jsfiddle.net/9zkrbj2m/6/

The problem is only when the specular highlight happens on a NodeMaterial and the Spotlight casts shadows...
Check the floor plane on my demo.
Try to deactivate Spotlight's shadows casting.

@MEBoo Thanks for the fiddle.

It seems to me the RectAreaLight specular highlight is incorrect with NodeMaterial regardless of whether another light casts a shadow; toggling the shadow can amplify the error.

Data is being corrupted somewhere, apparently. I am not sure what is going on...

/ping @sunag

sorry delay... RectAreaLightUniformsLib.js modify native uniforms but nodematerial not use native uniforms... this bug is because of this ltc_1 and ltc_2 is not sended to uniforms.
This example bellow fix this:

https://jsfiddle.net/8nhk975v/

 material.onBeforeCompile2 = material.onBeforeCompile;
 material.onBeforeCompile = function ( shader, renderer ) {

    this.onBeforeCompile2( shader, renderer );

    this.uniforms.ltc_1 = { value: undefined };
    this.uniforms.ltc_2 = { value: undefined };

};

Also, due to #16777 in r.106, you also need to call

THREE.RectAreaLightUniformsLib.init();
Was this page helpful?
0 / 5 - 0 ratings