-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
SpotLightMap2 #20290
SpotLightMap2 #20290
Conversation
a8b3194
to
9376065
Compare
9376065
to
d361e3e
Compare
Should I run |
Yes that would be great! |
all clear, ready for review ! |
|
||
var spotLight = new THREE.SpotLight( 0xffffff ); | ||
spotLight.position.set( 100, 1000, 100 ); | ||
spotLight.map = new THREE.TextureLoader().load(textureUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not include the usage of map
in the basic spot light example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's an editorial call, I'll remove it if needed
Ok now the spot light maps shoud work with or without shadow mapping ! |
That is weird, I cannot reproduce the test errors on my computer, neither visually nor with npm run test-e2e, which gives me yet another set of failing examples (!). |
I've downloaded your latest code and tested one of the failing examples (
|
Ok so, the culprit is here On my computer (windows/chrome), the preprocessor is ok with it. I could |
Ok, tests are fixed.
turned into
Thus, it chocked on |
This comment has been minimized.
This comment has been minimized.
Thanks @Mugen87 for your reviews! I agree this is a bit more complicated than I expected, but that was the simplest solution I found to support the 4 cases (with/without shadowmap and with/without texturemap) with no big refactoring and with minimal impact on the shadowmap code path. |
Spent some time reviewing this and I'm not sure adding a How about doing a const light = new THREE.TextureLight( texture );
light.setSize( 2, 1 ); // We can add a method to make sure the frustum matches the texture size.
scene.add( light ); I think having a different type of light will make the implementation more readable. @mbredif What do you think? |
Not exactly, the aspect ratio of the projected texture is not fixed to 1. The complication comes from supporting both an optional texture and an optional shadowmap (4 cases). A tradeoff could be to introduce a TextureLight with optional shadowmap support. I expect some redundance (a lot?) with SpotLight but the code would be simpler (mostly in the shader : one extra for loop for TextureLights instead of a larger for loop with index checks to distinguish the 4 spotlight cases). Also the TextureLight could be slightly simpler by not supporting the circular spot lighting defined by (angle, penumbra...) On a related note, have you ever thought about a ShaderLight, that could be tuned by advanced users, similar to (Raw)ShaderMaterial is offered for advanced Material users ? |
That's what I'm proposing yep!
Interesting! |
This is called a "Projector" in Unity, I think, if you're interested in a more consistent / intuitive name. In Unity it can be used to multiple the surface color by the texture (create custom shadows from textures) or additively for lighting. It also supports orthographic projection as well as attenuated projection (though those features can come later if needed).
You should be able to achieve this by updating a RenderTarget passed into a TextureLight, right? This looks great! Looking forward to this feature. |
We can't use |
Oh I see -- just took a look at Projector.js and as far as I can tell it's just used in SVGRenderer and is pretty undocumented, right? It seems like it could be pretty safely renamed to something like |
Hi, this functionality is super awesome. Thank you. Apologies for being 'that guy' - as im unfamiliar with the release cycles of three.js - is this in good enough shape to start using off of this branch? if not, is this expected to be rolled into dev / master for a release? Thank you! |
Hello everybody,
The texture on objects are ok, but the textures projected by spotlight have some artifacts around the white pixel points and colors are brighter. Original file texture: Texture loaded on material of mesh: Texture projected on mesh: Any advise to solve these issue? |
@RobertoAlda, there might be other issues, but the spotlight effect sure does not help by modulating the mapped color.
That goes towards the hint from @mrdoob to remove the spot light falloff from this and rework this PR as a TextureLight... |
At this point, the main blocker are the conflicting files. Any chance you could clean these up? |
I gave it a try : |
Closing in favor of #21944. |
rebased version of the original PR #14621