-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
Generate biomes for smooth sdf VoxelLodTerrain #633
Comments
You can't do all of this with a basic generator such as |
There is another recent issue asking the same question, also doing the same mistakes (and that gets asked a lot because people don't read the docs / don't realize how Godot works) so to avoid repeating myself I'll link to it: #626 (comment) |
Thank you for the quick reply and the links, they are really helpful! Sorry I'm quite new to godot. For the biomes materials, it is correct to set |
Yes
Like for many terrains, using standalone materials is not possible because blending between different textures wouldn't work (and Godot doesn't come with something to handle it). So typically you have to do this in a single shader material, mixing procedural approaches (such as using normals to decide which texture to blend) and voxel data (for cases where the actual voxels tell what texture to use). This comes with a whole bunch of caveats and compromises, compared to heightmaps or regular models. See https://voxel-tools.readthedocs.io/en/latest/smooth_terrain/#texturing |
My suspicion is that your generator is not outputting LODs correctly. Note that with LOD1, world positions you sample on noise must be spaced twice as much, and so on by powers of two for each higher LOD index. |
I was experimenting with the shader code in the docs with the custom VoxelGeneratorScript with 4 simple textures: func _ready():
var img_red = Image.create(16, 16, true, Image.FORMAT_RGBA8)
img_red.fill(Color.RED)
var img_green = Image.create(16, 16, true, Image.FORMAT_RGBA8)
img_green.fill(Color.GREEN)
var img_blue = Image.create(16, 16, true, Image.FORMAT_RGBA8)
img_blue.fill(Color.BLUE)
var img_yellow = Image.create(16, 16, true, Image.FORMAT_RGBA8)
img_yellow.fill(Color.YELLOW)
var texture_2d_array = Texture2DArray.new()
texture_2d_array.create_from_images([img_red, img_green, img_blue, img_yellow])
var material = terrain.material as ShaderMaterial
material.set_shader_parameter("u_texture_array", texture_2d_array) However, it generated some black areas. Do you know what could be the problem area that caused the black zone to appear and how to fix it? (p.s. The hills are generated with a cellular noise in the VoxelGeneratorScript.) |
I can't tell, sorry. The problem is somewhere else that you havent posted. Probably your generator |
In the example shader code, does the v_indices and v_weights correspond directly to the voxel buffer's CHANNEL_INDICES and CHANNEL_WEIGHTS values?
In my generator, it is set using biome values are generated using a noise I've tried to change the values of the heights and the material indices in relation to the biome noise values, but some voxels still appear black. |
Yes, though with a slightly different encoding.
That's wrong. You are setting only one index per voxel, but the engine expects 4 at once. Values you set in here must be encoded as shown here: https://voxel-tools.readthedocs.io/en/latest/smooth_terrain/#voxel-data Check these functions for encoding: |
It works now. Thank you for your support. |
My current setup:
What is the correct approach when it comes to generating different biomes with temperature, humidity, etc. with the VoxelLodTerrain using channel sdf? I believe it cannot be done in the same way as the blocky terrain, since it doesn't use channel type. Could you please provide a simple example/workflow description of how to do this with smooth terrain? Should it be done in the shader instead of the generator?
The text was updated successfully, but these errors were encountered: