Skip to content

Implement basic directional shadow CSM with PCF#1252

Open
adfriz wants to merge 18 commits intoleezer3:masterfrom
adfriz:directional-shadow
Open

Implement basic directional shadow CSM with PCF#1252
adfriz wants to merge 18 commits intoleezer3:masterfrom
adfriz:directional-shadow

Conversation

@adfriz
Copy link
Copy Markdown
Contributor

@adfriz adfriz commented Apr 2, 2026

  • Add CascadedShadowMap and CascadedShadowCaster to LibRender2.
  • Implement shadow depth shaders for depth pass rendering.
  • Update default shaders to support shadow sampling and application.
  • Add shadow configuration settings (Resolution, Distance, Cascades, Strength) across OpenBVE, RouteViewer, and ObjectViewer.
  • Update math library with frustum and matrix helper functions.
  • Add localization for shadow settings in English and Indonesian.

Note:
Only tested locally in release and debug builds on windows.
Need further fix, not guaranteed 100% works on all route and trains.
Need more test for linux and macos.

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 2, 2026

First off, congratualtions.
I've tried playing with this several times, but haven't ever got results which are quite right.

Faces using transparency aren't quite right yet though- I don't think they're casting shadow at all, but I haven't got as far as debugging it properly.
test.zip

(This is a particularly egregious example- 8 transparent pixels in the whole texture. Transparency shouldn't be used here at all, but I seem to have done so accidentally when building the object....)

I've made a small change in the main branch so that faces which declare a transparent color but don't actuallly use it will work correctly, and this should also help general performance a little.

With row / column major etc.:
I suspect you've probably already realised this, but to be specific, the internal mathematical assumptions of OpenBVE are in DirectX format, which is going to be a legacy of BVE2 (Direct3D retained mode!).

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 5, 2026

Screenshot_20260405_133138 I built and tested it. Shadows do appear, but is this correct for now? They don't appear on the ground... Also, are shadows currently visible on vehicles in the outer view, but not on any objects?

@adfriz
Copy link
Copy Markdown
Contributor Author

adfriz commented Apr 5, 2026

I built and tested it. Shadows do appear, but is this correct for now? They don't appear on the ground... Also, are shadows currently visible on vehicles in the outer view, but not on any objects?

can you use this settings ?

image

add this floor object, there is now shadow casting on the floor because object viewer didn't have a floor.

save it as floor.b3d

[MeshBuilder]
Vertex -15.0000, 0.0000, -150.0000
Vertex -15.0000, 0.0000, 150.0000
Vertex 15.0000, 0.0000, 150.0000
Vertex 15.0000, 0.0000, -150.0000
Face 0, 1, 2, 3
Coordinates 0, 0.0000, 1.0000
Coordinates 1, 0.0000, 0.0000
Coordinates 2, 1.0000, 0.0000
Coordinates 3, 1.0000, 1.0000

@adfriz
Copy link
Copy Markdown
Contributor Author

adfriz commented Apr 5, 2026

First off, congratualtions. I've tried playing with this several times, but haven't ever got results which are quite right.

Faces using transparency aren't quite right yet though- I don't think they're casting shadow at all, but I haven't got as far as debugging it properly. test.zip

(This is a particularly egregious example- 8 transparent pixels in the whole texture. Transparency shouldn't be used here at all, but I seem to have done so accidentally when building the object....)

I've made a small change in the main branch so that faces which declare a transparent color but don't actuallly use it will work correctly, and this should also help general performance a little.

With row / column major etc.: I suspect you've probably already realised this, but to be specific, the internal mathematical assumptions of OpenBVE are in DirectX format, which is going to be a legacy of BVE2 (Direct3D retained mode!).

Thank you leezer3.

for that test object i have fix the code related to it.

image

test2.zip

for that row / column major, i was confused at first... especially i was searching about opengl tutorials but thanks for pointing that out, and at least the shadow works now, need more test though...

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 5, 2026

It now appears on the ground!
This is the result of trying a similar angle with these settings.
Shadows now appear, but the same shadow appears no matter where I go.
Is this because I'm using Linux + Mono?
shadow
Screenshot_20260405_190148
Screenshot_20260405_190151

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 5, 2026

When I run by 'mono OpenBve.exe', it crashed.
When launched with Wine, it loads, and the lighting seems normal.
But the shadows are not displayed.
OpenBVE Crash- 2026.4.05[21.02].log
Screenshot_20260405_210101

@adfriz
Copy link
Copy Markdown
Contributor Author

adfriz commented Apr 5, 2026

When I run by 'mono OpenBve.exe', it crashed. When launched with Wine, it loads, and the lighting seems normal. But the shadows are not displayed.

please try build it again, i have tweak the shader version.

and make sure use the new renderer and the shadow resolution set to on. the shadow wont work in old renderer.
image

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 5, 2026

I haven't yet had a chance to test on Mac (only got an Intel available though), but it definitely will need the most recent commit- GLSL 4.1 is the best it does.

A good universal new feature like ths might be an opportunity to drop the old renderer entirely. I considered this a year ago (when adding smoke and the MSTS keyframe animations), but never quite got further than the draft PR thoughts.

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 5, 2026

Screenshot_20260405_220759 Screenshot_20260405_220909 Screenshot_20260405_220915 Screenshot_20260405_221026 Thank you! I built and tested the new version. It didn't crash this time. I think I kept the settings the same, is that correct? The results seem unchanged. I would appreciate it if you could show me the correct results when you read the route on your end. It seems that the ObjectViewer no longer reacts to shadows at all.

@adfriz
Copy link
Copy Markdown
Contributor Author

adfriz commented Apr 5, 2026

I haven't yet had a chance to test on Mac (only got an Intel available though), but it definitely will need the most recent commit- GLSL 4.1 is the best it does.

A good universal new feature like ths might be an opportunity to drop the old renderer entirely. I considered this a year ago (when adding smoke and the MSTS keyframe animations), but never quite got further than the draft PR thoughts.

i think the same about old renderer, on my machine on the most route files if i use the old one i get "stable" micro stutter and trying bve5 route drop it to below 40fps

@adfriz
Copy link
Copy Markdown
Contributor Author

adfriz commented Apr 5, 2026

Thank you! I built and tested the new version. It didn't crash this time. I think I kept the settings the same, is that correct? The results seem unchanged. I would appreciate it if you could show me the correct results when you read the route on your end. It seems that the ObjectViewer no longer reacts to shadows at all.

this one is hard... because im not using linux. but i suspect in the main program the renderer maybe auto fallback to the old renderer...

for the object viewer i think you need to change something on the shadow settings, try change the resolution to high and press ok. and if you can see the shadow you can change it back to medium.

its known issue on my side, sometimes the object viewer didnt register the shadow settings after rebuilds.

can you do full rebuild of the source code please?

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 5, 2026

Previously, displaying coordinates with the C key caused a crash. It didn't happen this time, so I thought it was a new source code.

I downloaded the ZIP file again, rebuilt everything, and tried displaying it in RouteViewer again.

Are the settings correct?
shadow2b

I tried various angles, but the shadows didn't appear.

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 11, 2026

The very first build I compiled displayed correctly on Linux.
However, the latest patched version doesn't show any shadows at all.
I had an acquaintance test the latest build, and they said it didn't display on their Windows 10 either.

Screenshot_20260411_233521

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 12, 2026

2026-04-12 10:06:23
OpenBVE 1.7.2357.594-christopher Crash Log
Program is running on the MacOS backend
Current screen resolution is: Windowed 960px X 600px 
Current routefile is: 
Current train is: 
The current routefile caused the following exception: 
System.InvalidOperationException: OpenGL Error: InvalidEnum
  at LibRender2.BaseRenderer.ResetShader (LibRender2.Shaders.Shader shader) [0x00028] in /Users/christopher/RiderProjects/OpenBVE/source/LibRender2/BaseRenderer.cs:1360 
  at OpenBve.Graphics.NewRenderer.RenderScene (System.Double TimeElapsed, System.Double RealTimeElapsed) [0x00cc7] in /Users/christopher/RiderProjects/OpenBVE/source/OpenBVE/Graphics/NewRenderer.cs:379 
  at OpenBve.OpenBVEGame.OnRenderFrame (OpenTK.FrameEventArgs e) [0x000fa] in /Users/christopher/RiderProjects/OpenBVE/source/OpenBVE/System/GameWindow.cs:129 
  at OpenTK.GameWindow.OnRenderFrameInternal (OpenTK.FrameEventArgs e) [0x00010] in /mnt/b/opentk/opentk/src/OpenTK/GameWindow.cs:901 
  at OpenTK.GameWindow.RaiseRenderFrame (System.Double elapsed, System.Double& timestamp) [0x0000c] in /mnt/b/opentk/opentk/src/OpenTK/GameWindow.cs:476 
  at OpenTK.GameWindow.DispatchRenderFrame () [0x00038] in /mnt/b/opentk/opentk/src/OpenTK/GameWindow.cs:452 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x00104] in /mnt/b/opentk/opentk/src/OpenTK/GameWindow.cs:375 
  at OpenTK.GameWindow.Run () [0x00000] in /mnt/b/opentk/opentk/src/OpenTK/GameWindow.cs:298 
  at OpenBve.MainLoop.StartLoopEx (OpenBve.LaunchParameters result) [0x00378] in /Users/christopher/RiderProjects/OpenBVE/source/OpenBVE/System/MainLoop.cs:110 
  at OpenBve.Program.Main (System.String[] args) [0x007d5] in /Users/christopher/RiderProjects/OpenBVE/source/OpenBVE/System/Program.cs:300   at System.Environment.get_StackTrace () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System/Environment.cs:316 
  at OpenBve.Program.Main (System.String[] args) [0x009c4] in /Users/christopher/RiderProjects/OpenBVE/source/OpenBVE/System/Program.cs:332 
Current program memory usage: 103.71mb
System memory free: 0mb

Apple doesn't like the current build at all.
Something you're doing with OpenGL isn't quite right, and is triggering GL.InvalidEnum
(The stack trace isn't particularly helpful here, all it's really doing is throwing a fit the first time it calls GL.GetError)

If I disable the GL.GetError, the loading screen background texture is black, but the loading screen works.
In-game, the main screen is blank grey, but text works.

Going to try this on the desktop in a minute, it's a lot easier to debug things in Visual Studio.

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 12, 2026

OK, so now I can see things with a proper debugger, the issue is that something you're doing is not compatible with a forwards compatible GL4.1 context. (In other words you're using something that's been deprecated)
I haven't yet chased this down.

Shadows are working for me on Windows, but I suspect this is probably related for those who they don't. (I'm guessing, but it may well be dropping to GL2 if the context fails)

leezer3 added a commit that referenced this pull request Apr 12, 2026
@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 12, 2026

Screenshot_20260412_151102

This is definitely working on Debian for me with the latest changes, I will note that the default light directions for many older routes are not really compatible with shadows.

I'll take another look on Apple later today or tomorrow, now that I've found some forwards compatible context issues in master.

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 12, 2026

Why don't shadows appear when I build and run this link in Release mode on my Ubuntu system...?
The lighting is depicted correctly.
https://github.com/leezer3/OpenBVE/tree/a4af7768573896a3c3035d29a47cd4cdb8f1c314
Screenshot_20260413_003719
Screenshot_20260413_004337

@AmberIsFrozen
Copy link
Copy Markdown
Contributor

Why don't shadows appear when I build and run this link in Release mode on my Ubuntu system...? The lighting is depicted correctly. https://github.com/leezer3/OpenBVE/tree/a4af7768573896a3c3035d29a47cd4cdb8f1c314

The CSM logs are written to the console (Which i think we should move it to OpenBVE's logging system but that's another topic), so try launching it in the terminal and see what kind of output it gives.

Curiously I am getting the following:

[CSM] Init failed: [ShadowDepthShader] Compile error (FragmentShaderArb): 0:29(24): error: syntax error, unexpected end of file

Couldn't quite tell if it's my fault

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 12, 2026

18 個の警告
0 エラー

経過時間 00:00:06.74
user@OpenBVE-a4af7768573896a3c3035d29a47cd4cdb8f1c314$ msbuild ./OpenBVE.sln | grep CSM
user@OpenBVE-a4af7768573896a3c3035d29a47cd4cdb8f1c314$
A warning appears. There didn't seem to be any CSM errors.
Should I avoid building here?

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 12, 2026

Putting that aside, I have been waiting for this feature for many, many years.
Thank you so much for implementing it!
I am truly grateful.

@AmberIsFrozen
Copy link
Copy Markdown
Contributor

18 個の警告
0 エラー

経過時間 00:00:06.74 user@OpenBVE-a4af7768573896a3c3035d29a47cd4cdb8f1c314$ msbuild ./OpenBVE.sln | grep CSM user@OpenBVE-a4af7768573896a3c3035d29a47cd4cdb8f1c314$ A warning appears. There didn't seem to be any CSM errors. Should I avoid building here?

I meant in runtime, when you run the OpenBVE program (i.e. mono OpenBve.exe), or look at the console tab in an IDE while you were running/debugging it.

... Though now that your images load on my side, it doesn't seems to be the same issue (I didn't get any lighting at all and just reverted back as if shadow were turned off)

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 12, 2026

[CSM] Init failed: [ShadowDepthShader] Compile error (FragmentShaderArb): 0:29(24): error: syntax error, unexpected end of file

user@bin_debug$
I'm sorry.
You're right, I got the same error when I ran it.

Addendum:
I'm sorry. I misunderstood that the resolution drops drastically when viewed at an angle. It displayed finely at certain angles.
I learned that it won't display properly unless it's at a clear viewing angle.

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 12, 2026

https://github.com/leezer3/OpenBVE/tree/7c7cb61dc88fb89d5ffd631439c0bebe6d9935a8
user@bin_release$ mono ObjectViewer.exe
ATTENTION: default value of option mesa_glthread overridden by environment.
[CSM] Reloading shadow settings from options...
[CSM] Initialized: 3 cascades, 2048×2048, distance=300m, strength=70%
[CSM] Reloading shadow settings from options...
[CSM] Resized to 3 cascades at 2048×2048
[CSM] Initialized: 3 cascades, 2048×2048, distance=300m, strength=70%
user@bin_release$
In this very first pull request, when the ObjectViewer was executed, it displayed like this and the shadow appeared correctly.

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 12, 2026

I know what's going on, and it's messy.

The line endings are getting messed up, and compiling the shader is throwing a fit as a result.
I'm not clear why at the minute. It ought to be handling this better (the repository is configured as auto, and the others work). The other shaders are loaded as an embedded resource to try and mitigate this, but it shouldn't matter....

shadow.zip
c0274fc

I've built this one locally from the latest on my branch, which fixes the shaders as an embedded resource. I think this one will work on Linux again.

I think it might well work OK on Apple too, but would need the shadows enabling manually via the CFG file at the minute.
I'll see what I can do about adding a GL menu option to my branch over the next few days and do some more playing on Apple.

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 13, 2026

I tried it with Shadow.zip and it worked!
I was so amazed I was mesmerized.
I felt the graphics display had really revolution!
I can't thank you enough.
My heartfelt thanks.
Screenshot_20260413_090929
Screenshot_20260413_084937
Screenshot_20260413_084929
Screenshot_20260413_085858

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 13, 2026

When I launched OpenBVE using shadow.zip, even with Shadow Resolution set to 4096, it only appeared as a blurred version of 512.
RouteViewer displayed a clear image at 4096.
I'm reporting this just in case.

Addendum:
I'm sorry. I misunderstood that the resolution drops drastically at an angle. It displayed finely at certain angles.
I learned that it won't display properly unless we use a specific angle.
Furthermore, I learned that at certain angles, the external view of the vehicle being driven and the FreeObj shadows don't display.
It would be happy if the shadows displayed even when viewed directly to the side…

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 13, 2026

I'm not sure why the quality is messed up for you- seems to work here.
Possibly try closing and re-opening the game after changing any options- the quality is only currently updated when the renderer initializes.

I've added a GL menu impimentation for the main game this morning, will see about testing on Apple again.

Another observation:
Turning off shadows for ground objects (only) in most, if not all routes will produce noticably better results- I'm seeing a lot of BVE2 era content with small gaps in the grounds on curves, which then produce some odd shadow effects.

It's a pity that I don't think there's a way to tell internally what type of object something is, other than whether it's dynamic (animated / train) or not.
Will do some more playing

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 15, 2026

Our default light (before modifying with the LightDirection command) is positioned nearly overhead, which gives an even illumination to the scene, no matter which way the camera is rotated.

If you're then using 2D (vertical) planes for the majority of your objects, with the light essentially overhead, they can't cast a shadow, no matter which way they're pointing. In this case horizontal planes will still cast shadows, but it very much depends on how the objects in question were designed.

A possible way to get around this would be to alter the default light position to something lower in the sky, but that then makes the other lighting 'wrong' to the original.


Your route works OK, as you've changed the default light direction.

@adfriz
Copy link
Copy Markdown
Contributor Author

adfriz commented Apr 15, 2026

@adfriz See if you think that's any better- I've changed from the three columns to three options pages :)

Really, the second options page is now a little sparse, but it works better I think.

Thank you! It didn't work on one route, but it worked on BVE HOKKAIDO! https://ilovetrainhokkaido.web.fc2.com/bvehokkaido.htm Shadows didn't appear in the outer view on this route. It seems like the lighting settings aren't configured correctly on this route.

With that one, it's mostly because the objects are all 2D. (a really good example is the bridge at the start of the route) If your object isn't 3D, shadows cast from to the ground will not work well.

That's better, thanks. that empty space can be used for future settings like post processing SSAO, bloom, etc....

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 15, 2026

I think so too
0;
Light.Direction(30, 90);
Light.Ambient(0.5, 0.5, 0.5);
Light.Diffuse(0.5, 0.5, 0.5);
to the
IIDA/深名線/map.txt
IIDA/深名線/mapA.txt
IIDA/深名線/mapX.txt
IIDA/深名線/mapY.txt
But it didn't change.
I thought it was 4 random and wrote all 4.

adfriz and others added 15 commits April 15, 2026 12:15
- Add CascadedShadowMap and CascadedShadowCaster to LibRender2.
- Implement shadow depth shaders for depth pass rendering.
- Update default shaders to support shadow sampling and application.
- Add shadow configuration settings (Resolution, Distance, Cascades, Strength) across OpenBVE, RouteViewer, and ObjectViewer.
- Update math library with frustum and matrix helper functions.
- Add localization for shadow settings in English and Indonesian.
- Converted RouteViewer to a tabbed layout matching ObjectViewer.
- Added sun direction sliders (Azimuth/Elevation) to RouteViewer.
- Unified shadow resolution and distance values across both viewers.
- Made options windows resizable with AutoScroll support.
- Changed default shadow resolution to Off and added control enabling logic.
- Fixed shadow initialization after route loading in RouteViewer.
- Clamp minimum FOV in shadow bounding sphere calculation to prevent shadows from clipping when zooming in.
- Apply dynamic shadow bias directly in the fragment shader to minimize shadow acne and detachment artifacts.
- Introduce new Shadow Bias options in the UI for OpenBVE, RouteViewer, and ObjectViewer.
- Set the default shadow bias value to 0.000005
Update viewport to Scenery mode before running the shadow pass, preventing the cab's 50m far-clip matrix from incorrectly capping the shadow distance.
- Added AlphaFaces to the CSM shadow pass so cutout objects cast shadows.
- Reset LastBoundTexture after the shadow pass to prevent texture bleeding on untextured meshes.
- Added alpha-discard in shadow depth shader to prevent transparent meshes from casting shadows.
- Implemented slope-scaled shadow normal bias in fragment shader to cure shadow acne.
- Expose Normal Bias settings in OpenBVE, RouteViewer, and ObjectViewer UI/Options.
- Support for 4-value RGBA color parsing for legacy and Assimp parsers.
Note: shadow bias and shadow normal bias need more tweak.
- Standardize global default ShadowBias to 0.000050 in BaseOptions.
- Set default ShadowResolution to Off across all applications.
- Remove hardcoded shadow setting overrides in Object Viewer to respect global defaults.
- Implement a 3-column layout in the main Options interface to better utilize screen space when maximized.
- Fix UI clipping/gaps in the Options menu by explicitly synchronizing groupbox widths during form resize.
@leezer3 leezer3 force-pushed the directional-shadow branch from 1f8fee8 to 027cf27 Compare April 15, 2026 11:21
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 16, 2026

I used TFO with an X object use for Bve5's, and while the bridge's shadow is visible in the outer view, the X object itself doesn't have a shadow on the roof. The X object itself has an effect applied, but the object itself doesn't seem to X obj have any other effects.
https://sites.google.com/view/shino-bve/download/vehicle-str/series701-mori?authuser=0
影が701にはない

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 17, 2026

shadow2.zip

I think that will fix the X object issues.
This appears to have been an oversight when implementing the new parsers (all faces marked as emissive)

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 17, 2026

I think it's very good!
Screenshot_20260417_194042-1
I checked with the Tozai Line in Bve5 and it seemed to be working.
My Tohoku Shinkansen displayed an error message saying "Object not defined" and I couldn't select it from the menu screen.
RouteViewer and ObjectViewer failed to start, displaying the following error.

user@完全版影$ mono ./RouteViewer.exe
ATTENTION: default value of option mesa_glthread overridden by environment.

Unhandled Exception:
System.MissingMethodException: Method not found: bool OpenBveApi.Hosts.HostInterface.LoadTexture(OpenBveApi.Textures.Texture&,OpenBveApi.Textures.OpenGlTextureWrapMode,bool)
  at LibRender2.BaseRenderer.Initialize () [0x00355] in <e6efa370d6fc4c64b48341a94b7dbe65>:0 
  at RouteViewer.NewRenderer.Initialize () [0x00000] in <12d0d3e6eb534093964d07f48d8955ce>:0 
  at RouteViewer.RouteViewer.OnLoad (System.EventArgs e) [0x0010d] in <12d0d3e6eb534093964d07f48d8955ce>:0 
  at OpenTK.GameWindow.OnLoadInternal (System.EventArgs e) [0x00000] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x0008f] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at RouteViewer.Program.Main (System.String[] args) [0x00404] in <12d0d3e6eb534093964d07f48d8955ce>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: bool OpenBveApi.Hosts.HostInterface.LoadTexture(OpenBveApi.Textures.Texture&,OpenBveApi.Textures.OpenGlTextureWrapMode,bool)
  at LibRender2.BaseRenderer.Initialize () [0x00355] in <e6efa370d6fc4c64b48341a94b7dbe65>:0 
  at RouteViewer.NewRenderer.Initialize () [0x00000] in <12d0d3e6eb534093964d07f48d8955ce>:0 
  at RouteViewer.RouteViewer.OnLoad (System.EventArgs e) [0x0010d] in <12d0d3e6eb534093964d07f48d8955ce>:0 
  at OpenTK.GameWindow.OnLoadInternal (System.EventArgs e) [0x00000] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x0008f] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at RouteViewer.Program.Main (System.String[] args) [0x00404] in <12d0d3e6eb534093964d07f48d8955ce>:0 
user@完全版影$ mono ObjectViewer.exe
ATTENTION: default value of option mesa_glthread overridden by environment.

Unhandled Exception:
System.MissingMethodException: Method not found: bool OpenBveApi.Hosts.HostInterface.LoadTexture(OpenBveApi.Textures.Texture&,OpenBveApi.Textures.OpenGlTextureWrapMode,bool)
  at LibRender2.BaseRenderer.Initialize () [0x00355] in <e6efa370d6fc4c64b48341a94b7dbe65>:0 
  at ObjectViewer.Graphics.NewRenderer.Initialize () [0x00000] in <d8ac25a64b2141e8ab25dc582fa4171d>:0 
  at ObjectViewer.ObjectViewer.OnLoad (System.EventArgs e) [0x000ad] in <d8ac25a64b2141e8ab25dc582fa4171d>:0 
  at OpenTK.GameWindow.OnLoadInternal (System.EventArgs e) [0x00000] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x0008f] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at ObjectViewer.Program.Main (System.String[] args) [0x0035b] in <d8ac25a64b2141e8ab25dc582fa4171d>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: bool OpenBveApi.Hosts.HostInterface.LoadTexture(OpenBveApi.Textures.Texture&,OpenBveApi.Textures.OpenGlTextureWrapMode,bool)
  at LibRender2.BaseRenderer.Initialize () [0x00355] in <e6efa370d6fc4c64b48341a94b7dbe65>:0 
  at ObjectViewer.Graphics.NewRenderer.Initialize () [0x00000] in <d8ac25a64b2141e8ab25dc582fa4171d>:0 
  at ObjectViewer.ObjectViewer.OnLoad (System.EventArgs e) [0x000ad] in <d8ac25a64b2141e8ab25dc582fa4171d>:0 
  at OpenTK.GameWindow.OnLoadInternal (System.EventArgs e) [0x00000] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x0008f] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <e46468b16ff44a7bab3c89a1e73ac3b5>:0 
  at ObjectViewer.Program.Main (System.String[] args) [0x0035b] in <d8ac25a64b2141e8ab25dc582fa4171d>:0 
user@完全版影$ 

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 18, 2026

After deleting and reconfiguring the settings, OpenBVE started working.
RouteViewer and ObjectViewer remained not works.
Screenshot_20260418_133803-1

@adfriz
Copy link
Copy Markdown
Contributor Author

adfriz commented Apr 18, 2026

After deleting and reconfiguring the settings, OpenBVE started working. RouteViewer and ObjectViewer remained not works. Screenshot_20260418_133803-1

what settings you changed?

try delete the old debug and release folder and maybe do full rebuilds could fix it.

@leezer3
Copy link
Copy Markdown
Owner

leezer3 commented Apr 18, 2026

It's probably something with my build.
We've had funny issues before with local vs. remote builds.

Strange thing is I don't think the method it's on about has been touched at all.

@ginga81
Copy link
Copy Markdown
Contributor

ginga81 commented Apr 18, 2026

/home/user/.config/OpenBve/Settings
I deleted everything in this folder.
After that, I extracted shadow2.zip and it loaded successfully when I launched it.
東北新幹線Bve5影
The image seems corrupted, so I'll upload it again.

- Added LightAzimuth and LightElevation to Route Viewer options (Save/Load).
- Disabled shadow controls in the UI if the current renderer is not compatible (GL 1.2), matching ObjectViewer behavior.
- Added a safety check to prevent zero ShadowBias during initialization.
- Standardized ShadowStrength string formatting in the options file for consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants