[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27405] trunk/blender: Restored Environment maps

Matt Ebb matt at mke3.net
Thu Mar 11 08:43:49 CET 2010


Revision: 27405
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27405
Author:   broken
Date:     2010-03-11 08:43:49 +0100 (Thu, 11 Mar 2010)

Log Message:
-----------
Restored Environment maps

* Fixed up RNA and UI
* Brought back 'Save' and 'Clear' operators (in the little triangle menu in 
environment map properties)
* While I was at it, noticed that environment maps were only using 8bit 
colour, changed it to use full 32bit float instead for proper HDR colour etc,
so environment map reflections have the correct colour range
--> http://mke3.net/blender/devel/2.5/env_hdr.jpg

This fixes [#20904] Environment Map does not render; also missing panel

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_texture.py
    trunk/blender/source/blender/blenkernel/intern/texture.c
    trunk/blender/source/blender/editors/render/render_intern.h
    trunk/blender/source/blender/editors/render/render_ops.c
    trunk/blender/source/blender/editors/render/render_shading.c
    trunk/blender/source/blender/editors/space_file/writeimage.c
    trunk/blender/source/blender/makesrna/intern/rna_texture.c
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c
    trunk/blender/source/blender/render/intern/source/envmap.c

Modified: trunk/blender/release/scripts/ui/properties_texture.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_texture.py	2010-03-11 07:24:26 UTC (rev 27404)
+++ trunk/blender/release/scripts/ui/properties_texture.py	2010-03-11 07:43:49 UTC (rev 27405)
@@ -33,6 +33,17 @@
         layout.operator("material.mtex_paste", icon='PASTEDOWN')
 
 
+class TEXTURE_MT_envmap_specials(bpy.types.Menu):
+    bl_label = "Environment Map Specials"
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.operator("texture.envmap_save", icon='IMAGEFILE')
+        layout.operator("texture.envmap_clear", icon='FILE_REFRESH')
+        layout.operator("texture.envmap_clear_all", icon='FILE_REFRESH')
+
+
 def active_node_mat(mat):
     if mat:
         mat_node = mat.active_node_material
@@ -587,7 +598,20 @@
 
         layout.template_image(tex, "image", tex.image_user)
 
+def texture_filter_common(tex, layout):
 
+        layout.label(text="Filter:")
+        layout.prop(tex, "filter", text="")
+        if tex.mipmap and tex.filter in ('AREA', 'EWA', 'FELINE'):
+            if tex.filter == 'FELINE':
+                layout.prop(tex, "filter_probes", text="Probes")
+            else:
+                layout.prop(tex, "filter_eccentricity", text="Eccentricity")
+                
+        layout.prop(tex, "filter_size")
+        layout.prop(tex, "filter_size_minimum")
+        
+
 class TEXTURE_PT_image_sampling(TextureTypePanel):
     bl_label = "Image Sampling"
     bl_default_closed = True
@@ -619,23 +643,14 @@
         row.active = tex.normal_map
         row.prop(tex, "normal_space", text="")
 
-        col.label(text="Filter:")
-        col.prop(tex, "filter", text="")
-        col.prop(tex, "filter_size")
-        col.prop(tex, "filter_size_minimum")
         col.prop(tex, "mipmap")
-
         row = col.row()
         row.active = tex.mipmap
         row.prop(tex, "mipmap_gauss")
-
         col.prop(tex, "interpolation")
-        if tex.mipmap and tex.filter != 'DEFAULT':
-            if tex.filter == 'FELINE':
-                col.prop(tex, "filter_probes", text="Probes")
-            else:
-                col.prop(tex, "filter_eccentricity", text="Eccentricity")
 
+        texture_filter_common(tex, col)
+        
 
 class TEXTURE_PT_image_mapping(TextureTypePanel):
     bl_label = "Image Mapping"
@@ -714,11 +729,52 @@
     def draw(self, context):
         layout = self.layout
 
-        # tex = context.texture
+        tex = context.texture
+        env = tex.environment_map
+        
+        wide_ui = context.region.width > narrowui
+        
+        row = layout.row()
+        row.prop(env, "source", expand=True)
+        row.menu("TEXTURE_MT_envmap_specials", icon='DOWNARROW_HLT', text="")
+        
+        if env.source == 'IMAGE_FILE':
+            layout.template_ID(tex, "image", open="image.open")
+            layout.template_image(tex, "image", tex.image_user, compact=True)
+        else:
+            layout.prop(env, "mapping")
+            if env.mapping == 'PLANE':
+                layout.prop(env, "zoom")
+            layout.prop(env, "viewpoint_object")
+            
+            split = layout.split()
+            
+            col = split.column()
+            col.prop(env, "ignore_layers")
+            col.prop(env, "resolution")
+            col.prop(env, "depth")
 
-        layout.label(text="Nothing yet")
+            if wide_ui:
+                col = split.column(align=True)
+            
+            col.label(text="Clipping:")
+            col.prop(env, "clip_start", text="Start")
+            col.prop(env, "clip_end", text="End")
 
 
+class TEXTURE_PT_envmap_sampling(TextureTypePanel):
+    bl_label = "Environment Map Sampling"
+    bl_default_closed = True
+    tex_type = 'ENVIRONMENT_MAP'
+
+    def draw(self, context):
+        layout = self.layout
+
+        tex = context.texture
+        
+        texture_filter_common(tex, layout)
+        
+
 class TEXTURE_PT_musgrave(TextureTypePanel):
     bl_label = "Musgrave"
     tex_type = 'MUSGRAVE'
@@ -970,6 +1026,7 @@
 
 classes = [
     TEXTURE_MT_specials,
+    TEXTURE_MT_envmap_specials,
 
     TEXTURE_PT_context_texture,
     TEXTURE_PT_preview,
@@ -985,6 +1042,7 @@
     TEXTURE_PT_image_mapping,
     TEXTURE_PT_plugin,
     TEXTURE_PT_envmap,
+    TEXTURE_PT_envmap_sampling,
     TEXTURE_PT_musgrave,
     TEXTURE_PT_voronoi,
     TEXTURE_PT_distortednoise,

Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c	2010-03-11 07:24:26 UTC (rev 27404)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c	2010-03-11 07:43:49 UTC (rev 27405)
@@ -483,10 +483,10 @@
 	tex->vn_coltype = 0;
 
 	if (tex->env) {
-		tex->env->stype=ENV_STATIC;
+		tex->env->stype=ENV_ANIM;
 		tex->env->clipsta=0.1;
 		tex->env->clipend=100;
-		tex->env->cuberes=100;
+		tex->env->cuberes=600;
 		tex->env->depth=0;
 	}
 
@@ -1040,10 +1040,11 @@
 	
 	env= MEM_callocN(sizeof(EnvMap), "envmap");
 	env->type= ENV_CUBE;
-	env->stype= ENV_STATIC;
+	env->stype= ENV_ANIM;
 	env->clipsta= 0.1;
 	env->clipend= 100.0;
-	env->cuberes= 100;
+	env->cuberes= 600;
+	env->viewscale = 0.5;
 	
 	return env;
 } 

Modified: trunk/blender/source/blender/editors/render/render_intern.h
===================================================================
--- trunk/blender/source/blender/editors/render/render_intern.h	2010-03-11 07:24:26 UTC (rev 27404)
+++ trunk/blender/source/blender/editors/render/render_intern.h	2010-03-11 07:43:49 UTC (rev 27405)
@@ -55,6 +55,9 @@
 void SCENE_OT_render_layer_remove(struct wmOperatorType *ot);
 
 void TEXTURE_OT_slot_move(struct wmOperatorType *ot);
+void TEXTURE_OT_envmap_save(struct wmOperatorType *ot);
+void TEXTURE_OT_envmap_clear(struct wmOperatorType *ot);
+void TEXTURE_OT_envmap_clear_all(struct wmOperatorType *ot);
 
 /* render_internal.c */
 void RENDER_OT_view_show(struct wmOperatorType *ot);

Modified: trunk/blender/source/blender/editors/render/render_ops.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_ops.c	2010-03-11 07:24:26 UTC (rev 27404)
+++ trunk/blender/source/blender/editors/render/render_ops.c	2010-03-11 07:43:49 UTC (rev 27405)
@@ -67,6 +67,9 @@
 #endif
 	
 	WM_operatortype_append(TEXTURE_OT_slot_move);
+	WM_operatortype_append(TEXTURE_OT_envmap_save);
+	WM_operatortype_append(TEXTURE_OT_envmap_clear);
+	WM_operatortype_append(TEXTURE_OT_envmap_clear_all);
 
 	/* render_internal.c */
 	WM_operatortype_append(RENDER_OT_view_show);

Modified: trunk/blender/source/blender/editors/render/render_shading.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_shading.c	2010-03-11 07:24:26 UTC (rev 27404)
+++ trunk/blender/source/blender/editors/render/render_shading.c	2010-03-11 07:43:49 UTC (rev 27405)
@@ -37,21 +37,29 @@
 #include "DNA_object_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_space_types.h"
 #include "DNA_world_types.h"
 
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_font.h"
+#include "BKE_global.h"
 #include "BKE_icons.h"
+#include "BKE_image.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_material.h"
 #include "BKE_node.h"
+#include "BKE_report.h"
 #include "BKE_scene.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
 #include "BKE_world.h"
 
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_editVert.h"
 #include "BLI_listbase.h"
@@ -764,6 +772,196 @@
 
 
 
+/********************** environment map operators *********************/
+
+static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int imtype)
+{
+	ImBuf *ibuf;
+	int dx;
+	int retval;
+	
+	if(env->cube[1]==NULL) {
+		BKE_report(op->reports, RPT_ERROR, "There is no generated environment map available to save");
+		return OPERATOR_CANCELLED;
+	}
+	
+	dx= env->cube[1]->x;
+	
+	ibuf = IMB_allocImBuf(3*dx, 2*dx, 24, IB_rectfloat, 0);
+	
+	if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+		ibuf->profile = IB_PROFILE_LINEAR_RGB;
+	
+	IMB_rectcpy(ibuf, env->cube[0], 0, 0, 0, 0, dx, dx);
+	IMB_rectcpy(ibuf, env->cube[1], dx, 0, 0, 0, dx, dx);
+	IMB_rectcpy(ibuf, env->cube[2], 2*dx, 0, 0, 0, dx, dx);
+	IMB_rectcpy(ibuf, env->cube[3], 0, dx, 0, 0, dx, dx);
+	IMB_rectcpy(ibuf, env->cube[4], dx, dx, 0, 0, dx, dx);
+	IMB_rectcpy(ibuf, env->cube[5], 2*dx, dx, 0, 0, dx, dx);
+	
+	if (BKE_write_ibuf(scene, ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) 
+		retval = OPERATOR_FINISHED;
+	else {
+		BKE_reportf(op->reports, RPT_ERROR, "Error saving environment map to %s.", str);
+		retval = OPERATOR_CANCELLED;
+	}
+	IMB_freeImBuf(ibuf);
+	ibuf = NULL;
+
+	return retval;
+}
+
+static int envmap_save_exec(bContext *C, wmOperator *op)
+{
+	Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+	Scene *scene = CTX_data_scene(C);
+	//int imtype = RNA_enum_get(op->ptr, "file_type");
+	int imtype = scene->r.imtype;
+	char path[FILE_MAX];
+	
+	RNA_string_get(op->ptr, "path", path);
+	
+	if(scene->r.scemode & R_EXTENSION)  {
+		BKE_add_image_extension(path, imtype);
+	}
+	
+	WM_cursor_wait(1);
+	
+	save_envmap(op, scene, tex->env, path, imtype);
+	
+	WM_cursor_wait(0);
+	
+	WM_event_add_notifier(C, NC_TEXTURE, tex);
+	
+	return OPERATOR_FINISHED;
+}
+
+static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+	//Scene *scene= CTX_data_scene(C);
+	
+	if(!RNA_property_is_set(op->ptr, "relative_path"))
+		RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
+	
+	if(RNA_property_is_set(op->ptr, "path"))
+		return envmap_save_exec(C, op);
+
+	//RNA_enum_set(op->ptr, "file_type", scene->r.imtype);
+	
+	RNA_string_set(op->ptr, "path", G.sce);
+	WM_event_add_fileselect(C, op);
+	
+	return OPERATOR_RUNNING_MODAL;
+}
+
+static int envmap_save_poll(bContext *C)
+{
+	Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+
+	if (!tex) 
+		return 0;
+	if (!tex->env || !tex->env->ok)
+		return 0;
+	if (tex->env->type==ENV_PLANE) 
+		return 0;
+	if (tex->env->cube[1]==NULL)
+		return 0;
+	
+	return 1;
+}
+
+void TEXTURE_OT_envmap_save(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Save Environment Map";
+	ot->idname= "TEXTURE_OT_envmap_save";

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list