Revision: 48672
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48672
Author:   kupoman
Date:     2012-07-06 06:58:33 +0000 (Fri, 06 Jul 2012)
Log Message:
-----------
Converting custom shaders over to using a datablock, as well as creating a more 
general shader object that can be used for vertex, fragment, or geometry 
shaders. These new objects automatically detect uniforms from the shader source 
and exposes them in the UI. There is still a lot of work to do including fixing 
the saving and loading of the new custom shaders, fixing the automatic uniforms 
to work more than once, making the viewport update to shader changes, fixing up 
any BGE code that is affected by these changes, and continuing to clear out the 
old style of custom shader.

Modified Paths:
--------------
    branches/ge_harmony/release/scripts/startup/bl_ui/properties_material.py
    branches/ge_harmony/source/blender/CMakeLists.txt
    branches/ge_harmony/source/blender/blenkernel/BKE_main.h
    branches/ge_harmony/source/blender/blenkernel/BKE_material.h
    branches/ge_harmony/source/blender/blenkernel/CMakeLists.txt
    branches/ge_harmony/source/blender/blenkernel/intern/idcode.c
    branches/ge_harmony/source/blender/blenkernel/intern/library.c
    branches/ge_harmony/source/blender/blenkernel/intern/material.c
    branches/ge_harmony/source/blender/blenloader/intern/readfile.c
    branches/ge_harmony/source/blender/editors/interface/interface_templates.c
    branches/ge_harmony/source/blender/editors/render/render_intern.h
    branches/ge_harmony/source/blender/editors/render/render_ops.c
    branches/ge_harmony/source/blender/editors/render/render_shading.c
    branches/ge_harmony/source/blender/gpu/intern/gpu_extensions.c
    branches/ge_harmony/source/blender/gpu/intern/gpu_material.c
    branches/ge_harmony/source/blender/makesdna/DNA_ID.h
    branches/ge_harmony/source/blender/makesdna/DNA_material_types.h
    branches/ge_harmony/source/blender/makesdna/intern/makesdna.c
    branches/ge_harmony/source/blender/makesrna/RNA_access.h
    branches/ge_harmony/source/blender/makesrna/intern/CMakeLists.txt
    branches/ge_harmony/source/blender/makesrna/intern/makesrna.c
    branches/ge_harmony/source/blender/makesrna/intern/rna_ID.c
    branches/ge_harmony/source/blender/makesrna/intern/rna_internal.h
    branches/ge_harmony/source/blender/makesrna/intern/rna_material.c
    branches/ge_harmony/source/gameengine/Converter/BL_BlenderDataConversion.cpp

Added Paths:
-----------
    branches/ge_harmony/source/blender/blenkernel/BKE_shader.h
    branches/ge_harmony/source/blender/blenkernel/intern/shader.c
    branches/ge_harmony/source/blender/makesdna/DNA_shader_types.h
    branches/ge_harmony/source/blender/makesrna/intern/rna_shader.c

Modified: 
branches/ge_harmony/release/scripts/startup/bl_ui/properties_material.py
===================================================================
--- branches/ge_harmony/release/scripts/startup/bl_ui/properties_material.py    
2012-07-06 06:24:02 UTC (rev 48671)
+++ branches/ge_harmony/release/scripts/startup/bl_ui/properties_material.py    
2012-07-06 06:58:33 UTC (rev 48672)
@@ -627,38 +627,44 @@
                
         mat = active_node_mat(context.material)
 
-        col.prop(mat, "use_external_sources")
-
-        if mat.use_external_sources:
-            col.prop(mat, "vertex_shader")
-            col.prop(mat, "geometry_shader")
-            col.prop(mat, "fragment_shader")
-        else:
-            col.prop(mat, "vertex_text")
-            col.prop(mat, "geometry_text")
-            col.prop(mat, "fragment_text")
-
-        col.prop(mat, "geometry_input")
-        col.prop(mat, "geometry_output")
-
-        col.operator("material.force_update", text="Reload Shaders")
-               
-        col.label(text="Custom Uniforms:")
         row = layout.row()
         col = row.column()
-        col.template_list(mat, "uniforms", mat, "active_uniform_index")
+        col.template_list(mat, "shaders", mat, "active_shader_index", rows=2)
+        col.template_ID(mat, "active_shader", new="shader.new")
         col = row.column(align=True)
-        col.operator("material.uniform_add", icon='ZOOMIN', text="")
-        col.operator("material.uniform_remove", icon='ZOOMOUT', text="").index 
= mat.active_uniform_index
+        col.operator("material.shader_add", icon='ZOOMIN', text="")
+        col.operator("material.shader_remove", icon='ZOOMOUT', text="").index 
= mat.active_shader_index
+
+        col = layout.column()
+        
+        shader = mat.active_shader
+        if shader:
+            col.operator("material.force_update", text="Reload Shader")
+            
+            row = col.row()
+            row.prop(shader, "type", expand=True)
+            
+            col.label("Source:")
+            row = col.row()
+            row.prop(shader, "shader_location", expand=True)
+            if shader.shader_location == "INTERNAL":
+                col.prop(shader, "source_text", text="")
+            elif shader.shader_location == "EXTERNAL":
+                col.prop(shader, "source_path", text="")
                
-        lay = mat.active_uniform
-        if lay:
-            row = layout.row()
-            row.prop(lay, "name")
-            row.prop(lay, "type", text="")
-            if hasattr(lay, "value"):
-                row = layout.row()
-                row.prop(lay, "value")
+            col.label("Uniforms:")
+            
+            for uniform in shader.uniforms:
+                print(uniform, uniform.type, uniform.value)
+                if hasattr(uniform, "value"):
+                    if uniform.type in ("VEC2", "VEC3", "VEC4", "IVEC2", 
"IVEC3", "IVEC4"):
+                        col.label(uniform.name + ":")
+                        row = col.row()
+                        row.prop(uniform, "value", text="")
+                    else:
+                        row = col.row()
+                        row.label(uniform.name + ":")
+                        row.prop(uniform, "value", text="")
 
 class MATERIAL_PT_game_settings(MaterialButtonsPanel, Panel):
     bl_label = "Game Settings"

Modified: branches/ge_harmony/source/blender/CMakeLists.txt
===================================================================
--- branches/ge_harmony/source/blender/CMakeLists.txt   2012-07-06 06:24:02 UTC 
(rev 48671)
+++ branches/ge_harmony/source/blender/CMakeLists.txt   2012-07-06 06:58:33 UTC 
(rev 48672)
@@ -71,6 +71,7 @@
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sdna_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sensor_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sequence_types.h
+       ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_shader_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_smoke_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sound_types.h
        ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_space_types.h

Modified: branches/ge_harmony/source/blender/blenkernel/BKE_main.h
===================================================================
--- branches/ge_harmony/source/blender/blenkernel/BKE_main.h    2012-07-06 
06:24:02 UTC (rev 48671)
+++ branches/ge_harmony/source/blender/blenkernel/BKE_main.h    2012-07-06 
06:58:33 UTC (rev 48672)
@@ -87,6 +87,7 @@
        ListBase gpencil;
        ListBase movieclip;
        ListBase mask;
+       ListBase shader;
 
        char id_tag_update[256];
 } Main;

Modified: branches/ge_harmony/source/blender/blenkernel/BKE_material.h
===================================================================
--- branches/ge_harmony/source/blender/blenkernel/BKE_material.h        
2012-07-06 06:24:02 UTC (rev 48671)
+++ branches/ge_harmony/source/blender/blenkernel/BKE_material.h        
2012-07-06 06:58:33 UTC (rev 48672)
@@ -53,7 +53,6 @@
 void init_material(struct Material *ma);
 struct Material *BKE_material_add(const char *name);
 struct Material *BKE_material_copy(struct Material *ma);
-void init_custom_uniform(struct CustomUniform *cu);
 struct CustomUniform *copy_custom_uniform(struct CustomUniform *cu);
 struct Material *localize_material(struct Material *ma);
 struct Material *give_node_material(struct Material *ma); /* returns node 
material or self */

Added: branches/ge_harmony/source/blender/blenkernel/BKE_shader.h
===================================================================
--- branches/ge_harmony/source/blender/blenkernel/BKE_shader.h                  
        (rev 0)
+++ branches/ge_harmony/source/blender/blenkernel/BKE_shader.h  2012-07-06 
06:58:33 UTC (rev 48672)
@@ -0,0 +1,49 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BKE_SHADER_H__
+#define __BKE_SHADER_H__
+
+/** \file BKE_shader.h
+ *  \ingroup bke
+ *  \brief General operations, lookup, etc. for shaders.
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void init_shader(struct Shader *sh);
+
+struct Shader *BKE_shader_add(const char *name);
+struct Shader *BKE_shader_copy(struct Shader *sh);
+
+void BKE_shader_read_source(struct Shader *sh);
+#ifdef __cplusplus
+}
+#endif
+
+#endif


Property changes on: branches/ge_harmony/source/blender/blenkernel/BKE_shader.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: branches/ge_harmony/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- branches/ge_harmony/source/blender/blenkernel/CMakeLists.txt        
2012-07-06 06:24:02 UTC (rev 48671)
+++ branches/ge_harmony/source/blender/blenkernel/CMakeLists.txt        
2012-07-06 06:58:33 UTC (rev 48672)
@@ -128,6 +128,7 @@
        intern/seqcache.c
        intern/seqeffects.c
        intern/sequencer.c
+    intern/shader.c
        intern/shrinkwrap.c
        intern/sketch.c
        intern/smoke.c
@@ -212,6 +213,7 @@
        BKE_screen.h
        BKE_script.h
        BKE_sequencer.h
+    BKE_shader.h
        BKE_shrinkwrap.h
        BKE_sketch.h
        BKE_smoke.h

Modified: branches/ge_harmony/source/blender/blenkernel/intern/idcode.c
===================================================================
--- branches/ge_harmony/source/blender/blenkernel/intern/idcode.c       
2012-07-06 06:24:02 UTC (rev 48671)
+++ branches/ge_harmony/source/blender/blenkernel/intern/idcode.c       
2012-07-06 06:58:33 UTC (rev 48672)
@@ -80,6 +80,7 @@
        { ID_WM,        "WindowManager", "window_managers", 0},
        { ID_MC,        "MovieClip", "movieclips",  IDTYPE_FLAGS_ISLINKABLE},
        { ID_MSK,        "Mask",     "masks",       IDTYPE_FLAGS_ISLINKABLE},
+       { ID_SH,                "Shader",       "shaders",              0},
 };
 static int nidtypes = sizeof(idtypes) / sizeof(idtypes[0]);
 

Modified: branches/ge_harmony/source/blender/blenkernel/intern/library.c
===================================================================
--- branches/ge_harmony/source/blender/blenkernel/intern/library.c      
2012-07-06 06:24:02 UTC (rev 48671)
+++ branches/ge_harmony/source/blender/blenkernel/intern/library.c      
2012-07-06 06:58:33 UTC (rev 48672)
@@ -490,6 +490,8 @@
                        return &(mainlib->movieclip);
                case ID_MSK:
                        return &(mainlib->mask);
+               case ID_SH:
+                       return &(mainlib->shader);
        }
        return NULL;
 }
@@ -688,6 +690,9 @@
                case ID_MSK:
                        id = MEM_callocN(sizeof(Mask), "Mask");
                        break;
+               case ID_SH:
+                       id = MEM_callocN(sizeof(Shader), "Shader");
+                       break;
        }
        return id;
 }

Modified: branches/ge_harmony/source/blender/blenkernel/intern/material.c
===================================================================
--- branches/ge_harmony/source/blender/blenkernel/intern/material.c     
2012-07-06 06:24:02 UTC (rev 48671)
+++ branches/ge_harmony/source/blender/blenkernel/intern/material.c     
2012-07-06 06:58:33 UTC (rev 48672)
@@ -200,18 +200,10 @@
        ma->shade_flag = MA_APPROX_OCCLUSION;
        ma->preview = NULL;
 
-       ma->csi.flag= 0;
-       ma->csi.geom_in= MA_CS_GEOM_IN_TRIS;
-       ma->csi.geom_out= MA_CS_GEOM_OUT_TRIANGLE_STRIP;
-       ma->csi.sources = NULL;
+       ma->custom_shaders.first = NULL;
+       ma->custom_shaders.last = NULL;
 }
 
-void init_custom_uniform(CustomUniform *cu)
-{
-       strcpy(&cu->name[0], "Uniform");
-       cu->type = MA_UNF_FLOAT;
-}
-
 CustomUniform *copy_custom_uniform(CustomUniform *cu)
 {
        CustomUniform *copy = MEM_callocN(sizeof(CustomUniform), 
"copycustomuniform");

Added: branches/ge_harmony/source/blender/blenkernel/intern/shader.c
===================================================================
--- branches/ge_harmony/source/blender/blenkernel/intern/shader.c               
                (rev 0)

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to