Light from a disco ball?

What would be the best way to simulate the light from a disco ball?

In Unity you would use a point light and then give it a “cookie” which I believe is a cubemap that works as a texture filter for the light.

How hard do you think that would be to implement?

UPDATE

Eeeek looking at how we bind the stuff for the pointLight, It might be better to extend the materials I need and bind the data for the single light and cubemap.

1 Like

https://playground.babylonjs.com/#V6JU3U

think I got it.

1 Like

https://playground.babylonjs.com/#V6JU3U#2

Now the question is how do I get a shadowMap to contribute to this and obfuscate the “light” from the projected cubemap on the correct meshes.

I have a 0.0 intensity light in the scene at the same position as my shader light so that the normal attributes get bound to the shader for the meshes.

My guess is I need to capture a cubeDepthPass from the lights perspective, then sample that on the fragment check my depth at that position and if its farther then what the sample for the depth Pass says then don’t add any color from the projection?

Sooo the next question (that ill prolly end up self answering anyways) is how do you generate a cubeDepthMap? Time to google ^_^.

UPDATE
It looks like you can have the shadowMap from the pointlight Generate even if the intensity is 0!
https://playground.babylonjs.com/#XDNVAY#9
Happy days.

https://playground.babylonjs.com/#V6JU3U#4
So I got all the way to sampling the light maps texture, but I’m sure this is not correct. How do I get the right mask data?

3 Likes

Adding @nasimiasl who might be able to help with the custom material

hey i will back soon for this thanks @sebavan

1 Like

Thank you, yeah I’m just not sure why I can get the shadow stuff to work the way I was expecting. Gonna try to take a look today agian.

I’ve done it before so not sure where my disconnect is this time.

1 Like

i will start that on shaderbuilder for do it faster then we can convert that :slight_smile:

that is heavy request for FPS i will try make simply as i can

i start with define line calculate
float Line(vec3 p1,vec3 p2,vec3 p){

            vec3 norm = normalize(p2-p1);

            vec3 p3 = p1 + norm*length(p-p1); 

            return  pow(1.-max(0., length( (p3-p))) ,1.);               

        }

https://www.babylonjs-playground.com/#I5NJSE#10

1 Like

This is cool, but not really what I am looking for.

I just need to figure out how to get the shadows appearing on the meshes in my example pg and I can take it from there. Definitely appreciate your attempt to help though!

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

This is what it would look like, but this only works with one shadow system. I essentially need to highjack this so the regular shadow systems can work over the top.

i know that need you calculate 3 lines per each face and can detect space behind the face by math but we need very optimized line code

Naw, I just need to test the position vs the depth of the probe texture and match that up. I think I figured out what I’m doing wrong and will see about fixing it here soon.

I’ll toss the real texture on there and show an example here today if I get a chance. I appreciate your help but think we got it :wink:.

1 Like