Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    31
  • comments
    55
  • views
    46644

Voxel lighting problem solved

Sign in to follow this  
CC Ricers

1878 views

[color=rgb(51,51,51)][font=Georgia]


[font=arial]I have fixed a problem that has bugged me for quite some time. For most of the development of SeedWorld, up until last week, every chunk was not able to access voxels from immediate neighbors. This shortcoming was avoided with the code for voxel collisions, which worked by finding the right[/font]

[/font][/color][color=rgb(51,51,51)][font=Georgia]


[font=arial]chunk from the group of chunks to test whether a block is solid or empty, given world coordinates as input. But sometimes you needed to find out based on local coordinates, relative to a chunk's location. This was evident in the mesh building process, as it did ray casting from each visible voxel to determine if a voxel needs to be shaded darker, and by how much.[/font]

[/font][/color]
[color=rgb(51,51,51)][font=Georgia]


[font=arial]The edge voxels were a problem for raycasting since it could not raycast further out from the edges of the chunk. Any rays that reached the edge were considered "not blocked" and the voxel received full light. This created a seam of lighter colored voxels around the edges.[/font]

[/font][/color]
[color=rgb(51,51,51)][font=Georgia]


[font=arial]20150214-banding1.png?w=605[/font]

[/font][/color]
[color=rgb(51,51,51)][font=Georgia]


[font=arial]Now since each chunk now has access to its eight neighbors surrounding the sides, you can simply make the ray "step into" these chunks and continue traveling the distance it's supposed to instead of ending prematurely. My first attempt to fix this didn't go well. I was modifying the starting coordinates of each ray and using that to find the neighbor chunk. It ended up looking worse:[/font]

[/font][/color]
[color=rgb(51,51,51)][font=Georgia]


[font=arial]20150214-banding2.png?w=605[/font]

[/font][/color]
[color=rgb(51,51,51)][font=Georgia]


[font=arial]These seams appeared because the ray was checking against the solid voxel it started from. So it always subtracted contribution from the light, making the edges dark. This was fixed by updating the ray coordinates after each step, seeing if they go out of bounds (from 0 to 32) and then picking the correct neighbor chunk to continue and reset the local coordinates. Now the seams are gone and the shading is correct.[/font]

[/font][/color]
[color=rgb(51,51,51)][font=Georgia]


[font=arial]20150214-no-banding.png?w=605[/font]

[/font][/color]
[color=rgb(51,51,51)][font=Georgia]


[font=arial]Now the chunks don't look as obvious. This was pretty satisfying to fix, and probably so much that I will move on to work on other parts of the game. There are still visible seams at height intervals (because rays don't have neighbors to check on the Y axis) but this is still a lot better than seeing an entire grid of lines going across the landscape. So it's not something I am focused on improving at the moment.[/font]

[/font][/color]
[color=rgb(51,51,51)][font=Georgia]


[font=arial]As for what I will be working on next, I have been looking at some UI libraries to see which I will add into the game. I've already picked one to try for the moment, and if it is easy enough to use without having to break or re-code a large part of my game, I'll stick with it and start adding some game features.[/font]

[/font][/color]
Sign in to follow this  


5 Comments


Recommended Comments

This is reminding me more and more of that one game that came out about a year ago. I cant remember the name off the top of my head but it had alot of steam behind it. Guy released it and then nothing. Keep up the work as this is looking great!

Share this comment


Link to comment

This is reminding me more and more of that one game that came out about a year ago. I cant remember the name off the top of my head but it had alot of steam behind it. Guy released it and then nothing. Keep up the work as this is looking great!

 

Cube World?

Share this comment


Link to comment

This is reminding me more and more of that one game that came out about a year ago. I cant remember the name off the top of my head but it had alot of steam behind it. Guy released it and then nothing. Keep up the work as this is looking great!

 

Actually it was like 2-3 years ago and yes it was Cube World.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!