Jump to content

Fog without binding to camera


Koroldev
 Share

Recommended Posts

Hi guys! I make map with the dark forest and I need make center of the map with good light, but the closer to the forest, then map gets darker. I need something like the fog but without binding to the camera. Fog always in position 0, 0, 0 and if player go to coordinates 100, 100, 100 then his go to the dark. While I did just the fog attached to the camera and if the player closer to the forest, then fog far from the player and camera. And the forest does not seem so dark. Anybody haves some ideas how do it?

 

Безымянный.png

Безымянный2.png

Link to comment
Share on other sites

Hi Negrant, good to see you, and nice looking scene.

I have 2 non-fog ideas. 

1.  All lights have .range property.  A point light above map-center... would light center well, but range could "fall-off" at tree line.  And don't forget the included/excluded things on lights, too.  You could exclude the trees from primary point light, and ONLY include the trees in a low-intensity hemi-light... used only to light the forest/trees.  Unfortunately, the ground might cause problems, as it is the same material... center-of-map or in-woods.  Difficult to do light includes and excludes with common ground material for woods and center. 

1A.  Also, perhaps spotlight over center of map, but light cone not wide enough to reach tree-line?  Then light entire area with low-intensity hemi.  Map center will be bright, but woods will be much darker.  Careful use of .range and light Y position (on flat ground) gives soft edges.  [test scene]

2. Use a very high point light over center, with shadow generator.  Then put a large torus beneath light.  Put only torus in shadowMap renderlist, and set ground and trees to .receiveShadows = true.   There is a way to make the torus invisible, and still cast soft-edge shadow.  (Perhaps create a smaller torus near-to light, instead of larger torus near-to map?  Experiment.)  This torus, if placed and sized properly...  should allow bright light thru center, but will cast large circular soft-shadow in surrounding area (the woods).  Adjust torus settings for needed soft-shadow size.  *shrug*  [test scene]

Not very good ideas, eh?  I think fog is done deep in BJS engine, and not easily customized.  Not sure, though.  Perhaps others will comment soon, too.

Addenda: http://playground.babylonjs.com/#PNJNN  Shadow demo from playground examples.  Line 44 - I set torus.visibility = .99.  Shadows missing.  uh oh.  Maybe I lied.  Perhaps it is NOT easy to cast shadow with invisible torus.  hmm.  And watch that torus as it orbits.  It looks retarded sometimes.  :o   hmm.

Link to comment
Share on other sites

On 12/19/2016 at 6:54 PM, Wingnut said:

Hi Negrant, good to see you, and nice looking scene.

Hi, thank, I am trying do something atmospherically and dynamically, work on it :)

Quote

1.  All lights have .range property.  A point light above map-center... would light center well, but range could "fall-off" at tree line.  And don't forget the included/excluded things on lights, too.  You could exclude the trees from primary point light, and ONLY include the trees in a low-intensity hemi-light... used only to light the forest/trees.  Unfortunately, the ground might cause problems, as it is the same material... center-of-map or in-woods.  Difficult to do light includes and excludes with common ground material for woods and center. 

I tried do something with this method, I like this idea, but I use scene.ambientColor = new BABYLON.Color3(0.3, 0.3, 0.3) - it add to my scene more cartoon style, but then all meshes on my scene, even without light looks bright. And only the fog can make it darker.

Quote

2. Use a very high point light over center, with shadow generator.  Then put a large torus beneath light.  Put only torus in shadowMap renderlist, and set ground and trees to .receiveShadows = true.   There is a way to make the torus invisible, and still cast soft-edge shadow.  (Perhaps create a smaller torus near-to light, instead of larger torus near-to map?  Experiment.)  This torus, if placed and sized properly...  should allow bright light thru center, but will cast large circular soft-shadow in surrounding area (the woods).  Adjust torus settings for needed soft-shadow size.  *shrug*  [test scene]

I don't want use the shadows, because I am trying do my game more performant. I like your thought process and your ideas, you are cool dude B)
I came up with another idea, I am counting distance and angle to the center of my map and depending of this parameters I am changing the fogStart, fogFinish and fogDensity. If player closer to the forest, then I reduce the scope of the fog, but if player turns round and look on center of the map, then I increase the scope of the fog. This method has its flaws but I am working on this algorithm to do it more realistic. Thank for help and for ideas - it help me to look at the problem from another angle :)

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...