how to mask out vertex colors?
Asked Answered
T

3

0

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;
	
}
Teaspoon answered 7/7, 2022 at 18:38 Comment(0)
E
0

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

Everett answered 7/7, 2022 at 19:22 Comment(0)
T
0

Everett
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;
	
}

Teaspoon answered 10/7, 2022 at 17:46 Comment(0)
T
0

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

Teaspoon answered 12/7, 2022 at 16:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.