Announcement: Be excellent to each other.


Caravel Forum : DROD Boards : Bugs : Regression: light rendering on moving platform not aligned
New Topic New Poll Post Reply
Poster Message
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged

File: platform lighting.jpg (14.5 KB)
Downloaded 221 times.
License: Public Domain
icon Regression: light rendering on moving platform not aligned (+2)  
When a light shines on a platform, moving the platform will show the lighting not in sync with the platform. It shines at the platform's destination, but the lighting should be clipped (though that might not be technically how we handle it in code) to where the platform is during the movement tweening.

This is now happening in both 5.1.1 and RPG 1.2.8, which I copied the new room rendering changes over to, so something broke in those changes.



____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 11-13-2020 04:46 AM]
11-13-2020 at 04:43 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged

File: LightIsDark.png (6.1 KB)
Downloaded 203 times.
License: Public Domain
icon Re: Regression: light rendering on moving platform not aligned (+3)  
This was an intentional change actually, that I needed to do in order to add broken support for drawing O-Layer image overlays above platforms. Compare the attached hold's The Entrance with how it looks in 5.1.1 and 5.1.0 (attached in the next post).

Essentially the idea is that we have this rendering order at the moment:

1. Draw O-Layer except platforms
2. Draw Platforms
3. Draw O-Layer effects
4. Draw Platform lighting
5. Draw T-Layer, while also applying lighting

The issue is the combination of a moving platform, drawing platform lighting, room darkness. Pit tiles only get room darkness, while platforms also receive cast light. Let's say I change it so that platform lighting is applied directly at the light's position:



So platform P moves from tile A to tile D. Tiles A, B and C are pit and only receive room darkness. Tile D is a platform (because from game's perspective the platform is already there) and thus it receives no lighting from step #5, because lighting was already applied at step #4, so D would be completely bright, while the parts of platform that are on A, B and C would be darker than required.

There are two solutions I can think of but I didn't want to implement them due to how complex they are:

1. When drawing each T-Layer tile, check if it is not partially covered by a moving platform, and if it is only draw the darkness over the part that is not on platform. I was afraid of this change because it seemed very computationally intensive.
2. Draw lighting to a separate surface, so that different passes overwrite (rather than multiply/add) the light, and then draw the whole light surface over the room all at once. So first it would draw the regular lighting for all the tiles, then draw Platform lighting on top of it, replacing the pit's darkness, and then finally apply the lighting to the room surface.

Solution #2 would have some additional benefits too - it could potentially simplify other code (eg. how moving mirrors/kegs are drawn) and open the door for more lighting variation with different elements.

But I was a little bit scared to do either of those changes.

____________________________
My website | Facebook | Twitter
11-13-2020 at 08:36 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged

File: Skells aaa.hold (750.3 KB)
Downloaded 21 times.
License: Public Domain
icon Re: Regression: light rendering on moving platform not aligned (+2)  
And the aforementioned hold

____________________________
My website | Facebook | Twitter
11-13-2020 at 08:37 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Regression: light rendering on moving platform not aligned (+2)  
Sounds like a complex issue.

Let's think about it for a while.

I'm confident we can come up with something that works.

Lighting used to be rendered on both moving platforms and t-layer objects properly, and I am optimistic we can recover that logic.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 11-13-2020 04:29 PM]
11-13-2020 at 03:19 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Regression: light rendering on moving platform not aligned (+2)  
You're talking about this change you made to align the platform lighting to the room tiles, even during animation, correct?

The shading should be aligned to the room tiles, but the lighting should be drawn on the platform as it moves. I'm going to play with it to see if I can make an improvement.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
11-13-2020 at 04:29 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Regression: light rendering on moving platform not aligned (0)  
Well...this one's a toughie. Brainstorming:

I've concluded that, in order to layer rendering in this order:

1. pit (and other o-layer tiles)
2. (moving) pit-platforms
3. o-layer effects

and then apply (in either order, as long as they don't conflict)

* platform darkness + lighting
* pit darkness

and then draw

* t-layer items w/ darkness + lighting

...then as you indicated, this ordering would logically require the "pit darkness" step be aware of where moving platforms are and not apply darkness on top of them. This might be what you meant by your proposal #1, but I'm not sure.

I don't believe we have a routine to subtract rectangular regions or a tile mask when shading a tile, but that seems to be what we need in this case.

I think we don't need to worry about the computational complexity for figuring out these regions. It can be done efficiently enough. I'm scared to implement this too, but I don't want the rendering to take a step backward here, so we have to get this done if we want to keep the lighting and darkness completely on top of o-layer effects.

Edit: How about, when pit darkness is rendered, replace AddDark with AddDarkMask, applying an ad-hoc tile mask that's set to the pixels of platforms drawn on that tile? Well...gulp...I'm going to try something out...

Edit: okay! Half of the task is done. So far, so good...

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 11-13-2020 10:40 PM]
11-13-2020 at 09:45 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged
icon Re: Regression: light rendering on moving platform not aligned (0)  
Frankly I like my proposition #2 best (probably because I am not sure I understand your solution, I likely need to look at it tomorrow when I am less sleepy) - have a separate surface for the light layer, so the rendering would be something like this:

1. Draw O-Layer except platforms
2. Draw Platforms
3. Draw O-Layer effects
4. Draw T-Layer
5. Draw Lighting to LightSurface
6. Draw Platform light to LightSurface (replacing pixels, not adding/multiplying values)
7. Draw LightSurface

____________________________
My website | Facebook | Twitter

[Last edited by skell at 11-13-2020 10:46 PM]
11-13-2020 at 10:32 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Regression: light rendering on moving platform not aligned (+1)  
PR for RPG 1.2.8.

It contains some bonus subtle light casting rendering improvements.

If this looks good, I'll be migrating these changes to 5.1.1.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
11-14-2020 at 10:14 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Regression: light rendering on moving platform not aligned (0)  
PR

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
11-17-2020 at 11:08 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Regression: light rendering on moving platform not aligned (+1)  
This is not quite fixed in 5.1.1.371.

Create a room with weather at maximum darkness, and turn the repeat rate to its lowest. Create a big platform on a pit, and place some Light (ceiling) on some squares.

When you move the pit across the lit up squares, a thick border between the light and dark squares appears.
12-15-2020 at 09:24 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Bugs : Regression: light rendering on moving platform not aligned
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.