foumfo

Prevent light from escaping through planes/meshes

Recommended Posts

(I fix some little things, now we have a scene for testing ;) https://playground.babylonjs.com/#M6HJ3P#2)

[edit]

as asked, here my changed:

  • attach camera to player seems to be break, so I disable player - doesn't need for tests
  • add a mesh sphere to the light position
  • push meshes to shadowgenerator

now, just try to find time to help

[/edit]

Share this post


Link to post
Share on other sites

https://playground.babylonjs.com/#M6HJ3P#8

Hey, I get to play, too, right?  I cranked-up the shadowGenerator's resolution a bit, and then did a bunch of other un-helpful things.

What's the issue, here?  Merged wall panels don't act correctly when used to block light?   Never mind telling me, I'm terrible at shadow management, anyway.  :)

All in all, that .25 in line 86... really affects the shadows.  The slight "tilt".  Interesting.  Sorry for killing the light sphere mesh.  I was in a spotlight frame of mind.  heh.

Share this post


Link to post
Share on other sites

After some testing, I've made some observations:

1. light.shadowMinZ is necessary it seems for lighting to work

2.light.shadowMaxZ breaks the lighting in the scene

3. shadowGenerator.bias = 0.0001 is the only value of it that works, but with a few glitches

4. adding a mesh as the lights parent definitely breaks everything up. And thats the worst of it because I need this to work.

check it out: https://playground.babylonjs.com/#M6HJ3P#10

Share this post


Link to post
Share on other sites

I still can't get it to work in my scene:

image.thumb.png.c81bf7c2a6270dca3e303de6a0b44d60.png

var shadowGenerator = new BABYLON.ShadowGenerator(1024, playerLight);
    for(i = 0; i < scene.meshes.length; i++){
        if(scene.meshes[i].name != "sphere"){
            scene.meshes[i].receiveShadows = true;
        }
    }
shadowGenerator.addShadowCaster(wallsFinal);
shadowGenerator.bias = 0.0017;
light.shadowMaxZ = 100;
light.shadowMinZ = 0.0001;

and this when I add all the meshes as shadowCasters:

image.thumb.png.1a49e32551dff07b6830b35202c49baf.png

The only kind of light that works surprisingly well is a spotlight, just like wingnut's example but that's not what I'm looking for:

image.thumb.png.981c60207489cd807641cda321318b69.png

 

Share this post


Link to post
Share on other sites

I would assume he wants to drop duplicate vertices.

so like he he merged two planes instead of the point array being
//First Plane
-1, -1,  0,
-1,  1,  0,
0,  -1,  0,
0, 1,  0,
//second Plane
0,  -1,  0,
0, 1,  0,
1, -1, 0,
1, 1, 0

it would be:
-1, -1,  0,
-1,  1,  0,
0,  -1,  0,
0, 1,  0,
1, -1, 0,
1, 1, 0

after merge.  I think that's what he is going for.

Share this post


Link to post
Share on other sites
18 minutes ago, Pryme8 said:

I would assume he wants to drop duplicate vertices.

Yeah, something like that. For example, 'merging' all duplicate vertices in a MergedMesh. Would it help in any way in terms of lighting and performance?

 

Share this post


Link to post
Share on other sites
1 hour ago, Deltakosh said:

It could break lighting as normals will be merged as well :)

Regarding performance it clearly depends on the number of duplicates we will remove

Still if it can be done it's worth a shot

Share this post


Link to post
Share on other sites

There is a method to remove duplicated vertices http://doc.babylonjs.com/samples/minimise_vertices however this will have an effect on lighting and textures where planes meet so you many find it produces more problems than it solves. You need to read this as well http://doc.babylonjs.com/resources/facets  (incorrect link on min verts page - will correct)

Note the following PG ONLY deals with minimizing vertices (196 before to 92 after) and makes no attempt to help with lights and shadows issues.

https://playground.babylonjs.com/#M6HJ3P#14

Share this post


Link to post
Share on other sites
50 minutes ago, JohnK said:

There is a method to remove duplicated vertices http://doc.babylonjs.com/samples/minimise_vertices however this will have an effect on lighting and textures where planes meet so you many find it produces more problems than it solves. You need to read this as well http://doc.babylonjs.com/resources/facets  (incorrect link on min verts page - will correct)

Note the following PG ONLY deals with minimizing vertices (196 before to 92 after) and makes no attempt to help with lights and shadows issues.

https://playground.babylonjs.com/#M6HJ3P#14

I see. So it's better to just leave the merged planes as it is right?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.