2011-02-23 10:52:22 +00:00
|
|
|
/*
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2006 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): Brecht Van Lommel.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:25:53 +00:00
|
|
|
/** \file blender/gpu/intern/gpu_material.c
|
|
|
|
* \ingroup gpu
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "GL/glew.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_math.h"
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "BKE_anim.h"
|
|
|
|
#include "BKE_colortools.h"
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
#include "BKE_global.h"
|
2011-01-29 16:13:15 +00:00
|
|
|
#include "BKE_image.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_node.h"
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
#include "BKE_texture.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2011-01-30 16:24:23 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
#include "GPU_extensions.h"
|
|
|
|
#include "GPU_material.h"
|
|
|
|
|
|
|
|
#include "gpu_codegen.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* Structs */
|
|
|
|
|
|
|
|
typedef enum DynMatProperty {
|
|
|
|
DYN_LAMP_CO = 1,
|
|
|
|
DYN_LAMP_VEC = 2,
|
|
|
|
DYN_LAMP_IMAT = 4,
|
|
|
|
DYN_LAMP_PERSMAT = 8,
|
|
|
|
} DynMatProperty;
|
|
|
|
|
|
|
|
struct GPUMaterial {
|
|
|
|
Scene *scene;
|
|
|
|
Material *ma;
|
|
|
|
|
|
|
|
/* for creating the material */
|
|
|
|
ListBase nodes;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
|
|
|
|
/* for binding the material */
|
|
|
|
GPUPass *pass;
|
|
|
|
GPUVertexAttribs attribs;
|
|
|
|
int bound;
|
|
|
|
int builtins;
|
|
|
|
int alpha, obcolalpha;
|
|
|
|
int dynproperty;
|
|
|
|
|
|
|
|
/* for passing uniforms */
|
|
|
|
int viewmatloc, invviewmatloc;
|
|
|
|
int obmatloc, invobmatloc;
|
|
|
|
int obcolloc;
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
ListBase lamps;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GPULamp {
|
|
|
|
Scene *scene;
|
|
|
|
Object *ob;
|
|
|
|
Object *par;
|
|
|
|
Lamp *la;
|
|
|
|
|
2010-07-27 11:10:34 +00:00
|
|
|
int type, mode, lay, hide;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
float dynenergy, dyncol[3];
|
|
|
|
float energy, col[3];
|
|
|
|
|
|
|
|
float co[3], vec[3];
|
|
|
|
float dynco[3], dynvec[3];
|
|
|
|
float obmat[4][4];
|
|
|
|
float imat[4][4];
|
|
|
|
float dynimat[4][4];
|
|
|
|
|
|
|
|
float spotsi, spotbl, k;
|
|
|
|
float dist, att1, att2;
|
|
|
|
|
|
|
|
float bias, d, clipend;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
int falloff_type;
|
|
|
|
struct CurveMapping *curfalloff;
|
|
|
|
|
|
|
|
float winmat[4][4];
|
|
|
|
float viewmat[4][4];
|
|
|
|
float persmat[4][4];
|
|
|
|
float dynpersmat[4][4];
|
|
|
|
|
|
|
|
GPUFrameBuffer *fb;
|
|
|
|
GPUTexture *tex;
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
ListBase materials;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Functions */
|
|
|
|
|
|
|
|
static GPUMaterial *GPU_material_construct_begin(Material *ma)
|
|
|
|
{
|
|
|
|
GPUMaterial *material = MEM_callocN(sizeof(GPUMaterial), "GPUMaterial");
|
|
|
|
|
|
|
|
material->ma= ma;
|
|
|
|
|
|
|
|
return material;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gpu_material_set_attrib_id(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
GPUVertexAttribs *attribs;
|
|
|
|
GPUShader *shader;
|
|
|
|
GPUPass *pass;
|
|
|
|
char name[32];
|
|
|
|
int a, b;
|
|
|
|
|
|
|
|
attribs= &material->attribs;
|
|
|
|
pass= material->pass;
|
|
|
|
if(!pass) {
|
|
|
|
attribs->totlayer = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
shader= GPU_pass_shader(pass);
|
|
|
|
if(!shader) {
|
|
|
|
attribs->totlayer = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert from attribute number to the actual id assigned by opengl,
|
|
|
|
* in case the attrib does not get a valid index back, it was probably
|
|
|
|
* removed by the glsl compiler by dead code elimination */
|
|
|
|
|
|
|
|
for(a=0, b=0; a<attribs->totlayer; a++) {
|
|
|
|
sprintf(name, "att%d", attribs->layer[a].glindex);
|
|
|
|
attribs->layer[a].glindex = GPU_shader_get_attribute(shader, name);
|
|
|
|
|
|
|
|
if(attribs->layer[a].glindex >= 0) {
|
|
|
|
attribs->layer[b] = attribs->layer[a];
|
|
|
|
b++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
attribs->totlayer = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int GPU_material_construct_end(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
if (material->outlink) {
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
GPUShader *shader;
|
|
|
|
|
|
|
|
outlink = material->outlink;
|
|
|
|
material->pass = GPU_generate_pass(&material->nodes, outlink,
|
|
|
|
&material->attribs, &material->builtins, material->ma->id.name);
|
|
|
|
|
|
|
|
if(!material->pass)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
gpu_material_set_attrib_id(material);
|
|
|
|
|
|
|
|
shader = GPU_pass_shader(material->pass);
|
|
|
|
|
|
|
|
if(material->builtins & GPU_VIEW_MATRIX)
|
|
|
|
material->viewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_VIEW_MATRIX));
|
|
|
|
if(material->builtins & GPU_INVERSE_VIEW_MATRIX)
|
|
|
|
material->invviewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_VIEW_MATRIX));
|
|
|
|
if(material->builtins & GPU_OBJECT_MATRIX)
|
|
|
|
material->obmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBJECT_MATRIX));
|
|
|
|
if(material->builtins & GPU_INVERSE_OBJECT_MATRIX)
|
|
|
|
material->invobmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_OBJECT_MATRIX));
|
|
|
|
if(material->builtins & GPU_OBCOLOR)
|
|
|
|
material->obcolloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBCOLOR));
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_free(Material *ma)
|
|
|
|
{
|
|
|
|
LinkData *link;
|
2008-09-05 14:33:36 +00:00
|
|
|
LinkData *nlink, *mlink, *next;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
for(link=ma->gpumaterial.first; link; link=link->next) {
|
|
|
|
GPUMaterial *material = link->data;
|
|
|
|
|
|
|
|
if(material->pass)
|
|
|
|
GPU_pass_free(material->pass);
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
for(nlink=material->lamps.first; nlink; nlink=nlink->next) {
|
|
|
|
GPULamp *lamp = nlink->data;
|
|
|
|
|
|
|
|
for(mlink=lamp->materials.first; mlink; mlink=next) {
|
|
|
|
next = mlink->next;
|
|
|
|
if(mlink->data == ma)
|
|
|
|
BLI_freelinkN(&lamp->materials, mlink);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&material->lamps);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
MEM_freeN(material);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&ma->gpumaterial);
|
|
|
|
}
|
|
|
|
|
2009-08-16 20:14:49 +00:00
|
|
|
void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
if(material->pass) {
|
2008-09-05 14:33:36 +00:00
|
|
|
LinkData *nlink;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPULamp *lamp;
|
|
|
|
|
|
|
|
/* handle layer lamps */
|
2008-09-05 14:33:36 +00:00
|
|
|
for(nlink=material->lamps.first; nlink; nlink=nlink->next) {
|
|
|
|
lamp= nlink->data;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2010-07-27 11:10:34 +00:00
|
|
|
if(!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
lamp->dynenergy = lamp->energy;
|
|
|
|
VECCOPY(lamp->dyncol, lamp->col);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lamp->dynenergy = 0.0f;
|
|
|
|
lamp->dyncol[0]= lamp->dyncol[1]= lamp->dyncol[2] = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 20:14:49 +00:00
|
|
|
GPU_pass_bind(material->pass, time, mipmap);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
material->bound = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4])
|
|
|
|
{
|
|
|
|
if(material->pass) {
|
|
|
|
GPUShader *shader = GPU_pass_shader(material->pass);
|
2008-09-05 14:33:36 +00:00
|
|
|
LinkData *nlink;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPULamp *lamp;
|
|
|
|
float invmat[4][4], col[4];
|
|
|
|
|
|
|
|
/* handle builtins */
|
|
|
|
if(material->builtins & GPU_VIEW_MATRIX) {
|
|
|
|
GPU_shader_uniform_vector(shader, material->viewmatloc, 16, 1, (float*)viewmat);
|
|
|
|
}
|
|
|
|
if(material->builtins & GPU_INVERSE_VIEW_MATRIX) {
|
|
|
|
GPU_shader_uniform_vector(shader, material->invviewmatloc, 16, 1, (float*)viewinv);
|
|
|
|
}
|
|
|
|
if(material->builtins & GPU_OBJECT_MATRIX) {
|
|
|
|
GPU_shader_uniform_vector(shader, material->obmatloc, 16, 1, (float*)obmat);
|
|
|
|
}
|
|
|
|
if(material->builtins & GPU_INVERSE_OBJECT_MATRIX) {
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(invmat, obmat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_shader_uniform_vector(shader, material->invobmatloc, 16, 1, (float*)invmat);
|
|
|
|
}
|
|
|
|
if(material->builtins & GPU_OBCOLOR) {
|
|
|
|
QUATCOPY(col, obcol);
|
|
|
|
CLAMP(col[3], 0.0f, 1.0f);
|
|
|
|
GPU_shader_uniform_vector(shader, material->obcolloc, 4, 1, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update lamps */
|
2008-09-05 14:33:36 +00:00
|
|
|
for(nlink=material->lamps.first; nlink; nlink=nlink->next) {
|
|
|
|
lamp= nlink->data;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
if(material->dynproperty & DYN_LAMP_VEC) {
|
|
|
|
VECCOPY(lamp->dynvec, lamp->vec);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(lamp->dynvec);
|
|
|
|
negate_v3(lamp->dynvec);
|
|
|
|
mul_mat3_m4_v3(viewmat, lamp->dynvec);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(material->dynproperty & DYN_LAMP_CO) {
|
|
|
|
VECCOPY(lamp->dynco, lamp->co);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(viewmat, lamp->dynco);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(material->dynproperty & DYN_LAMP_IMAT)
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_m4m4(lamp->dynimat, viewinv, lamp->imat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(material->dynproperty & DYN_LAMP_PERSMAT)
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_m4m4(lamp->dynpersmat, viewinv, lamp->persmat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GPU_pass_update_uniforms(material->pass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_unbind(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
if (material->pass) {
|
|
|
|
material->bound = 0;
|
|
|
|
GPU_pass_unbind(material->pass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_material_bound(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
return material->bound;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_vertex_attributes(GPUMaterial *material, GPUVertexAttribs *attribs)
|
|
|
|
{
|
|
|
|
*attribs = material->attribs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link)
|
|
|
|
{
|
|
|
|
if(!material->outlink)
|
|
|
|
material->outlink= link;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_enable_alpha(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
material->alpha= 1;
|
|
|
|
}
|
|
|
|
|
2011-08-27 03:20:32 +00:00
|
|
|
GPUBlendMode GPU_material_blend_mode(GPUMaterial *material, float obcol[4])
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
if(material->alpha || (material->obcolalpha && obcol[3] < 1.0f))
|
|
|
|
return GPU_BLEND_ALPHA;
|
|
|
|
else
|
|
|
|
return GPU_BLEND_SOLID;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gpu_material_add_node(GPUMaterial *material, GPUNode *node)
|
|
|
|
{
|
|
|
|
BLI_addtail(&material->nodes, node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Code generation */
|
|
|
|
|
2011-05-02 13:52:41 +00:00
|
|
|
static int gpu_do_color_management(GPUMaterial *mat)
|
|
|
|
{
|
|
|
|
return ((mat->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) &&
|
|
|
|
!((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT)));
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **lv, GPUNodeLink **dist)
|
|
|
|
{
|
|
|
|
GPUNodeLink *visifac, *inpr;
|
|
|
|
|
|
|
|
/* from get_lamp_visibility */
|
|
|
|
if(lamp->type==LA_SUN || lamp->type==LA_HEMI) {
|
|
|
|
mat->dynproperty |= DYN_LAMP_VEC;
|
|
|
|
GPU_link(mat, "lamp_visibility_sun_hemi", GPU_dynamic_uniform(lamp->dynvec), lv, dist, &visifac);
|
|
|
|
return visifac;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mat->dynproperty |= DYN_LAMP_CO;
|
|
|
|
GPU_link(mat, "lamp_visibility_other", GPU_builtin(GPU_VIEW_POSITION), GPU_dynamic_uniform(lamp->dynco), lv, dist, &visifac);
|
|
|
|
|
|
|
|
if(lamp->type==LA_AREA)
|
|
|
|
return visifac;
|
|
|
|
|
|
|
|
switch(lamp->falloff_type)
|
|
|
|
{
|
|
|
|
case LA_FALLOFF_CONSTANT:
|
|
|
|
break;
|
|
|
|
case LA_FALLOFF_INVLINEAR:
|
|
|
|
GPU_link(mat, "lamp_falloff_invlinear", GPU_uniform(&lamp->dist), *dist, &visifac);
|
|
|
|
break;
|
|
|
|
case LA_FALLOFF_INVSQUARE:
|
|
|
|
GPU_link(mat, "lamp_falloff_invsquare", GPU_uniform(&lamp->dist), *dist, &visifac);
|
|
|
|
break;
|
|
|
|
case LA_FALLOFF_SLIDERS:
|
|
|
|
GPU_link(mat, "lamp_falloff_sliders", GPU_uniform(&lamp->dist), GPU_uniform(&lamp->att1), GPU_uniform(&lamp->att2), *dist, &visifac);
|
|
|
|
break;
|
|
|
|
case LA_FALLOFF_CURVE:
|
|
|
|
{
|
|
|
|
float *array;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
curvemapping_table_RGBA(lamp->curfalloff, &array, &size);
|
|
|
|
GPU_link(mat, "lamp_falloff_curve", GPU_uniform(&lamp->dist), GPU_texture(size, array), *dist, &visifac);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(lamp->mode & LA_SPHERE)
|
|
|
|
GPU_link(mat, "lamp_visibility_sphere", GPU_uniform(&lamp->dist), *dist, visifac, &visifac);
|
|
|
|
|
|
|
|
if(lamp->type == LA_SPOT) {
|
|
|
|
if(lamp->mode & LA_SQUARE) {
|
|
|
|
mat->dynproperty |= DYN_LAMP_VEC|DYN_LAMP_IMAT;
|
|
|
|
GPU_link(mat, "lamp_visibility_spot_square", GPU_dynamic_uniform(lamp->dynvec), GPU_dynamic_uniform((float*)lamp->dynimat), *lv, &inpr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mat->dynproperty |= DYN_LAMP_VEC;
|
|
|
|
GPU_link(mat, "lamp_visibility_spot_circle", GPU_dynamic_uniform(lamp->dynvec), *lv, &inpr);
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_link(mat, "lamp_visibility_spot", GPU_uniform(&lamp->spotsi), GPU_uniform(&lamp->spotbl), inpr, visifac, &visifac);
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_link(mat, "lamp_visibility_clamp", visifac, &visifac);
|
|
|
|
|
|
|
|
return visifac;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void area_lamp_vectors(LampRen *lar)
|
|
|
|
{
|
2010-03-22 09:30:00 +00:00
|
|
|
float xsize= 0.5*lar->area_size, ysize= 0.5*lar->area_sizey, multifac;
|
|
|
|
|
|
|
|
/* make it smaller, so area light can be multisampled */
|
|
|
|
multifac= 1.0f/sqrt((float)lar->ray_totsamp);
|
|
|
|
xsize *= multifac;
|
|
|
|
ysize *= multifac;
|
|
|
|
|
|
|
|
/* corner vectors */
|
|
|
|
lar->area[0][0]= lar->co[0] - xsize*lar->mat[0][0] - ysize*lar->mat[1][0];
|
|
|
|
lar->area[0][1]= lar->co[1] - xsize*lar->mat[0][1] - ysize*lar->mat[1][1];
|
|
|
|
lar->area[0][2]= lar->co[2] - xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
|
|
|
|
|
|
|
|
/* corner vectors */
|
|
|
|
lar->area[1][0]= lar->co[0] - xsize*lar->mat[0][0] + ysize*lar->mat[1][0];
|
|
|
|
lar->area[1][1]= lar->co[1] - xsize*lar->mat[0][1] + ysize*lar->mat[1][1];
|
|
|
|
lar->area[1][2]= lar->co[2] - xsize*lar->mat[0][2] + ysize*lar->mat[1][2];
|
|
|
|
|
|
|
|
/* corner vectors */
|
|
|
|
lar->area[2][0]= lar->co[0] + xsize*lar->mat[0][0] + ysize*lar->mat[1][0];
|
|
|
|
lar->area[2][1]= lar->co[1] + xsize*lar->mat[0][1] + ysize*lar->mat[1][1];
|
|
|
|
lar->area[2][2]= lar->co[2] + xsize*lar->mat[0][2] + ysize*lar->mat[1][2];
|
|
|
|
|
|
|
|
/* corner vectors */
|
|
|
|
lar->area[3][0]= lar->co[0] + xsize*lar->mat[0][0] - ysize*lar->mat[1][0];
|
|
|
|
lar->area[3][1]= lar->co[1] + xsize*lar->mat[0][1] - ysize*lar->mat[1][1];
|
|
|
|
lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
|
|
|
|
/* only for correction button size, matrix size works on energy */
|
|
|
|
lar->areasize= lar->dist*lar->dist/(4.0*xsize*ysize);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void ramp_blend(GPUMaterial *mat, GPUNodeLink *fac, GPUNodeLink *col1, GPUNodeLink *col2, int type, GPUNodeLink **outcol)
|
|
|
|
{
|
2010-12-03 17:05:21 +00:00
|
|
|
static const char *names[] = {"mix_blend", "mix_add", "mix_mult", "mix_sub",
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
"mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light",
|
|
|
|
"mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat",
|
2009-10-19 11:50:01 +00:00
|
|
|
"mix_val", "mix_color", "mix_soft", "mix_linear"};
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
GPU_link(mat, names[type], fac, col1, col2, outcol);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_colorband_blend(GPUMaterial *mat, ColorBand *coba, GPUNodeLink *fac, float rampfac, int type, GPUNodeLink *incol, GPUNodeLink **outcol)
|
|
|
|
{
|
|
|
|
GPUNodeLink *tmp, *alpha, *col;
|
|
|
|
float *array;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
/* do colorband */
|
|
|
|
colorband_table_RGBA(coba, &array, &size);
|
|
|
|
GPU_link(mat, "valtorgb", fac, GPU_texture(size, array), &col, &tmp);
|
|
|
|
|
|
|
|
/* use alpha in fac */
|
|
|
|
GPU_link(mat, "mtex_alpha_from_col", col, &alpha);
|
|
|
|
GPU_link(mat, "math_multiply", alpha, GPU_uniform(&rampfac), &fac);
|
|
|
|
|
|
|
|
/* blending method */
|
|
|
|
ramp_blend(mat, fac, incol, col, type, outcol);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff)
|
|
|
|
{
|
|
|
|
Material *ma= shi->mat;
|
|
|
|
GPUMaterial *mat= shi->gpumat;
|
|
|
|
GPUNodeLink *fac;
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(ma->ramp_col) {
|
|
|
|
if(ma->rampin_col==MA_RAMP_IN_RESULT) {
|
|
|
|
GPU_link(mat, "ramp_rgbtobw", *diff, &fac);
|
|
|
|
|
|
|
|
/* colorband + blend */
|
|
|
|
do_colorband_blend(mat, ma->ramp_col, fac, ma->rampfac_col, ma->rampblend_col, *diff, diff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *rgb, GPUNodeLink **diff)
|
|
|
|
{
|
|
|
|
GPUNodeLink *fac, *tmp, *addcol;
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) &&
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ma->ramp_col && (ma->mode & MA_RAMP_COL)) {
|
|
|
|
/* MA_RAMP_IN_RESULT is exceptional */
|
|
|
|
if(ma->rampin_col==MA_RAMP_IN_RESULT) {
|
|
|
|
addcol = shi->rgb;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* input */
|
|
|
|
switch(ma->rampin_col) {
|
|
|
|
case MA_RAMP_IN_ENERGY:
|
|
|
|
GPU_link(mat, "ramp_rgbtobw", rgb, &fac);
|
|
|
|
break;
|
|
|
|
case MA_RAMP_IN_SHADER:
|
|
|
|
fac= is;
|
|
|
|
break;
|
|
|
|
case MA_RAMP_IN_NOR:
|
|
|
|
GPU_link(mat, "vec_math_dot", shi->view, shi->vn, &tmp, &fac);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GPU_link(mat, "set_value_zero", &fac);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* colorband + blend */
|
|
|
|
do_colorband_blend(mat, ma->ramp_col, fac, ma->rampfac_col, ma->rampblend_col, shi->rgb, &addcol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
addcol = shi->rgb;
|
|
|
|
|
|
|
|
/* output to */
|
2011-05-02 14:01:45 +00:00
|
|
|
GPU_link(mat, "shade_madd_clamped", *diff, rgb, addcol, diff);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ramp_spec_result(GPUShadeInput *shi, GPUNodeLink **spec)
|
|
|
|
{
|
|
|
|
Material *ma= shi->mat;
|
|
|
|
GPUMaterial *mat= shi->gpumat;
|
|
|
|
GPUNodeLink *fac;
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) &&
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ma->ramp_spec && ma->rampin_spec==MA_RAMP_IN_RESULT) {
|
|
|
|
GPU_link(mat, "ramp_rgbtobw", *spec, &fac);
|
|
|
|
|
|
|
|
/* colorband + blend */
|
|
|
|
do_colorband_blend(mat, ma->ramp_spec, fac, ma->rampfac_spec, ma->rampblend_spec, *spec, spec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_specular_ramp(GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *t, GPUNodeLink **spec)
|
|
|
|
{
|
|
|
|
Material *ma= shi->mat;
|
|
|
|
GPUMaterial *mat= shi->gpumat;
|
|
|
|
GPUNodeLink *fac, *tmp;
|
|
|
|
|
|
|
|
*spec = shi->specrgb;
|
|
|
|
|
|
|
|
/* MA_RAMP_IN_RESULT is exception */
|
|
|
|
if(ma->ramp_spec && (ma->rampin_spec!=MA_RAMP_IN_RESULT)) {
|
|
|
|
|
|
|
|
/* input */
|
|
|
|
switch(ma->rampin_spec) {
|
|
|
|
case MA_RAMP_IN_ENERGY:
|
|
|
|
fac = t;
|
|
|
|
break;
|
|
|
|
case MA_RAMP_IN_SHADER:
|
|
|
|
fac = is;
|
|
|
|
break;
|
|
|
|
case MA_RAMP_IN_NOR:
|
|
|
|
GPU_link(mat, "vec_math_dot", shi->view, shi->vn, &tmp, &fac);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GPU_link(mat, "set_value_zero", &fac);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* colorband + blend */
|
|
|
|
do_colorband_blend(mat, ma->ramp_spec, fac, ma->rampfac_spec, ma->rampblend_spec, *spec, spec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static void add_user_list(ListBase *list, void *data)
|
2008-09-05 14:33:36 +00:00
|
|
|
{
|
|
|
|
LinkData *link = MEM_callocN(sizeof(LinkData), "GPULinkData");
|
|
|
|
link->data = data;
|
|
|
|
BLI_addtail(list, link);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *lamp)
|
|
|
|
{
|
|
|
|
Material *ma= shi->mat;
|
|
|
|
GPUMaterial *mat= shi->gpumat;
|
|
|
|
GPUNodeLink *lv, *dist, *visifac, *is, *inp, *i, *vn, *view;
|
2010-10-07 10:04:07 +00:00
|
|
|
GPUNodeLink *outcol, *specfac, *t, *shadfac= NULL;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
float one = 1.0f;
|
|
|
|
|
|
|
|
if((lamp->mode & LA_ONLYSHADOW) && !(ma->mode & MA_SHADOW))
|
|
|
|
return;
|
|
|
|
|
|
|
|
vn= shi->vn;
|
|
|
|
view= shi->view;
|
|
|
|
|
|
|
|
visifac= lamp_get_visibility(mat, lamp, &lv, &dist);
|
|
|
|
|
|
|
|
/*if(ma->mode & MA_TANGENT_V)
|
|
|
|
GPU_link(mat, "shade_tangent_v", lv, GPU_attribute(CD_TANGENT, ""), &vn);*/
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_inp", vn, lv, &inp);
|
|
|
|
|
|
|
|
if(lamp->mode & LA_NO_DIFF) {
|
|
|
|
GPU_link(mat, "shade_is_no_diffuse", &is);
|
|
|
|
}
|
|
|
|
else if(lamp->type == LA_HEMI) {
|
|
|
|
GPU_link(mat, "shade_is_hemi", inp, &is);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(lamp->type == LA_AREA) {
|
2010-10-31 15:39:37 +00:00
|
|
|
float area[4][4]= {{0.0f}}, areasize= 0.0f;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
mat->dynproperty |= DYN_LAMP_VEC|DYN_LAMP_CO;
|
|
|
|
GPU_link(mat, "shade_inp_area", GPU_builtin(GPU_VIEW_POSITION), GPU_dynamic_uniform(lamp->dynco), GPU_dynamic_uniform(lamp->dynvec), vn, GPU_uniform((float*)area),
|
|
|
|
GPU_uniform(&areasize), GPU_uniform(&lamp->k), &inp);
|
|
|
|
}
|
|
|
|
|
|
|
|
is= inp; /* Lambert */
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(ma->diff_shader==MA_DIFF_ORENNAYAR)
|
|
|
|
GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view, GPU_uniform(&ma->roughness), &is);
|
|
|
|
else if(ma->diff_shader==MA_DIFF_TOON)
|
|
|
|
GPU_link(mat, "shade_diffuse_toon", vn, lv, view, GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
|
|
|
|
else if(ma->diff_shader==MA_DIFF_MINNAERT)
|
|
|
|
GPU_link(mat, "shade_diffuse_minnaert", inp, vn, view, GPU_uniform(&ma->darkness), &is);
|
|
|
|
else if(ma->diff_shader==MA_DIFF_FRESNEL)
|
|
|
|
GPU_link(mat, "shade_diffuse_fresnel", vn, lv, view, GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS))
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(ma->shade_flag & MA_CUBIC)
|
|
|
|
GPU_link(mat, "shade_cubic", is, &is);
|
|
|
|
|
|
|
|
i = is;
|
|
|
|
GPU_link(mat, "shade_visifac", i, visifac, shi->refl, &i);
|
|
|
|
|
2011-07-27 06:55:20 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/*if(ma->mode & MA_TANGENT_VN)
|
|
|
|
GPU_link(mat, "shade_tangent_v_spec", GPU_attribute(CD_TANGENT, ""), &vn);*/
|
|
|
|
|
|
|
|
/* this replaces if(i > 0.0) conditional until that is supported */
|
|
|
|
// done in shade_visifac now, GPU_link(mat, "mtex_value_clamp_positive", i, &i);
|
|
|
|
|
|
|
|
if((ma->mode & MA_SHADOW) && GPU_lamp_has_shadow_buffer(lamp)) {
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS)) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
mat->dynproperty |= DYN_LAMP_PERSMAT;
|
|
|
|
|
|
|
|
GPU_link(mat, "test_shadowbuf",
|
|
|
|
GPU_builtin(GPU_VIEW_POSITION),
|
|
|
|
GPU_dynamic_texture(lamp->tex),
|
|
|
|
GPU_dynamic_uniform((float*)lamp->dynpersmat),
|
|
|
|
GPU_uniform(&lamp->bias), inp, &shadfac);
|
|
|
|
|
|
|
|
if(lamp->mode & LA_ONLYSHADOW) {
|
|
|
|
GPU_link(mat, "shade_only_shadow", i, shadfac,
|
2008-09-05 15:08:01 +00:00
|
|
|
GPU_dynamic_uniform(&lamp->dynenergy), &shadfac);
|
|
|
|
|
|
|
|
if(!(lamp->mode & LA_NO_DIFF))
|
|
|
|
GPU_link(mat, "shade_only_shadow_diffuse", shadfac, shi->rgb,
|
|
|
|
shr->diff, &shr->diff);
|
|
|
|
|
|
|
|
if(!(lamp->mode & LA_NO_SPEC))
|
|
|
|
GPU_link(mat, "shade_only_shadow_specular", shadfac, shi->specrgb,
|
|
|
|
shr->spec, &shr->spec);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
add_user_list(&mat->lamps, lamp);
|
2008-10-11 18:52:36 +00:00
|
|
|
add_user_list(&lamp->materials, shi->gpumat->ma);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_link(mat, "math_multiply", i, shadfac, &i);
|
|
|
|
}
|
|
|
|
}
|
2009-08-18 15:27:48 +00:00
|
|
|
else if((mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) {
|
2008-09-05 14:33:36 +00:00
|
|
|
add_user_list(&mat->lamps, lamp);
|
2008-10-11 18:52:36 +00:00
|
|
|
add_user_list(&lamp->materials, shi->gpumat->ma);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&one), &shadfac);
|
|
|
|
|
|
|
|
if(GPU_link_changed(shi->refl) || ma->ref != 0.0f) {
|
|
|
|
if(!(lamp->mode & LA_NO_DIFF)) {
|
|
|
|
GPUNodeLink *rgb;
|
|
|
|
GPU_link(mat, "shade_mul_value", i, GPU_dynamic_uniform(lamp->dyncol), &rgb);
|
|
|
|
add_to_diffuse(mat, ma, shi, is, rgb, &shr->diff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else if(!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) &&
|
|
|
|
(GPU_link_changed(shi->spec) || ma->spec != 0.0f)) {
|
|
|
|
if(lamp->type == LA_HEMI) {
|
|
|
|
GPU_link(mat, "shade_hemi_spec", vn, lv, view, GPU_uniform(&ma->spec), shi->har, visifac, &t);
|
|
|
|
GPU_link(mat, "shade_add_spec", t, GPU_dynamic_uniform(lamp->dyncol), shi->specrgb, &outcol);
|
2011-05-02 14:01:45 +00:00
|
|
|
GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(ma->spec_shader==MA_SPEC_PHONG)
|
|
|
|
GPU_link(mat, "shade_phong_spec", vn, lv, view, shi->har, &specfac);
|
|
|
|
else if(ma->spec_shader==MA_SPEC_COOKTORR)
|
|
|
|
GPU_link(mat, "shade_cooktorr_spec", vn, lv, view, shi->har, &specfac);
|
|
|
|
else if(ma->spec_shader==MA_SPEC_BLINN)
|
|
|
|
GPU_link(mat, "shade_blinn_spec", vn, lv, view, GPU_uniform(&ma->refrac), shi->har, &specfac);
|
|
|
|
else if(ma->spec_shader==MA_SPEC_WARDISO)
|
|
|
|
GPU_link(mat, "shade_wardiso_spec", vn, lv, view, GPU_uniform(&ma->rms), &specfac);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "shade_toon_spec", vn, lv, view, GPU_uniform(&ma->param[2]), GPU_uniform(&ma->param[3]), &specfac);
|
|
|
|
|
|
|
|
if(lamp->type==LA_AREA)
|
|
|
|
GPU_link(mat, "shade_spec_area_inp", specfac, inp, &specfac);
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_spec_t", shadfac, shi->spec, visifac, specfac, &t);
|
|
|
|
|
|
|
|
if(ma->mode & MA_RAMP_SPEC) {
|
|
|
|
GPUNodeLink *spec;
|
|
|
|
do_specular_ramp(shi, specfac, t, &spec);
|
|
|
|
GPU_link(mat, "shade_add_spec", t, GPU_dynamic_uniform(lamp->dyncol), spec, &outcol);
|
2011-05-02 14:01:45 +00:00
|
|
|
GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "shade_add_spec", t, GPU_dynamic_uniform(lamp->dyncol), shi->specrgb, &outcol);
|
2011-05-02 14:01:45 +00:00
|
|
|
GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
add_user_list(&mat->lamps, lamp);
|
2008-10-11 18:52:36 +00:00
|
|
|
add_user_list(&lamp->materials, shi->gpumat->ma);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr)
|
|
|
|
{
|
|
|
|
Base *base;
|
|
|
|
Object *ob;
|
2010-12-17 15:37:59 +00:00
|
|
|
Scene *sce_iter;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPULamp *lamp;
|
|
|
|
|
2010-12-17 15:37:59 +00:00
|
|
|
for(SETLOOPER(shi->gpumat->scene, sce_iter, base)) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ob= base->object;
|
|
|
|
|
|
|
|
if(ob->type==OB_LAMP) {
|
|
|
|
lamp = GPU_lamp_from_blender(shi->gpumat->scene, ob, NULL);
|
|
|
|
if(lamp)
|
|
|
|
shade_one_light(shi, shr, lamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ob->transflag & OB_DUPLI) {
|
|
|
|
DupliObject *dob;
|
|
|
|
ListBase *lb = object_duplilist(shi->gpumat->scene, ob);
|
|
|
|
|
|
|
|
for(dob=lb->first; dob; dob=dob->next) {
|
2011-02-20 15:48:01 +00:00
|
|
|
Object *ob_iter = dob->ob;
|
|
|
|
|
|
|
|
if(ob_iter->type==OB_LAMP) {
|
|
|
|
copy_m4_m4(ob_iter->obmat, dob->mat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2011-02-20 15:48:01 +00:00
|
|
|
lamp = GPU_lamp_from_blender(shi->gpumat->scene, ob_iter, ob);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(lamp)
|
|
|
|
shade_one_light(shi, shr, lamp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free_object_duplilist(lb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void texture_rgb_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg, int blendtype, GPUNodeLink **in)
|
|
|
|
{
|
|
|
|
switch(blendtype) {
|
|
|
|
case MTEX_BLEND:
|
|
|
|
GPU_link(mat, "mtex_rgb_blend", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_MUL:
|
|
|
|
GPU_link(mat, "mtex_rgb_mul", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_SCREEN:
|
|
|
|
GPU_link(mat, "mtex_rgb_screen", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_OVERLAY:
|
|
|
|
GPU_link(mat, "mtex_rgb_overlay", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_SUB:
|
|
|
|
GPU_link(mat, "mtex_rgb_sub", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_ADD:
|
|
|
|
GPU_link(mat, "mtex_rgb_add", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_DIV:
|
|
|
|
GPU_link(mat, "mtex_rgb_div", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_DIFF:
|
|
|
|
GPU_link(mat, "mtex_rgb_diff", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_DARK:
|
|
|
|
GPU_link(mat, "mtex_rgb_dark", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_LIGHT:
|
|
|
|
GPU_link(mat, "mtex_rgb_light", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_BLEND_HUE:
|
|
|
|
GPU_link(mat, "mtex_rgb_hue", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_BLEND_SAT:
|
|
|
|
GPU_link(mat, "mtex_rgb_sat", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_BLEND_VAL:
|
|
|
|
GPU_link(mat, "mtex_rgb_val", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_BLEND_COLOR:
|
|
|
|
GPU_link(mat, "mtex_rgb_color", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GPU_link(mat, "set_rgb_zero", &in);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
static void texture_value_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg, int blendtype, GPUNodeLink **in)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
switch(blendtype) {
|
|
|
|
case MTEX_BLEND:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_blend", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
case MTEX_MUL:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_mul", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
case MTEX_SCREEN:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_screen", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
case MTEX_SUB:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_sub", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
case MTEX_ADD:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_add", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
case MTEX_DIV:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_div", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
case MTEX_DIFF:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_diff", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
case MTEX_DARK:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_dark", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
case MTEX_LIGHT:
|
2009-10-01 17:15:23 +00:00
|
|
|
GPU_link(mat, "mtex_value_light", out, tex, fact, facg, in);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GPU_link(mat, "set_value_zero", &in);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_material_tex(GPUShadeInput *shi)
|
|
|
|
{
|
|
|
|
Material *ma= shi->mat;
|
|
|
|
GPUMaterial *mat= shi->gpumat;
|
|
|
|
MTex *mtex;
|
|
|
|
Tex *tex;
|
|
|
|
GPUNodeLink *texco, *tin, *trgb, *tnor, *tcol, *stencil, *tnorfac;
|
2011-02-17 22:34:41 +00:00
|
|
|
GPUNodeLink *texco_norm, *texco_orco, *texco_object;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPUNodeLink *texco_global, *texco_uv = NULL;
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *newnor, *orn;
|
2011-05-23 15:23:31 +00:00
|
|
|
/*char *lastuvname = NULL;*/ /*UNUSED*/
|
2010-08-06 18:40:05 +00:00
|
|
|
float one = 1.0f, norfac, ofs[3];
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
int tex_nr, rgbnor, talpha;
|
2011-02-07 21:57:40 +00:00
|
|
|
int init_done = 0, iBumpSpacePrev;
|
|
|
|
GPUNodeLink *vNorg, *vNacc, *fPrevMagnitude;
|
2011-02-14 18:18:46 +00:00
|
|
|
int iFirstTimeNMap=1;
|
2011-08-22 19:57:54 +00:00
|
|
|
int found_deriv_map = 0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&one), &stencil);
|
|
|
|
|
|
|
|
GPU_link(mat, "texco_norm", GPU_builtin(GPU_VIEW_NORMAL), &texco_norm);
|
|
|
|
GPU_link(mat, "texco_orco", GPU_attribute(CD_ORCO, ""), &texco_orco);
|
|
|
|
GPU_link(mat, "texco_object", GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
|
|
|
|
GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
|
|
|
|
GPU_builtin(GPU_VIEW_POSITION), &texco_object);
|
2011-02-14 18:18:46 +00:00
|
|
|
//GPU_link(mat, "texco_tangent", GPU_attribute(CD_TANGENT, ""), &texco_tangent);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "texco_global", GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
|
|
|
|
GPU_builtin(GPU_VIEW_POSITION), &texco_global);
|
|
|
|
|
|
|
|
orn= texco_norm;
|
|
|
|
|
|
|
|
/* go over texture slots */
|
|
|
|
for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
|
|
|
|
/* separate tex switching */
|
|
|
|
if(ma->septex & (1<<tex_nr)) continue;
|
|
|
|
|
|
|
|
if(ma->mtex[tex_nr]) {
|
|
|
|
mtex= ma->mtex[tex_nr];
|
|
|
|
|
|
|
|
tex= mtex->tex;
|
2011-03-03 17:58:06 +00:00
|
|
|
if(tex == NULL) continue;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* which coords */
|
|
|
|
if(mtex->texco==TEXCO_ORCO)
|
|
|
|
texco= texco_orco;
|
|
|
|
else if(mtex->texco==TEXCO_OBJECT)
|
|
|
|
texco= texco_object;
|
|
|
|
else if(mtex->texco==TEXCO_NORM)
|
2008-10-11 19:34:48 +00:00
|
|
|
texco= orn;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else if(mtex->texco==TEXCO_TANGENT)
|
|
|
|
texco= texco_object;
|
|
|
|
else if(mtex->texco==TEXCO_GLOB)
|
|
|
|
texco= texco_global;
|
2011-06-20 09:08:41 +00:00
|
|
|
else if(mtex->texco==TEXCO_REFL) {
|
|
|
|
GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
texco= shi->ref;
|
2011-06-20 09:08:41 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else if(mtex->texco==TEXCO_UV) {
|
|
|
|
if(1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 0)) {
|
|
|
|
GPU_link(mat, "texco_uv", GPU_attribute(CD_MTFACE, mtex->uvname), &texco_uv);
|
2011-05-23 15:23:31 +00:00
|
|
|
/*lastuvname = mtex->uvname;*/ /*UNUSED*/
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
texco= texco_uv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* in case of uv, this would just undo a multiplication in texco_uv */
|
|
|
|
if(mtex->texco != TEXCO_UV)
|
|
|
|
GPU_link(mat, "mtex_2d_mapping", texco, &texco);
|
|
|
|
|
|
|
|
if(mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f)
|
|
|
|
GPU_link(mat, "mtex_mapping_size", texco, GPU_uniform(mtex->size), &texco);
|
|
|
|
|
|
|
|
ofs[0] = mtex->ofs[0] + 0.5f - 0.5f*mtex->size[0];
|
|
|
|
ofs[1] = mtex->ofs[1] + 0.5f - 0.5f*mtex->size[1];
|
|
|
|
ofs[2] = 0.0f;
|
|
|
|
if(ofs[0] != 0.0f || ofs[1] != 0.0f || ofs[2] != 0.0f)
|
|
|
|
GPU_link(mat, "mtex_mapping_ofs", texco, GPU_uniform(ofs), &texco);
|
|
|
|
|
2008-09-05 20:34:35 +00:00
|
|
|
talpha = 0;
|
|
|
|
rgbnor = 0;
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(tex && tex->type == TEX_IMAGE && tex->ima) {
|
2011-01-29 12:01:11 +00:00
|
|
|
GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser), &tin, &trgb);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
rgbnor= TEX_RGB;
|
2008-09-05 20:34:35 +00:00
|
|
|
|
|
|
|
if(tex->imaflag & TEX_USEALPHA)
|
|
|
|
talpha= 1;
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else continue;
|
|
|
|
|
|
|
|
/* texture output */
|
|
|
|
if((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
|
|
|
|
GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
|
|
|
|
rgbnor -= TEX_RGB;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mtex->texflag & MTEX_NEGATIVE) {
|
|
|
|
if(rgbnor & TEX_RGB)
|
|
|
|
GPU_link(mat, "mtex_rgb_invert", trgb, &trgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_value_invert", tin, &tin);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mtex->texflag & MTEX_STENCIL) {
|
|
|
|
if(rgbnor & TEX_RGB)
|
|
|
|
GPU_link(mat, "mtex_rgb_stencil", stencil, trgb, &stencil, &trgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_value_stencil", stencil, tin, &stencil, &tin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mapping */
|
|
|
|
if(mtex->mapto & (MAP_COL+MAP_COLSPEC)) {
|
|
|
|
/* stencil maps on the texture control slider, not texture intensity value */
|
|
|
|
if((rgbnor & TEX_RGB)==0) {
|
|
|
|
GPU_link(mat, "set_rgb", GPU_uniform(&mtex->r), &tcol);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "set_rgba", trgb, &tcol);
|
|
|
|
|
|
|
|
if(mtex->mapto & MAP_ALPHA)
|
|
|
|
GPU_link(mat, "set_value", stencil, &tin);
|
2008-09-05 20:34:35 +00:00
|
|
|
else if(talpha)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "mtex_alpha_from_col", trgb, &tin);
|
2008-09-05 20:34:35 +00:00
|
|
|
else
|
|
|
|
GPU_link(mat, "set_value_one", &tin);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2010-07-29 10:09:20 +00:00
|
|
|
|
|
|
|
if(tex->type==TEX_IMAGE)
|
2011-05-02 13:52:41 +00:00
|
|
|
if(gpu_do_color_management(mat))
|
2010-08-15 09:34:18 +00:00
|
|
|
GPU_link(mat, "srgb_to_linearrgb", tcol, &tcol);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
if(mtex->mapto & MAP_COL) {
|
|
|
|
GPUNodeLink *colfac;
|
|
|
|
|
|
|
|
if(mtex->colfac == 1.0f) colfac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colfac), stencil, &colfac);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
texture_rgb_blend(mat, tcol, shi->rgb, tin, colfac, mtex->blendtype, &shi->rgb);
|
2009-10-01 17:15:23 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) {
|
|
|
|
GPUNodeLink *colspecfac;
|
|
|
|
|
|
|
|
if(mtex->colspecfac == 1.0f) colspecfac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colspecfac), stencil, &colspecfac);
|
|
|
|
|
|
|
|
texture_rgb_blend(mat, tcol, shi->specrgb, tin, colspecfac, mtex->blendtype, &shi->specrgb);
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) {
|
2011-01-29 12:01:11 +00:00
|
|
|
if(tex->type==TEX_IMAGE) {
|
2011-08-22 19:57:54 +00:00
|
|
|
found_deriv_map = tex->imaflag & TEX_DERIVATIVEMAP;
|
|
|
|
|
2011-01-29 12:01:11 +00:00
|
|
|
if(tex->imaflag & TEX_NORMALMAP) {
|
|
|
|
/* normalmap image */
|
|
|
|
GPU_link(mat, "mtex_normal", texco, GPU_image(tex->ima, &tex->iuser), &tnor );
|
|
|
|
|
|
|
|
if(mtex->norfac < 0.0f)
|
|
|
|
GPU_link(mat, "mtex_negate_texnormal", tnor, &tnor);
|
|
|
|
|
|
|
|
if(mtex->normapspace == MTEX_NSPACE_TANGENT)
|
2011-02-14 18:18:46 +00:00
|
|
|
{
|
|
|
|
if(iFirstTimeNMap!=0)
|
|
|
|
{
|
|
|
|
// use unnormalized normal (this is how we bake it - closer to gamedev)
|
|
|
|
GPUNodeLink *vNegNorm;
|
|
|
|
GPU_link(mat, "vec_math_negate", GPU_builtin(GPU_VIEW_NORMAL), &vNegNorm);
|
|
|
|
GPU_link(mat, "mtex_nspace_tangent", GPU_attribute(CD_TANGENT, ""), vNegNorm, tnor, &newnor);
|
|
|
|
iFirstTimeNMap = 0;
|
|
|
|
}
|
|
|
|
else // otherwise use accumulated perturbations
|
|
|
|
{
|
|
|
|
GPU_link(mat, "mtex_nspace_tangent", GPU_attribute(CD_TANGENT, ""), shi->vn, tnor, &newnor);
|
|
|
|
}
|
|
|
|
}
|
2011-01-29 12:01:11 +00:00
|
|
|
else
|
|
|
|
newnor = tnor;
|
|
|
|
|
2011-04-02 02:08:33 +00:00
|
|
|
norfac = MIN2(fabsf(mtex->norfac), 1.0f);
|
2011-01-30 16:24:23 +00:00
|
|
|
|
|
|
|
if(norfac == 1.0f && !GPU_link_changed(stencil)) {
|
|
|
|
shi->vn = newnor;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tnorfac = GPU_uniform(&norfac);
|
|
|
|
|
|
|
|
if(GPU_link_changed(stencil))
|
|
|
|
GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac);
|
|
|
|
|
|
|
|
GPU_link(mat, "mtex_blend_normal", tnorfac, shi->vn, newnor, &shi->vn);
|
|
|
|
}
|
|
|
|
|
2011-08-22 19:57:54 +00:00
|
|
|
} else if( (mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) || found_deriv_map) {
|
2011-01-29 12:01:11 +00:00
|
|
|
/* ntap bumpmap image */
|
2011-02-07 21:57:40 +00:00
|
|
|
int iBumpSpace;
|
2011-08-22 19:57:54 +00:00
|
|
|
float ima_x, ima_y;
|
2011-01-29 12:01:11 +00:00
|
|
|
float hScale = 0.1f; // compatibility adjustment factor for all bumpspace types
|
2011-01-30 16:57:28 +00:00
|
|
|
float hScaleTex = 13.0f; // factor for scaling texspace bumps
|
2011-01-29 12:01:11 +00:00
|
|
|
|
|
|
|
GPUNodeLink *surf_pos = GPU_builtin(GPU_VIEW_POSITION);
|
2011-02-07 21:57:40 +00:00
|
|
|
GPUNodeLink *vR1, *vR2;
|
|
|
|
GPUNodeLink *dBs, *dBt, *fDet;
|
2011-01-29 12:01:11 +00:00
|
|
|
|
2011-01-30 16:57:28 +00:00
|
|
|
if( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
|
|
|
|
hScale = hScaleTex;
|
2011-01-30 16:24:23 +00:00
|
|
|
norfac = hScale * mtex->norfac;
|
|
|
|
tnorfac = GPU_uniform(&norfac);
|
|
|
|
|
|
|
|
if(GPU_link_changed(stencil))
|
|
|
|
GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac);
|
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
if( !init_done ) {
|
|
|
|
// copy shi->vn to vNorg and vNacc, set magnitude to 1
|
|
|
|
GPU_link(mat, "mtex_bump_normals_init", shi->vn, &vNorg, &vNacc, &fPrevMagnitude);
|
|
|
|
iBumpSpacePrev = 0;
|
|
|
|
init_done = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find current bump space
|
2011-01-29 12:01:11 +00:00
|
|
|
if( mtex->texflag & MTEX_BUMP_OBJECTSPACE )
|
2011-02-07 21:57:40 +00:00
|
|
|
iBumpSpace = 1;
|
|
|
|
else if( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
|
|
|
|
iBumpSpace = 2;
|
2011-01-29 12:01:11 +00:00
|
|
|
else
|
2011-02-07 21:57:40 +00:00
|
|
|
iBumpSpace = 4; // ViewSpace
|
|
|
|
|
|
|
|
// re-initialize if bump space changed
|
|
|
|
if( iBumpSpacePrev != iBumpSpace ) {
|
|
|
|
|
|
|
|
if( mtex->texflag & MTEX_BUMP_OBJECTSPACE )
|
|
|
|
GPU_link( mat, "mtex_bump_init_objspace",
|
|
|
|
surf_pos, vNorg,
|
|
|
|
GPU_builtin(GPU_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
|
|
|
|
fPrevMagnitude, vNacc,
|
|
|
|
&fPrevMagnitude, &vNacc,
|
|
|
|
&vR1, &vR2, &fDet );
|
|
|
|
|
|
|
|
else if( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
|
|
|
|
GPU_link( mat, "mtex_bump_init_texturespace",
|
|
|
|
surf_pos, vNorg,
|
|
|
|
fPrevMagnitude, vNacc,
|
|
|
|
&fPrevMagnitude, &vNacc,
|
|
|
|
&vR1, &vR2, &fDet );
|
|
|
|
|
|
|
|
else
|
|
|
|
GPU_link( mat, "mtex_bump_init_viewspace",
|
|
|
|
surf_pos, vNorg,
|
|
|
|
fPrevMagnitude, vNacc,
|
|
|
|
&fPrevMagnitude, &vNacc,
|
|
|
|
&vR1, &vR2, &fDet );
|
|
|
|
|
|
|
|
iBumpSpacePrev = iBumpSpace;
|
|
|
|
}
|
2011-08-22 19:57:54 +00:00
|
|
|
|
|
|
|
// resolve texture resolution
|
|
|
|
if( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) {
|
|
|
|
ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser);
|
|
|
|
ima_x= 512.0f; ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only
|
|
|
|
if(ibuf) {
|
|
|
|
ima_x= ibuf->x;
|
|
|
|
ima_y= ibuf->y;
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 21:57:40 +00:00
|
|
|
|
2011-01-29 12:01:11 +00:00
|
|
|
|
2011-08-22 19:57:54 +00:00
|
|
|
if(found_deriv_map) {
|
|
|
|
GPU_link( mat, "mtex_bump_deriv",
|
|
|
|
texco, GPU_image(tex->ima, &tex->iuser), GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac,
|
|
|
|
&dBs, &dBt );
|
|
|
|
}
|
|
|
|
else if( mtex->texflag & MTEX_3TAP_BUMP )
|
2011-01-29 12:01:11 +00:00
|
|
|
GPU_link( mat, "mtex_bump_tap3",
|
2011-01-30 16:24:23 +00:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser), tnorfac,
|
2011-01-29 12:01:11 +00:00
|
|
|
&dBs, &dBt );
|
|
|
|
else
|
|
|
|
GPU_link( mat, "mtex_bump_tap5",
|
2011-01-30 16:24:23 +00:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser), tnorfac,
|
2011-01-29 12:01:11 +00:00
|
|
|
&dBs, &dBt );
|
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
|
2011-01-29 16:13:15 +00:00
|
|
|
if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
|
|
|
|
|
2011-01-29 12:01:11 +00:00
|
|
|
GPU_link( mat, "mtex_bump_apply_texspace",
|
2011-02-07 21:57:40 +00:00
|
|
|
fDet, dBs, dBt, vR1, vR2,
|
|
|
|
GPU_image(tex->ima, &tex->iuser), texco, GPU_uniform(&ima_x), GPU_uniform(&ima_y), vNacc,
|
|
|
|
&vNacc, &shi->vn );
|
2011-01-30 16:24:23 +00:00
|
|
|
} else
|
|
|
|
GPU_link( mat, "mtex_bump_apply",
|
2011-02-07 21:57:40 +00:00
|
|
|
fDet, dBs, dBt, vR1, vR2, vNacc,
|
|
|
|
&vNacc, &shi->vn );
|
2011-01-29 12:01:11 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 12:01:11 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "vec_math_negate", shi->vn, &orn);
|
|
|
|
}
|
|
|
|
|
|
|
|
if((mtex->mapto & MAP_VARS)) {
|
|
|
|
if(rgbnor & TEX_RGB) {
|
|
|
|
if(talpha)
|
|
|
|
GPU_link(mat, "mtex_alpha_from_col", trgb, &tin);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
|
|
|
|
}
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *difffac;
|
|
|
|
|
|
|
|
if(mtex->difffac == 1.0f) difffac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->difffac), stencil, &difffac);
|
|
|
|
|
|
|
|
texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->refl, tin, difffac, mtex->blendtype, &shi->refl);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "mtex_value_clamp_positive", shi->refl, &shi->refl);
|
|
|
|
}
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *specfac;
|
|
|
|
|
|
|
|
if(mtex->specfac == 1.0f) specfac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->specfac), stencil, &specfac);
|
|
|
|
|
|
|
|
texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->spec, tin, specfac, mtex->blendtype, &shi->spec);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "mtex_value_clamp_positive", shi->spec, &shi->spec);
|
|
|
|
}
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *emitfac;
|
|
|
|
|
|
|
|
if(mtex->emitfac == 1.0f) emitfac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->emitfac), stencil, &emitfac);
|
|
|
|
|
|
|
|
texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->emit, tin, emitfac, mtex->blendtype, &shi->emit);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "mtex_value_clamp_positive", shi->emit, &shi->emit);
|
|
|
|
}
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *hardfac;
|
|
|
|
|
|
|
|
if(mtex->hardfac == 1.0f) hardfac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->hardfac), stencil, &hardfac);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "mtex_har_divide", shi->har, &shi->har);
|
2009-10-01 17:15:23 +00:00
|
|
|
texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->har, tin, hardfac, mtex->blendtype, &shi->har);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "mtex_har_multiply_clamp", shi->har, &shi->har);
|
|
|
|
}
|
|
|
|
if(mtex->mapto & MAP_ALPHA) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *alphafac;
|
|
|
|
|
|
|
|
if(mtex->alphafac == 1.0f) alphafac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->alphafac), stencil, &alphafac);
|
|
|
|
|
|
|
|
texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, alphafac, mtex->blendtype, &shi->alpha);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "mtex_value_clamp", shi->alpha, &shi->alpha);
|
|
|
|
}
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *ambfac;
|
|
|
|
|
|
|
|
if(mtex->ambfac == 1.0f) ambfac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->ambfac), stencil, &ambfac);
|
|
|
|
|
|
|
|
texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->amb, tin, ambfac, mtex->blendtype, &shi->amb);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "mtex_value_clamp", shi->amb, &shi->amb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
|
|
|
|
{
|
|
|
|
float hard = ma->har;
|
|
|
|
|
|
|
|
memset(shi, 0, sizeof(*shi));
|
|
|
|
|
|
|
|
shi->gpumat = mat;
|
|
|
|
shi->mat = ma;
|
|
|
|
|
|
|
|
GPU_link(mat, "set_rgb", GPU_uniform(&ma->r), &shi->rgb);
|
|
|
|
GPU_link(mat, "set_rgb", GPU_uniform(&ma->specr), &shi->specrgb);
|
|
|
|
GPU_link(mat, "shade_norm", GPU_builtin(GPU_VIEW_NORMAL), &shi->vn);
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&ma->alpha), &shi->alpha);
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&ma->ref), &shi->refl);
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&ma->spec), &shi->spec);
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&ma->emit), &shi->emit);
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&hard), &shi->har);
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&ma->amb), &shi->amb);
|
|
|
|
GPU_link(mat, "shade_view", GPU_builtin(GPU_VIEW_POSITION), &shi->view);
|
|
|
|
GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol);
|
2011-05-02 13:52:41 +00:00
|
|
|
if(gpu_do_color_management(mat))
|
|
|
|
GPU_link(mat, "srgb_to_linearrgb", shi->vcol, &shi->vcol);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
|
|
|
|
{
|
|
|
|
GPUMaterial *mat= shi->gpumat;
|
|
|
|
GPUNodeLink *emit, *ulinfac, *ulogfac, *mistfac;
|
|
|
|
Material *ma= shi->mat;
|
|
|
|
World *world= mat->scene->world;
|
|
|
|
float linfac, logfac, misttype;
|
|
|
|
|
|
|
|
memset(shr, 0, sizeof(*shr));
|
|
|
|
|
|
|
|
if(ma->mode & MA_VERTEXCOLP)
|
|
|
|
shi->rgb = shi->vcol;
|
|
|
|
|
|
|
|
do_material_tex(shi);
|
|
|
|
|
2009-08-15 19:35:03 +00:00
|
|
|
if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_material_enable_alpha(mat);
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if((mat->scene->gm.flag & GAME_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
shr->combined = shi->rgb;
|
|
|
|
shr->alpha = shi->alpha;
|
2008-10-04 20:22:43 +00:00
|
|
|
GPU_link(mat, "set_rgb", shi->rgb, &shr->diff);
|
|
|
|
GPU_link(mat, "set_rgb_zero", &shr->spec);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(GPU_link_changed(shi->emit) || ma->emit != 0.0f) {
|
|
|
|
if((ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL) {
|
|
|
|
GPU_link(mat, "shade_add", shi->emit, shi->vcol, &emit);
|
|
|
|
GPU_link(mat, "shade_mul", emit, shi->rgb, &shr->diff);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GPU_link(mat, "shade_mul_value", shi->emit, shi->rgb, &shr->diff);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GPU_link(mat, "set_rgb_zero", &shr->diff);
|
|
|
|
|
|
|
|
GPU_link(mat, "set_rgb_zero", &shr->spec);
|
|
|
|
|
|
|
|
material_lights(shi, shr);
|
|
|
|
|
|
|
|
shr->combined = shr->diff;
|
|
|
|
shr->alpha = shi->alpha;
|
|
|
|
|
|
|
|
if(world) {
|
2010-03-22 09:30:00 +00:00
|
|
|
/* exposure correction */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(world->exp!=0.0f || world->range!=1.0f) {
|
|
|
|
linfac= 1.0 + pow((2.0*world->exp + 0.5), -10);
|
2011-04-02 02:08:33 +00:00
|
|
|
logfac= log((linfac-1.0f)/linfac)/world->range;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&linfac), &ulinfac);
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&logfac), &ulogfac);
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_exposure_correct", shr->combined,
|
|
|
|
ulinfac, ulogfac, &shr->combined);
|
|
|
|
GPU_link(mat, "shade_exposure_correct", shr->spec,
|
|
|
|
ulinfac, ulogfac, &shr->spec);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ambient color */
|
|
|
|
if(world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) {
|
|
|
|
if(GPU_link_changed(shi->amb) || ma->amb != 0.0f)
|
|
|
|
GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb),
|
|
|
|
GPU_uniform(&world->ambr), &shr->combined);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined);
|
|
|
|
if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec);
|
|
|
|
|
|
|
|
if(GPU_link_changed(shi->spec) || ma->spec != 0.0f)
|
|
|
|
GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined);
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_link(mat, "mtex_alpha_to_col", shr->combined, shr->alpha, &shr->combined);
|
|
|
|
|
|
|
|
if(ma->shade_flag & MA_OBCOLOR)
|
|
|
|
GPU_link(mat, "shade_obcolor", shr->combined, GPU_builtin(GPU_OBCOLOR), &shr->combined);
|
|
|
|
|
|
|
|
if(world && (world->mode & WO_MIST) && !(ma->mode & MA_NOMIST)) {
|
|
|
|
misttype = world->mistype;
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_mist_factor", GPU_builtin(GPU_VIEW_POSITION),
|
|
|
|
GPU_uniform(&world->miststa), GPU_uniform(&world->mistdist),
|
|
|
|
GPU_uniform(&misttype), GPU_uniform(&world->misi), &mistfac);
|
|
|
|
|
|
|
|
GPU_link(mat, "mix_blend", mistfac, shr->combined,
|
|
|
|
GPU_uniform(&world->horr), &shr->combined);
|
|
|
|
}
|
|
|
|
|
2009-08-15 19:35:03 +00:00
|
|
|
if(!((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(world && (GPU_link_changed(shr->alpha) || ma->alpha != 1.0f))
|
|
|
|
GPU_link(mat, "shade_world_mix", GPU_uniform(&world->horr),
|
|
|
|
shr->combined, &shr->combined);
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_alpha_opaque", shr->combined, &shr->combined);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ma->shade_flag & MA_OBCOLOR) {
|
|
|
|
mat->obcolalpha = 1;
|
|
|
|
GPU_link(mat, "shade_alpha_obcolor", shr->combined, GPU_builtin(GPU_OBCOLOR), &shr->combined);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static GPUNodeLink *GPU_blender_material(GPUMaterial *mat, Material *ma)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
GPUShadeInput shi;
|
|
|
|
GPUShadeResult shr;
|
|
|
|
|
|
|
|
GPU_shadeinput_set(mat, ma, &shi);
|
|
|
|
GPU_shaderesult_set(&shi, &shr);
|
|
|
|
|
|
|
|
return shr.combined;
|
|
|
|
}
|
|
|
|
|
|
|
|
GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma)
|
|
|
|
{
|
|
|
|
GPUMaterial *mat;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
LinkData *link;
|
|
|
|
|
|
|
|
for(link=ma->gpumaterial.first; link; link=link->next)
|
|
|
|
if(((GPUMaterial*)link->data)->scene == scene)
|
|
|
|
return link->data;
|
|
|
|
|
|
|
|
mat = GPU_material_construct_begin(ma);
|
|
|
|
mat->scene = scene;
|
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ntreeGPUMaterialNodes(ma->nodetree, mat);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outlink = GPU_blender_material(mat, ma);
|
|
|
|
GPU_material_output_link(mat, outlink);
|
|
|
|
}
|
|
|
|
|
2011-07-28 14:28:27 +00:00
|
|
|
if(gpu_do_color_management(mat))
|
|
|
|
if(mat->outlink)
|
|
|
|
GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/*if(!GPU_material_construct_end(mat)) {
|
|
|
|
GPU_material_free(mat);
|
|
|
|
mat= NULL;
|
|
|
|
return 0;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
GPU_material_construct_end(mat);
|
|
|
|
|
|
|
|
link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
|
|
|
|
link->data = mat;
|
|
|
|
BLI_addtail(&ma->gpumaterial, link);
|
|
|
|
|
|
|
|
return mat;
|
|
|
|
}
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
void GPU_materials_free(void)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
Object *ob;
|
|
|
|
Material *ma;
|
|
|
|
extern Material defmaterial;
|
|
|
|
|
|
|
|
for(ma=G.main->mat.first; ma; ma=ma->id.next)
|
|
|
|
GPU_material_free(ma);
|
|
|
|
|
|
|
|
GPU_material_free(&defmaterial);
|
|
|
|
|
2009-06-13 16:49:30 +00:00
|
|
|
for(ob=G.main->object.first; ob; ob=ob->id.next)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_lamp_free(ob);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lamps and shadow buffers */
|
|
|
|
|
2010-07-27 11:10:34 +00:00
|
|
|
void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[][4])
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float mat[4][4];
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
lamp->lay = lay;
|
2010-07-27 11:10:34 +00:00
|
|
|
lamp->hide = hide;
|
2008-09-05 14:33:36 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(mat, obmat);
|
|
|
|
normalize_m4(mat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
VECCOPY(lamp->vec, mat[2]);
|
|
|
|
VECCOPY(lamp->co, mat[3]);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(lamp->obmat, mat);
|
|
|
|
invert_m4_m4(lamp->imat, mat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-05-13 06:42:15 +00:00
|
|
|
void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy)
|
|
|
|
{
|
2009-05-22 06:12:18 +00:00
|
|
|
lamp->energy = energy;
|
|
|
|
if(lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
|
|
|
|
|
|
|
|
lamp->col[0]= r* lamp->energy;
|
|
|
|
lamp->col[1]= g* lamp->energy;
|
|
|
|
lamp->col[2]= b* lamp->energy;
|
2009-05-13 06:42:15 +00:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp)
|
|
|
|
{
|
|
|
|
float temp, angle, pixsize, wsize;
|
|
|
|
|
|
|
|
lamp->scene = scene;
|
|
|
|
lamp->ob = ob;
|
|
|
|
lamp->par = par;
|
|
|
|
lamp->la = la;
|
|
|
|
|
|
|
|
/* add_render_lamp */
|
|
|
|
lamp->mode = la->mode;
|
|
|
|
lamp->type = la->type;
|
|
|
|
|
|
|
|
lamp->energy = la->energy;
|
|
|
|
if(lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
|
|
|
|
|
|
|
|
lamp->col[0]= la->r*lamp->energy;
|
|
|
|
lamp->col[1]= la->g*lamp->energy;
|
|
|
|
lamp->col[2]= la->b*lamp->energy;
|
|
|
|
|
2010-07-30 10:44:00 +00:00
|
|
|
GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), ob->obmat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
lamp->spotsi= la->spotsize;
|
|
|
|
if(lamp->mode & LA_HALO)
|
2011-04-02 02:08:33 +00:00
|
|
|
if(lamp->spotsi > 170.0f)
|
|
|
|
lamp->spotsi = 170.0f;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
lamp->spotsi= cos(M_PI*lamp->spotsi/360.0);
|
2011-04-02 02:08:33 +00:00
|
|
|
lamp->spotbl= (1.0f - lamp->spotsi)*la->spotblend;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
lamp->k= la->k;
|
|
|
|
|
|
|
|
lamp->dist= la->dist;
|
|
|
|
lamp->falloff_type= la->falloff_type;
|
|
|
|
lamp->att1= la->att1;
|
|
|
|
lamp->att2= la->att2;
|
|
|
|
lamp->curfalloff= la->curfalloff;
|
|
|
|
|
|
|
|
/* initshadowbuf */
|
|
|
|
lamp->bias = 0.02f*la->bias;
|
|
|
|
lamp->size = la->bufsize;
|
|
|
|
lamp->d= la->clipsta;
|
|
|
|
lamp->clipend= la->clipend;
|
|
|
|
|
|
|
|
/* arbitrary correction for the fact we do no soft transition */
|
|
|
|
lamp->bias *= 0.25f;
|
|
|
|
|
|
|
|
/* makeshadowbuf */
|
|
|
|
angle= saacos(lamp->spotsi);
|
|
|
|
temp= 0.5f*lamp->size*cos(angle)/sin(angle);
|
|
|
|
pixsize= (lamp->d)/temp;
|
|
|
|
wsize= pixsize*0.5f*lamp->size;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
perspective_m4( lamp->winmat,-wsize, wsize, -wsize, wsize, lamp->d, lamp->clipend);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gpu_lamp_shadow_free(GPULamp *lamp)
|
|
|
|
{
|
2008-10-12 13:32:28 +00:00
|
|
|
if(lamp->tex) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_texture_free(lamp->tex);
|
2008-10-12 13:32:28 +00:00
|
|
|
lamp->tex= NULL;
|
|
|
|
}
|
|
|
|
if(lamp->fb) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_framebuffer_free(lamp->fb);
|
2008-10-12 13:32:28 +00:00
|
|
|
lamp->fb= NULL;
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
|
|
|
|
{
|
|
|
|
Lamp *la;
|
|
|
|
GPULamp *lamp;
|
|
|
|
LinkData *link;
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
for(link=ob->gpulamp.first; link; link=link->next) {
|
|
|
|
lamp = (GPULamp*)link->data;
|
|
|
|
|
|
|
|
if(lamp->par == par && lamp->scene == scene)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return link->data;
|
2008-09-05 14:33:36 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
lamp = MEM_callocN(sizeof(GPULamp), "GPULamp");
|
|
|
|
|
|
|
|
link = MEM_callocN(sizeof(LinkData), "GPULampLink");
|
|
|
|
link->data = lamp;
|
|
|
|
BLI_addtail(&ob->gpulamp, link);
|
|
|
|
|
|
|
|
la = ob->data;
|
|
|
|
gpu_lamp_from_blender(scene, ob, par, la, lamp);
|
|
|
|
|
|
|
|
if(la->type==LA_SPOT && (la->mode & LA_SHAD_BUF)) {
|
|
|
|
/* opengl */
|
|
|
|
lamp->fb = GPU_framebuffer_create();
|
|
|
|
if(!lamp->fb) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
2011-03-06 23:12:12 +00:00
|
|
|
lamp->tex = GPU_texture_create_depth(lamp->size, lamp->size, NULL);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(!lamp->tex) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
2011-03-06 23:12:12 +00:00
|
|
|
if(!GPU_framebuffer_texture_attach(lamp->fb, lamp->tex, NULL)) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_framebuffer_restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_lamp_free(Object *ob)
|
|
|
|
{
|
|
|
|
GPULamp *lamp;
|
|
|
|
LinkData *link;
|
2008-09-05 14:33:36 +00:00
|
|
|
LinkData *nlink;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
Material *ma;
|
|
|
|
|
|
|
|
for(link=ob->gpulamp.first; link; link=link->next) {
|
|
|
|
lamp = link->data;
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
while(lamp->materials.first) {
|
|
|
|
nlink = lamp->materials.first;
|
|
|
|
ma = nlink->data;
|
|
|
|
BLI_freelinkN(&lamp->materials, nlink);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if(ma->gpumaterial.first)
|
|
|
|
GPU_material_free(ma);
|
|
|
|
}
|
|
|
|
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
|
|
|
|
MEM_freeN(lamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&ob->gpulamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_lamp_has_shadow_buffer(GPULamp *lamp)
|
|
|
|
{
|
2009-08-18 15:27:48 +00:00
|
|
|
return (!(lamp->scene->gm.flag & GAME_GLSL_NO_SHADOWS) &&
|
2010-03-22 09:30:00 +00:00
|
|
|
!(lamp->scene->gm.flag & GAME_GLSL_NO_LIGHTS) &&
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
lamp->tex && lamp->fb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize, float winmat[][4])
|
|
|
|
{
|
|
|
|
float rangemat[4][4], persmat[4][4];
|
|
|
|
|
|
|
|
/* initshadowbuf */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(lamp->viewmat, lamp->obmat);
|
|
|
|
normalize_v3(lamp->viewmat[0]);
|
|
|
|
normalize_v3(lamp->viewmat[1]);
|
|
|
|
normalize_v3(lamp->viewmat[2]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* makeshadowbuf */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_m4m4(persmat, lamp->viewmat, lamp->winmat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* opengl depth buffer is range 0.0..1.0 instead of -1.0..1.0 in blender */
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(rangemat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
rangemat[0][0] = 0.5f;
|
|
|
|
rangemat[1][1] = 0.5f;
|
|
|
|
rangemat[2][2] = 0.5f;
|
|
|
|
rangemat[3][0] = 0.5f;
|
|
|
|
rangemat[3][1] = 0.5f;
|
|
|
|
rangemat[3][2] = 0.5f;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_m4m4(lamp->persmat, persmat, rangemat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* opengl */
|
2009-10-28 18:03:04 +00:00
|
|
|
glDisable(GL_SCISSOR_TEST);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_framebuffer_texture_bind(lamp->fb, lamp->tex);
|
|
|
|
|
|
|
|
/* set matrices */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(viewmat, lamp->viewmat);
|
|
|
|
copy_m4_m4(winmat, lamp->winmat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
*winsize = lamp->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp)
|
|
|
|
{
|
|
|
|
GPU_framebuffer_texture_unbind(lamp->fb, lamp->tex);
|
|
|
|
GPU_framebuffer_restore();
|
2009-10-28 18:03:04 +00:00
|
|
|
glEnable(GL_SCISSOR_TEST);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_lamp_shadow_layer(GPULamp *lamp)
|
|
|
|
{
|
|
|
|
if(lamp->fb && lamp->tex && (lamp->mode & (LA_LAYER|LA_LAYER_SHADOW)))
|
|
|
|
return lamp->lay;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|