-
Notifications
You must be signed in to change notification settings - Fork 201
Improve the shadows handler code #2710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…e cost of breaking custom shaders compatibility * Work on tighter shadow box * Remove custom in-shader bias formulas and use standard OpenGL Polygon Offsets instead * Switch to front face culling for terrain rendering to combat weird ROAM artifacts. Many years ago that caused issues, but perhaps it won't anymore
…center to be pixel perfect on the shadow map texture
…ding to the shadow cuboid w/o the extraShadowCamHeight adjustments
|
|
||
| const float t = -(plane.dot(p0) + plane.w) / denom; | ||
| if (t < 0.0f || t > 1.0f) | ||
| if (t < 0.0f/* || t > 1.0f*/) // we only care abut the case when the intersection is behind p0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we? The function seems only used in some shadow debug code currently, but this is a generic math function that takes a definite endpoint argument for the ray. Maybe there should be a separate "infinite ray towards a direction" function, or maybe the caller in this case can just put p1 like 1000x further away to guarantee a hit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think you're right, I'm making massive changes to this branch now in order to implement shadow cascades, once done I will make another function for ray vs plane.
| float mapPolygonOffsetScale = 10.0f; | ||
| float mapPolygonOffsetUnits = 10000.0f; | ||
| float objPolygonOffsetScale = 5.0f; | ||
| float objPolygonOffsetUnits = 1000.0f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if somebody tweaks the values? Could use a "larger means X, current value chosen via Y" comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it controls the absolute and slope dependent shadow depth offsets. It's pretty hard to explain the exact effects though, so I mostly got to these values by experiment.
/debugshadowfrustumin conjunction with new/freezeshadowfrustumallow to freeze all shadow cube related calculations/updates and view the frozen state in the world space.PolygonOffset, the values of which I hand-tuned to work better in most of the casesShadowProjectionModeandShadowColorModeare now deprecated. I don't think anyone used it ever.