Skip to content

Bleed per-pixel light up when rendering walls#7812

Merged
AJenbo merged 1 commit intodiasurgical:masterfrom
StephenCWills:per-pixel-light-bleedup
Mar 7, 2025
Merged

Bleed per-pixel light up when rendering walls#7812
AJenbo merged 1 commit intodiasurgical:masterfrom
StephenCWills:per-pixel-light-bleedup

Conversation

@StephenCWills
Copy link
Copy Markdown
Member

This PR bleeds light up from the top edge of the base diamond to the top of wall/ceiling tiles, as described in #7809.

For this to work, we first need to copy light data for the base diamond of the wall tile from the per-pixel lightmap into a new 64x32 buffer. As we do this, we also compute where the top edge of the base diamond is so we can bleed data up from there to the top of the buffer. This new buffer becomes the source for light data used when rendering the base diamond. Then, when rendering the rest of the CEL data above the base diamond, we simply reuse the top row of the 64x32 buffer for every rendering instruction, allowing us to apply the same lighting to the rest of the graphic.

This effect really does make the lighting on walls and ceilings look remarkably similar to the tile-based lighting.

DevilutionX-2025-03-06_01.20.28.mp4

Unfortunately, it does reintroduce some banding between ceiling tiles. The best way to resolve this is to differentiate between wall tiles and ceiling tiles, which will require some work to add additional tile properties and/or masks for each tile graphic. That will be outside the scope of this PR.

This resolves #7809

@kphoenix137
Copy link
Copy Markdown
Collaborator

Since walls are thicker, wouldn't it be more accurate to copy the light value from lower down rather than the top of the floor diamond?
image

@StephenCWills
Copy link
Copy Markdown
Member Author

StephenCWills commented Mar 6, 2025

Since walls are thicker, wouldn't it be more accurate to copy the light value from lower down rather than the top of the floor diamond?

There are a couple problems with that approach, illustrated by your example.

  • There is plenty of floor between the green and red lines in your graphic, so it's a bit hard to say that it would definitely be better.
  • The green lines don't reach the far edges of the tile. If you bleed up from the green lines, you won't have any light data to copy into the corners of the base diamond. It gets even worse if the wall also extends all the way to the edge of the graphic.

@StephenCWills
Copy link
Copy Markdown
Member Author

Thinking about it again, so long as the midpoint for the green lines is at least halfway up from the bottom of the tile, you would actually be able to extend those green lines all the way to the bottom of the bounding box for the base tile and just copy light values from there. Since the lightmap doesn't actually care about the shape of any given CEL, it should have light data for those pixels even if the current CEL wouldn't actually render there.

So my second bullet point isn't correct. It really is only a question of whether it actually makes any real difference to choose the green lines instead of the red lines. Since the technique of copying light values up is more of a low-effort approximation than an actual shading technique, I don't think it would really make much of a difference.

@AJenbo
Copy link
Copy Markdown
Member

AJenbo commented Mar 6, 2025

KP's suggestion would require different rendering for floor and wall tiles or floor tiles would not blend any longer, we do already indicate where most of these are, but even then some tiles a re bit of a hybrid and there would be a tile seam around any tile that doesn't have walls on both sides, which would actually be quite frequent.

I think doing better then what this PR does would require making masks for all tiles that splits tiles in to 3 lighting types:
1: floor (like before this PR)
2: walls (what this PR does)
3: ceiling: same as 1 but offset by 90 pixels (different per level type

I do consider what's done in this PR to be roughly the best that can be done for lighting with 2D rendering techniques and just the original data, at least while staying faithful to the look.

@StephenCWills StephenCWills force-pushed the per-pixel-light-bleedup branch from 47b86ec to 211645a Compare March 6, 2025 14:19
@StephenCWills StephenCWills force-pushed the per-pixel-light-bleedup branch from 211645a to 71217ac Compare March 6, 2025 15:35
@AJenbo
Copy link
Copy Markdown
Member

AJenbo commented Mar 7, 2025

I made a debug tile set for the cathedral with no graphics: levels.zip

Here is the default lighting:
image

Master:
image

This PR:
image

@AJenbo AJenbo merged commit b83f006 into diasurgical:master Mar 7, 2025
23 checks passed
@StephenCWills StephenCWills deleted the per-pixel-light-bleedup branch March 7, 2025 02:11
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.

More accurate replicate the original lighting in the perpixel lighting

3 participants