[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30834] branches/soc-2010-kwk: Bump Map Painting with painting error "RNA_boolean_get: OperatorStrokeElement.flip not found"

Konrad Kleine konrad at konradwilhelm.de
Wed Jul 28 14:03:50 CEST 2010


Revision: 30834
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30834
Author:   kwk
Date:     2010-07-28 14:03:50 +0200 (Wed, 28 Jul 2010)

Log Message:
-----------
Bump Map Painting with painting error "RNA_boolean_get: OperatorStrokeElement.flip not found"

* Visualization in 3D viewport works but painting is broken.
* GLSL code cleanups.
* Removed textureSize2D because some people reported this function was not working on their GPUs.
  * Added Shader model independent uniform "texsize" as function input.
  * textureSize2D is only available in Shader Model 4 cards.

* Still some improvements for enabling preview GLSL rendering and final rendering need to be made. Fredrik H. made some suggestions.

Modified Paths:
--------------
    branches/soc-2010-kwk/release/scripts/ui/properties_texture.py
    branches/soc-2010-kwk/source/blender/gpu/intern/gpu_material.c
    branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl
    branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl.c
    branches/soc-2010-kwk/source/blender/makesdna/DNA_texture_types.h
    branches/soc-2010-kwk/source/blender/makesrna/intern/rna_texture.c

Modified: branches/soc-2010-kwk/release/scripts/ui/properties_texture.py
===================================================================
--- branches/soc-2010-kwk/release/scripts/ui/properties_texture.py	2010-07-28 11:10:56 UTC (rev 30833)
+++ branches/soc-2010-kwk/release/scripts/ui/properties_texture.py	2010-07-28 12:03:50 UTC (rev 30834)
@@ -670,6 +670,9 @@
         col.prop(tex, "invert_alpha", text="Invert")
         col.separator()
         col.prop(tex, "flip_axis", text="Flip X/Y Axis")
+        col.separator()
+        col.label(text="Bump preview:")
+        col.prop(tex, "gen_norm_from_height", text="Height to Normal")
 
         if wide_ui:
             col = split.column()

Modified: branches/soc-2010-kwk/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/soc-2010-kwk/source/blender/gpu/intern/gpu_material.c	2010-07-28 11:10:56 UTC (rev 30833)
+++ branches/soc-2010-kwk/source/blender/gpu/intern/gpu_material.c	2010-07-28 12:03:50 UTC (rev 30834)
@@ -959,8 +959,13 @@
 			talpha = 0;
 			rgbnor = 0;
 
-			if(tex && tex->type == TEX_IMAGE && tex->ima) {
-				GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser), &tin, &trgb, &tnor);
+			if(tex && tex->type == TEX_IMAGE && tex->ima) {				
+				if (tex->imaflag & TEX_GEN_NORMAL_FROM_HEIGHT) {					
+					GPU_link(mat, "mtex_image_h2n", texco, GPU_image(tex->ima, &tex->iuser), GPU_uniform(mtex->size), &tin, &trgb, &tnor);
+				}
+				else {
+					GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser), &tin, &trgb, &tnor);	
+				}	
 				rgbnor= TEX_RGB;
 
 				if(tex->imaflag & TEX_USEALPHA)
@@ -1025,7 +1030,7 @@
 			}
 
 			if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) {
-				if((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP)) {
+				if((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP)) {					
 					if(mtex->norfac < 0.0f)
 						GPU_link(mat, "mtex_negate_texnormal", tnor, &tnor);
 

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-28 11:10:56 UTC (rev 30833)
+++ branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl	2010-07-28 12:03:50 UTC (rev 30834)
@@ -1066,6 +1066,37 @@
 	normal = 2.0*(vec3(color.r, -color.g, color.b) - vec3(0.5, -0.5, 0.5));
 }
 
+/*
+	Helper function for on the fly normal map generation from height map.
+*/
+void mtex_image_h2n_rgb2float(vec4 color, out float outval)
+{
+	float scale = 1.0;
+	outval = (color.r + color.g + color .b) / 3.0 * scale;
+}
+
+/*
+	On the fly normal map generation from bump map.
+	
+	This is replacement for mtex_image which generates the normal value from a height value.
+	It is inspired by The GIMP normal map plugin. I took the explicit algorithm and
+	streamlined it to fit implicit GPU computation.
+*/
+void mtex_image_h2n(vec3 texcoord, sampler2D image, vec3 texsize, out float value, out vec4 color, out vec3 normal)
+{
+	float down, up, right, left;
+	/*vec2 texsize = textureSize2D(image, 0);*/ /* Only with SM4 */
+	
+	mtex_image_h2n_rgb2float( texture2D(image, texcoord.st+vec2(0,1)/texsize.xy), down );
+	mtex_image_h2n_rgb2float( texture2D(image, texcoord.st+vec2(0,-1)/texsize.xy), up );
+	mtex_image_h2n_rgb2float( texture2D(image, texcoord.st+vec2(1,0)/texsize.xy), right );
+	mtex_image_h2n_rgb2float( texture2D(image, texcoord.st+vec2(-1,0)/texsize.xy), left );
+
+	normal = normalize(vec3(left - right, down - up, 1.0));
+	color = texture2D(image, texcoord.xy);
+	value = 1.0;
+}
+
 void mtex_negate_texnormal(vec3 normal, out vec3 outnormal)
 {
 	outnormal = vec3(-normal.x, -normal.y, normal.z);
@@ -1592,49 +1623,3 @@
 {
 	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 */
-
-
-

Modified: branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl.c
===================================================================
--- branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl.c	2010-07-28 11:10:56 UTC (rev 30833)
+++ branches/soc-2010-kwk/source/blender/gpu/intern/gpu_shader_material.glsl.c	2010-07-28 12:03:50 UTC (rev 30834)
@@ -1,1055 +1,1091 @@
 /* DataToC output of file <gpu_shader_material_glsl> */
 
-int datatoc_gpu_shader_material_glsl_size= 33537;
+int datatoc_gpu_shader_material_glsl_size= 34704;
 char datatoc_gpu_shader_material_glsl[]= {
- 10,
-102,108,111, 97,116, 32,101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111, 97,116, 32,102, 41, 10,123, 10,  9,114,101,
-116,117,114,110, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 50, 56, 52, 54, 44, 32,102, 41, 59, 10,125, 10, 10,118,
-111,105,100, 32,114,103, 98, 95,116,111, 95,104,115,118, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117,116, 32,118,101, 99,
- 52, 32,111,117,116, 99,111,108, 41, 10,123, 10,  9,102,108,111, 97,116, 32, 99,109, 97,120, 44, 32, 99,109,105,110, 44, 32,104,
- 44, 32,115, 44, 32,118, 44, 32, 99,100,101,108,116, 97, 59, 10,  9,118,101, 99, 51, 32, 99, 59, 10, 10,  9, 99,109, 97,120, 32,
- 61, 32,109, 97,120, 40,114,103, 98, 91, 48, 93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93,
- 41, 41, 59, 10,  9, 99,109,105,110, 32, 61, 32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, 32,109,105,110, 40,114,103, 98, 91,
- 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 10,  9, 99,100,101,108,116, 97, 32, 61, 32, 99,109, 97,120, 45, 99,109,105,
-110, 59, 10, 10,  9,118, 32, 61, 32, 99,109, 97,120, 59, 10,  9,105,102, 32, 40, 99,109, 97,120, 33, 61, 48, 46, 48, 41, 10,  9,
-  9,115, 32, 61, 32, 99,100,101,108,116, 97, 47, 99,109, 97,120, 59, 10,  9,101,108,115,101, 32,123, 10,  9,  9,115, 32, 61, 32,
- 48, 46, 48, 59, 10,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 10,  9,125, 10, 10,  9,105,102, 32, 40,115, 32, 61, 61, 32, 48, 46,
- 48, 41, 32,123, 10,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 10,  9,125, 10,  9,101,108,115,101, 32,123, 10,  9,  9, 99, 32, 61,
- 32, 40,118,101, 99, 51, 40, 99,109, 97,120, 44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41, 32, 45, 32,114,103, 98, 46,120,
-121,122, 41, 47, 99,100,101,108,116, 97, 59, 10, 10,  9,  9,105,102, 32, 40,114,103, 98, 46,120, 61, 61, 99,109, 97,120, 41, 32,
-104, 32, 61, 32, 99, 91, 50, 93, 32, 45, 32, 99, 91, 49, 93, 59, 10,  9,  9,101,108,115,101, 32,105,102, 32, 40,114,103, 98, 46,
-121, 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 50, 46, 48, 32, 43, 32, 99, 91, 48, 93, 32, 45, 32, 32, 99, 91, 50, 93, 59,
- 10,  9,  9,101,108,115,101, 32,104, 32, 61, 32, 52, 46, 48, 32, 43, 32, 99, 91, 49, 93, 32, 45, 32, 99, 91, 48, 93, 59, 10, 10,
-  9,  9,104, 32, 47, 61, 32, 54, 46, 48, 59, 10, 10,  9,  9,105,102, 32, 40,104, 60, 48, 46, 48, 41, 10,  9,  9,  9,104, 32, 43,
- 61, 32, 49, 46, 48, 59, 10,  9,125, 10, 10,  9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,104, 44, 32,115, 44, 32,
-118, 44, 32,114,103, 98, 46,119, 41, 59, 10,125, 10, 10,118,111,105,100, 32,104,115,118, 95,116,111, 95,114,103, 98, 40,118,101,
- 99, 52, 32,104,115,118, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10,  9,102,108,111, 97,
-116, 32,105, 44, 32,102, 44, 32,112, 44, 32,113, 44, 32,116, 44, 32,104, 44, 32,115, 44, 32,118, 59, 10,  9,118,101, 99, 51, 32,
-114,103, 98, 59, 10, 10,  9,104, 32, 61, 32,104,115,118, 91, 48, 93, 59, 10,  9,115, 32, 61, 32,104,115,118, 91, 49, 93, 59, 10,
-  9,118, 32, 61, 32,104,115,118, 91, 50, 93, 59, 10, 10,  9,105,102, 40,115, 61, 61, 48, 46, 48, 41, 32,123, 10,  9,  9,114,103,
- 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,118, 44, 32,118, 41, 59, 10,  9,125, 10,  9,101,108,115,101, 32,123, 10,  9,  9,
-105,102, 40,104, 61, 61, 49, 46, 48, 41, 10,  9,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 10,  9,  9, 10,  9,  9,104, 32, 42, 61,
- 32, 54, 46, 48, 59, 10,  9,  9,105, 32, 61, 32,102,108,111,111,114, 40,104, 41, 59, 10,  9,  9,102, 32, 61, 32,104, 32, 45, 32,
-105, 59, 10,  9,  9,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,102, 44, 32,102, 44, 32,102, 41, 59, 10,  9,  9,112, 32, 61, 32,
-118, 42, 40, 49, 46, 48, 45,115, 41, 59, 10,  9,  9,113, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42,102, 41, 41, 59, 10,
-  9,  9,116, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42, 40, 49, 46, 48, 45,102, 41, 41, 41, 59, 10,  9,  9, 10,  9,  9,
-105,102, 32, 40,105, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,116, 44, 32,112,
- 41, 59, 10,  9,  9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 49, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101,
- 99, 51, 40,113, 44, 32,118, 44, 32,112, 41, 59, 10,  9,  9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 50, 46, 48,
- 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,118, 44, 32,116, 41, 59, 10,  9,  9,101,108,115,101, 32,105,102,
- 32, 40,105, 32, 61, 61, 32, 51, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,113, 44, 32,118, 41, 59,
- 10,  9,  9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 52, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51,

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list