Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeMaterial: Incorrect RectAreaLight specular highlight #16375

Closed
1 task done
MEBoo opened this issue May 2, 2019 · 9 comments
Closed
1 task done

NodeMaterial: Incorrect RectAreaLight specular highlight #16375

MEBoo opened this issue May 2, 2019 · 9 comments
Labels

Comments

@MEBoo
Copy link

MEBoo commented May 2, 2019

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
  • Dev
@WestLangley
Copy link
Collaborator

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.

@MEBoo
Copy link
Author

MEBoo commented May 3, 2019

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

@WestLangley
Copy link
Collaborator

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.

@MEBoo MEBoo changed the title RectAreaLight over bright when another light has shadow casting enabled RectAreaLight over bright on NodeMaterial when another light has shadow casting enabled May 4, 2019
@MEBoo MEBoo changed the title RectAreaLight over bright on NodeMaterial when another light has shadow casting enabled RectAreaLight over bright specular highlight on NodeMaterial when another light has shadow casting enabled May 4, 2019
@MEBoo
Copy link
Author

MEBoo commented May 4, 2019

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.

@WestLangley WestLangley changed the title RectAreaLight over bright specular highlight on NodeMaterial when another light has shadow casting enabled NodeMaterial: Incorrect RectAreaLight specular highlight May 4, 2019
@WestLangley WestLangley reopened this May 4, 2019
@WestLangley
Copy link
Collaborator

@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...

@WestLangley
Copy link
Collaborator

/ping @sunag

@sunag
Copy link
Collaborator

sunag commented Jun 18, 2019

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 };

};

@WestLangley
Copy link
Collaborator

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

THREE.RectAreaLightUniformsLib.init();

@sunag
Copy link
Collaborator

sunag commented Jun 18, 2019

this PR fix this issue
#16796
b08bc89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants