[Bf-blender-cvs] [fa47437426b] blender2.8: OpenGL: clean up smoke & fire shaders

Mike Erwin noreply at git.blender.org
Fri May 19 17:10:45 CEST 2017


Commit: fa47437426b8e4d72d15bcf3517b31c4202c095c
Author: Mike Erwin
Date:   Fri May 19 10:43:32 2017 -0400
Branches: blender2.8
https://developer.blender.org/rBfa47437426b8e4d72d15bcf3517b31c4202c095c

OpenGL: clean up smoke & fire shaders

TODO: swap gl_Vertex for vec3 pos, update smoke setup code

===================================================================

M	source/blender/gpu/shaders/gpu_shader_fire_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl

===================================================================

diff --git a/source/blender/gpu/shaders/gpu_shader_fire_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fire_frag.glsl
index 025cb0ee6e4..fc9cafb6b02 100644
--- a/source/blender/gpu/shaders/gpu_shader_fire_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fire_frag.glsl
@@ -1,20 +1,15 @@
 
 in vec3 coords;
 out vec4 fragColor;
-#define texture1D texture
-#define texture3D texture
 
 uniform sampler3D flame_texture;
 uniform sampler1D spectrum_texture;
 
 void main()
 {
-	float flame = texture3D(flame_texture, coords).r;
-	vec4 emission = texture1D(spectrum_texture, flame);
+	float flame = texture(flame_texture, coords).r;
+	vec4 emission = texture(spectrum_texture, flame);
 
-	vec4 color;
-	color.rgb = emission.a * emission.rgb;
-	color.a = emission.a;
-
-	fragColor = color;
+	fragColor.rgb = emission.a * emission.rgb;
+	fragColor.a = emission.a;
 }
diff --git a/source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl b/source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl
index 1bf57f0dcc2..b57bd5b6a37 100644
--- a/source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl
@@ -1,8 +1,6 @@
 
-  in vec3 coords;
-  out vec4 fragColor;
-  #define texture1D texture
-  #define texture3D texture
+in vec3 coords;
+out vec4 fragColor;
 
 uniform vec3 active_color;
 uniform float step_size;
@@ -19,7 +17,7 @@ uniform sampler3D color_band_texture;
 void main()
 {
 	/* compute color and density from volume texture */
-	vec4 soot = texture3D(soot_texture, coords);
+	vec4 soot = texture(soot_texture, coords);
 
 #ifndef USE_COBA
 	vec3 soot_color;
@@ -27,7 +25,7 @@ void main()
 		soot_color = active_color * soot.rgb / soot.a;
 	}
 	else {
-		soot_color = vec3(0, 0, 0);
+		soot_color = vec3(0);
 	}
 	float soot_density = density_scale * soot.a;
 
@@ -36,16 +34,14 @@ void main()
 	float soot_alpha = 1.0 - soot_transmittance;
 
 	/* shade */
-	float shadow = texture3D(shadow_texture, coords).r;
+	float shadow = texture(shadow_texture, coords).r;
 	soot_color *= soot_transmittance * shadow;
 
 	/* premultiply alpha */
-	vec4 color = vec4(soot_alpha * soot_color, soot_alpha);
+	fragColor = vec4(soot_alpha * soot_color, soot_alpha);
 #else
-	float color_band = texture3D(color_band_texture, coords).r;
-	vec4 transfer_function = texture1D(transfer_texture, color_band);
-	vec4 color = transfer_function * density_scale;
+	float color_band = texture(color_band_texture, coords).r;
+	vec4 transfer_function = texture(transfer_texture, color_band);
+	fragColor = transfer_function * density_scale;
 #endif
-
-	fragColor = color;
 }
diff --git a/source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl b/source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl
index 108376b1c86..8c30e9baf9e 100644
--- a/source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl
@@ -9,6 +9,7 @@ uniform vec3 ob_sizei;
 
 void main()
 {
+	// TODO: swap gl_Vertex for vec3 pos, update smoke setup code
 	gl_Position = ModelViewProjectionMatrix * vec4(gl_Vertex.xyz * ob_sizei, 1.0);
 	coords = (gl_Vertex.xyz - min_location) * invsize;
 }




More information about the Bf-blender-cvs mailing list