Skip to content

Change: Realtime sun and shadow preview in ObjectViewer and RouteView… - #1433

Merged
leezer3 merged 8 commits into
leezer3:masterfrom
adfriz:realtime-update-shadow
Sep 26, 2026
Merged

leezer3 merged 8 commits into
leezer3:masterfrom
adfriz:realtime-update-shadow

Conversation

@adfriz

@adfriz adfriz commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

…er options

Screen.Recording.2026-09-26.000020.mp4

need test for macos and linux.

i hope #1405 can be merged first, so i can update this with those new parameter.

@adfriz

adfriz commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

I will try visiting #1405 tomorrow. already past midnight here.

@ginga81 if you have time, try this PR.

@leezer3

leezer3 commented Sep 25, 2026

Copy link
Copy Markdown
Owner

My suspicion is this is likely to be unhappy on anything other than Windows.

Something we tried relatively early in the life of OpenBVE was triggering forms from plugins- this worked OK on Windows, but not anywhere else.

I'd have to go back through older stuff, but IIRC its got to do with the fact that the form has to own the window message pump on Linux etc. to actually work correctly. Trying to run as anything other than a blocking dialog was producing unpredictable results on both.

Modeless dialog with memory-only updates; GPU shadow reallocs run on the render thread. RouteViewer pauses scene updates while open and renders on-demand.
@adfriz

adfriz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

the last commit i hope works on linux and macos.

unfortunately i cant test other OS natively because my device is not that good...

@ginga81

ginga81 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Since shadows did not appear on the specific ground surface in ObjectViewer, I used the b3d ground file that was utilized when implementing the shadow feature.
For the Tohoku Shinkansen, the file is:
Railway/Object/OpenOBJs/Grounds/ground2.csv
Using this for the ground surface resulted in no shadows appearing.

As shown in the video, the PR testing confirmed that changes were reflected in real-time on Linux as well.
Regarding the Resolution, Draw Distance, and Cascades dropdown menus, the shadows did not disappear even when, for example, Resolution was set to "Off."
The text boxes for adjusting the Strength, Shadow Bias, and Normal Bias values ​​are now working.
RouteViewer crashed, so I am providing the terminal logs.

#1025
In RouteViewer on Linux, when I press the 'P' key to display the tracks with color coding, the change is not reflected in real-time.
Is it possible to enable real-time updates for the track display on Linux as well, using the same method as in this PR?

user@bin_release$ mono RouteViewer.exe
ATTENTION: default value of option mesa_glthread overridden by environment.

Unhandled Exception:
System.DllNotFoundException: openal32.dll assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) OpenTK.Audio.OpenAL.Alc.OpenDevice(string)
  at SoundManager.SoundsBase.Initialize (SoundManager.SoundRange range) [0x0011f] in <fea9dd3d8a72442592ad93fcfd596bcb>:0 
  at RouteViewer.RouteViewer.OnLoad (System.EventArgs e) [0x00126] in <0d68a5b1db1c475b93b73258c283aa89>:0 
  at OpenTK.GameWindow.OnLoadInternal (System.EventArgs e) [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x000a1] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at RouteViewer.Program.Main (System.String[] args) [0x004bf] in <0d68a5b1db1c475b93b73258c283aa89>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: openal32.dll assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) OpenTK.Audio.OpenAL.Alc.OpenDevice(string)
  at SoundManager.SoundsBase.Initialize (SoundManager.SoundRange range) [0x0011f] in <fea9dd3d8a72442592ad93fcfd596bcb>:0 
  at RouteViewer.RouteViewer.OnLoad (System.EventArgs e) [0x00126] in <0d68a5b1db1c475b93b73258c283aa89>:0 
  at OpenTK.GameWindow.OnLoadInternal (System.EventArgs e) [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x000a1] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at RouteViewer.Program.Main (System.String[] args) [0x004bf] in <0d68a5b1db1c475b93b73258c283aa89>:0 
user@bin_release$ 
record-2026-09-26_14.05.15.mp4

@adfriz

adfriz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Thats odd, the openal not found. can you try full rebuild and test the route viewer again?

and try a screen record it what you do until it crash.

@ginga81

ginga81 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

I downloaded the ZIP again, built it, ran RouteViewer, and recorded a video.

record-2026-09-26_15.56.19.mp4
record-2026-09-26_15.56.56.mp4

Deploy OpenTK.dll.config with every build so Mono applies the native library mappings on non-makefile builds. RouteViewer now reports a missing libopenal1 or a corrupt install instead of dying with a stack trace.
@adfriz

adfriz commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor Author

That new commit might work?
can you try it again?

@ginga81

ginga81 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

This time, RouteViewer loaded successfully.
You need to click the "OK" button and reload each time to enable Resolution, Draw Distance, and Cascades.

I loaded the same ALFA-X and ground, but in ObjectViewer, the shadows no longer appear even when enabled. The train body changes accordingly regardless of whether the setting is enabled or disabled, but nothing appears on the ground.

@adfriz

adfriz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

ok, now try again please. currently only for route viewer.

Now you can just close the options window without pressing OK, it will save it temporarily. but if you reload the route with F5 it should be reset and follow the route light direction.

@adfriz

adfriz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

ok that 2 commits should fix the object viewer and add built in ground mesh and fix the shadow settings, should be realtime same as route viewer

@ginga81

ginga81 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

The built-in ground mesh is incredibly helpful!
Changing the dropdown and closing the window didn't actually apply the change.
I didn't notice any other issues.

record-2026-09-26_20.10.03.mp4
record-2026-09-26_20.14.24.mp4

@adfriz

adfriz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Try again please.

@ginga81

ginga81 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

With this latest update, I believe it is now fully functional on Linux, behaving exactly like the demo video submitted with the PR.
I was incredibly surprised, and at the same time, I learned a great deal about the nature of shadows.
It has become immediately clear how specific actions result in specific types of shadows.

@adfriz

adfriz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

so all ok?

Now we need to wait for leezer3 i think he got macos device to test this PR.

@ginga81

ginga81 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

As looked in the your initial demo video in Windows, I found that it behaved the same way on Linux.
There were no crashes or similar issues.
I believe this is the first time I’ve seen dialog's widget changes reflected in real-time on Linux with mono.
I was truly amazed!

@adfriz

adfriz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for your help testing this PR in linux 👍

@leezer3

leezer3 commented Sep 26, 2026

Copy link
Copy Markdown
Owner

I can certainly try on Apple, but it'll be of limited use, as it only supports the GL menu, not the popup one.

@adfriz

adfriz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

oh its not? well... its expected from apple ecosystem, i still dont like how apple stop supporting opengl to 4.1 in their x86 processor.

This pr is technically a workaround until the proper GL menu finished.

@ginga81

ginga81 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Sorry.
I would greatly appreciate it if you could prioritize implementing the ground display feature in ObjectViewer.
Could you please consider this?

@leezer3

leezer3 commented Sep 26, 2026

Copy link
Copy Markdown
Owner

No crashes on Apple so I'll merge for the minute.

Need to add a shadow option to the GL menu now we've thought of this though....

Maybe not in Object Viewer, as there's definitely no GL slider control, so may be of limited use there. I'll try and look at that on Monday if you don't do anything on that.

@leezer3
leezer3 merged commit b850d49 into leezer3:master Sep 26, 2026
5 checks passed
@ginga81

ginga81 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

I was having fun playing around with it when RouteViewer crashed.

user@bin_release$ mono RouteViewer.exe
ATTENTION: default value of option mesa_glthread overridden by environment.
[CSM] Resized to 2 cascades at 4096×4096
X11 Error encountered: 
  Error: BadWindow (invalid Window parameter)
  Request:     25 (0)
  Resource ID: 0x23CCAFC
  Serial:      289810
  Hwnd:        <null>
  Control:     <null>  at System.Environment.get_StackTrace () [0x00000] in <d636f104d58046fd9b195699bcb1a744>:0 
  at System.Windows.Forms.XplatUIX11.HandleError (System.IntPtr display, System.Windows.Forms.XErrorEvent& error_event) [0x00000] in <25c2bdf9d79a43a599eb46bd15cd77fb>:0 
  at OpenTK.Platform.X11.Functions.XCheckWindowEvent (System.IntPtr , System.IntPtr , OpenTK.Platform.X11.EventMask , OpenTK.Platform.X11.XEvent& ) [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.Platform.X11.X11GLNative.ProcessEvents () [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.NativeWindow.ProcessEvents (System.Boolean retainEvents) [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.NativeWindow.ProcessEvents () [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at RouteViewer.Program.Main (System.String[] args) [0x00000] in <9b6811b63cfa476cb3e308b0125d8edb>:0 


Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at LibRender2.BaseRenderer.RenderFace (LibRender2.Shaders.Shader shader, OpenBveApi.Objects.ObjectState state, OpenBveApi.Objects.MeshFace face, System.Boolean debugTouchMode, System.Boolean screenSpace) [0x00169] in <d7e9a14dab03497d831f41d8c395dd4a>:0 
  at LibRender2.BaseRenderer.RenderFace (LibRender2.Objects.FaceState state, System.Boolean isDebugTouchMode) [0x00000] in <d7e9a14dab03497d831f41d8c395dd4a>:0 
  at LibRender2.Objects.FaceState.Draw () [0x00000] in <d7e9a14dab03497d831f41d8c395dd4a>:0 
  at RouteViewer.NewRenderer.RenderScene (System.Double timeElapsed) [0x008b2] in <9b6811b63cfa476cb3e308b0125d8edb>:0 
  at RouteViewer.RouteViewer.OnRenderFrame (OpenTK.FrameEventArgs e) [0x000cb] in <9b6811b63cfa476cb3e308b0125d8edb>:0 
  at OpenTK.GameWindow.OnRenderFrameInternal (OpenTK.FrameEventArgs e) [0x00016] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.RaiseRenderFrame (System.Double elapsed, System.Double& timestamp) [0x0000c] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.DispatchRenderFrame () [0x0003e] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x00122] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at RouteViewer.Program.Main (System.String[] args) [0x004bf] in <9b6811b63cfa476cb3e308b0125d8edb>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at LibRender2.BaseRenderer.RenderFace (LibRender2.Shaders.Shader shader, OpenBveApi.Objects.ObjectState state, OpenBveApi.Objects.MeshFace face, System.Boolean debugTouchMode, System.Boolean screenSpace) [0x00169] in <d7e9a14dab03497d831f41d8c395dd4a>:0 
  at LibRender2.BaseRenderer.RenderFace (LibRender2.Objects.FaceState state, System.Boolean isDebugTouchMode) [0x00000] in <d7e9a14dab03497d831f41d8c395dd4a>:0 
  at LibRender2.Objects.FaceState.Draw () [0x00000] in <d7e9a14dab03497d831f41d8c395dd4a>:0 
  at RouteViewer.NewRenderer.RenderScene (System.Double timeElapsed) [0x008b2] in <9b6811b63cfa476cb3e308b0125d8edb>:0 
  at RouteViewer.RouteViewer.OnRenderFrame (OpenTK.FrameEventArgs e) [0x000cb] in <9b6811b63cfa476cb3e308b0125d8edb>:0 
  at OpenTK.GameWindow.OnRenderFrameInternal (OpenTK.FrameEventArgs e) [0x00016] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.RaiseRenderFrame (System.Double elapsed, System.Double& timestamp) [0x0000c] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.DispatchRenderFrame () [0x0003e] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run (System.Double updates_per_second, System.Double frames_per_second) [0x00122] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at OpenTK.GameWindow.Run () [0x00000] in <6ff0f34f7bb74e4294c4aabf46d15732>:0 
  at RouteViewer.Program.Main (System.String[] args) [0x004bf] in <9b6811b63cfa476cb3e308b0125d8edb>:0 
user@bin_release$ 

It happened with the "Elevation (Theta)" slider.

@adfriz

adfriz commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

@ginga81 This PR and shadow smooth PR already merged. Please try testing master branch.

@ginga81

ginga81 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

I checked the daily build, and at the RouteViewer, I think it's working well.
I think that it seems the shadows no longer appear in Object Viewer.
影がでない

@adfriz

adfriz commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

@ginga81 please try testing #1437

please do full rebuild first

@ginga81

ginga81 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

I gave it a try.
However, I felt it still wasn't coming out.
影がでない2

@adfriz

adfriz commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

can you check the log.txt ? oh lets move the discussion to #1437

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.

3 participants