Code Monkey home page Code Monkey logo

Comments (6)

wilfredjonathanjames avatar wilfredjonathanjames commented on September 15, 2024 1

Also, it's important to note that only the objects that cast shadow, not the ones that receives shadow, should be given as input to generate_shadow_map.

That's a really helpful point, thanks! Would be great to know when this changes, but no pressure on my side.

from three-d.

asny avatar asny commented on September 15, 2024

Only the cube should cast shadow, so if you only use the cube when generating the shadow map, it should look better. The problem is that the ground is really big and the 1024x1024 pixel shadow map will be stretched over a large area.

from three-d.

wilfredjonathanjames avatar wilfredjonathanjames commented on September 15, 2024

Ah that makes sense. So if I had custom terrain that I'd generated in some third party software and wanted it to cast shadows on itself, I would simply need to choose a larger shadow map?

from three-d.

asny avatar asny commented on September 15, 2024

Using the shadow map technique over large areas is generally not a good idea, you'll have to move the directional light with the camera to only cast shadow close to the camera view where the shadows are visible or maybe make several directional lights.

I came to think about that in the case you present, the artifacts are more visible by the direction of the light being close to parallel to the ground. Also, the shadow has a soft edge which is not looking good in this case.

from three-d.

wilfredjonathanjames avatar wilfredjonathanjames commented on September 15, 2024

Ah ok, in that case does a directional light have a some local bounds that it generates shadow maps within? Is there something like a ScissorBox that applies here? I know these are probably quite simple questions, and appreciate your time.

from three-d.

asny avatar asny commented on September 15, 2024

Ah ok, in that case does a directional light have a some local bounds that it generates shadow maps within? Is there something like a ScissorBox that applies here?

Yes, it will position the shadow map camera such that the objects that cast shadow are all within its viewport. That means, if you have a large object or two objects that are far away from each other, the shadow map will cover a large area and the shadows therefore look pixelated.

you'll have to move the directional light with the camera to only cast shadow close to the camera view

This was not a well thought out reply, of course you can't move a directional light. Instead, you could generate the shadow map with only the objects that are just in front of the camera. Also, it's important to note that only the objects that cast shadow, not the ones that receives shadow, should be given as input to generate_shadow_map.

maybe make several directional lights.

I have considered supporting multiple shadow maps on a single directional light, but unfortunately there's more important tasks at the moment.

I know these are probably quite simple questions, and appreciate your time.

I think they're totally valid questions, I'll convert this into a discussion afterwards so others may find answers to the same questions 👍 I should maybe also update the documentation of generate_shadow_map to make it a bit more clear.

from three-d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.