Skip to content

SdfPlane graph node writing to weight channel through OutputSDF #826

@AntoineRR

Description

@AntoineRR

First of all thank you for this amazing plugin, it does work very well and help me a lot!

Describe the bug
While playing with the VoxelGraphGenerator, I noticed some weights were being added by the SdfPlane node even though I didn't want it. This is very visible when using a shader that displays weight values on the sides of a bound VoxelTerrain (see screenshot).
My guess is that the SdfPlane node just writes the y value to channel sdf and at some point it overflows onto the weight channel. I get the same issue when I plug InputY directly to OutputSdf.

To Reproduce

  • Create a new VoxelTerrain
  • Set its bounds to (-32, -32, -32) and (32, 32, 32)
  • Assign it a new ShaderMaterial with the following shader :
shader_type spatial;

#include "res://addons/zylann.voxel/shaders/transvoxel.gdshaderinc"
#include "res://addons/zylann.voxel/shaders/voxel_texturing.gdshaderinc"

varying vec4 v_material_weights;


void vertex() {
	VERTEX = get_transvoxel_position(VERTEX, CUSTOM0);

    v_material_weights = decode_8bit_vec4(CUSTOM1.y) / 255.0;
}

void fragment() {
	ALBEDO = vec3(v_material_weights.rgb);
}
  • Assign a VoxelMesherTransvoxel with the "Mixel4" texturing mode
  • Assign a VoxelGraphGenerator
  • Add an OutputWeight node (should set the first weight to 0)
  • Regenerate Terrain

Expected behavior
I would expect the weights to be set to 0 accross all the voxels

Screenshots

Image

Workaround
For my use case, the simplest workaround is to use the following graph. The sdf is probably less precise but it's ok for me.

Image

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions