Elvas Tower: Graphics coding issue - Elvas Tower

Jump to content

Posting Rules

All new threads will be started by members of the Open Rails team, Staff, and/or Admins. Existing threads started in other forums may get moved here when it makes sense to do so.

Once a thread is started any member may post replies to it.
  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Graphics coding issue Help wanted Rate Topic: -----

#1 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,871
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

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,

#2 User is offline   YoRyan 

  • Conductor
  • Group: Status: Active Member
  • Posts: 391
  • Joined: 19-February 20
  • Gender:Male
  • Location:California, United States
  • Simulator:Open Rails/unstable
  • Country:

Posted 21 July 2020 - 10:17 PM

Happy to report a successful result, Chris!

Before:
Attached Image: fshad_before.jpg

After:
Attached Image: fshad_after.jpg

(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 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,871
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 22 July 2020 - 08:27 AM

View PostYoRyan, 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.

#4 User is offline   YoRyan 

  • Conductor
  • Group: Status: Active Member
  • Posts: 391
  • Joined: 19-February 20
  • Gender:Male
  • Location:California, United States
  • Simulator:Open Rails/unstable
  • Country:

Posted 22 July 2020 - 08:59 AM

It's the angle. All looks well from the air.

Attached thumbnail(s)

  • Attached Image: fshad_fix.jpg


#5 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,871
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 22 July 2020 - 09:53 AM

View PostYoRyan, 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".

View PostYoRyan, 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 User is offline   CrisGer 

  • Member, Board of Directors
  • PipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 5,361
  • Joined: 06-October 09
  • Gender:Male
  • Location:Colorado and California
  • Simulator:MSTS OR
  • Country:

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

#7 User is offline   YoRyan 

  • Conductor
  • Group: Status: Active Member
  • Posts: 391
  • Joined: 19-February 20
  • Gender:Male
  • Location:California, United States
  • Simulator:Open Rails/unstable
  • Country:

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.

#8 User is offline   Eldorado.Railroad 

  • Foreman Of Engines
  • Group: Status: Contributing Member
  • Posts: 983
  • Joined: 31-May 10
  • Gender:Male
  • Country:

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

#9 User is offline   YoRyan 

  • Conductor
  • Group: Status: Active Member
  • Posts: 391
  • Joined: 19-February 20
  • Gender:Male
  • Location:California, United States
  • Simulator:Open Rails/unstable
  • Country:

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.

#10 User is offline   copperpen 

  • Executive Vice President
  • Group: Status: Elite Member
  • Posts: 3,144
  • Joined: 08-August 05
  • Gender:Male
  • Simulator:MSTS & OR
  • Country:

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.

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users