Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-08 17:07:16 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-08 17:07:16 +0400
commit28ee0f92184af8ba6f44d08eda23ce5eb3815697 (patch)
tree6aada8d509c7470bd3bff6e52ba32e1fd54ef2ee /source/blender/gpu
parent19df3147f6920a2856bccb6e4601d57288119999 (diff)
Texturing: texture and 3d view draw type changes, these should only have any
effect for a render engine using new shading nodes. In short: * No longer uses images assigned to faces in the uv layer, rather the active image texture node is what is edited/painted/drawn. * Textured draw type now shows the active image texture node, with solid lighting. * Material draw mode shows GLSL shader of a simplified material node tree, using solid lighting. * Textures for modifiers, brushes, etc, are now available from a dropdown in the texture tab in the properties editor. These do not use new shading nodes yet. http://wiki.blender.org/index.php/Dev:2.6/Source/Render/TextureWorkflow
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/intern/gpu_draw.c49
-rw-r--r--source/blender/gpu/intern/gpu_material.c20
2 files changed, 39 insertions, 30 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 4c828264061..d08d7cf2ead 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -62,7 +62,7 @@
#include "BKE_material.h"
#include "BKE_node.h"
#include "BKE_object.h"
-
+#include "BKE_scene.h"
#include "BLI_threads.h"
#include "BLI_blenlib.h"
@@ -952,15 +952,17 @@ static struct GPUMaterialState {
} 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);
@@ -1001,6 +1003,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
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));
@@ -1032,7 +1035,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
/* 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));
@@ -1049,7 +1052,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
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 */
@@ -1062,7 +1065,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
}
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)
@@ -1223,6 +1226,7 @@ void GPU_end_object_materials(void)
int GPU_default_lights(void)
{
+ float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}, position[4];
int a, count = 0;
/* initialize */
@@ -1248,27 +1252,28 @@ int GPU_default_lights(void)
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
- glLightfv(GL_LIGHT0, GL_POSITION, U.light[0].vec);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, U.light[0].col);
- glLightfv(GL_LIGHT0, GL_SPECULAR, U.light[0].spec);
-
- glLightfv(GL_LIGHT1, GL_POSITION, U.light[1].vec);
- glLightfv(GL_LIGHT1, GL_DIFFUSE, U.light[1].col);
- glLightfv(GL_LIGHT1, GL_SPECULAR, U.light[1].spec);
-
- glLightfv(GL_LIGHT2, GL_POSITION, U.light[2].vec);
- glLightfv(GL_LIGHT2, GL_DIFFUSE, U.light[2].col);
- glLightfv(GL_LIGHT2, GL_SPECULAR, U.light[2].spec);
-
for(a=0; a<8; a++) {
if(a<3) {
if(U.light[a].flag) {
glEnable(GL_LIGHT0+a);
+
+ normalize_v3_v3(position, U.light[a].vec);
+ position[3]= 0.0f;
+
+ glLightfv(GL_LIGHT0+a, GL_POSITION, position);
+ glLightfv(GL_LIGHT0+a, GL_DIFFUSE, U.light[a].col);
+ glLightfv(GL_LIGHT0+a, GL_SPECULAR, U.light[a].spec);
+
count++;
}
- else
+ else {
glDisable(GL_LIGHT0+a);
-
+
+ glLightfv(GL_LIGHT0+a, GL_POSITION, zero);
+ glLightfv(GL_LIGHT0+a, GL_DIFFUSE, zero);
+ glLightfv(GL_LIGHT0+a, GL_SPECULAR, zero);
+ }
+
// clear stuff from other opengl lamp usage
glLightf(GL_LIGHT0+a, GL_SPOT_CUTOFF, 180.0);
glLightf(GL_LIGHT0+a, GL_CONSTANT_ATTENUATION, 1.0);
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 9344b4e680a..02ba2eba9e9 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -1415,29 +1415,33 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma)
if(((GPUMaterial*)link->data)->scene == scene)
return link->data;
+ /* allocate material */
mat = GPU_material_construct_begin(ma);
mat->scene = scene;
if(!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) {
+ /* create nodes */
ntreeGPUMaterialNodes(ma->nodetree, mat);
}
else {
+ /* create material */
outlink = GPU_blender_material(mat, ma);
GPU_material_output_link(mat, outlink);
}
- if(gpu_do_color_management(mat))
- if(mat->outlink)
- GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &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);
+ }
- /*if(!GPU_material_construct_end(mat)) {
- GPU_material_free(mat);
- mat= NULL;
- return 0;
- }*/
GPU_material_construct_end(mat);
+ /* note that even if building the shader fails in some way, we still keep
+ it to avoid trying to compile again and again, and simple do not use
+ the actual shader on drawing */
+
link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
link->data = mat;
BLI_addtail(&ma->gpumaterial, link);