[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45259] branches/ge_candy: Added 'mipmap' option to material for viewport and GE.

Matthew Smith mjdietel at gmail.com
Thu Mar 29 14:16:05 CEST 2012


Revision: 45259
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45259
Author:   mokazon
Date:     2012-03-29 12:15:48 +0000 (Thu, 29 Mar 2012)
Log Message:
-----------
Added 'mipmap' option to material for viewport and GE.

Problems: 
* You have to do something like reloading texture for the mipmapping option to take effect
*Mipmapping option seems to affect all materials with the same texture

Modified Paths:
--------------
    branches/ge_candy/release/scripts/startup/bl_ui/properties_material.py
    branches/ge_candy/source/blender/gpu/intern/gpu_draw.c
    branches/ge_candy/source/blender/makesdna/DNA_material_types.h
    branches/ge_candy/source/blender/makesrna/intern/rna_material.c

Modified: branches/ge_candy/release/scripts/startup/bl_ui/properties_material.py
===================================================================
--- branches/ge_candy/release/scripts/startup/bl_ui/properties_material.py	2012-03-29 11:31:44 UTC (rev 45258)
+++ branches/ge_candy/release/scripts/startup/bl_ui/properties_material.py	2012-03-29 12:15:48 UTC (rev 45259)
@@ -631,6 +631,7 @@
         row.prop(game, "use_backface_culling")
         row.prop(game, "invisible")
         row.prop(game, "text")
+        row.prop(game, "mipmap")
 
         row = layout.row()
         row.label(text="Alpha Blend:")

Modified: branches/ge_candy/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- branches/ge_candy/source/blender/gpu/intern/gpu_draw.c	2012-03-29 11:31:44 UTC (rev 45258)
+++ branches/ge_candy/source/blender/gpu/intern/gpu_draw.c	2012-03-29 12:15:48 UTC (rev 45259)
@@ -72,6 +72,7 @@
 
 #include "smoke_API.h"
 
+
 extern Material defmaterial; /* from material.c */
 
 /* These are some obscure rendering functions shared between the
@@ -619,16 +620,22 @@
 	/* create image */
 	glGenTextures(1, (GLuint *)bind);
 	glBindTexture( GL_TEXTURE_2D, *bind);
-
 	if (!(gpu_get_mipmap() && mipmap)) {
 		if(use_high_bit_depth)
 			glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA16,  rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
 		else
 			glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA,  rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
+		if (mipmap == 0)
+		
+			
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+		else
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
 	}
 	else {
+		
 		if(use_high_bit_depth)
 			gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect);
 		else
@@ -727,7 +734,6 @@
 	
 	if(!GTS.domipmap)
 		return;
-
 	if(mipmap) {
 		for(ima=G.main->image.first; ima; ima=ima->id.next) {
 			if(ima->bindcode) {
@@ -1227,13 +1233,16 @@
 		alphablend = GMS.alphablend[nr];
 
 		if(gattribs && GMS.gmatbuf[nr]) {
+			int mipmap = 0;
 			/* bind glsl material and get attributes */
 			Material *mat = GMS.gmatbuf[nr];
 			float auto_bump_scale;
 
 			gpumat = GPU_material_from_blender(GMS.gscene, mat);
 			GPU_material_vertex_attributes(gpumat, gattribs);
-			GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT));
+			if(!(GMS.gob->mode & OB_MODE_TEXTURE_PAINT) && (mat->game.flag & GEMAT_MIPMAP))
+				mipmap = 1;
+			GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, mipmap);
 
 			auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
 			GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, auto_bump_scale);

Modified: branches/ge_candy/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/ge_candy/source/blender/makesdna/DNA_material_types.h	2012-03-29 11:31:44 UTC (rev 45258)
+++ branches/ge_candy/source/blender/makesdna/DNA_material_types.h	2012-03-29 12:15:48 UTC (rev 45259)
@@ -188,17 +188,18 @@
 #define GEMAT_BACKCULL 		16 /* KX_BACKCULL */
 #define GEMAT_SHADED		32 /* KX_LIGHT */
 #define GEMAT_TEXT		64 /* RAS_RENDER_3DPOLYGON_TEXT */
-#define	GEMAT_NOPHYSICS		128
-#define GEMAT_INVISIBLE 	256
+#define GEMAT_MIPMAP		128
+#define	GEMAT_NOPHYSICS		256
+#define GEMAT_INVISIBLE 	512
 
 // Face Orientation Options - face_orientation
 #define GEMAT_NORMAL		0
-#define GEMAT_HALO		512  /* BILLBOARD_SCREENALIGNED  */
-#define GEMAT_BILLBOARD		1024 /* BILLBOARD_AXISALIGNED */
-#define GEMAT_SHADOW		2048 /* SHADOW */
+#define GEMAT_HALO		1024  /* BILLBOARD_SCREENALIGNED  */
+#define GEMAT_BILLBOARD		2048 /* BILLBOARD_AXISALIGNED */
+#define GEMAT_SHADOW		4096 /* SHADOW */
 
 // Use Textures - not defined directly in the UI
-#define GEMAT_TEX		4096 /* KX_TEX */
+#define GEMAT_TEX		8192 /* KX_TEX */
 
 
 /* **************** MATERIAL ********************* */

Modified: branches/ge_candy/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/ge_candy/source/blender/makesrna/intern/rna_material.c	2012-03-29 11:31:44 UTC (rev 45258)
+++ branches/ge_candy/source/blender/makesrna/intern/rna_material.c	2012-03-29 12:15:48 UTC (rev 45259)
@@ -787,6 +787,11 @@
 	RNA_def_property_ui_text(prop, "Text", "Use material as text in Game Engine ");
 	RNA_def_property_update(prop, 0, "rna_Material_draw_update");
 
+	prop = RNA_def_property(srna, "mipmap", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_MIPMAP); /* use bitflags */
+	RNA_def_property_ui_text(prop, "MipMaps", "Use mipmapping on this material ");
+	RNA_def_property_update(prop, 0, "rna_Material_draw_update");
+
 	prop = RNA_def_property(srna, "invisible", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_INVISIBLE); /* use bitflags */
 	RNA_def_property_ui_text(prop, "Invisible", "Make face invisible");




More information about the Bf-blender-cvs mailing list