Revision: 40961
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40961
Author:   blendix
Date:     2011-10-12 15:48:26 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
Cycles: don't use glsl in textured draw mode, to keep things simpler and faster
there for now. Also add viewport color setting for materials for solid draw 
mode.

Modified Paths:
--------------
    branches/cycles/intern/cycles/blender/addon/ui.py
    branches/cycles/source/blender/editors/space_view3d/view3d_draw.c
    branches/cycles/source/blender/gpu/GPU_material.h
    branches/cycles/source/blender/gpu/intern/gpu_draw.c
    branches/cycles/source/blender/gpu/intern/gpu_material.c
    branches/cycles/source/blender/nodes/shader/node_shader_tree.c
    branches/cycles/source/blender/nodes/shader/node_shader_util.c
    branches/cycles/source/blender/nodes/shader/node_shader_util.h
    branches/cycles/source/gameengine/Ketsji/BL_BlenderShader.cpp
    
branches/cycles/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

Modified: branches/cycles/intern/cycles/blender/addon/ui.py
===================================================================
--- branches/cycles/intern/cycles/blender/addon/ui.py   2011-10-12 15:45:52 UTC 
(rev 40960)
+++ branches/cycles/intern/cycles/blender/addon/ui.py   2011-10-12 15:48:26 UTC 
(rev 40961)
@@ -463,8 +463,7 @@
 
     @classmethod
     def poll(cls, context):
-        return False
-        #return context.material and CyclesButtonsPanel.poll(context)
+        return context.material and CyclesButtonsPanel.poll(context)
 
     def draw(self, context):
         layout = self.layout
@@ -472,6 +471,9 @@
         mat = context.material
         cmat = mat.cycles
 
+        layout.prop(mat, "diffuse_color", text="Viewport Color")
+
+        """
         split = layout.split()
     
         col = split.column()
@@ -479,6 +481,7 @@
 
         col = split.column()
         col.prop(cmat, "homogeneous_volume")
+        """
 
 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
     bl_label = ""

Modified: branches/cycles/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- branches/cycles/source/blender/editors/space_view3d/view3d_draw.c   
2011-10-12 15:45:52 UTC (rev 40960)
+++ branches/cycles/source/blender/editors/space_view3d/view3d_draw.c   
2011-10-12 15:48:26 UTC (rev 40961)
@@ -2156,8 +2156,15 @@
        if(ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) || ((v3d->drawtype == 
OB_SOLID) && (v3d->flag2 & V3D_SOLID_TEX))) {
                mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
 
-               if(v3d->drawtype == OB_MATERIAL || scene->gm.matmode == 
GAME_MAT_GLSL)
-                       mask |= CD_MASK_ORCO;
+               if(scene_use_new_shading_nodes(scene)) {
+                       /* todo: use orco in textured draw mode */
+                       if(v3d->drawtype == OB_MATERIAL)
+                               mask |= CD_MASK_ORCO;
+               }
+               else {
+                       if(scene->gm.matmode == GAME_MAT_GLSL)
+                               mask |= CD_MASK_ORCO;
+               }
        }
 
        return mask;

Modified: branches/cycles/source/blender/gpu/GPU_material.h
===================================================================
--- branches/cycles/source/blender/gpu/GPU_material.h   2011-10-12 15:45:52 UTC 
(rev 40960)
+++ branches/cycles/source/blender/gpu/GPU_material.h   2011-10-12 15:48:26 UTC 
(rev 40961)
@@ -121,13 +121,12 @@
 int GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, 
GPUNodeStack *out, ...);
 
 void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link);
-int GPU_material_drawtype(GPUMaterial *material);
 void GPU_material_enable_alpha(GPUMaterial *material);
 GPUBlendMode GPU_material_alpha_blend(GPUMaterial *material, float obcol[4]);
 
 /* High level functions to create and use GPU materials */
 
-GPUMaterial *GPU_material_from_blender(struct Scene *scene, struct Material 
*ma, int drawtype);
+GPUMaterial *GPU_material_from_blender(struct Scene *scene, struct Material 
*ma);
 void GPU_material_free(struct Material *ma);
 
 void GPU_materials_free(void);

Modified: branches/cycles/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- branches/cycles/source/blender/gpu/intern/gpu_draw.c        2011-10-12 
15:45:52 UTC (rev 40960)
+++ branches/cycles/source/blender/gpu/intern/gpu_draw.c        2011-10-12 
15:48:26 UTC (rev 40961)
@@ -64,8 +64,8 @@
 #include "BKE_material.h"
 #include "BKE_node.h"
 #include "BKE_object.h"
+#include "BKE_scene.h"
 
-
 #include "BLI_threads.h"
 #include "BLI_blenlib.h"
 
@@ -941,7 +941,6 @@
        Material *gboundmat;
        Object *gob;
        Scene *gscene;
-       int gdrawtype;
        int glay;
        float (*gviewmat)[4];
        float (*gviewinv)[4];
@@ -955,15 +954,17 @@
 } GMS = {NULL};
 
 /* fixed function material, alpha handed by caller */
-static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material 
*bmat, const int gamma, const Object *ob)
+static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material 
*bmat, const int gamma, const Object *ob, const int new_shading_nodes)
 {
-       if (bmat->mode & MA_SHLESS) {
+       if(new_shading_nodes || bmat->mode & MA_SHLESS) {
                copy_v3_v3(smat->diff, &bmat->r);
                smat->diff[3]= 1.0;
 
-               if(gamma) {
+               if(gamma)
                        linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
-               }       
+
+               zero_v4(smat->spec);
+               smat->hard= 0;
        }
        else {
                mul_v3_v3fl(smat->diff, &bmat->r, bmat->ref + bmat->emit);
@@ -1004,6 +1005,7 @@
        GPUBlendMode alphablend;
        int a;
        int gamma = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+       int new_shading_nodes = scene_use_new_shading_nodes(scene);
        
        /* initialize state */
        memset(&GMS, 0, sizeof(GMS));
@@ -1013,7 +1015,6 @@
 
        GMS.gob = ob;
        GMS.gscene = scene;
-       GMS.gdrawtype = v3d->drawtype;
        GMS.totmat= ob->totcol+1; /* materials start from 1, default material 
is 0 */
        GMS.glay= v3d->lay;
        GMS.gviewmat= rv3d->viewmat;
@@ -1036,14 +1037,14 @@
 
        /* no materials assigned? */
        if(ob->totcol==0) {
-               gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob);
+               gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob, 
new_shading_nodes);
 
                /* do material 1 too, for displists! */
                memcpy(&GMS.matbuf[1], &GMS.matbuf[0], 
sizeof(GPUMaterialFixed));
 
                if(glsl) {
                        GMS.gmatbuf[0]= &defmaterial;
-                       GPU_material_from_blender(GMS.gscene, &defmaterial, 
GMS.gdrawtype);
+                       GPU_material_from_blender(GMS.gscene, &defmaterial);
                }
 
                GMS.alphablend[0]= GPU_BLEND_SOLID;
@@ -1053,11 +1054,11 @@
        for(a=1; a<=ob->totcol; a++) {
                /* find a suitable material */
                ma= give_current_material(ob, a);
-               if(!glsl) ma= gpu_active_node_material(ma);
+               if(!glsl && !new_shading_nodes) ma= 
gpu_active_node_material(ma);
                if(ma==NULL) ma= &defmaterial;
 
                /* create glsl material if requested */
-               gpumat = (glsl)? GPU_material_from_blender(GMS.gscene, ma, 
GMS.gdrawtype): NULL;
+               gpumat = (glsl)? GPU_material_from_blender(GMS.gscene, ma): 
NULL;
 
                if(gpumat) {
                        /* do glsl only if creating it succeed, else fallback */
@@ -1066,7 +1067,7 @@
                }
                else {
                        /* fixed function opengl materials */
-                       gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob);
+                       gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob, 
new_shading_nodes);
 
                        alphablend = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: 
GPU_BLEND_ALPHA;
                        if(do_alpha_pass && GMS.alphapass)
@@ -1127,7 +1128,7 @@
        /* unbind glsl material */
        if(GMS.gboundmat) {
                if(GMS.alphapass) glDepthMask(0);
-               GPU_material_unbind(GPU_material_from_blender(GMS.gscene, 
GMS.gboundmat, GMS.gdrawtype));
+               GPU_material_unbind(GPU_material_from_blender(GMS.gscene, 
GMS.gboundmat));
                GMS.gboundmat= NULL;
        }
 
@@ -1145,7 +1146,7 @@
                        /* bind glsl material and get attributes */
                        Material *mat = GMS.gmatbuf[nr];
 
-                       gpumat = GPU_material_from_blender(GMS.gscene, mat, 
GMS.gdrawtype);
+                       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));
                        GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, 
GMS.gviewmat, GMS.gviewinv, GMS.gob->col);
@@ -1193,7 +1194,7 @@
 
        if(GMS.gboundmat) {
                if(GMS.alphapass) glDepthMask(0);
-               GPU_material_unbind(GPU_material_from_blender(GMS.gscene, 
GMS.gboundmat, GMS.gdrawtype));
+               GPU_material_unbind(GPU_material_from_blender(GMS.gscene, 
GMS.gboundmat));
                GMS.gboundmat= NULL;
        }
 

Modified: branches/cycles/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/cycles/source/blender/gpu/intern/gpu_material.c    2011-10-12 
15:45:52 UTC (rev 40960)
+++ branches/cycles/source/blender/gpu/intern/gpu_material.c    2011-10-12 
15:48:26 UTC (rev 40961)
@@ -80,7 +80,6 @@
 struct GPUMaterial {
        Scene *scene;
        Material *ma;
-       int drawtype;
 
        /* for creating the material */
        ListBase nodes;
@@ -354,11 +353,6 @@
                material->outlink= link;
 }
 
-int GPU_material_drawtype(GPUMaterial *material)
-{
-       return material->drawtype;
-}
-
 void GPU_material_enable_alpha(GPUMaterial *material)
 {
        material->alpha= 1;
@@ -1413,27 +1407,19 @@
        return shr.combined;
 }
 
-GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma, int 
drawtype)
+GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma)
 {
        GPUMaterial *mat;
        GPUNodeLink *outlink;
        LinkData *link;
 
-       /* find an existing glsl shader that is already compiled */
-       for(link=ma->gpumaterial.first; link; link=link->next) {
-               mat= (GPUMaterial*)link->data;
-               if(mat->scene == scene && mat->drawtype == drawtype)
+       for(link=ma->gpumaterial.first; link; link=link->next)
+               if(((GPUMaterial*)link->data)->scene == scene)
                        return link->data;
-       }
 
-       /* in texture draw mode, we need an active texture node */
-       if(drawtype == OB_TEXTURE && (!ma->use_nodes || 
!nodeGetActiveTexture(ma->nodetree)))
-               return NULL;
-
        /* allocate material */
        mat = GPU_material_construct_begin(ma);
        mat->scene = scene;
-       mat->drawtype = drawtype;
 
        if(!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && 
ma->use_nodes) {
                /* create nodes */
@@ -1443,12 +1429,15 @@
                /* create material */
                outlink = GPU_blender_material(mat, ma);
                GPU_material_output_link(mat, outlink);
+       }
 
+       if(!scene_use_new_shading_nodes(scene)) {
                if(gpu_do_color_management(mat))
                        if(mat->outlink)
                                GPU_link(mat, "linearrgb_to_srgb", 
mat->outlink, &mat->outlink);
        }
 
+
        GPU_material_construct_end(mat);
 
        /* note that even if building the shader fails in some way, we still 
keep
@@ -1730,7 +1719,7 @@
        if(!GPU_glsl_support())
                return NULL;
 
-       mat = GPU_material_from_blender(scene, ma, OB_TEXTURE);
+       mat = GPU_material_from_blender(scene, ma);
        pass = (mat)? mat->pass: NULL;
 
        if(pass && pass->fragmentcode && pass->vertexcode) {

Modified: branches/cycles/source/blender/nodes/shader/node_shader_tree.c
===================================================================
--- branches/cycles/source/blender/nodes/shader/node_shader_tree.c      
2011-10-12 15:45:52 UTC (rev 40960)
+++ branches/cycles/source/blender/nodes/shader/node_shader_tree.c      
2011-10-12 15:48:26 UTC (rev 40961)
@@ -123,14 +123,10 @@
 void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat)
 {
        bNodeTreeExec *exec;
-       bNode *tex_node = NULL;
 
-       if(GPU_material_drawtype(mat) == OB_TEXTURE)
-               tex_node= nodeGetActiveTexture(ntree);
-
        exec = ntreeShaderBeginExecTree(ntree, 1);
 
-       ntreeExecGPUNodes(exec, tex_node, mat, 1);
+       ntreeExecGPUNodes(exec, mat, 1);
 
        ntreeShaderEndExecTree(exec, 1);
 }

Modified: branches/cycles/source/blender/nodes/shader/node_shader_util.c

@@ 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