Просмотр исходного кода

add blendmodes to ground shader

sl@cccfr.de лет назад: 2
Родитель
Сommit
965cd98729
1 измененных файлов с 23 добавлено и 7 удалено
  1. 23 7
      shader/ground_shader.tres

+ 23 - 7
shader/ground_shader.tres

@@ -31,16 +31,32 @@ uniform int depth_max_layers;
 uniform vec2 depth_flip;
 uniform vec3 uv1_scale;
 uniform vec3 uv1_offset;
-uniform vec3 uv2_scale;
+uniform vec2 uv2_scale;
 uniform vec3 uv2_offset;
 
+vec4 soft_light(vec4 base, vec4 blend){
+	vec4 limit = step(0.5, blend);
+	return mix(2.0 * base * blend + base * base * (1.0 - 2.0 * blend), sqrt(base) * (2.0 * blend - 1.0) + (2.0 * base) * (1.0 - blend), limit);
+}
 
-void vertex() {
-	UV=UV*uv1_scale.xy+uv1_offset.xy;
+vec4 overlay(vec4 base, vec4 blend){
+	vec4 limit = step(0.5, base);
+	return mix(2.0 * base * blend, 1.0 - 2.0 * (1.0 - base) * (1.0 - blend), limit);
 }
 
+vec4 color_burn(vec4 base, vec4 blend){
+	return 1.0 - (1.0 - base) / blend;
+}
 
+vec4 screen(vec4 base, vec4 blend){
+	return 1.0 - (1.0 - base) * (1.0 - blend);
+}
 
+void vertex() {
+	UV=UV*uv1_scale.xy+uv1_offset.xy;
+	float depth = texture(texture_depth, UV).a;
+	VERTEX.y += depth * depth_scale;
+}
 
 void fragment() {
 	vec2 base_uv = UV;
@@ -68,11 +84,11 @@ void fragment() {
 		//base_uv=ofs;
 	}*/
 	
-	vec2 scaled_uv = base_uv*vec2(512,512);
+	vec2 scaled_uv = base_uv*uv2_scale;
 	vec4 albedo_tex = texture(texture_albedo,scaled_uv);
 	vec4 albedo_tex_big = texture(texture_albedo_big,base_uv);
-	ALBEDO = albedo.rgb * (albedo_tex.rgb + albedo_tex_big.rgb);
-	
+	//ALBEDO = albedo.rgb * (albedo_tex.rgb + albedo_tex_big.rgb);
+	ALBEDO = screen(albedo_tex, albedo_tex_big).rgb;
 	float roughness_tex = dot(texture(texture_roughness,scaled_uv),roughness_texture_channel);
 	ROUGHNESS = roughness_tex * roughness;
 	SPECULAR = specular;
@@ -99,7 +115,7 @@ shader_param/depth_max_layers = 32
 shader_param/depth_flip = Vector2( 1, 1 )
 shader_param/uv1_scale = Vector3( 1, 1, 1 )
 shader_param/uv1_offset = Vector3( 0, 0, 0 )
-shader_param/uv2_scale = Vector3( 1, 1, 1 )
+shader_param/uv2_scale = Vector2( 512, 512 )
 shader_param/uv2_offset = Vector3( 0, 0, 0 )
 shader_param/texture_albedo = ExtResource( 6 )
 shader_param/texture_roughness = ExtResource( 4 )