Jump to content

How do you "stop" light at plain edges? is it possible?


aWeirdo
 Share

Recommended Posts

Hello!

So, i have been messing around with babylonjs for a couple weeks now, just trying different stuff out, now, i have a rectangular plain, aprox 150x100,

 

i want the "center" of the plain to be well lit from all directions, while at the edge, the light should rapidly fade out to black,

 

I have tried several set-ups, 

 

so far, the best results i've gotten regarding getting the fade-out effect is using 3 spotlights(1 in each end and 1 in the middel of the plain), but since they only cast light from above, all the objects sides are completely black.

 

Does anyone have a solution for this? is it even possible?

var light0 = new BABYLON.SpotLight("Spot0", new BABYLON.Vector3(0, 100, 0), new BABYLON.Vector3(0, -1, 0), 0.8, 2, scene);	light0.diffuse = new BABYLON.Color3(1, 1, 1);	light0.specular = new BABYLON.Color3(0, 0, 0);

post-17943-0-99563900-1452086759_thumb.p

Link to comment
Share on other sites

You want far away parts of the world to be dark, have you considered using fog for this instead of lighting? (if not, maybe you should...)

Then use some ambient lighting term and maybe a secondary light to act as a highlight (because ambient terms are rather flat)

Link to comment
Share on other sites

Hey and welcome,

 

If the bright area is centered on the camera, then as chg said: fog + ambient lighting is definitely the way to go.

 

If not, then I think your best bet is writing a custom ShaderMaterial, to which you'll pass the center coordinates of the bright area and then to a nice color fadeoff according to this. Try looking at the docs if you don't know where to start :)

 

Good luck

Link to comment
Share on other sites

Hi aW :)

 

Is this what you are trying to do?

 

Playground

 

Two lights, one a point  light and one a hemispheric light. Important lines are 35 and 36 - what objects get illuminated by what light.

 

You can play with pointlight's intensity and range to get the fall off effect you want

 

cheers, gryff :)

Link to comment
Share on other sites

Hi aW :)

 

Is this what you are trying to do?

 

Playground

 

Two lights, one a point  light and one a hemispheric light. Important lines are 35 and 36 - what objects get illuminated by what light.

 

You can play with pointlight's intensity and range to get the fall off effect you want

 

cheers, gryff :)

 

Yes, That is exactly what i was looking for.

 

Thank you :-)

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...