how do i make this shader only apply vertex offset on vertex color green?

shader_type spatial;
render_mode blend_mix, depth_prepass_alpha, cull_disabled, diffuse_burley, specular_schlick_ggx;
uniform float alphatreshold;
uniform float strenght : hint_range(0.0, 1.0, 0.05);
uniform float speed : hint_range(0.0, 3.0, 0.1);

uniform sampler2D colortex : source_color,filter_linear_mipmap,repeat_disable;
uniform sampler2D normaltex :  hint_roughness_normal,filter_linear_mipmap,repeat_disable;
uniform sampler2D roughnesstex : hint_roughness_gray,filter_linear_mipmap,repeat_disable;



void vertex() {
	
	float vertexcolorgreen = COLOR.g;
	VERTEX.x += sin(TIME * speed + VERTEX.x + VERTEX.z ) * strenght;
	VERTEX.y += sin(TIME * speed + VERTEX.y + VERTEX.x ) * strenght;

}

void fragment() {
	// Place fragment code here.
	ALPHA = texture(colortex,UV).a;
	ALPHA_SCISSOR_THRESHOLD = alphatreshold;
	ALBEDO= texture(colortex,UV).rgb;
	NORMAL_MAP = texture(normaltex,UV).rgb;
	SPECULAR = 0.5;
	ROUGHNESS = texture(roughnesstex,UV).r;
	
}
  • You have to multiply by COLOR.g when moving the vertex.

You have to multiply by COLOR.g when moving the vertex.

  • DJM replied to this.

    spacecloud
    that works,

    works fine for my grass, but when appling it to my tree branches, it doesnt . i think it has to do with the pivot being to far away

    shader_type spatial;
    render_mode blend_mix, depth_prepass_alpha, cull_disabled, diffuse_burley, specular_schlick_ggx;
    uniform float alphatreshold;
    uniform float strenght : hint_range(0.0, 1.0, 0.05);
    uniform float speed : hint_range(0.0, 1.0, 0.1);
    
    uniform sampler2D colortex : source_color,filter_linear_mipmap,repeat_disable;
    uniform sampler2D normaltex :  hint_roughness_normal,filter_linear_mipmap,repeat_disable;
    uniform sampler2D roughnesstex : hint_roughness_gray,filter_linear_mipmap,repeat_disable;
    
    
    
    void vertex() {
    	
    	
    	
    	VERTEX.x += sin(TIME * speed + VERTEX.x + VERTEX.z ) * strenght * COLOR.g;
    	VERTEX.y += sin(TIME * speed + VERTEX.y + VERTEX.x ) * strenght * COLOR.g;
    	VERTEX.z += sin(TIME * speed + VERTEX.z + VERTEX.y ) * strenght * COLOR.g;
    
    }
    
    void fragment() {
    	// Place fragment code here.
    	ALPHA = texture(colortex,UV).a;
    	ALPHA_SCISSOR_THRESHOLD = alphatreshold;
    	ALBEDO= texture(colortex,UV).rgb;
    	NORMAL_MAP = texture(normaltex,UV).rgb;
    	SPECULAR = 0.5;
    	ROUGHNESS = texture(roughnesstex,UV).r;
    	
    }

    the editor becomes really ,really slow when i use this shader. there must be something wrong with it.
    i was wondering why the editor became so unresponsive, so i deleted the trees and grass and works fine again