Refactor librenderer2 to modular rendering pipeline and state management#1275
Refactor librenderer2 to modular rendering pipeline and state management#1275adfriz wants to merge 13 commits into
Conversation
Overhauled LibRender2 to use a structured pipeline architecture. - Split rendering logic into specialized passes (Geometry, Sky, Shadow, Overlay). - Added SceneManager to decouple visibility logic from the renderer. - Implemented GraphicsDevice for centralized OpenGL state caching. - Introduced GpuResourceManager for managed resource lifecycles. - Unified the rendering loop across all application modules.
|
Without digging too far into what you've done, I'd suggest that you probably want to convert the rest of the SetBlend calls from the base renderer. Looks like the blending mode is off to cause the halo. |
- Replace direct OpenGL calls (GL.DepthMask, GL.Enable, GL.BlendFunc, etc.) with GraphicsDevice cached state methods across LibRender2 and OpenBVE renderer. - Add null-safety checks to Transformation constructors and Vector3 transformation operations to prevent NullReferenceExceptions. - Ensure proper renderer de-initialization in GameWindow during application shutdown. - Update Transformation constructors to use default vectors (Right, Down, Forward) when the input transformation is null.
This reverts commit 03dd64b.
- Implement a blend state stack (PushBlendFunc/PopBlendFunc) in BaseRenderer to allow safe temporary blending changes. - Convert direct OpenGL blending calls in OpenGlString and Background to use BaseRenderer helper methods. - Fix "halo" visual bug by ensuring proper restoration of blending state in text rendering. - Restore null-safety checks in Transformation constructors and Vector3 operations to prevent crashes. - Fix compilation error in NewRenderer by adding missing using directive.
- Implemented Opaque Face Batching to significantly reduce draw calls. - Optimized VisibleObjectLibrary with O(1) insertion and deferred VAO sorting. - Replaced expensive parallel distance sorting with camera-forward dot product (20x faster). - Fixed race conditions in ObjectLibrary by using thread-safe cloning for alpha faces. - Resolved Z-fighting and flickering artifacts using DepthFunction.Lequal. - Added defensive null checks for VAOs and animation matrices to prevent crashes. - Implemented AABB and Bounding Sphere generation for future culling optimizations. - Optimized state management for night textures to minimize redundant GL calls.
- Updated default fragment shader for better lighting/transparency handling. - Refactored OverlayPass, SkyPass and main Renderer entry points for consistency. - Updated ShaderLayout and FaceState to support recent performance optimizations.
|
The cab overlay faces aren't right at the minute- I'm seeing a lot of stuff in 2D (BVE4 / BVE2 era cabs) being glitchy. |
- Implement RenderFace in BaseRenderer to unify drawing across passes - Optimize matrix and VAO updates by tracking current ObjectState - Refactor ShadowPass to use centralized RenderFace logic - Improve OverlayPass handling for new renderer path - Fix light direction sign in ShadowPass - Ensure proper shader state reset when switching programs
|
on master, shadow currently not affected if using night time texture or its emissive material. do you think i should give player 2 new checkbox in the shadow settings to allow player to choose if shadow cast on faces with night time texture and emissive material? it should say like: because some trains content like the fujikyu 6000 above wont cast shadow on the interior because it use night time texture. |
|
Less options is better really. I will note the following which you may or may not have seen: See also the linked issue. |



Overhauled LibRender2 to use a multipass pipeline architecture.
Although it works locally, it have some bugs like shadow not working, some weird halo effect around texture, ingame gui looks odd, 2d cab looks too bright.
WIP, not tested in macos and linux.
currently only synced to commit d37ec8e from upstream master.