-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
New shadow volumes based on internal scenes #312
Conversation
…nderContext, InternalUseOldShadowVolumes for testing.
We talked about this with @and3md , I'm making a note here too:
|
This has been addressed in Shadow volumes now work on OpenGLES! Along with shadow maps, 3D textures, occlusion query and much more -- see CGE news ( https://castle-engine.io/wp/ ) around the coming weekend, I will describe everything that happened. In the end I used code and ideas from this branch, although I didn't just merge the commits. We've done a lot of code changes since this PR, in particular Here's a screenshot from Android (rather low-end 32-bit Android tablet, so don't worry about FPS :) ): |
This PR adds new shadow volumes algorithms compatible wit OpenGL ES (works on mobile phones). Don't merge it now to master (a lot of code duplication for testing).
Current state
We have now four algorithms for testing:
InternalUseOldShadowVolumes := true
to use itInternalUseOldShadowVolumes
andInternalShadowVolumesUseDepth
tofalse
OpaqueTrianglesEnd
orTransparentTrianglesEnd
(setInternalUseOldShadowVolumes
andInternalShadowVolumesUseDepthV2
tofalse
andInternalShadowVolumesUseDepth
totrue
)RenderSilhouetteShadowVolume
(setInternalUseOldShadowVolumes
tofalse
andInternalShadowVolumesUseDepth
andInternalShadowVolumesUseDepthV2
totrue
)I think internal scene based with DEPTH approach in cups (V2) is the most promising.
Algorithms correctness
All algorithms works the same (shadows are the same), with our example models but test that please.
Speed
In base scenario internal scene based algorithm is slower than the old one. It can be faster when we set
TCastleViewport.InternalShadowVolumeUpdateFactor
to value bigger than 0 (0 = update every frame). What makes shadows are updated less frequently than every frame. New algorithm works faster on desktop when there are more objects and update factor > 0. On mobile rendering slows down the most.I think old algorithm is faster because graphic card driver can buffer
glVertex
calls more efficiently (maybe in one VBO) than we switching our VBO it on every internal castle scene. Or maybe that's because we have two scenes per shape.So we need find a way to speed up internal scenes or maybe we should make only two "global" internal scenes (or internal scenes per
TCastleScene
) not scenes for each shape.So there are two things to optimize:
How to test?
TGLShadowVolumeRenderer.Render testing
It also can be tested, when
InternalShadowVolumesOldRender
istrue
there is the old render withglPushAttrib()
/glPushAttrib()
Code style
Code has a lot duplications but will be cleaned after testing/choose new solution.