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
|
|
|
* ***** 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;
|
2011-12-09 23:26:06 +00:00
|
|
|
int obcolloc, obautobumpscaleloc;
|
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
|
|
|
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;
|
2012-07-23 20:24:35 +00:00
|
|
|
float dyndist, dynatt1, dynatt2;
|
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 dist, att1, att2;
|
2012-05-01 02:50:17 +00:00
|
|
|
float shadow_color[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
|
|
|
|
|
|
|
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;
|
2012-05-01 02:50:17 +00:00
|
|
|
GPUFrameBuffer *blurfb;
|
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
|
|
|
GPUTexture *tex;
|
2012-05-01 02:50:17 +00:00
|
|
|
GPUTexture *depthtex;
|
|
|
|
GPUTexture *blurtex;
|
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
|
|
|
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
|
|
|
};
|
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
/* Forward declaration so shade_light_textures() can use this, while still keeping the code somewhat organized */
|
|
|
|
static void texture_rgb_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
|
|
|
/* 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;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!pass) {
|
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
|
|
|
attribs->totlayer = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
shader= GPU_pass_shader(pass);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!shader) {
|
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
|
|
|
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 */
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (a=0, b=0; a<attribs->totlayer; a++) {
|
2012-01-11 12:33:51 +00:00
|
|
|
BLI_snprintf(name, sizeof(name), "att%d", attribs->layer[a].attribid);
|
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
|
|
|
attribs->layer[a].glindex = GPU_shader_get_attribute(shader, name);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (attribs->layer[a].glindex >= 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
|
|
|
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);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!material->pass)
|
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 0;
|
|
|
|
|
|
|
|
gpu_material_set_attrib_id(material);
|
|
|
|
|
|
|
|
shader = GPU_pass_shader(material->pass);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_VIEW_MATRIX)
|
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->viewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_VIEW_MATRIX));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_INVERSE_VIEW_MATRIX)
|
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->invviewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_VIEW_MATRIX));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_OBJECT_MATRIX)
|
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->obmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBJECT_MATRIX));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_INVERSE_OBJECT_MATRIX)
|
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->invobmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_OBJECT_MATRIX));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_OBCOLOR)
|
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->obcolloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBCOLOR));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_AUTO_BUMPSCALE)
|
2011-12-09 23:26:06 +00:00
|
|
|
material->obautobumpscaleloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_AUTO_BUMPSCALE));
|
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 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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (link=ma->gpumaterial.first; link; link=link->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
|
|
|
GPUMaterial *material = link->data;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->pass)
|
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_free(material->pass);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (nlink=material->lamps.first; nlink; nlink=nlink->next) {
|
2008-09-05 14:33:36 +00:00
|
|
|
GPULamp *lamp = nlink->data;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (mlink=lamp->materials.first; mlink; mlink=next) {
|
2008-09-05 14:33:36 +00:00
|
|
|
next = mlink->next;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mlink->data == ma)
|
2008-09-05 14:33:36 +00:00
|
|
|
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
|
|
|
{
|
2012-03-24 06:38:07 +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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
for (nlink=material->lamps.first; nlink; nlink=nlink->next) {
|
2008-09-05 14:33:36 +00:00
|
|
|
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
|
|
|
|
2012-03-24 06:38:07 +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;
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3(lamp->dyncol, lamp->col);
|
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 {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[4][4], float viewmat[4][4], float viewinv[4][4], float obcol[4], float autobumpscale)
|
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
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->pass) {
|
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
|
|
|
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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_VIEW_MATRIX) {
|
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->viewmatloc, 16, 1, (float*)viewmat);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_INVERSE_VIEW_MATRIX) {
|
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->invviewmatloc, 16, 1, (float*)viewinv);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_OBJECT_MATRIX) {
|
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->obmatloc, 16, 1, (float*)obmat);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_OBCOLOR) {
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v4_v4(col, obcol);
|
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
|
|
|
CLAMP(col[3], 0.0f, 1.0f);
|
|
|
|
GPU_shader_uniform_vector(shader, material->obcolloc, 4, 1, col);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_AUTO_BUMPSCALE) {
|
2011-12-09 23:26:06 +00:00
|
|
|
GPU_shader_uniform_vector(shader, material->obautobumpscaleloc, 1, 1, &autobumpscale);
|
|
|
|
}
|
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
|
|
|
/* update lamps */
|
2012-03-24 06:38:07 +00:00
|
|
|
for (nlink=material->lamps.first; nlink; nlink=nlink->next) {
|
2008-09-05 14:33:36 +00:00
|
|
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->dynproperty & DYN_LAMP_VEC) {
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3(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
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->dynproperty & DYN_LAMP_CO) {
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3(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
|
|
|
}
|
|
|
|
|
2012-05-01 20:08:23 +00:00
|
|
|
if (material->dynproperty & DYN_LAMP_IMAT) {
|
Math lib: matrix multiplication order fix for two functions that were
inconsistent with similar functions & math notation:
mul_m4_m4m4(R, B, A) => mult_m4_m4m4(R, A, B)
mul_m3_m3m4(R, B, A) => mult_m3_m3m4(R, A, B)
For branch maintainers, it should be relatively simple to fix things manually,
it's also possible run this script after merging to do automatic replacement:
http://www.pasteall.org/27459/python
2011-12-16 19:53:12 +00:00
|
|
|
mult_m4_m4m4(lamp->dynimat, lamp->imat, viewinv);
|
2012-05-01 20:08:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (material->dynproperty & DYN_LAMP_PERSMAT) {
|
2012-05-01 02:50:17 +00:00
|
|
|
if (!GPU_lamp_has_shadow_buffer(lamp)) /* The lamp matrices are already updated if we're using shadow buffers */
|
|
|
|
GPU_lamp_update_buffer_mats(lamp);
|
Math lib: matrix multiplication order fix for two functions that were
inconsistent with similar functions & math notation:
mul_m4_m4m4(R, B, A) => mult_m4_m4m4(R, A, B)
mul_m3_m3m4(R, B, A) => mult_m3_m3m4(R, A, B)
For branch maintainers, it should be relatively simple to fix things manually,
it's also possible run this script after merging to do automatic replacement:
http://www.pasteall.org/27459/python
2011-12-16 19:53:12 +00:00
|
|
|
mult_m4_m4m4(lamp->dynpersmat, lamp->persmat, viewinv);
|
2012-05-01 02:50:17 +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_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)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!material->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
|
|
|
material->outlink= link;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_enable_alpha(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
material->alpha= 1;
|
|
|
|
}
|
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GPUBlendMode GPU_material_alpha_blend(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
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->alpha || (material->obcolalpha && obcol[3] < 1.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
|
|
|
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 */
|
|
|
|
|
2012-09-09 11:04:49 +00:00
|
|
|
int GPU_material_do_color_management(GPUMaterial *mat)
|
2011-05-02 13:52:41 +00:00
|
|
|
{
|
2012-10-01 11:14:02 +00:00
|
|
|
if (!BKE_scene_check_color_management_enabled(mat->scene))
|
|
|
|
return FALSE;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
|
|
|
return !((mat->scene->gm.flag & GAME_GLSL_NO_COLOR_MANAGEMENT));
|
2011-05-02 13:52: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
|
|
|
static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **lv, GPUNodeLink **dist)
|
|
|
|
{
|
|
|
|
GPUNodeLink *visifac, *inpr;
|
|
|
|
|
|
|
|
/* from get_lamp_visibility */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->type==LA_SUN || lamp->type==LA_HEMI) {
|
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;
|
2011-09-09 11:55:38 +00:00
|
|
|
GPU_link(mat, "lamp_visibility_sun_hemi", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), lv, dist, &visifac);
|
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 visifac;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mat->dynproperty |= DYN_LAMP_CO;
|
2011-09-09 11:55:38 +00:00
|
|
|
GPU_link(mat, "lamp_visibility_other", GPU_builtin(GPU_VIEW_POSITION), GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob), lv, dist, &visifac);
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->type==LA_AREA)
|
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 visifac;
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (lamp->falloff_type) {
|
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
|
|
|
case LA_FALLOFF_CONSTANT:
|
|
|
|
break;
|
|
|
|
case LA_FALLOFF_INVLINEAR:
|
2012-07-23 20:24:35 +00:00
|
|
|
GPU_link(mat, "lamp_falloff_invlinear", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac);
|
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 LA_FALLOFF_INVSQUARE:
|
2012-07-23 20:24:35 +00:00
|
|
|
GPU_link(mat, "lamp_falloff_invsquare", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac);
|
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 LA_FALLOFF_SLIDERS:
|
2012-07-23 20:24:35 +00:00
|
|
|
GPU_link(mat, "lamp_falloff_sliders", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), GPU_dynamic_uniform(&lamp->att1, GPU_DYNAMIC_LAMP_ATT1, lamp->ob), GPU_dynamic_uniform(&lamp->att2, GPU_DYNAMIC_LAMP_ATT2, lamp->ob), *dist, &visifac);
|
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 LA_FALLOFF_CURVE:
|
|
|
|
{
|
|
|
|
float *array;
|
|
|
|
int size;
|
|
|
|
|
2012-08-21 14:43:51 +00:00
|
|
|
curvemapping_initialize(lamp->curfalloff);
|
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
|
|
|
curvemapping_table_RGBA(lamp->curfalloff, &array, &size);
|
2012-07-23 20:24:35 +00:00
|
|
|
GPU_link(mat, "lamp_falloff_curve", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), GPU_texture(size, array), *dist, &visifac);
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->mode & LA_SPHERE)
|
2012-07-23 20:24:35 +00:00
|
|
|
GPU_link(mat, "lamp_visibility_sphere", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, visifac, &visifac);
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->type == LA_SPOT) {
|
|
|
|
if (lamp->mode & LA_SQUARE) {
|
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_IMAT;
|
2011-09-09 11:55:38 +00:00
|
|
|
GPU_link(mat, "lamp_visibility_spot_square", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), GPU_dynamic_uniform((float*)lamp->dynimat, GPU_DYNAMIC_LAMP_DYNIMAT, lamp->ob), *lv, &inpr);
|
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 {
|
|
|
|
mat->dynproperty |= DYN_LAMP_VEC;
|
2011-09-09 11:55:38 +00:00
|
|
|
GPU_link(mat, "lamp_visibility_spot_circle", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), *lv, &inpr);
|
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
|
|
|
}
|
|
|
|
|
2012-07-23 20:24:35 +00:00
|
|
|
GPU_link(mat, "lamp_visibility_spot", GPU_dynamic_uniform(&lamp->spotsi, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob), GPU_dynamic_uniform(&lamp->spotbl, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob), inpr, visifac, &visifac);
|
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, "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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) {
|
|
|
|
if (ma->ramp_col) {
|
|
|
|
if (ma->rampin_col==MA_RAMP_IN_RESULT) {
|
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, "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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) &&
|
2012-05-20 19:49:27 +00:00
|
|
|
ma->ramp_col && (ma->mode & MA_RAMP_COL))
|
|
|
|
{
|
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_IN_RESULT is exceptional */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->rampin_col==MA_RAMP_IN_RESULT) {
|
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
|
|
|
addcol = shi->rgb;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* input */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (ma->rampin_col) {
|
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
|
|
|
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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) &&
|
2012-05-20 19:49:27 +00:00
|
|
|
ma->ramp_spec && ma->rampin_spec==MA_RAMP_IN_RESULT)
|
|
|
|
{
|
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, "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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->ramp_spec && (ma->rampin_spec!=MA_RAMP_IN_RESULT)) {
|
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
|
|
|
|
|
|
|
/* input */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (ma->rampin_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
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
static void shade_light_textures(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **rgb)
|
|
|
|
{
|
|
|
|
GPUNodeLink *tex_rgb;
|
|
|
|
MTex *mtex = NULL;
|
|
|
|
int i;
|
|
|
|
float one = 1.f;
|
|
|
|
|
|
|
|
for (i=0; i<MAX_MTEX; ++i) {
|
|
|
|
mtex = lamp->la->mtex[i];
|
|
|
|
|
|
|
|
if (mtex && mtex->tex->type & TEX_IMAGE && mtex->tex->ima) {
|
|
|
|
mat->dynproperty |= DYN_LAMP_PERSMAT;
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_light_texture",
|
|
|
|
GPU_builtin(GPU_VIEW_POSITION),
|
2012-08-30 17:42:04 +00:00
|
|
|
GPU_image(mtex->tex->ima, &mtex->tex->iuser, FALSE),
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
|
|
|
|
&tex_rgb);
|
|
|
|
texture_rgb_blend(mat, tex_rgb, *rgb, GPU_uniform(&one), GPU_uniform(&mtex->colfac), mtex->blendtype, rgb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2012-05-01 02:50:17 +00:00
|
|
|
GPUNodeLink *outcol, *specfac, *t, *shadfac= NULL, *lcol;
|
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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((lamp->mode & LA_ONLYSHADOW) && !(ma->mode & MA_SHADOW))
|
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;
|
|
|
|
|
|
|
|
vn= shi->vn;
|
|
|
|
view= shi->view;
|
|
|
|
|
|
|
|
visifac= lamp_get_visibility(mat, lamp, &lv, &dist);
|
|
|
|
|
2012-04-21 12:51:47 +00:00
|
|
|
/*if (ma->mode & MA_TANGENT_V)
|
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, "shade_tangent_v", lv, GPU_attribute(CD_TANGENT, ""), &vn);*/
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_inp", vn, lv, &inp);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->mode & LA_NO_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
|
|
|
GPU_link(mat, "shade_is_no_diffuse", &is);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (lamp->type == LA_HEMI) {
|
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, "shade_is_hemi", inp, &is);
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
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;
|
2011-09-09 11:55:38 +00:00
|
|
|
GPU_link(mat, "shade_inp_area", GPU_builtin(GPU_VIEW_POSITION), GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob), GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), vn, GPU_uniform((float*)area),
|
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_uniform(&areasize), GPU_uniform(&lamp->k), &inp);
|
|
|
|
}
|
|
|
|
|
|
|
|
is= inp; /* Lambert */
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) {
|
|
|
|
if (ma->diff_shader==MA_DIFF_ORENNAYAR)
|
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, "shade_diffuse_oren_nayer", inp, vn, lv, view, GPU_uniform(&ma->roughness), &is);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ma->diff_shader==MA_DIFF_TOON)
|
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, "shade_diffuse_toon", vn, lv, view, GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ma->diff_shader==MA_DIFF_MINNAERT)
|
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, "shade_diffuse_minnaert", inp, vn, view, GPU_uniform(&ma->darkness), &is);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ma->diff_shader==MA_DIFF_FRESNEL)
|
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, "shade_diffuse_fresnel", vn, lv, view, GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS))
|
|
|
|
if (ma->shade_flag & MA_CUBIC)
|
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, "shade_cubic", is, &is);
|
|
|
|
|
|
|
|
i = is;
|
|
|
|
GPU_link(mat, "shade_visifac", i, visifac, shi->refl, &i);
|
2012-05-01 02:50:17 +00:00
|
|
|
|
2012-05-20 21:19:55 +00:00
|
|
|
GPU_link(mat, "set_value", GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), &lcol);
|
2012-05-01 02:50:17 +00:00
|
|
|
shade_light_textures(mat, lamp, &lcol);
|
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
|
|
|
|
2012-03-09 18:28:30 +00:00
|
|
|
#if 0
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->mode & MA_TANGENT_VN)
|
2012-03-09 18:28:30 +00:00
|
|
|
GPU_link(mat, "shade_tangent_v_spec", GPU_attribute(CD_TANGENT, ""), &vn);
|
|
|
|
#endif
|
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
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
/* this replaces if (i > 0.0) conditional until that is supported */
|
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
|
|
|
// done in shade_visifac now, GPU_link(mat, "mtex_value_clamp_positive", i, &i);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((ma->mode & MA_SHADOW) && GPU_lamp_has_shadow_buffer(lamp)) {
|
|
|
|
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;
|
2012-05-01 02:50:17 +00:00
|
|
|
|
|
|
|
if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
|
|
|
|
GPU_link(mat, "test_shadowbuf_vsm",
|
|
|
|
GPU_builtin(GPU_VIEW_POSITION),
|
|
|
|
GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
|
|
|
|
GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
|
|
|
|
GPU_uniform(&lamp->bias), GPU_uniform(&lamp->la->bleedbias), inp, &shadfac);
|
2012-05-22 06:29:46 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_link(mat, "test_shadowbuf",
|
|
|
|
GPU_builtin(GPU_VIEW_POSITION),
|
|
|
|
GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
|
|
|
|
GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
|
|
|
|
GPU_uniform(&lamp->bias), inp, &shadfac);
|
|
|
|
}
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->mode & LA_ONLYSHADOW) {
|
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, "shade_only_shadow", i, shadfac,
|
2011-09-09 11:55:38 +00:00
|
|
|
GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob), &shadfac);
|
2008-09-05 15:08:01 +00:00
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
if (!(lamp->mode & LA_NO_DIFF)) {
|
|
|
|
GPU_link(mat, "mix_mult", shadfac, shr->diff,
|
|
|
|
GPU_uniform(lamp->shadow_color), &shr->diff);
|
|
|
|
}
|
2008-09-05 15:08:01 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(lamp->mode & LA_NO_SPEC))
|
2008-09-05 15:08:01 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +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);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GPU_link_changed(shi->refl) || ma->ref != 0.0f) {
|
|
|
|
if (!(lamp->mode & LA_NO_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
|
|
|
GPUNodeLink *rgb;
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_link(mat, "shade_mul_value", i, lcol, &rgb);
|
|
|
|
GPU_link(mat, "mtex_value_invert", shadfac, &shadfac);
|
|
|
|
GPU_link(mat, "mix_mult", shadfac, rgb, GPU_uniform(lamp->shadow_color), &rgb);
|
|
|
|
GPU_link(mat, "mtex_value_invert", shadfac, &shadfac);
|
2012-06-04 20:11:09 +00:00
|
|
|
add_to_diffuse(mat, ma, shi, is, rgb, &shr->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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-14 13:08:19 +00:00
|
|
|
if (mat->scene->gm.flag & GAME_GLSL_NO_SHADERS) {
|
|
|
|
/* pass */
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) &&
|
2012-05-20 19:49:27 +00:00
|
|
|
(GPU_link_changed(shi->spec) || ma->spec != 0.0f))
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->type == LA_HEMI) {
|
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, "shade_hemi_spec", vn, lv, view, GPU_uniform(&ma->spec), shi->har, visifac, &t);
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_link(mat, "shade_add_spec", t, lcol, 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 {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->spec_shader==MA_SPEC_PHONG)
|
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, "shade_phong_spec", vn, lv, view, shi->har, &specfac);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ma->spec_shader==MA_SPEC_COOKTORR)
|
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, "shade_cooktorr_spec", vn, lv, view, shi->har, &specfac);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ma->spec_shader==MA_SPEC_BLINN)
|
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, "shade_blinn_spec", vn, lv, view, GPU_uniform(&ma->refrac), shi->har, &specfac);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ma->spec_shader==MA_SPEC_WARDISO)
|
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, "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);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->type==LA_AREA)
|
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, "shade_spec_area_inp", specfac, inp, &specfac);
|
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_link(mat, "shade_spec_t", shadfac, shi->spec, visifac, specfac, &t);
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->mode & MA_RAMP_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
|
|
|
GPUNodeLink *spec;
|
|
|
|
do_specular_ramp(shi, specfac, t, &spec);
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_link(mat, "shade_add_spec", t, lcol, 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 {
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_link(mat, "shade_add_spec", t, lcol, 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;
|
|
|
|
|
2012-03-24 06:38:07 +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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob->type==OB_LAMP) {
|
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 = GPU_lamp_from_blender(shi->gpumat->scene, ob, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp)
|
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
|
|
|
shade_one_light(shi, shr, lamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ob->transflag & OB_DUPLI) {
|
|
|
|
DupliObject *dob;
|
2012-10-04 21:40:39 +00:00
|
|
|
ListBase *lb = object_duplilist(shi->gpumat->scene, ob, FALSE);
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (dob=lb->first; dob; dob=dob->next) {
|
2011-02-20 15:48:01 +00:00
|
|
|
Object *ob_iter = dob->ob;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob_iter->type==OB_LAMP) {
|
2011-02-20 15:48:01 +00:00
|
|
|
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);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp)
|
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
|
|
|
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)
|
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (blendtype) {
|
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
|
|
|
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
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (blendtype) {
|
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
|
|
|
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;
|
2012-05-19 13:28:19 +00:00
|
|
|
int init_done = FALSE, iBumpSpacePrev = 0; /* Not necessary, quiting gcc warning. */
|
2011-02-07 21:57:40 +00:00
|
|
|
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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
|
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
|
|
|
/* separate tex switching */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->septex & (1<<tex_nr)) 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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->mtex[tex_nr]) {
|
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
|
|
|
mtex= ma->mtex[tex_nr];
|
|
|
|
|
|
|
|
tex= mtex->tex;
|
2012-03-24 06:38:07 +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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->texco==TEXCO_ORCO)
|
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_orco;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mtex->texco==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
|
|
|
texco= texco_object;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mtex->texco==TEXCO_NORM)
|
2008-10-11 19:34:48 +00:00
|
|
|
texco= orn;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mtex->texco==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
|
|
|
texco= texco_object;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mtex->texco==TEXCO_GLOB)
|
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_global;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mtex->texco==TEXCO_REFL) {
|
2011-06-20 09:08:41 +00:00
|
|
|
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
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (mtex->texco==TEXCO_UV) {
|
|
|
|
if (1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 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, "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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->texco != TEXCO_UV)
|
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_2d_mapping", texco, &texco);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.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
|
|
|
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;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ofs[0] != 0.0f || ofs[1] != 0.0f || ofs[2] != 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
|
|
|
GPU_link(mat, "mtex_mapping_ofs", texco, GPU_uniform(ofs), &texco);
|
|
|
|
|
2008-09-05 20:34:35 +00:00
|
|
|
talpha = 0;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tex && tex->type == TEX_IMAGE && tex->ima) {
|
2012-08-30 17:42:04 +00:00
|
|
|
GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, FALSE), &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
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
talpha= 1;
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
2012-07-07 22:51:57 +00:00
|
|
|
else {
|
|
|
|
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
|
|
|
|
|
|
|
/* texture output */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
|
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_rgbtoint", trgb, &tin);
|
|
|
|
rgbnor -= TEX_RGB;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->texflag & MTEX_NEGATIVE) {
|
|
|
|
if (rgbnor & TEX_RGB)
|
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_rgb_invert", trgb, &trgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_value_invert", tin, &tin);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->texflag & MTEX_STENCIL) {
|
|
|
|
if (rgbnor & TEX_RGB)
|
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_rgb_stencil", stencil, trgb, &stencil, &trgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_value_stencil", stencil, tin, &stencil, &tin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mapping */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->mapto & (MAP_COL+MAP_COLSPEC)) {
|
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
|
|
|
/* stencil maps on the texture control slider, not texture intensity value */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((rgbnor & TEX_RGB)==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_rgb", GPU_uniform(&mtex->r), &tcol);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "set_rgba", trgb, &tcol);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->mapto & MAP_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, "set_value", stencil, &tin);
|
2012-03-24 06:38:07 +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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tex->type==TEX_IMAGE)
|
2012-09-09 11:04:49 +00:00
|
|
|
if (GPU_material_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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->mapto & MAP_COL) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *colfac;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->colfac == 1.0f) colfac = stencil;
|
2009-10-01 17:15:23 +00:00
|
|
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *colspecfac;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->colspecfac == 1.0f) colspecfac = stencil;
|
2009-10-01 17:15:23 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) {
|
|
|
|
if (tex->type==TEX_IMAGE) {
|
2011-08-22 19:57:54 +00:00
|
|
|
found_deriv_map = tex->imaflag & TEX_DERIVATIVEMAP;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tex->imaflag & TEX_NORMALMAP) {
|
2011-01-29 12:01:11 +00:00
|
|
|
/* normalmap image */
|
2012-08-30 17:42:04 +00:00
|
|
|
GPU_link(mat, "mtex_normal", texco, GPU_image(tex->ima, &tex->iuser, TRUE), &tnor);
|
2011-01-29 12:01:11 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->norfac < 0.0f)
|
2011-01-29 12:01:11 +00:00
|
|
|
GPU_link(mat, "mtex_negate_texnormal", tnor, &tnor);
|
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
if (mtex->normapspace == MTEX_NSPACE_TANGENT) {
|
|
|
|
if (iFirstTimeNMap != 0) {
|
2011-02-14 18:18:46 +00:00
|
|
|
// 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;
|
|
|
|
}
|
2012-03-07 04:53:43 +00:00
|
|
|
else { /* otherwise use accumulated perturbations */
|
2011-02-14 18:18:46 +00:00
|
|
|
GPU_link(mat, "mtex_nspace_tangent", GPU_attribute(CD_TANGENT, ""), shi->vn, tnor, &newnor);
|
|
|
|
}
|
|
|
|
}
|
2012-03-07 04:53:43 +00:00
|
|
|
else {
|
2011-01-29 12:01:11 +00:00
|
|
|
newnor = tnor;
|
2012-03-07 04:53:43 +00:00
|
|
|
}
|
2011-01-29 12:01:11 +00:00
|
|
|
|
2012-10-23 13:28:22 +00:00
|
|
|
norfac = min_ff(fabsf(mtex->norfac), 1.0f);
|
2011-01-30 16:24:23 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (norfac == 1.0f && !GPU_link_changed(stencil)) {
|
2011-01-30 16:24:23 +00:00
|
|
|
shi->vn = newnor;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tnorfac = GPU_uniform(&norfac);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GPU_link_changed(stencil))
|
2011-01-30 16:24:23 +00:00
|
|
|
GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac);
|
|
|
|
|
|
|
|
GPU_link(mat, "mtex_blend_normal", tnorfac, shi->vn, newnor, &shi->vn);
|
|
|
|
}
|
|
|
|
|
2012-03-07 04:53:43 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if ( (mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_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-12-09 23:26:06 +00:00
|
|
|
float hScale;
|
2011-09-22 05:36:52 +00:00
|
|
|
|
|
|
|
float imag_tspace_dimension_x = 1024.0f; // only used for texture space variant
|
|
|
|
float aspect = 1.0f;
|
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-12-09 23:26:06 +00:00
|
|
|
|
|
|
|
hScale = 0.1; // compatibility adjustment factor for all bumpspace types
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
|
2011-12-09 23:26:06 +00:00
|
|
|
hScale = 13.0f; // factor for scaling texspace bumps
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (found_deriv_map!=0)
|
2011-12-09 23:26:06 +00:00
|
|
|
hScale = 1.0f;
|
|
|
|
|
|
|
|
// resolve texture resolution
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) {
|
2012-11-15 15:59:58 +00:00
|
|
|
ImBuf *ibuf= BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL);
|
2011-12-09 23:26:06 +00:00
|
|
|
ima_x= 512.0f; ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf) {
|
2011-12-09 23:26:06 +00:00
|
|
|
ima_x= ibuf->x;
|
|
|
|
ima_y= ibuf->y;
|
|
|
|
aspect = ((float) ima_y) / ima_x;
|
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(tex->ima, ibuf, NULL);
|
2011-12-09 23:26:06 +00:00
|
|
|
}
|
2011-09-30 09:55:21 +00:00
|
|
|
|
|
|
|
// The negate on norfac is done because the
|
|
|
|
// normal in the renderer points inward which corresponds
|
|
|
|
// to inverting the bump map. Should this ever change
|
|
|
|
// this negate must be removed.
|
|
|
|
norfac = -hScale * mtex->norfac;
|
2012-03-07 04:53:43 +00:00
|
|
|
if (found_deriv_map) {
|
2012-01-03 22:27:30 +00:00
|
|
|
float fVirtDim = sqrtf(fabsf(ima_x*mtex->size[0]*ima_y*mtex->size[1]));
|
2012-01-03 22:18:52 +00:00
|
|
|
norfac /= MAX2(fVirtDim, FLT_EPSILON);
|
|
|
|
}
|
2011-12-09 23:26:06 +00:00
|
|
|
|
2011-01-30 16:24:23 +00:00
|
|
|
tnorfac = GPU_uniform(&norfac);
|
2011-12-09 23:26:06 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (found_deriv_map)
|
2011-12-09 23:26:06 +00:00
|
|
|
GPU_link(mat, "math_multiply", tnorfac, GPU_builtin(GPU_AUTO_BUMPSCALE), &tnorfac);
|
2011-01-30 16:24:23 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GPU_link_changed(stencil))
|
2011-01-30 16:24:23 +00:00
|
|
|
GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( !init_done ) {
|
2011-02-07 21:57:40 +00:00
|
|
|
// 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;
|
2012-05-19 13:28:19 +00:00
|
|
|
init_done = TRUE;
|
2011-02-07 21:57:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// find current bump space
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE )
|
2011-02-07 21:57:40 +00:00
|
|
|
iBumpSpace = 1;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
|
2011-02-07 21:57:40 +00:00
|
|
|
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
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( iBumpSpacePrev != iBumpSpace ) {
|
2011-02-07 21:57:40 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE )
|
2012-04-29 17:11:40 +00:00
|
|
|
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);
|
2011-02-07 21:57:40 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_init_texturespace",
|
|
|
|
surf_pos, vNorg,
|
|
|
|
fPrevMagnitude, vNacc,
|
|
|
|
&fPrevMagnitude, &vNacc,
|
|
|
|
&vR1, &vR2, &fDet);
|
2011-02-07 21:57:40 +00:00
|
|
|
|
|
|
|
else
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_init_viewspace",
|
|
|
|
surf_pos, vNorg,
|
|
|
|
fPrevMagnitude, vNacc,
|
|
|
|
&fPrevMagnitude, &vNacc,
|
|
|
|
&vR1, &vR2, &fDet);
|
2011-02-07 21:57:40 +00:00
|
|
|
|
|
|
|
iBumpSpacePrev = iBumpSpace;
|
|
|
|
}
|
|
|
|
|
2011-01-29 12:01:11 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (found_deriv_map) {
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_deriv",
|
2012-08-30 17:42:04 +00:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser, TRUE), GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac,
|
2012-04-29 17:11:40 +00:00
|
|
|
&dBs, &dBt );
|
2011-08-22 19:57:54 +00:00
|
|
|
}
|
2012-04-29 17:11:40 +00:00
|
|
|
else if ( mtex->texflag & MTEX_3TAP_BUMP)
|
|
|
|
GPU_link(mat, "mtex_bump_tap3",
|
2012-08-30 17:42:04 +00:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser, TRUE), tnorfac,
|
2012-04-29 17:11:40 +00:00
|
|
|
&dBs, &dBt );
|
|
|
|
else if ( mtex->texflag & MTEX_5TAP_BUMP)
|
|
|
|
GPU_link(mat, "mtex_bump_tap5",
|
2012-08-30 17:42:04 +00:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser, TRUE), tnorfac,
|
2012-04-29 17:11:40 +00:00
|
|
|
&dBs, &dBt );
|
2012-03-24 06:38:07 +00:00
|
|
|
else if ( mtex->texflag & MTEX_BICUBIC_BUMP ) {
|
|
|
|
if (GPU_bicubic_bump_support()) {
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_bicubic",
|
2012-08-30 17:42:04 +00:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser, TRUE), tnorfac,
|
2012-04-29 17:11:40 +00:00
|
|
|
&dBs, &dBt);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_tap5",
|
2012-08-30 17:42:04 +00:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser, TRUE), tnorfac,
|
2012-04-29 17:11:40 +00:00
|
|
|
&dBs, &dBt);
|
2011-12-15 13:58:09 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 12:01:11 +00:00
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
|
2011-09-22 05:36:52 +00:00
|
|
|
float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x;
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_apply_texspace",
|
|
|
|
fDet, dBs, dBt, vR1, vR2,
|
2012-08-30 17:42:04 +00:00
|
|
|
GPU_image(tex->ima, &tex->iuser, TRUE), texco,
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_uniform(&imag_tspace_dimension_x), GPU_uniform(&imag_tspace_dimension_y), vNacc,
|
|
|
|
&vNacc, &shi->vn );
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_apply",
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((mtex->mapto & MAP_VARS)) {
|
|
|
|
if (rgbnor & TEX_RGB) {
|
|
|
|
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);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->difffac == 1.0f) difffac = stencil;
|
2009-10-01 17:15:23 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-03-24 06:38:07 +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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->specfac == 1.0f) specfac = stencil;
|
2009-10-01 17:15:23 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-03-24 06:38:07 +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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->emitfac == 1.0f) emitfac = stencil;
|
2009-10-01 17:15:23 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-03-24 06:38:07 +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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->hardfac == 1.0f) hardfac = stencil;
|
2009-10-01 17:15:23 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->mapto & MAP_ALPHA) {
|
2009-10-01 17:15:23 +00:00
|
|
|
GPUNodeLink *alphafac;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->alphafac == 1.0f) alphafac = stencil;
|
2009-10-01 17:15:23 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-03-24 06:38:07 +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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex->ambfac == 1.0f) ambfac = stencil;
|
2009-10-01 17:15:23 +00:00
|
|
|
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;
|
2012-07-26 08:57:41 +00:00
|
|
|
float one = 1.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
|
|
|
|
|
|
|
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);
|
2012-07-26 08:57:41 +00:00
|
|
|
|
|
|
|
if (ma->mode & MA_TRANSP)
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&ma->alpha), &shi->alpha);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&one), &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, "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);
|
2012-09-09 11:04:49 +00:00
|
|
|
if (GPU_material_do_color_management(mat))
|
2011-05-02 13:52:41 +00:00
|
|
|
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));
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->mode & MA_VERTEXCOLP)
|
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
|
|
|
shi->rgb = shi->vcol;
|
|
|
|
|
|
|
|
do_material_tex(shi);
|
|
|
|
|
2012-03-24 06:38:07 +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);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((mat->scene->gm.flag & GAME_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) {
|
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);
|
2012-09-03 13:17:21 +00:00
|
|
|
GPU_link(mat, "set_value", shi->alpha, &shr->alpha);
|
|
|
|
shr->combined = shr->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
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GPU_link_changed(shi->emit) || ma->emit != 0.0f) {
|
|
|
|
if ((ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL) {
|
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, "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;
|
2012-09-03 13:17:21 +00:00
|
|
|
|
|
|
|
GPU_link(mat, "set_value", shi->alpha, &shr->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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (world) {
|
2010-03-22 09:30:00 +00:00
|
|
|
/* exposure correction */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (world->exp!=0.0f || world->range!=1.0f) {
|
2011-11-11 12:00:08 +00:00
|
|
|
linfac= 1.0f + powf((2.0f*world->exp + 0.5f), -10);
|
|
|
|
logfac= logf((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 */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) {
|
|
|
|
if (GPU_link_changed(shi->amb) || ma->amb != 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
|
|
|
GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb),
|
|
|
|
GPU_uniform(&world->ambr), &shr->combined);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined);
|
|
|
|
if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GPU_link_changed(shi->spec) || ma->spec != 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
|
|
|
GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined);
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_link(mat, "mtex_alpha_to_col", shr->combined, shr->alpha, &shr->combined);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->shade_flag & MA_OBCOLOR)
|
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, "shade_obcolor", shr->combined, GPU_builtin(GPU_OBCOLOR), &shr->combined);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (world && (world->mode & WO_MIST) && !(ma->mode & MA_NOMIST)) {
|
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
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))) {
|
|
|
|
if (world && (GPU_link_changed(shr->alpha) || ma->alpha != 1.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
|
|
|
GPU_link(mat, "shade_world_mix", GPU_uniform(&world->horr),
|
|
|
|
shr->combined, &shr->combined);
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_alpha_opaque", shr->combined, &shr->combined);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->shade_flag & MA_OBCOLOR) {
|
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->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;
|
|
|
|
}
|
|
|
|
|
2012-12-03 08:31:16 +00:00
|
|
|
static GPUNodeLink *gpu_material_diffuse_bsdf(GPUMaterial *mat, Material *ma)
|
|
|
|
{
|
|
|
|
static float roughness = 0.0f;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
|
|
|
|
GPU_link(mat, "node_bsdf_diffuse", GPU_uniform(&ma->r), GPU_uniform(&roughness), GPU_builtin(GPU_VIEW_NORMAL), &outlink);
|
|
|
|
|
|
|
|
return 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
|
|
|
GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma)
|
|
|
|
{
|
|
|
|
GPUMaterial *mat;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
LinkData *link;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (link=ma->gpumaterial.first; link; link=link->next)
|
|
|
|
if (((GPUMaterial*)link->data)->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;
|
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
/* allocate material */
|
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 = GPU_material_construct_begin(ma);
|
|
|
|
mat->scene = scene;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* create 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 {
|
2012-12-18 01:46:15 +00:00
|
|
|
if (BKE_scene_use_new_shading_nodes(scene)) {
|
2012-12-03 08:31:16 +00:00
|
|
|
/* create simple diffuse material instead of nodes */
|
|
|
|
outlink = gpu_material_diffuse_bsdf(mat, ma);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* create blender material */
|
|
|
|
outlink = GPU_blender_material(mat, 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
|
|
|
GPU_material_output_link(mat, outlink);
|
|
|
|
}
|
|
|
|
|
2012-09-09 11:04:49 +00:00
|
|
|
if (GPU_material_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
|
|
|
|
|
|
|
GPU_material_construct_end(mat);
|
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
/* note that even if building the shader fails in some way, we still keep
|
2012-03-09 18:28:30 +00:00
|
|
|
* it to avoid trying to compile again and again, and simple do not use
|
|
|
|
* the actual shader on drawing */
|
2011-11-08 13:07:16 +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
|
|
|
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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (ma=G.main->mat.first; ma; ma=ma->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_material_free(ma);
|
|
|
|
|
|
|
|
GPU_material_free(&defmaterial);
|
|
|
|
|
2012-03-24 06:38:07 +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 */
|
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[4][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
|
|
|
|
2011-11-07 01:38:32 +00:00
|
|
|
copy_v3_v3(lamp->vec, mat[2]);
|
|
|
|
copy_v3_v3(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;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
|
2009-05-22 06:12:18 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-07-23 20:24:35 +00:00
|
|
|
void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2)
|
|
|
|
{
|
|
|
|
lamp->dist = distance;
|
|
|
|
lamp->att1 = att1;
|
|
|
|
lamp->att2 = att2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend)
|
|
|
|
{
|
2012-11-03 18:23:30 +00:00
|
|
|
lamp->spotsi= cosf((float)M_PI * spotsize / 360.0f);
|
|
|
|
lamp->spotbl= (1.0f - lamp->spotsi) * spotblend;
|
2012-07-23 20:24:35 +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;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
|
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->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;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->mode & LA_HALO)
|
|
|
|
if (lamp->spotsi > 170.0f)
|
2011-04-02 02:08:33 +00:00
|
|
|
lamp->spotsi = 170.0f;
|
2011-11-11 12:00:08 +00:00
|
|
|
lamp->spotsi= cosf((float)M_PI*lamp->spotsi/360.0f);
|
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 */
|
2012-05-01 02:50:17 +00:00
|
|
|
if (lamp->type == LA_SUN) {
|
|
|
|
wsize = la->shadow_frustum_size;
|
2012-05-01 20:08:23 +00:00
|
|
|
orthographic_m4(lamp->winmat, -wsize, wsize, -wsize, wsize, lamp->d, lamp->clipend);
|
2012-05-01 02:50:17 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
angle= saacos(lamp->spotsi);
|
|
|
|
temp= 0.5f*lamp->size*cosf(angle)/sinf(angle);
|
|
|
|
pixsize= (lamp->d)/temp;
|
|
|
|
wsize= pixsize*0.5f*lamp->size;
|
|
|
|
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)
|
|
|
|
{
|
2012-03-24 06:38:07 +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;
|
|
|
|
}
|
2012-05-01 02:50:17 +00:00
|
|
|
if (lamp->depthtex) {
|
|
|
|
GPU_texture_free(lamp->depthtex);
|
|
|
|
lamp->depthtex= NULL;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
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;
|
|
|
|
}
|
2012-05-01 20:08:23 +00:00
|
|
|
if (lamp->blurtex) {
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_texture_free(lamp->blurtex);
|
|
|
|
lamp->blurtex= NULL;
|
|
|
|
}
|
2012-05-01 20:08:23 +00:00
|
|
|
if (lamp->blurfb) {
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_framebuffer_free(lamp->blurfb);
|
|
|
|
lamp->blurfb= 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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (link=ob->gpulamp.first; link; link=link->next) {
|
2008-09-05 14:33:36 +00:00
|
|
|
lamp = (GPULamp*)link->data;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
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);
|
|
|
|
|
2012-05-02 10:10:05 +00:00
|
|
|
if ((la->type==LA_SPOT && (la->mode & LA_SHAD_BUF)) || (la->type==LA_SUN && (la->mode & LA_SHAD_RAY))) {
|
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 */
|
|
|
|
lamp->fb = GPU_framebuffer_create();
|
2012-03-24 06:38:07 +00:00
|
|
|
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_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
|
|
|
|
/* Shadow depth map */
|
|
|
|
lamp->depthtex = GPU_texture_create_depth(lamp->size, lamp->size, NULL);
|
|
|
|
if (!lamp->depthtex) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GPU_framebuffer_texture_attach(lamp->fb, lamp->depthtex, NULL)) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Shadow color map */
|
|
|
|
lamp->tex = GPU_texture_create_vsm_shadow_map(lamp->size, NULL);
|
|
|
|
if (!lamp->tex) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GPU_framebuffer_texture_attach(lamp->fb, lamp->tex, NULL)) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FBO and texture for blurring */
|
|
|
|
lamp->blurfb = GPU_framebuffer_create();
|
|
|
|
if (!lamp->blurfb) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
lamp->blurtex = GPU_texture_create_vsm_shadow_map(lamp->size*0.5, NULL);
|
|
|
|
if (!lamp->blurtex) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GPU_framebuffer_texture_attach(lamp->blurfb, lamp->blurtex, NULL)) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
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
|
|
|
}
|
2012-05-01 02:50:17 +00:00
|
|
|
else {
|
|
|
|
lamp->tex = GPU_texture_create_depth(lamp->size, lamp->size, NULL);
|
2012-05-01 20:08:23 +00:00
|
|
|
if (!lamp->tex) {
|
2012-05-01 02:50:17 +00:00
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
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
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
if (!GPU_framebuffer_texture_attach(lamp->fb, lamp->tex, NULL)) {
|
|
|
|
gpu_lamp_shadow_free(lamp);
|
|
|
|
return lamp;
|
|
|
|
}
|
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_restore();
|
2012-05-01 02:50:17 +00:00
|
|
|
|
|
|
|
lamp->shadow_color[0] = la->shdwr;
|
|
|
|
lamp->shadow_color[1] = la->shdwg;
|
|
|
|
lamp->shadow_color[2] = la->shdwb;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lamp->shadow_color[0] = 1.0;
|
|
|
|
lamp->shadow_color[1] = 1.0;
|
|
|
|
lamp->shadow_color[2] = 1.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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (link=ob->gpulamp.first; link; link=link->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
|
|
|
lamp = link->data;
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
while (lamp->materials.first) {
|
2008-09-05 14:33:36 +00:00
|
|
|
nlink = lamp->materials.first;
|
|
|
|
ma = nlink->data;
|
|
|
|
BLI_freelinkN(&lamp->materials, nlink);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma->gpumaterial.first)
|
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_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);
|
|
|
|
}
|
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
void GPU_lamp_update_buffer_mats(GPULamp *lamp)
|
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 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 */
|
Math lib: matrix multiplication order fix for two functions that were
inconsistent with similar functions & math notation:
mul_m4_m4m4(R, B, A) => mult_m4_m4m4(R, A, B)
mul_m3_m3m4(R, B, A) => mult_m3_m3m4(R, A, B)
For branch maintainers, it should be relatively simple to fix things manually,
it's also possible run this script after merging to do automatic replacement:
http://www.pasteall.org/27459/python
2011-12-16 19:53:12 +00:00
|
|
|
mult_m4_m4m4(persmat, lamp->winmat, lamp->viewmat);
|
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;
|
|
|
|
|
Math lib: matrix multiplication order fix for two functions that were
inconsistent with similar functions & math notation:
mul_m4_m4m4(R, B, A) => mult_m4_m4m4(R, A, B)
mul_m3_m3m4(R, B, A) => mult_m3_m3m4(R, A, B)
For branch maintainers, it should be relatively simple to fix things manually,
it's also possible run this script after merging to do automatic replacement:
http://www.pasteall.org/27459/python
2011-12-16 19:53:12 +00:00
|
|
|
mult_m4_m4m4(lamp->persmat, rangemat, persmat);
|
2012-05-01 02:50:17 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[4][4], int *winsize, float winmat[4][4])
|
2012-05-01 02:50:17 +00:00
|
|
|
{
|
|
|
|
GPU_lamp_update_buffer_mats(lamp);
|
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);
|
2011-10-28 16:57:06 +00:00
|
|
|
GPU_framebuffer_texture_bind(lamp->fb, lamp->tex,
|
|
|
|
GPU_texture_opengl_width(lamp->tex), GPU_texture_opengl_height(lamp->tex));
|
2012-05-01 20:08:23 +00:00
|
|
|
if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE)
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_shader_bind(GPU_shader_get_builtin_shader(GPU_SHADER_VSM_STORE));
|
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
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2012-05-01 20:08:23 +00:00
|
|
|
if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_shader_unbind(GPU_shader_get_builtin_shader(GPU_SHADER_VSM_STORE));
|
|
|
|
GPU_framebuffer_blur(lamp->fb, lamp->tex, lamp->blurfb, lamp->blurtex);
|
|
|
|
}
|
|
|
|
|
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_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)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->fb && lamp->tex && (lamp->mode & (LA_LAYER|LA_LAYER_SHADOW)))
|
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 lamp->lay;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-09-09 11:55:38 +00:00
|
|
|
/* export the GLSL shader */
|
|
|
|
|
|
|
|
GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
|
|
|
|
{
|
|
|
|
static struct {
|
|
|
|
GPUBuiltin gputype;
|
|
|
|
GPUDynamicType dynamictype;
|
|
|
|
GPUDataType datatype;
|
2012-10-21 05:46:41 +00:00
|
|
|
} builtins[] = {
|
2011-09-09 11:55:38 +00:00
|
|
|
{ GPU_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_VIEWMAT, GPU_DATA_16F },
|
|
|
|
{ GPU_INVERSE_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_VIEWIMAT, GPU_DATA_16F },
|
|
|
|
{ GPU_OBJECT_MATRIX, GPU_DYNAMIC_OBJECT_MAT, GPU_DATA_16F },
|
|
|
|
{ GPU_INVERSE_OBJECT_MATRIX, GPU_DYNAMIC_OBJECT_IMAT, GPU_DATA_16F },
|
|
|
|
{ GPU_OBCOLOR, GPU_DYNAMIC_OBJECT_COLOR, GPU_DATA_4F },
|
2011-12-09 23:26:06 +00:00
|
|
|
{ GPU_AUTO_BUMPSCALE, GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE, GPU_DATA_1F },
|
2011-09-09 11:55:38 +00:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
GPUShaderExport *shader = NULL;
|
|
|
|
GPUPass *pass;
|
|
|
|
GPUInput *input;
|
|
|
|
GPUMaterial *mat;
|
|
|
|
GPUInputUniform *uniform;
|
|
|
|
GPUInputAttribute *attribute;
|
|
|
|
GLint lastbindcode;
|
|
|
|
int i, liblen, fraglen;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!GPU_glsl_support())
|
2011-09-09 11:55:38 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
mat = GPU_material_from_blender(scene, ma);
|
|
|
|
pass = (mat)? mat->pass: NULL;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pass && pass->fragmentcode && pass->vertexcode) {
|
2011-09-09 11:55:38 +00:00
|
|
|
shader = MEM_callocN(sizeof(GPUShaderExport), "GPUShaderExport");
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (input = pass->inputs.first; input; input = input->next) {
|
2011-09-09 11:55:38 +00:00
|
|
|
uniform = MEM_callocN(sizeof(GPUInputUniform), "GPUInputUniform");
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (input->ima) {
|
2011-09-09 11:55:38 +00:00
|
|
|
/* image sampler uniform */
|
|
|
|
uniform->type = GPU_DYNAMIC_SAMPLER_2DIMAGE;
|
|
|
|
uniform->datatype = GPU_DATA_1I;
|
|
|
|
uniform->image = input->ima;
|
|
|
|
uniform->texnumber = input->texid;
|
|
|
|
BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (input->tex) {
|
2011-09-09 11:55:38 +00:00
|
|
|
/* generated buffer */
|
|
|
|
uniform->texnumber = input->texid;
|
|
|
|
uniform->datatype = GPU_DATA_1I;
|
|
|
|
BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (input->textype) {
|
2011-09-09 11:55:38 +00:00
|
|
|
case GPU_SHADOW2D:
|
|
|
|
uniform->type = GPU_DYNAMIC_SAMPLER_2DSHADOW;
|
|
|
|
uniform->lamp = input->dynamicdata;
|
|
|
|
break;
|
|
|
|
case GPU_TEX2D:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GPU_texture_opengl_bindcode(input->tex)) {
|
2011-09-09 11:55:38 +00:00
|
|
|
uniform->type = GPU_DYNAMIC_SAMPLER_2DBUFFER;
|
|
|
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &lastbindcode);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(input->tex));
|
|
|
|
uniform->texsize = GPU_texture_opengl_width(input->tex) * GPU_texture_opengl_height(input->tex);
|
|
|
|
uniform->texpixels = MEM_mallocN(uniform->texsize*4, "RGBApixels");
|
|
|
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, uniform->texpixels);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, lastbindcode);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uniform->type = input->dynamictype;
|
|
|
|
BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (input->type) {
|
2011-09-09 11:55:38 +00:00
|
|
|
case 1:
|
|
|
|
uniform->datatype = GPU_DATA_1F;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
uniform->datatype = GPU_DATA_2F;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
uniform->datatype = GPU_DATA_3F;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
uniform->datatype = GPU_DATA_4F;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
uniform->datatype = GPU_DATA_9F;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
uniform->datatype = GPU_DATA_16F;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (uniform->type >= GPU_DYNAMIC_LAMP_FIRST && uniform->type <= GPU_DYNAMIC_LAMP_LAST)
|
2011-09-09 11:55:38 +00:00
|
|
|
uniform->lamp = input->dynamicdata;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (uniform->type != GPU_DYNAMIC_NONE)
|
2011-09-09 11:55:38 +00:00
|
|
|
BLI_addtail(&shader->uniforms, uniform);
|
|
|
|
else
|
|
|
|
MEM_freeN(uniform);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* process builtin uniform */
|
2012-03-24 06:38:07 +00:00
|
|
|
for (i=0; builtins[i].gputype; i++) {
|
|
|
|
if (mat->builtins & builtins[i].gputype) {
|
2011-09-09 11:55:38 +00:00
|
|
|
uniform = MEM_callocN(sizeof(GPUInputUniform), "GPUInputUniform");
|
|
|
|
uniform->type = builtins[i].dynamictype;
|
|
|
|
uniform->datatype = builtins[i].datatype;
|
|
|
|
BLI_strncpy(uniform->varname, GPU_builtin_name(builtins[i].gputype), sizeof(uniform->varname));
|
|
|
|
BLI_addtail(&shader->uniforms, uniform);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-21 14:14:58 +00:00
|
|
|
/* now link fragment shader with library shader */
|
|
|
|
/* TBD: remove the function that are not used in the main function */
|
2011-09-09 11:55:38 +00:00
|
|
|
liblen = (pass->libcode) ? strlen(pass->libcode) : 0;
|
|
|
|
fraglen = strlen(pass->fragmentcode);
|
|
|
|
shader->fragment = (char *)MEM_mallocN(liblen+fraglen+1, "GPUFragShader");
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pass->libcode)
|
2011-09-09 11:55:38 +00:00
|
|
|
memcpy(shader->fragment, pass->libcode, liblen);
|
|
|
|
memcpy(&shader->fragment[liblen], pass->fragmentcode, fraglen);
|
|
|
|
shader->fragment[liblen+fraglen] = 0;
|
|
|
|
|
|
|
|
// export the attribute
|
2012-03-24 06:38:07 +00:00
|
|
|
for (i=0; i<mat->attribs.totlayer; i++) {
|
2011-09-09 11:55:38 +00:00
|
|
|
attribute = MEM_callocN(sizeof(GPUInputAttribute), "GPUInputAttribute");
|
|
|
|
attribute->type = mat->attribs.layer[i].type;
|
|
|
|
attribute->number = mat->attribs.layer[i].glindex;
|
|
|
|
BLI_snprintf(attribute->varname, sizeof(attribute->varname), "att%d", mat->attribs.layer[i].attribid);
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (attribute->type) {
|
2011-09-09 11:55:38 +00:00
|
|
|
case CD_TANGENT:
|
|
|
|
attribute->datatype = GPU_DATA_4F;
|
|
|
|
break;
|
|
|
|
case CD_MTFACE:
|
|
|
|
attribute->datatype = GPU_DATA_2F;
|
|
|
|
attribute->name = mat->attribs.layer[i].name;
|
|
|
|
break;
|
|
|
|
case CD_MCOL:
|
|
|
|
attribute->datatype = GPU_DATA_4UB;
|
|
|
|
attribute->name = mat->attribs.layer[i].name;
|
|
|
|
break;
|
|
|
|
case CD_ORCO:
|
|
|
|
attribute->datatype = GPU_DATA_3F;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (attribute->datatype != GPU_DATA_NONE)
|
2011-09-09 11:55:38 +00:00
|
|
|
BLI_addtail(&shader->attributes, attribute);
|
|
|
|
else
|
|
|
|
MEM_freeN(attribute);
|
|
|
|
}
|
|
|
|
|
|
|
|
// export the vertex shader
|
|
|
|
shader->vertex = BLI_strdup(pass->vertexcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return shader;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_free_shader_export(GPUShaderExport *shader)
|
|
|
|
{
|
|
|
|
GPUInputUniform *uniform;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (shader == NULL)
|
2011-09-09 11:55:38 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (uniform = shader->uniforms.first; uniform; uniform=uniform->next)
|
|
|
|
if (uniform->texpixels)
|
2011-09-09 11:55:38 +00:00
|
|
|
MEM_freeN(uniform->texpixels);
|
|
|
|
|
|
|
|
BLI_freelistN(&shader->uniforms);
|
|
|
|
BLI_freelistN(&shader->attributes);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (shader->vertex)
|
2011-09-09 11:55:38 +00:00
|
|
|
MEM_freeN(shader->vertex);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (shader->fragment)
|
2011-09-09 11:55:38 +00:00
|
|
|
MEM_freeN(shader->fragment);
|
|
|
|
|
|
|
|
MEM_freeN(shader);
|
|
|
|
}
|
|
|
|
|