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

Support shadow intensity #14087

Closed
wants to merge 1 commit into from

Conversation

WestLangley
Copy link
Collaborator

As proposed in #8238.

The shadow intensity (darkness) can be changed without affecting the overall illumination of the scene.

This implementation adds a single uniform, renderer.shadowIntensity, that takes a value in [ 0, 1 ], defaulting to 1.

The approach works with (Gouraud) MeshLambertMaterial -- whose shadows are an approximation -- and it also works with the other built-in materials, where shadows are implemented correctly as the absence of light. (MeshLambertMaterial does not accommodate a per-light shadow intensity.)

I can add docs later if this is merged.

@mrdoob mrdoob added this to the r94 milestone May 22, 2018
@mrdoob mrdoob modified the milestones: r94, r95 Jun 27, 2018
@sunag
Copy link
Collaborator

sunag commented Jul 30, 2018

I think that for a more customized scene it should be per light light.shadow.intensity like Unity
https://docs.unity3d.com/Manual/ShadowOverview.html

@WestLangley
Copy link
Collaborator Author

I think that for a more customized scene it should be per light light.shadow.intensity

I do not think a per-light shadow intensity is possible with MeshLambertMaterial. It is possible for the other materials.

/ping @bhouston It the capability to control shadow intensity a worthwhile addition in your view -- or too hacky?

@mrdoob mrdoob modified the milestones: r95, r96 Jul 31, 2018
@mrdoob mrdoob modified the milestones: r96, r97 Aug 29, 2018
@mrdoob mrdoob modified the milestones: r97, r98 Sep 25, 2018
@WestLangley
Copy link
Collaborator Author

Closed due to lack of interest.

@iangilman
Copy link

I'm definitely interested! I'm not qualified to review the patch, but I'd use it if it landed…

@WestLangley
Copy link
Collaborator Author

For a workaround, you can use two lights: light1 and its clone:

var shadowIntensity = 0.5; // between 0 and 1

var light2 = light1.clone();
light1.castShadow = true;
light2.castShadow = false;
light1.intensity = shadowIntensity;
light2.intensity = 1 - shadowIntensity;

@iangilman
Copy link

Wow, that's brilliant in its simplicity! I wrestled with this problem for a bit and that solution never occurred to me. Thank you!

@WestLangley WestLangley deleted the dev-shadow_intensity branch October 24, 2018 15:48
@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 15, 2019

Closed due to lack of interest.

I think modulating the shadow intensity is something desirable for the library. I vote to reopen the PR and merge it with proper documentation.

@stevensanborn
Copy link

stevensanborn commented Feb 10, 2020

My issues with shadows are on the mesh level and would like to see it there. For instance a mesh with 10% opacity should not have a full shadow.
mentioned here

@manoj382
Copy link

For a workaround, you can use two lights: light1 and its clone:

var shadowIntensity = 0.5; // between 0 and 1

var light2 = light1.clone();
light1.castShadow = true;
light2.castShadow = false;
light1.intensity = shadowIntensity;
light2.intensity = 1 - shadowIntensity;

Saved me a lot of heartache. Thanks!

@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 8, 2024

Closed due to lack of interest.

@WestLangley Modulating shadow intensity or darkness for artistic purposes is a feature request that repeatedly comes up (latest request from the forum). The workaround via lights provides a solution but it would be easier and more intuitive to configure a property per light shadow as suggested in #14087 (comment). Now that MeshLambertMaterial has been refactored and uses per-fragment lighting, there should be no blocker anymore (MeshGouraudMaterial from the addons should not support this feature).

I have implemented this feature in Mugen87@65510a7 and it can be tested with this link:

https://rawcdn.githack.com/Mugen87/three.js/65510a73b201b29cdf2714710feb773f227c90d0/examples/webgl_lights_hemisphere.html

Would you support this change?

@WestLangley
Copy link
Collaborator Author

Would you support this change?

Yes. I support adding shadow intensity for artistic purposes, as I did in #8238.

Please note that shadow intensity should take values in [ 0, 1 ]. Your example allows values larger than that, and the example should be corrected.

@Mugen87 Mugen87 modified the milestones: r98, r166 Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants