Jump to content

Heightmap cast shadow issue


nittrus
 Share

Recommended Posts

So I would like to have my terrain cast shadows on it's self, like the mountains shadow the rest of the terrain, etc.
But when I try to do this by adding the groundPlane to the shadowGenerator, the entire mesh turns black.

Is there a way to do this, or is this not something that can be done yet? I really hope to be able to pull this off! :)

Link to comment
Share on other sites

On 10/13/2016 at 4:57 AM, Wingnut said:

Hai wingy!

I see that working, that is nice and is what I want, but isn't what I get but also, I'm using BABYLON.Mesh.CreateGround not heightfield.
However, I took that PG and modified it pretty close to what I have and found out that useVarianceShadowMap set to true was the culprit, however, now the shadow is showing for the hills but it looks destorted, I been playing with bias but not quite getting a better result, but it is better than the entire mesh being black, so yay progress!

Here is the modified PG: http://playground.babylonjs.com/#TCPB#2

Thanks for the help Wingy!

Link to comment
Share on other sites

.usePoissonSampling works, without .forceBackFacesOnly (near perfect from a distance)
http://babylonjs-playground.com/#TCPB#4

I think it is a bug in variance shadow mapping, in the Chebycev inequality function. (Only the variance/blur variance shadows use this)
I looked at it, and modified it yesterday evening but I could not figure it out... Weird, because it seems ok, but still not working. Maybe with fresh brain.
I would like to use the much nicer variance shadows, poisson is ugly from up close.

(How nice would be a distance-field shadow which smoothes out at a distance from the shadow caster.)

 

Link to comment
Share on other sites

In BABYLON shader source:
https://github.com/BabylonJS/Babylon.js/blob/master/src/Shaders/ShadersInclude/shadowsFragmentFunctions.fx#L141

Something very similar in playcanvas source:
https://github.com/playcanvas/engine/blob/master/src/graphics/program-lib/chunks/shadowVSM_common.frag

So I think I understand now what it does, but I cannot figure out why it is not working.
If I switch on both receiveShadows and shadow casting on everything , everything is shadowed.
Poisson works. (but it is not smooth)

I hope someone will help me !? <_<

Link to comment
Share on other sites

13 hours ago, BitOfGold said:

.usePoissonSampling works, without .forceBackFacesOnly (near perfect from a distance)
http://babylonjs-playground.com/#TCPB#4

I think it is a bug in variance shadow mapping, in the Chebycev inequality function. (Only the variance/blur variance shadows use this)
I looked at it, and modified it yesterday evening but I could not figure it out... Weird, because it seems ok, but still not working. Maybe with fresh brain.
I would like to use the much nicer variance shadows, poisson is ugly from up close.

(How nice would be a distance-field shadow which smoothes out at a distance from the shadow caster.)

 

I had actually discovered that, I even got it looking decent using poison sampling up close now and was able to lower the shadowmap size to regain a bit of performance.
I ended up having two lights for the sun position so to have a shadow generator for the terrain and one for the models, I had to lower the light level of one and the other and adjust shadow darkness until they synced up, it worked very well!

Blurvariance destroys performance so much that I won't even consider using it at this time, maybe if it gets better in the future but it does look nice, but I go from 40FPS with poison and all the other stuff in my scene down to 22FPS with blurvariance.. and that is just with that mode on.

Link to comment
Share on other sites

6 hours ago, BitOfGold said:

Two lights! And i thought of every possible method but not this simple!
You made my day :D
 

Glad to have helped! :)
Just remember there is a limit of lights you can have in a scene (I think 6 if I recall), but this was a light well used I think!

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