Shadowmap Artifacts

posted in VoxycDev
Published January 26, 2019
Advertisement

There is clearly something wrong with the images below. The shadows are not supposed to be this far away from the surfaces they are cast from. Can I correct this with bias or should I fix the scale? The shadows used to look real, but all this floating point multiplication must have got in the way. Two years ago it looked perfect. What happened with this shadowmap?

https://github.com/dimitrilozovoy/Voxyc/blob/master/engine/ShadowMap.cpp

https://github.com/dimitrilozovoy/Voxyc/blob/master/engine/ShapeRenderer.cpp

fatelessshadowmap1.thumb.png.887ee51d7cf1db1023db1717d189644a.pngfatelessshadowmap2.thumb.png.e31afbd0dfd97cf513eadba487433f17.pngfatelessshadowmap4.thumb.png.489184be368b73f3f9affbafffec6484.png

0 likes 3 comments

Comments

Programmer71

I'd check your light projection matrix , if you are using glm and 2 years ago things were ok, its probably something related to matrix projection, your code looks good to me, even if i hadn't the time to check it. Bias is used to reduce shadow acne , but introduces peter panning, usually it is set to 0.005 , but there are variations like tangent bias and other hack to minimize problems.

One question , why in this era of unreal and unity you have chisen to develop your engine ? i am too , by the way and i'd like to hear opinion form other apparently 'irresponsible' programmers.

 

January 26, 2019 09:45 AM
_Silence_

Shadow-mapping is tricky. If you change the light direction you also have to change the position of where the view from the light settles. A bit too far, too high or too left or right and the shadow will be displaced.

January 26, 2019 11:23 AM
VoxycDev
9 hours ago, Programmer71 said:

One question , why in this era of unreal and unity you have chisen to develop your engine ? i am too , by the way and i'd like to hear opinion form other apparently 'irresponsible' programmers.

Because probably like a lot of other people, I saw John Carmack's Wolfenstein 3D, Doom and Quake source code and said to myself "I want to do this too. Just like that." Also, I like developing on mobile and neither Unreal nor Unity editors run on mobile, at this time, as far as I know. Also, I like to have my own style in how the controller responds, how the game physically feels, etc. Also, I like how my games load fast (no loading unnecessary subsystems) when made with C++. Also, hopefully, pretty soon we'll have so much MIT-licensed open source code that we won't need Unity or Unreal and we'll just make everything from open-source faster than closed-source companies because there are simply more of us (more open source programmers out there than programmers in any particular game/engine development company), which seems to be the direction these days.

8 hours ago, _Silence_ said:

Shadow-mapping is tricky. If you change the light direction you also have to change the position of where the view from the light settles. A bit too far, too high or too left or right and the shadow will be displaced.

In my engine, i have a Lua function called setsun. I call it like this:

  setsun(10, 10, 10, -45, -45, 0, 50)

The parameters are:

  setsun (x position of light, y position of light, z position of light, pitch of light, yaw of light, roll of light, size of lit area)

I've been playing with these numbers for a day or two now. It seems that changing x, y, z too far away from 0 just gets less and area covered by light. Any size of lit area larger than 130, and light also disappears. Maybe I'm going to try to play with some simple blocks on different scales instead, simplify the scene, to see where the problem might be.

January 26, 2019 07:51 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement