OsnaCS / plantex

(UNMAINTAINED) :seedling: experimental open-world exploration game with plants :evergreen_tree: :leaves: :herb: :palm_tree:
Apache License 2.0
191 stars 37 forks source link

Tracking issue: shadow #108

Closed LukasKalbertodt closed 8 years ago

LukasKalbertodt commented 8 years ago

I don't have time to explain this right now, but the basic task is clear: we need sun shadows.

First you should implement the basic algorithm, which is already hard enough.

Here are some names of algorithms to search for to improve the shadow quality:

jonas-schievink commented 8 years ago

Rendering a plain simple 1024x1024 shadow map halfes my FPS :persevere:

jonas-schievink commented 8 years ago

Fun fact: There's no way to use a sampler2DShadow with glium. gg

jonas-schievink commented 8 years ago

How are we going to prevent the sun from shining into the side of caves at the outer chunk boundaries and lighting up parts of caves?

Cranc commented 8 years ago

i looked for it a bit but i found nothing concerning lighting on chunk boarders with a fast google search.

So i can just give you my "experience" about that stuff.

in mc they seem to kinda avoid that issue by

  1. having relatively narrow cave systems.
  2. the amount of chunks rendered is sufficient that possible lighting does not reach the player.
  3. the light falloff is pretty high so light in it self does not spread far (-1 light level per block).

the ideas i have don't seem to be in any way practical to solve this issue

  1. calculate light per chunk (so we do not calculate it if it goes through "unloaded" chunks) which will be a lot of pain and mess up chunk boarders.
  2. use the "sun" as a means to calculate the light level of a given pillar surface (sun actually does not emit the light this way).

After getting all that out my best "kinda solution" would be to

  1. make caves/tunnels go more deep and curved and get smaller the deeper they go [with some exceptions] like reality
  2. make the light of the sun fall of faster (maybe introducing light levels on blocks is not a bad idea sadly not much time for that)

other than that i cant think of anything currently.

LukasKalbertodt commented 8 years ago

How are we going to prevent the sun from shining into the side of caves at the outer chunk boundaries and lighting up parts of caves?

Like @Cranc mentioned in (2.), this is unlikely to be a problem. It's important to note that Minecraft doesn't have shadows at all, but rather an occlusion based custom lighting system. Thus it's not really helpful to look at Minecraft in this regard.

I think we have more important issues to deal with :wink:

Fun fact: There's no way to use a sampler2DShadow with glium. gg

This, on the other hand, is a shame... It's still possible to set the GL_TEXTURE_COMPARE_MODE by calling the OpenGL function manually, but I'm not sure if we want that.

jonas-schievink commented 8 years ago

sampler2DShadow effectively just does PCF (right?), which I've implemented manually in the linked PR

Lukas Kalbertodt notifications@github.com schrieb am So., 31. Juli 2016, 23:44:

How are we going to prevent the sun from shining into the side of caves at the outer chunk boundaries and lighting up parts of caves?

Like @Cranc https://github.com/Cranc mentioned in (2.), this is unlikely to be a problem. It's important to note that Minecraft doesn't have shadows at all, but rather an occlusion based custom lighting system. Thus it's not really helpful to look at Minecraft in this regard.

I think we have more important issues to deal with 😉

Fun fact: There's no way to use a sampler2DShadow with glium. gg

This, on the other hand, is a shame... It's still possible to set the GL_TEXTURE_COMPARE_MODE by calling the OpenGL function manually, but I'm not sure if we want that.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/OsnaCS/plantex/issues/108#issuecomment-236458547, or mute the thread https://github.com/notifications/unsubscribe-auth/ABtCRr86t_Zj8LJ7AboIj6F7qF0SfMQdks5qbRc0gaJpZM4JWf_s .

Gruß, Jonas

LukasKalbertodt commented 8 years ago

sampler2DShadow effectively just does PCF (right?), which I've implemented manually in the linked PR

Correct, but sampler2DShadow uses hardware acceleration. Your manual version fetches four values from the texture, while the shadow sampler only fetches one (of course, four values are read from the texture, but only one is transferred back to the shader). But I guess this is not worth worrying about right now.

LukasKalbertodt commented 8 years ago

Shadow looks fine for now. We could maybe improve performance still, but I will close this already.