First adjustments to the Entity System to make it work with different types
This commit is contained in:
@@ -12,6 +12,9 @@ uniform float brightness_add : hint_range(-1.0, 1.0) = 0.0;
|
||||
// Contrast multiplier in RGB space. 1.0 means no change.
|
||||
uniform float contrast_mult : hint_range(0.0, 2.0) = 1.0;
|
||||
|
||||
//Cached Color value to reapply modulate
|
||||
varying vec4 modulate;
|
||||
|
||||
// Converts an RGB color to HSV.
|
||||
vec3 rgb2hsv(vec3 c) {
|
||||
float cMax = max(max(c.r, c.g), c.b);
|
||||
@@ -65,6 +68,10 @@ vec3 hsv2rgb(vec3 c) {
|
||||
return rgb + vec3(m);
|
||||
}
|
||||
|
||||
void vertex(){
|
||||
modulate = COLOR;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// Get the original texture color.
|
||||
vec4 tex_color = texture(TEXTURE, UV);
|
||||
@@ -89,4 +96,6 @@ void fragment() {
|
||||
|
||||
// Output the final color while preserving the original alpha.
|
||||
COLOR = vec4(col, tex_color.a);
|
||||
//reapply vertex color value to keep modulate changes
|
||||
COLOR = COLOR * modulate;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,14 @@ shader_type canvas_item;
|
||||
|
||||
uniform vec2 tiling_scale = vec2(5.0, 5.0);
|
||||
uniform sampler2D noise : repeat_enable;
|
||||
varying vec4 modulate;
|
||||
|
||||
void vertex() {
|
||||
modulate = COLOR;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 uv = vec2(UV.x * tiling_scale.x, UV.y * tiling_scale.y); // Change 10.0 to control tiling scale
|
||||
COLOR = texture(TEXTURE, fract(uv));
|
||||
COLOR = COLOR * modulate;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ uniform float heightOffset : hint_range(0.0, 1.0);
|
||||
// With the offset value, you can if you want different moves for each asset. Just put a random value (1, 2, 3) in the editor. Don't forget to mark the material as unique if you use this
|
||||
uniform float offset = 0;
|
||||
|
||||
// caching color settings to reapply modulate value
|
||||
varying vec4 modulate;
|
||||
|
||||
float getWind(vec2 vertex, vec2 uv, float time){
|
||||
float diff = pow(maxStrength - minStrength, 2.0);
|
||||
float strength = clamp(minStrength + diff + sin(time / interval) * diff, minStrength, maxStrength) * strengthScale;
|
||||
@@ -47,8 +50,13 @@ float noise(vec2 x) {
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
modulate = COLOR;
|
||||
vec4 pos = MODEL_MATRIX * vec4(0.0, 0.0, 0.0, 1.0);
|
||||
//float time = TIME * speed + sin(VERTEX.x * noise(VERTEX.xy) * offset);
|
||||
float time = TIME * speed + sin(pos.x * offset) * cos( pos.x * offset) ;
|
||||
VERTEX.x += getWind(VERTEX.xy, UV, time);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
COLOR = modulate * COLOR;
|
||||
}
|
||||
Reference in New Issue
Block a user