Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L-system lighting bug #3421

Closed
paramat opened this issue Dec 3, 2015 · 7 comments
Closed

L-system lighting bug #3421

paramat opened this issue Dec 3, 2015 · 7 comments
Labels
Bug Issues that were confirmed to be a bug @ Mapgen @ Server / Client / Env.

Comments

@paramat
Copy link
Contributor

paramat commented Dec 3, 2015

This issue is to document some progress i made tracking down shadow bugs.
Same issue as #3455
Possibly related issues #3430 #3839

Working on my 'fracture' lua mapgen mod i noticed lighting bugs in mgv7 not present in mgv6 or singlenode. The difference is mgv7 uses 1 up 1 down overgeneration while mgv6 and singlenode do not. I solved the lighting bug in 'fracture' by calculating lighting over the entire overgenerated volume instead of just the mapchunk:
vm:calc_lighting({x = x0, y = y0 - 1, z = z0}, {x = x1, y = y1 + 1, z = z1})

I then thought about how 'moretrees' mod has shadow bugs in mgv7 and not in mgv6 and suspected that the overgeneration of mgv7 was incompatible with 'updateLighting' used by l-system tree generation. Studying the code, l-system tree code automatically emerges a large volume that probably touches the mapchunk top, when propagating sunlight into that volume it looks at the single layer of nodes just above the volume, which in mgv7 would often be the single layer of overgenerated nodes above a mapchunk, instead of 'ignore' in mgv6.

I noticed the moretrees shadow bugs were dependent on whether the mapchunk above had been generated first. 'updateLighting' was probably lookng at the lowest mapblock in the mapchunk above. If this was generated and full of sunlight no shadow bug. If it was ungenerated and therefore mostly full of 'ignore' but with a single layer of overgenerated nodes as it's lowest layer the shadow bugs occured.

I created a branch with a version of mgv7 without overgeneration and tried the moretrees mod, the more extreme shadows were fixed. Overgeneration is essential to avoid discontinuities at mapchunk borders, so i am currently testing a '0 up 2 down' overgeneration which so far seems to fix the more extreme shadow bugs, however it needs testing to see if the advantages of overgeneration remain. The '0 up' means the top of the generated volume now aligns with mapblock edges just as in mgv6, hopefully fixing the bug when propagating sunlight down.

Because the placement of schematics also uses 'updateLighting' the shadow bugs related to schematic placement may also be fixed by this method.

@paramat paramat added Bug Issues that were confirmed to be a bug @ Mapgen labels Dec 3, 2015
@0-afflatus
Copy link

👍 Good work tracking that down. Here's hoping ...

@paramat
Copy link
Contributor Author

paramat commented Dec 4, 2015

Unfortunately testing 0 up 2 down overgen i find many bugs at y = 47, 16x16 areas of stone where biomegen has failed, and ores in sand.

@paramat paramat changed the title Shadow bugs in mgv5/v7/flat/fractal caused by 1 up 1 down overgeneration Mgv5/v7/flat/fractal 1 up 1 down overgeneration changes lighting behaviour Dec 4, 2015
@paramat paramat closed this as completed Dec 4, 2015
@paramat
Copy link
Contributor Author

paramat commented Mar 27, 2016

Re-opening as this is useful information on the moretrees lighting bug.

@paramat paramat reopened this Mar 27, 2016
@paramat paramat changed the title Mgv5/v7/flat/fractal 1 up 1 down overgeneration changes lighting behaviour Moretrees lighting bug: Mapgen 1 up 1 down overgeneration changes lighting behaviour Mar 27, 2016
@paramat
Copy link
Contributor Author

paramat commented Mar 27, 2016

Mgv7

For a while the advice has been to use the moretrees option to place all trees as saplings that grow by ABM long after mapgen, ensuring the mapchunk above has been generated. This almost solves the lighting bugs but subtle (1 light level darker than it should be) shadows remain in water:

screenshot_20160327_113049

The water shadow is aligned to mapblock edges, so must be the area processed by l-system tree generation. This shadow is 48 nodes wide, which is the area emerged by l-system code.
These subtle shadows occur in sapling mode whether flying high or not.

This subtle shadow is also present when moretrees is used in the default mode of generating trees at mapgen time when generating world by flying near the clouds to ensure the upper mapchunks are generated first.

@paramat
Copy link
Contributor Author

paramat commented Mar 27, 2016

Mgv6

screenshot_20160327_174856

screenshot_20160327_175519

Subtle shadows are present in mgv6, using moretrees in the default mode of generating trees at mapgen. The pattern seems more variable, but is still aligned to mapblock edges. In the lower screenshot there is an area at the bottom without trees but still with a shadow. These shadows occur even if i fly high to generate the higher mapchunks first.

The subtle shadows in water are present in moretrees 'sapling' mode too, either travelling at ground level or flying high to generate higher mapchunks first.

@paramat
Copy link
Contributor Author

paramat commented Mar 27, 2016

We can split this issue into 2 now:

  1. Subtle shadows in water in all mapgens and in both moretrees modes, whether flying high or not, seems to be an issue with l-system code.
  2. Extreme and dark shadows in mapgens with 1-up 1-down overgeneration, in moretrees default mode when the surface mapchunk is generated before the mapchunk above, therefore when l-system trees are generated before the mapchunk above is generated.

@paramat paramat changed the title Moretrees lighting bug: Mapgen 1 up 1 down overgeneration changes lighting behaviour L-system lighting bug May 2, 2016
@paramat paramat modified the milestone: 0.4.14 May 2, 2016
@paramat
Copy link
Contributor Author

paramat commented Mar 11, 2017

#4967 merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Mapgen @ Server / Client / Env.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants