Graphics coding issue Help wanted
#1
Posted 17 July 2020 - 11:24 AM
Hi Guys,
I wonder if there is anyone here who could help with a small graphics problem that CrisGer has raised?
The shadows cast by forest trees are quite wrong and that affects the amazing CP&MR 1864 project he is leading.
Ryan Young has done some research and so has James Ross. Looks as though the original code was fine but an attempted optimisation has since broken it.
Ryan is not a graphics guy and as I have been pressing James to finish the MonoGame merge, I wonder if there's another pair of eyes which could spare some time to look at this instead?
The details are on Launchpad at https://bugs.launchpad.net/or/+bug/1863217
Many thanks,
I wonder if there is anyone here who could help with a small graphics problem that CrisGer has raised?
The shadows cast by forest trees are quite wrong and that affects the amazing CP&MR 1864 project he is leading.
Ryan Young has done some research and so has James Ross. Looks as though the original code was fine but an attempted optimisation has since broken it.
Ryan is not a graphics guy and as I have been pressing James to finish the MonoGame merge, I wonder if there's another pair of eyes which could spare some time to look at this instead?
The details are on Launchpad at https://bugs.launchpad.net/or/+bug/1863217
Many thanks,
#2
Posted 21 July 2020 - 10:17 PM
Happy to report a successful result, Chris!
Before:
After:
(Quite honestly, I have no idea how any of the linear algebra works. I used James' hints from the bug report to zero in on the forest shader's sun direction logic, which I then mirrored to the shadow map shader.)
Unfortunately, we have a problem: The patch does not apply cleanly against the Monogame pull request. This means it cannot be committed to unstable without a convoluted workaround like merging it into perpetualKid's repository first. Or we wait until Monogame is merged...
Before:
After:
(Quite honestly, I have no idea how any of the linear algebra works. I used James' hints from the bug report to zero in on the forest shader's sun direction logic, which I then mirrored to the shadow map shader.)
Unfortunately, we have a problem: The patch does not apply cleanly against the Monogame pull request. This means it cannot be committed to unstable without a convoluted workaround like merging it into perpetualKid's repository first. Or we wait until Monogame is merged...
#3
Posted 22 July 2020 - 08:27 AM
YoRyan, on 21 July 2020 - 10:17 PM, said:
Happy to report a successful result, Chris!
Great to see shadows now when it's not high noon, but are they all going in the same direction, I wonder?
I may be mistaken but the ones to the right of the track lie at an angle to the track (some crossing it). The ones on the left of the track seem to be more in line with the track. Hard to see from low down but perhaps a view from higher up will show everything is just fine.
#5
Posted 22 July 2020 - 09:53 AM
YoRyan, on 21 July 2020 - 10:17 PM, said:
(Quite honestly, I have no idea how any of the linear algebra works.
Linear algebra? Ouch!
Well done for leaving your "comfort zone".
YoRyan, on 21 July 2020 - 10:17 PM, said:
Or we wait until Monogame is merged...
I suggest we wait. Monogame is definitely getting nearer.
I'll let CrisG know that you have a fix for his problem.
#6
Posted 22 July 2020 - 02:00 PM
hi and thankis but ..how does the fix happen? is there a patch to apply? or is OPEN RAILS public release updated to fix this?
thannks
Chris
thannks
Chris
#7
Posted 22 July 2020 - 02:31 PM
The fix cannot be applied until the migration to Monogame is completed, after which it will be included in the testing release channel.
If you need it right away, I could also send you a custom build with the patch included.
If you need it right away, I could also send you a custom build with the patch included.
#8
Posted 14 August 2020 - 03:04 PM
Wow....the bug has been around for maybe 7 years...and I mentioned it in detail in 2016!
I have not looked at the fix, but as the camera facing billboards turn WRT the camera, do the dynamic shadows remain static for the given sun position?
In plain english, Forest() objects consist of flat objects, the camera moves, the object turns to face the camera. As the Forest() object turns, does the projection of the dynamic shadow from that object also change? If so, we have moving dynamic shadows that have nothing to do with the changing position of the sun. Does this not exact an undesirable performance penalty for large Forest()s, which was the purpose of said objects to reduce the number of displayed polygons? If the dynamic shadow does not move or get altered by the changing camera position, will this not look odd? This issue was side-stepped in MSTS by having Forest() objects that are displayed as two billboards at right angles to each other with acceptable results.
This is not clear from the posted screenshots.
Thanks,
Steve
I have not looked at the fix, but as the camera facing billboards turn WRT the camera, do the dynamic shadows remain static for the given sun position?
In plain english, Forest() objects consist of flat objects, the camera moves, the object turns to face the camera. As the Forest() object turns, does the projection of the dynamic shadow from that object also change? If so, we have moving dynamic shadows that have nothing to do with the changing position of the sun. Does this not exact an undesirable performance penalty for large Forest()s, which was the purpose of said objects to reduce the number of displayed polygons? If the dynamic shadow does not move or get altered by the changing camera position, will this not look odd? This issue was side-stepped in MSTS by having Forest() objects that are displayed as two billboards at right angles to each other with acceptable results.
This is not clear from the posted screenshots.
Thanks,
Steve
#9
Posted 14 August 2020 - 09:39 PM
The shadows are angled with respect to the sun. Unlike the trees themselves, they do not follow the angle of the camera. This admittedly looks a little odd, but it still looks much better than having no shadows whatsoever.
Forests and their shadows are both represented by a single primitive, so the performance impact is minimized.
Forests and their shadows are both represented by a single primitive, so the performance impact is minimized.
#10
Posted 15 August 2020 - 12:09 AM
Perhaps the way forward would be to use the old MSTS two billboard shape and not move it to always face the camera. It has always seemed a bit ridiculous to me to see a tree in one orientation while looking forwards only to see it completely reversed when looking backwards at it because the camera view has rotated the shape.