[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30669] branches/soc-2010-kwk/source/ blender/gpu/intern/gpu_shader_material.glsl: Added GLSL functions for Bump map painting through normal mapping a height texture .

Konrad Kleine konrad at konradwilhelm.de
Fri Jul 23 20:47:54 CEST 2010


Revision: 30669
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30669
Author:   kwk
Date:     2010-07-23 20:47:54 +0200 (Fri, 23 Jul 2010)

Log Message:
-----------
Added GLSL functions for Bump map painting through normal mapping a height texture. Inspired by The GIMP normalmap plugin. The functions aren't used by Blender yet.

Modified Paths:
--------------
    branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl

Modified: branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl
===================================================================
--- branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl	2010-07-23 18:42:15 UTC (rev 30668)
+++ branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl	2010-07-23 18:47:54 UTC (rev 30669)
@@ -1593,3 +1593,48 @@
 	outcol = vec4(col.rgb, col.a*obcol.a);
 }
 
+/* BEGIN (kwk) For bump map painting */
+
+void get_img_normal(float down, float up, float right, float left, out vec3 outvec)
+{
+	outvec = normalize(
+		vec3(
+			left - right,
+			down - up,
+			1.0f
+		)
+	);
+}
+
+void rgb2float(vec4 color, out float outval)
+{
+	float scale = 1.0f;
+	outval = (color.r + color.g + color .b) / 3.0f * scale;
+}
+
+void height_value_to_normal(sampler2D image, vec2 texcoord, out vec4 outcol)
+{
+	vec4 normal;
+	float down, up, right, left;
+	vec2 texsize = textureSize2D(image, 0);
+	
+	rgb2float( texture2D(image, texcoord.st+vec2(0,1)/texsize), down );
+	rgb2float( texture2D(image, texcoord.st+vec2(0,-1)/texsize), up );
+	rgb2float( texture2D(image, texcoord.st+vec2(1,0)/texsize), right );
+	rgb2float( texture2D(image, texcoord.st+vec2(-1,0)/texsize), left );
+
+	get_img_normal(down, up, right, left, normal.rgb);
+
+	/*normal.r = (normal.x + 1.0f) * 127.5f;
+	normal.g = (normal.y + 1.0f) * 127.5f;
+	normal.b = (normal.z + 1.0f) * 127.5f;*/
+	normal.rgb = normal.rgb + 0.5f;
+	normal.a = 1.0f;
+	
+	outvec = normalize(normal);
+}
+
+/* END (kwk) For bump map painting */
+
+
+





More information about the Bf-blender-cvs mailing list