Fix generator example
This commit is contained in:
parent
9384c9c926
commit
5f67d7ac57
@ -41,10 +41,10 @@ extends VoxelGeneratorScript
|
||||
|
||||
const channel : int = VoxelBuffer.CHANNEL_TYPE
|
||||
|
||||
func get_used_channels_mask() -> int:
|
||||
func _get_used_channels_mask() -> int:
|
||||
return 1 << channel
|
||||
|
||||
func generate_block(buffer : VoxelBuffer, origin : Vector3, lod : int) -> void:
|
||||
func _generate_block(buffer : VoxelBuffer, origin : Vector3, lod : int) -> void:
|
||||
if lod != 0:
|
||||
return
|
||||
if origin.y < 0:
|
||||
@ -62,9 +62,11 @@ const MyGenerator = preload("my_generator.gd")
|
||||
var terrain = $VoxelTerrain
|
||||
|
||||
func _ready():
|
||||
terrain.stream = MyGenerator.new()
|
||||
terrain.generator = MyGenerator.new()
|
||||
```
|
||||
|
||||
Make sure to have a `VoxelViewer` node in the scene under the camera, and you should see this:
|
||||
|
||||
![Custom stream](images/custom-stream.jpg)
|
||||
|
||||
Though `VoxelBuffer.fill()` is probably not what you want to use, the above is a quick example. Generate_block generally gives you a block of 16x16x16 cubes to fill all at once, so you may also use `VoxelBuffer.set_voxel()` to specify each one individually. You can change the channel to `VoxelBuffer.CHANNEL_SDF` to get smooth voxels using another mesher such as `VoxelMesherTransvoxel`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user