noise 2d grass shader

this is a 2d grass shader it.

Works on tilemaplayer

how to set it up:

for pixel perfect look leave it as it is BUT noise and noise2 for best look both should be cellular and domain warp should be on the rest do as you want with it.

also you should change around the Fractal and Cellular to your liking.

the noise should be diffrent from each other.

you can apply alpha by turning it on and setting the value.

if you want a smoother look change the “filter_nearest” to “filter_linear” inside the shader in noise and noise2.

color modifiers modify already existing texture.

note:

there is no 1 becuse i dont want to implement it.

 

 

 

 

 

Shader code
shader_type canvas_item;

uniform sampler2D noise:filter_nearest,repeat_enable;
uniform sampler2D noise2:filter_nearest,repeat_enable;
varying vec2 world_pos;
uniform float scale:hint_range(0.0, 10000.0, 20.0)=500.0;
//uniform float color_modifier:hint_range(0.0, 5.0, 0.01)=1.0;
uniform float color_modifier2:hint_range(0.0, 5.0, 0.01)=0.9;
uniform float color_modifier3:hint_range(0.0, 5.0, 0.01)=.8;
uniform float color_modifier4:hint_range(0.0, 5.0, 0.01)=0.85;

uniform float amount_covered:hint_range(0.0, 1.0, 0.01)=0.5;
uniform float alpha2:hint_range(0.0, 1.0, 0.01)=1.0;
uniform float alpha3:hint_range(0.0, 1.0, 0.01)=1.0;
uniform float alpha4:hint_range(0.0, 1.0, 0.01)=1.0;
//uniform bool col_alph1=false;
uniform bool col_alph2=false;
uniform bool col_alph3=false;
uniform bool col_alph4=false;

void vertex()
{
	world_pos = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
}

void fragment() {
	vec4 noise_tex = texture(noise,world_pos/scale);
	vec4 noise_tex2 = texture(noise2,world_pos/scale);
	vec4 tex_tex = texture(TEXTURE,UV);
	float ACM = 1.0;
	float AAC = ACM-amount_covered;
	
	if (noise_tex.r<=AAC)
		if (col_alph2==true)
			COLOR = vec4(tex_tex.rgb*color_modifier2,alpha2);
		else
			COLOR = vec4(tex_tex.rgb*color_modifier2,noise_tex.a);
	else if (noise_tex2.r>=AAC)
		if (col_alph3==true)
			COLOR = vec4(tex_tex.rgb*color_modifier3,alpha3);
		else
			COLOR = vec4(tex_tex.rgb*color_modifier3,noise_tex2.a);
	else if (noise_tex2.r<=AAC)
		if (col_alph4==true)
			COLOR = vec4(tex_tex.rgb*color_modifier4,alpha4);
		else
			COLOR = vec4(tex_tex.rgb*color_modifier4,noise_tex2.a);
}
Live Preview
Tags
2d, grass, noise, pixel, tilemaplayer
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from electrick

Related shaders

guest

0 Comments
Oldest
Newest Most Voted