Skip to content

Conversation

@cb341
Copy link
Owner

@cb341 cb341 commented Mar 9, 2025

Ambient Occlusion

In graphics, ambient occlusion is a shadowing technique used to make 3D objects look more realistic by simulating the soft shadows that should naturally occur when indirect or ambient lighting is cast out onto your scene.
https://www.pluralsight.com/resources/blog/software-development/understanding-ambient-occlusion

Implemented vertex level ambient occlusion for blocks with cube mesh representation.
There is a neighbor check performed on each vertex, thus making the mesher now super duper slow.
The more neighbors a given vertex has, the darker its color becomes.

The vertex color data could be influenced by light sources in the future and lighting could be calculated using floodfill.

Without

Screenshot From 2025-03-09 13-19-18

With

Screenshot From 2025-03-09 13-19-42

Problems

  • AO is not calculated correctly at chunk borders :/
  • Performance is dog water

Additional sources

https://0fps.net/2013/07/03/ambient-occlusion-for-minecraft-like-worlds/

may have been borrowed from https://github.com/CuddlyBunion341/tsmc2/blob/c1e94bc8dad44154835ab858dd783de1185af037/src/game/world/ChunkMesher.ts#L173-L199

@cb341 cb341 self-assigned this Mar 9, 2025
@cb341 cb341 marked this pull request as ready for review March 9, 2025 12:26
&texture_manager,
&mut meshes,
);
for (entity, chunk_mesh) in mesh_query.iter_mut() {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents flickering, as the meshing takes much more time now.

]);
normal.push(vertex.normal);

let check = |dx: i32, dy: i32, dz: i32| -> bool {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustc --explain E0434

@cb341
Copy link
Owner Author

cb341 commented Mar 11, 2025

Closing because performance sucks bad

@cb341 cb341 closed this Mar 11, 2025
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.

2 participants