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
|
2014-01-19 23:14:24 +11:00
|
|
|
*
|
|
|
|
* Manages materials, lights and textures.
|
2011-02-27 20:25:53 +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
|
|
|
#include <math.h>
|
|
|
|
#include <string.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_global.h"
|
2011-01-29 16:13:15 +00:00
|
|
|
#include "BKE_image.h"
|
2017-10-16 17:15:03 -02:00
|
|
|
#include "BKE_layer.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"
|
2014-04-28 01:08:10 +09:00
|
|
|
#include "BKE_group.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"
|
2015-12-06 21:20:19 +01:00
|
|
|
#include "GPU_framebuffer.h"
|
2017-04-03 15:38:00 +02:00
|
|
|
#include "GPU_lamp.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_material.h"
|
2015-12-06 21:20:19 +01:00
|
|
|
#include "GPU_shader.h"
|
|
|
|
#include "GPU_texture.h"
|
2017-07-14 17:40:54 +02:00
|
|
|
#include "GPU_uniformbuffer.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_codegen.h"
|
2017-04-03 15:38:00 +02:00
|
|
|
#include "gpu_lamp_private.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
|
|
|
|
2016-06-09 05:37:46 +10:00
|
|
|
#ifdef WITH_OPENSUBDIV
|
|
|
|
# include "BKE_DerivedMesh.h"
|
|
|
|
#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
|
|
|
|
|
|
|
/* Structs */
|
|
|
|
|
|
|
|
typedef enum DynMatProperty {
|
|
|
|
DYN_LAMP_CO = 1,
|
|
|
|
DYN_LAMP_VEC = 2,
|
|
|
|
DYN_LAMP_IMAT = 4,
|
|
|
|
DYN_LAMP_PERSMAT = 8,
|
|
|
|
} DynMatProperty;
|
|
|
|
|
2015-03-23 22:32:49 +01:00
|
|
|
static struct GPUWorld {
|
|
|
|
float mistenabled;
|
|
|
|
float mistype;
|
|
|
|
float miststart;
|
|
|
|
float mistdistance;
|
|
|
|
float mistintensity;
|
|
|
|
float mistcol[4];
|
|
|
|
float horicol[3];
|
|
|
|
float ambcol[4];
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
float zencol[3];
|
2015-03-23 22:32:49 +01:00
|
|
|
} GPUWorld;
|
2014-11-24 17:18:56 +01: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
|
|
|
struct GPUMaterial {
|
2017-04-27 22:27:09 +02:00
|
|
|
Scene *scene; /* DEPRECATED was only usefull for 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
|
|
|
Material *ma;
|
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
/* material for mesh surface, worlds or something else.
|
|
|
|
* some code generation is done differently depending on the use case */
|
2017-04-27 22:27:09 +02:00
|
|
|
int type; /* DEPRECATED */
|
|
|
|
|
2017-06-28 10:50:33 +10:00
|
|
|
const void *engine_type; /* attached engine type */
|
2017-04-27 22:27:09 +02:00
|
|
|
int options; /* to identify shader variations (shadow, probe, world background...) */
|
2014-11-24 17:18:56 +01: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
|
|
|
/* for creating the material */
|
|
|
|
ListBase nodes;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
|
|
|
|
/* for binding the material */
|
|
|
|
GPUPass *pass;
|
|
|
|
GPUVertexAttribs attribs;
|
|
|
|
int builtins;
|
|
|
|
int alpha, obcolalpha;
|
|
|
|
int dynproperty;
|
|
|
|
|
|
|
|
/* for passing uniforms */
|
|
|
|
int viewmatloc, invviewmatloc;
|
|
|
|
int obmatloc, invobmatloc;
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
int localtoviewmatloc, invlocaltoviewmatloc;
|
2011-12-09 23:26:06 +00:00
|
|
|
int obcolloc, obautobumpscaleloc;
|
2015-02-02 14:25:44 +01:00
|
|
|
int cameratexcofacloc;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
int partscalarpropsloc;
|
|
|
|
int partcoloc;
|
|
|
|
int partvel;
|
|
|
|
int partangvel;
|
|
|
|
|
2017-04-14 18:13:44 +03:00
|
|
|
int objectinfoloc;
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
ListBase lamps;
|
2015-05-01 12:06:05 +02:00
|
|
|
bool bound;
|
2015-07-20 16:08:06 +02:00
|
|
|
|
|
|
|
bool is_opensubdiv;
|
2017-10-27 16:07:44 +02:00
|
|
|
|
|
|
|
/* XXX: Should be in Material. But it depends on the output node
|
|
|
|
* used and since the output selection is difference for GPUMaterial...
|
|
|
|
*/
|
|
|
|
int domain;
|
|
|
|
|
2017-07-14 17:40:54 +02:00
|
|
|
GPUUniformBuffer *ubo; /* UBOs for shader uniforms. */
|
2017-11-14 00:49:54 +01:00
|
|
|
GPUUniformBuffer *sss_profile; /* UBO containing SSS profile. */
|
|
|
|
float *sss_radii; /* UBO containing SSS profile. */
|
2017-11-14 02:17:34 +01:00
|
|
|
int sss_samples;
|
2017-11-16 21:28:40 +01:00
|
|
|
int *sss_falloff;
|
2017-11-14 00:49:54 +01:00
|
|
|
bool sss_dirty;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
};
|
|
|
|
|
2017-10-27 16:07:44 +02:00
|
|
|
enum {
|
|
|
|
GPU_DOMAIN_SURFACE = (1 << 0),
|
2017-11-14 00:49:54 +01:00
|
|
|
GPU_DOMAIN_VOLUME = (1 << 1),
|
|
|
|
GPU_DOMAIN_SSS = (1 << 2)
|
2017-10-27 16:07:44 +02: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 */
|
2016-01-10 07:12:10 +11:00
|
|
|
static void texture_rgb_blend(
|
|
|
|
GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg,
|
|
|
|
int blendtype, GPUNodeLink **in);
|
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
|
|
|
/* Functions */
|
|
|
|
|
|
|
|
static GPUMaterial *GPU_material_construct_begin(Material *ma)
|
|
|
|
{
|
|
|
|
GPUMaterial *material = MEM_callocN(sizeof(GPUMaterial), "GPUMaterial");
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
material->ma = 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 material;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gpu_material_set_attrib_id(GPUMaterial *material)
|
|
|
|
{
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUVertexAttribs *attribs = &material->attribs;
|
|
|
|
GPUPass *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;
|
|
|
|
}
|
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUShader *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 */
|
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
int b = 0;
|
|
|
|
for (int a = 0; a < attribs->totlayer; a++) {
|
|
|
|
char name[32];
|
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);
|
|
|
|
|
2016-05-31 14:39:49 +02:00
|
|
|
BLI_snprintf(name, sizeof(name), "att%d_info", attribs->layer[a].attribid);
|
|
|
|
attribs->layer[a].glinfoindoex = GPU_shader_get_uniform(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;
|
|
|
|
}
|
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
static int gpu_material_construct_end(GPUMaterial *material, const char *passname)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
if (material->outlink) {
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *outlink = 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->pass = GPU_generate_pass(&material->nodes, outlink,
|
2015-07-20 16:08:06 +02:00
|
|
|
&material->attribs, &material->builtins, material->type,
|
2016-02-02 12:48:18 +01:00
|
|
|
passname,
|
|
|
|
material->is_opensubdiv,
|
|
|
|
GPU_material_use_new_shading_nodes(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
|
|
|
|
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);
|
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUShader *shader = GPU_pass_shader(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
|
|
|
|
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));
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
if (material->builtins & GPU_LOC_TO_VIEW_MATRIX)
|
|
|
|
material->localtoviewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_LOC_TO_VIEW_MATRIX));
|
|
|
|
if (material->builtins & GPU_INVERSE_LOC_TO_VIEW_MATRIX)
|
|
|
|
material->invlocaltoviewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_LOC_TO_VIEW_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));
|
2015-02-02 14:25:44 +01:00
|
|
|
if (material->builtins & GPU_CAMERA_TEXCO_FACTORS)
|
|
|
|
material->cameratexcofacloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_CAMERA_TEXCO_FACTORS));
|
2016-12-28 17:30:58 +01:00
|
|
|
if (material->builtins & GPU_PARTICLE_SCALAR_PROPS)
|
|
|
|
material->partscalarpropsloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_PARTICLE_SCALAR_PROPS));
|
|
|
|
if (material->builtins & GPU_PARTICLE_LOCATION)
|
|
|
|
material->partcoloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_PARTICLE_LOCATION));
|
|
|
|
if (material->builtins & GPU_PARTICLE_VELOCITY)
|
|
|
|
material->partvel = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_PARTICLE_VELOCITY));
|
|
|
|
if (material->builtins & GPU_PARTICLE_ANG_VELOCITY)
|
|
|
|
material->partangvel = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_PARTICLE_ANG_VELOCITY));
|
2017-04-14 18:13:44 +03:00
|
|
|
if (material->builtins & GPU_OBJECT_INFO)
|
|
|
|
material->objectinfoloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBJECT_INFO));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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;
|
|
|
|
}
|
2016-07-27 10:59:09 +02:00
|
|
|
else {
|
|
|
|
GPU_pass_free_nodes(&material->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
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
void GPU_material_free(ListBase *gpumaterial)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2016-01-07 16:32:02 -05:00
|
|
|
for (LinkData *link = 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);
|
|
|
|
|
2017-07-14 17:40:54 +02:00
|
|
|
if (material->ubo != NULL) {
|
|
|
|
GPU_uniformbuffer_free(material->ubo);
|
|
|
|
}
|
|
|
|
|
2017-11-14 00:49:54 +01:00
|
|
|
if (material->sss_profile != NULL) {
|
|
|
|
GPU_uniformbuffer_free(material->sss_profile);
|
|
|
|
}
|
|
|
|
|
2008-09-05 14:33:36 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
BLI_freelistN(gpumaterial);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
void GPU_material_bind(
|
|
|
|
GPUMaterial *material, int oblay, int viewlay, double time, int mipmap,
|
|
|
|
float viewmat[4][4], float viewinv[4][4], float camerafactors[4], bool scenelock)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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) {
|
2013-04-04 03:55:43 +00:00
|
|
|
GPUShader *shader = GPU_pass_shader(material->pass);
|
2014-05-29 14:53:33 +09:00
|
|
|
SceneRenderLayer *srl = scenelock ? BLI_findlink(&material->scene->r.layers, material->scene->r.actlay) : NULL;
|
2014-04-28 01:08:10 +09:00
|
|
|
|
|
|
|
if (srl)
|
|
|
|
viewlay &= srl->lay;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* handle layer lamps */
|
2014-11-24 17:18:56 +01:00
|
|
|
if (material->type == GPU_MATERIAL_TYPE_MESH) {
|
2016-01-07 16:32:02 -05:00
|
|
|
for (LinkData *nlink = material->lamps.first; nlink; nlink = nlink->next) {
|
|
|
|
GPULamp *lamp = nlink->data;
|
2014-11-24 17:18:56 +01:00
|
|
|
|
2017-08-12 13:22:26 +02:00
|
|
|
if ((lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay)) &&
|
|
|
|
GPU_lamp_visible(lamp, srl, material->ma))
|
2016-01-10 07:12:10 +11:00
|
|
|
{
|
2014-11-24 17:18:56 +01:00
|
|
|
lamp->dynenergy = lamp->energy;
|
|
|
|
copy_v3_v3(lamp->dyncol, lamp->col);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lamp->dynenergy = 0.0f;
|
2015-03-23 15:29:42 -04:00
|
|
|
lamp->dyncol[0] = lamp->dyncol[1] = lamp->dyncol[2] = 0.0f;
|
2014-11-24 17:18:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (material->dynproperty & DYN_LAMP_VEC) {
|
|
|
|
copy_v3_v3(lamp->dynvec, lamp->vec);
|
|
|
|
normalize_v3(lamp->dynvec);
|
|
|
|
negate_v3(lamp->dynvec);
|
|
|
|
mul_mat3_m4_v3(viewmat, lamp->dynvec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (material->dynproperty & DYN_LAMP_CO) {
|
|
|
|
copy_v3_v3(lamp->dynco, lamp->co);
|
|
|
|
mul_m4_v3(viewmat, lamp->dynco);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (material->dynproperty & DYN_LAMP_IMAT) {
|
|
|
|
mul_m4_m4m4(lamp->dynimat, lamp->imat, viewinv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (material->dynproperty & DYN_LAMP_PERSMAT) {
|
2016-01-10 07:12:10 +11:00
|
|
|
/* The lamp matrices are already updated if we're using shadow buffers */
|
|
|
|
if (!GPU_lamp_has_shadow_buffer(lamp)) {
|
2014-11-24 17:18:56 +01:00
|
|
|
GPU_lamp_update_buffer_mats(lamp);
|
2016-01-10 07:12:10 +11:00
|
|
|
}
|
2014-11-24 17:18:56 +01:00
|
|
|
mul_m4_m4m4(lamp->dynpersmat, lamp->persmat, viewinv);
|
|
|
|
}
|
2013-04-04 03:55:43 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-24 17:18:56 +01:00
|
|
|
|
2013-05-22 20:18:17 +00:00
|
|
|
/* note material must be bound before setting uniforms */
|
|
|
|
GPU_pass_bind(material->pass, time, mipmap);
|
|
|
|
|
2013-04-04 03:55:43 +00:00
|
|
|
/* handle per material built-ins */
|
|
|
|
if (material->builtins & GPU_VIEW_MATRIX) {
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_shader_uniform_vector(shader, material->viewmatloc, 16, 1, (float *)viewmat);
|
2013-04-04 03:55:43 +00:00
|
|
|
}
|
|
|
|
if (material->builtins & GPU_INVERSE_VIEW_MATRIX) {
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_shader_uniform_vector(shader, material->invviewmatloc, 16, 1, (float *)viewinv);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2015-02-02 14:25:44 +01:00
|
|
|
if (material->builtins & GPU_CAMERA_TEXCO_FACTORS) {
|
|
|
|
if (camerafactors) {
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_shader_uniform_vector(shader, material->cameratexcofacloc, 4, 1, (float *)camerafactors);
|
2015-02-02 14:25:44 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* use default, no scaling no offset */
|
|
|
|
float borders[4] = {1.0f, 1.0f, 0.0f, 0.0f};
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_shader_uniform_vector(shader, material->cameratexcofacloc, 4, 1, (float *)borders);
|
2015-02-02 14:25:44 +01: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
|
|
|
|
2013-03-23 03:11:48 +00:00
|
|
|
GPU_pass_update_uniforms(material->pass);
|
2013-04-04 03:55:43 +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
|
|
|
material->bound = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-14 18:13:44 +03:00
|
|
|
GPUBuiltin GPU_get_material_builtins(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
return material->builtins;
|
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
void GPU_material_bind_uniforms(
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
GPUMaterial *material, float obmat[4][4], float viewmat[4][4], float obcol[4],
|
2017-04-14 18:13:44 +03:00
|
|
|
float autobumpscale, GPUParticleInfo *pi, float object_info[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
|
|
|
{
|
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);
|
|
|
|
float invmat[4][4], col[4];
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
float localtoviewmat[4][4];
|
|
|
|
float invlocaltoviewmat[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
|
|
|
|
2013-04-04 03:55:43 +00:00
|
|
|
/* handle per object builtins */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (material->builtins & GPU_OBJECT_MATRIX) {
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_shader_uniform_vector(shader, material->obmatloc, 16, 1, (float *)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
|
|
|
}
|
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);
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_shader_uniform_vector(shader, material->invobmatloc, 16, 1, (float *)invmat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
if (material->builtins & GPU_LOC_TO_VIEW_MATRIX) {
|
|
|
|
if (viewmat) {
|
|
|
|
mul_m4_m4m4(localtoviewmat, viewmat, obmat);
|
|
|
|
GPU_shader_uniform_vector(shader, material->localtoviewmatloc, 16, 1, (float *)localtoviewmat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (material->builtins & GPU_INVERSE_LOC_TO_VIEW_MATRIX) {
|
|
|
|
if (viewmat) {
|
|
|
|
mul_m4_m4m4(localtoviewmat, viewmat, obmat);
|
|
|
|
invert_m4_m4(invlocaltoviewmat, localtoviewmat);
|
2016-01-24 12:21:13 +11:00
|
|
|
GPU_shader_uniform_vector(shader, material->invlocaltoviewmatloc, 16, 1, (float *)invlocaltoviewmat);
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
}
|
|
|
|
}
|
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);
|
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
if (material->builtins & GPU_PARTICLE_SCALAR_PROPS) {
|
|
|
|
GPU_shader_uniform_vector(shader, material->partscalarpropsloc, 4, 1, pi->scalprops);
|
|
|
|
}
|
|
|
|
if (material->builtins & GPU_PARTICLE_LOCATION) {
|
|
|
|
GPU_shader_uniform_vector(shader, material->partcoloc, 3, 1, pi->location);
|
|
|
|
}
|
|
|
|
if (material->builtins & GPU_PARTICLE_VELOCITY) {
|
|
|
|
GPU_shader_uniform_vector(shader, material->partvel, 3, 1, pi->velocity);
|
|
|
|
}
|
|
|
|
if (material->builtins & GPU_PARTICLE_ANG_VELOCITY) {
|
|
|
|
GPU_shader_uniform_vector(shader, material->partangvel, 3, 1, pi->angular_velocity);
|
|
|
|
}
|
2017-04-14 18:13:44 +03:00
|
|
|
if (material->builtins & GPU_OBJECT_INFO) {
|
|
|
|
GPU_shader_uniform_vector(shader, material->objectinfoloc, 3, 1, object_info);
|
|
|
|
}
|
2015-07-14 18:48:54 +02: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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_unbind(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
if (material->pass) {
|
|
|
|
material->bound = 0;
|
|
|
|
GPU_pass_unbind(material->pass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-01 12:06:05 +02:00
|
|
|
bool GPU_material_bound(GPUMaterial *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
|
|
|
{
|
|
|
|
return material->bound;
|
|
|
|
}
|
|
|
|
|
2013-11-25 20:58:23 +09:00
|
|
|
Scene *GPU_material_scene(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
return material->scene;
|
|
|
|
}
|
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
GPUMatType GPU_Material_get_type(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
return material->type;
|
|
|
|
}
|
|
|
|
|
2017-04-27 22:27:09 +02:00
|
|
|
GPUPass *GPU_material_get_pass(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
return material->pass;
|
|
|
|
}
|
2014-11-24 17:18:56 +01:00
|
|
|
|
2017-07-14 17:40:54 +02:00
|
|
|
GPUUniformBuffer *GPU_material_get_uniform_buffer(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
return material->ubo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create dynamic UBO from parameters
|
|
|
|
* \param ListBase of BLI_genericNodeN(GPUInput)
|
|
|
|
*/
|
|
|
|
void GPU_material_create_uniform_buffer(GPUMaterial *material, ListBase *inputs)
|
|
|
|
{
|
|
|
|
material->ubo = GPU_uniformbuffer_dynamic_create(inputs, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_uniform_buffer_tag_dirty(ListBase *gpumaterials)
|
|
|
|
{
|
|
|
|
for (LinkData *link = gpumaterials->first; link; link = link->next) {
|
|
|
|
GPUMaterial *material = link->data;
|
|
|
|
if (material->ubo != NULL) {
|
|
|
|
GPU_uniformbuffer_tag_dirty(material->ubo);
|
|
|
|
}
|
2017-11-14 00:49:54 +01:00
|
|
|
if (material->sss_profile != NULL) {
|
|
|
|
material->sss_dirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Eevee Subsurface scattering. */
|
|
|
|
/* Based on Separable SSS. by Jorge Jimenez and Diego Gutierrez */
|
|
|
|
|
2017-11-14 02:17:34 +01:00
|
|
|
#define SSS_SAMPLES 65
|
2017-11-14 00:49:54 +01:00
|
|
|
#define SSS_EXPONENT 2.0f /* Importance sampling exponent */
|
|
|
|
|
|
|
|
typedef struct GPUSssKernelData {
|
|
|
|
float kernel[SSS_SAMPLES][4];
|
|
|
|
float radii_n[3], max_radius;
|
|
|
|
} GPUSssKernelData;
|
|
|
|
|
2017-11-14 02:17:34 +01:00
|
|
|
static void sss_calculate_offsets(GPUSssKernelData *kd, int count)
|
2017-11-14 00:49:54 +01:00
|
|
|
{
|
2017-11-14 02:17:34 +01:00
|
|
|
float step = 2.0f / (float)(count - 1);
|
|
|
|
for (int i = 0; i < count; i++) {
|
2017-11-14 00:49:54 +01:00
|
|
|
float o = ((float)i) * step - 1.0f;
|
|
|
|
float sign = (o < 0.0f) ? -1.0f : 1.0f;
|
|
|
|
float ofs = sign * fabsf(powf(o, SSS_EXPONENT));
|
|
|
|
kd->kernel[i][3] = ofs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static float error_function(float x) {
|
|
|
|
/* Approximation of the error function by Abramowitz and Stegun
|
|
|
|
* https://en.wikipedia.org/wiki/Error_function#Approximation_with_elementary_functions */
|
|
|
|
const float a1 = 0.254829592f;
|
|
|
|
const float a2 = -0.284496736f;
|
|
|
|
const float a3 = 1.421413741f;
|
|
|
|
const float a4 = -1.453152027f;
|
|
|
|
const float a5 = 1.061405429f;
|
|
|
|
const float p = 0.3275911f;
|
|
|
|
|
|
|
|
float sign = (x < 0.0f) ? -1.0f : 1.0f;
|
|
|
|
x = fabsf(x);
|
|
|
|
|
|
|
|
float t = 1.0f / (1.0f + p * x);
|
|
|
|
float y = 1.0f - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * expf(-(x * x));
|
|
|
|
|
|
|
|
return sign * y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static float gaussian_primitive(float x) {
|
|
|
|
const float sigma = 0.3f; /* Contained mostly between -1..1 */
|
|
|
|
return 0.5f * error_function(x / ((float)M_SQRT2 * sigma));
|
|
|
|
}
|
|
|
|
|
|
|
|
static float gaussian_integral(float x0, float x1) {
|
2017-11-16 21:28:40 +01:00
|
|
|
return gaussian_primitive(x1) - gaussian_primitive(x0);
|
2017-11-14 00:49:54 +01:00
|
|
|
}
|
|
|
|
|
2017-11-16 21:28:40 +01:00
|
|
|
/* Resolution for each sample of the precomputed kernel profile */
|
|
|
|
#define INTEGRAL_RESOLUTION 32
|
|
|
|
#define BURLEY_TRUNCATE 16.0f
|
|
|
|
|
|
|
|
static float burley_profile(float r, float d)
|
2017-11-14 00:49:54 +01:00
|
|
|
{
|
2017-11-16 21:28:40 +01:00
|
|
|
float exp_r_3_d = expf(-r / (3.0f * d));
|
|
|
|
float exp_r_d = exp_r_3_d * exp_r_3_d * exp_r_3_d;
|
|
|
|
return (exp_r_d + exp_r_3_d) / (4.0f * d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static float burley_integral(float x0, float x1, float d)
|
|
|
|
{
|
|
|
|
const float range = x1 - x0;
|
|
|
|
const float step = range / INTEGRAL_RESOLUTION;
|
|
|
|
float integral = 0.0f;
|
|
|
|
|
|
|
|
for(int i = 0; i < INTEGRAL_RESOLUTION; ++i) {
|
|
|
|
float x = x0 + range * ((float)i + 0.5f) / (float)INTEGRAL_RESOLUTION;
|
|
|
|
float y = burley_profile(fabsf(x), d);
|
|
|
|
integral += y * step;
|
|
|
|
}
|
|
|
|
|
|
|
|
return integral;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void compute_sss_kernel(GPUSssKernelData *kd, float *radii, int sample_ct, int falloff_type)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
/* Minimum radius */
|
|
|
|
kd->radii_n[i] = MAX2(radii[i], 1e-15f);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Christensen-Burley fitting */
|
|
|
|
float l[3], d[3];
|
|
|
|
|
|
|
|
if (falloff_type == SHD_SUBSURFACE_BURLEY) {
|
|
|
|
mul_v3_v3fl(l, kd->radii_n, 0.25f * M_1_PI);
|
|
|
|
const float A = 1.0f;
|
|
|
|
const float s = 1.9f - A + 3.5f * (A - 0.8f) * (A - 0.8f);
|
|
|
|
/* XXX 0.6f Out of nowhere to match cycles! Empirical! Can be tweak better. */
|
|
|
|
mul_v3_v3fl(d, l, 0.6f / s);
|
|
|
|
mul_v3_v3fl(kd->radii_n, d, BURLEY_TRUNCATE);
|
|
|
|
}
|
|
|
|
|
2017-11-14 00:49:54 +01:00
|
|
|
/* Normalize size */
|
|
|
|
kd->max_radius = MAX3(kd->radii_n[0], kd->radii_n[1], kd->radii_n[2]);
|
2017-11-16 21:28:40 +01:00
|
|
|
kd->radii_n[0] /= kd->max_radius;
|
|
|
|
kd->radii_n[1] /= kd->max_radius;
|
|
|
|
kd->radii_n[2] /= kd->max_radius;
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2017-11-16 21:28:40 +01:00
|
|
|
/* Compute samples locations on the 1d kernel [-1..1] */
|
2017-11-14 02:17:34 +01:00
|
|
|
sss_calculate_offsets(kd, sample_ct);
|
2017-11-14 00:49:54 +01:00
|
|
|
|
|
|
|
/* Weights sum for normalization */
|
|
|
|
float sum[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
2017-11-16 21:28:40 +01:00
|
|
|
/* Compute integral of each sample footprint */
|
2017-11-14 02:17:34 +01:00
|
|
|
for (int i = 0; i < sample_ct; i++) {
|
2017-11-14 00:49:54 +01:00
|
|
|
float x0, x1;
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
x0 = kd->kernel[0][3] - abs(kd->kernel[0][3] - kd->kernel[1][3]) / 2.0f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
x0 = (kd->kernel[i - 1][3] + kd->kernel[i][3]) / 2.0f;
|
|
|
|
}
|
|
|
|
|
2017-11-14 02:17:34 +01:00
|
|
|
if (i == sample_ct - 1) {
|
|
|
|
x1 = kd->kernel[sample_ct - 1][3] + abs(kd->kernel[sample_ct - 2][3] - kd->kernel[sample_ct - 1][3]) / 2.0f;
|
2017-11-14 00:49:54 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
x1 = (kd->kernel[i][3] + kd->kernel[i + 1][3]) / 2.0f;
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:28:40 +01:00
|
|
|
if (falloff_type == SHD_SUBSURFACE_BURLEY) {
|
|
|
|
x0 *= kd->max_radius;
|
|
|
|
x1 *= kd->max_radius;
|
|
|
|
kd->kernel[i][0] = burley_integral(x0, x1, d[0]);
|
|
|
|
kd->kernel[i][1] = burley_integral(x0, x1, d[1]);
|
|
|
|
kd->kernel[i][2] = burley_integral(x0, x1, d[2]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
kd->kernel[i][0] = gaussian_integral(x0 / kd->radii_n[0], x1 / kd->radii_n[0]);
|
|
|
|
kd->kernel[i][1] = gaussian_integral(x0 / kd->radii_n[1], x1 / kd->radii_n[1]);
|
|
|
|
kd->kernel[i][2] = gaussian_integral(x0 / kd->radii_n[2], x1 / kd->radii_n[2]);
|
|
|
|
}
|
2017-11-14 00:49:54 +01:00
|
|
|
|
|
|
|
sum[0] += kd->kernel[i][0];
|
|
|
|
sum[1] += kd->kernel[i][1];
|
|
|
|
sum[2] += kd->kernel[i][2];
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:28:40 +01:00
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
if (sum[i] > 0.0f) {
|
|
|
|
/* Normalize */
|
|
|
|
for (int j = 0; j < sample_ct; j++) {
|
|
|
|
kd->kernel[j][i] /= sum[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Avoid 0 kernel sum. */
|
|
|
|
kd->kernel[sample_ct / 2][i] = 1.0f;
|
|
|
|
}
|
2017-11-14 00:49:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Put center sample at the start of the array (to sample first) */
|
|
|
|
float tmpv[4];
|
2017-11-14 02:17:34 +01:00
|
|
|
copy_v4_v4(tmpv, kd->kernel[sample_ct / 2]);
|
|
|
|
for (int i = sample_ct / 2; i > 0; i--) {
|
2017-11-14 00:49:54 +01:00
|
|
|
copy_v4_v4(kd->kernel[i], kd->kernel[i - 1]);
|
|
|
|
}
|
|
|
|
copy_v4_v4(kd->kernel[0], tmpv);
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:28:40 +01:00
|
|
|
void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, int *falloff_type)
|
2017-11-14 00:49:54 +01:00
|
|
|
{
|
|
|
|
material->sss_radii = radii;
|
2017-11-16 21:28:40 +01:00
|
|
|
material->sss_falloff = falloff_type;
|
2017-11-14 00:49:54 +01:00
|
|
|
material->sss_dirty = true;
|
|
|
|
|
|
|
|
/* Update / Create UBO */
|
|
|
|
if (material->sss_profile == NULL) {
|
|
|
|
material->sss_profile = GPU_uniformbuffer_create(sizeof(GPUSssKernelData), NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-14 02:17:34 +01:00
|
|
|
#undef SSS_EXPONENT
|
|
|
|
#undef SSS_SAMPLES
|
|
|
|
|
|
|
|
struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_ct)
|
2017-11-14 00:49:54 +01:00
|
|
|
{
|
2017-11-14 02:17:34 +01:00
|
|
|
if (material->sss_radii == NULL)
|
|
|
|
return NULL;
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2017-11-14 02:17:34 +01:00
|
|
|
if (material->sss_dirty || (material->sss_samples != sample_ct)) {
|
|
|
|
GPUSssKernelData kd;
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2017-11-16 21:28:40 +01:00
|
|
|
compute_sss_kernel(&kd, material->sss_radii, sample_ct, *material->sss_falloff);
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2017-11-14 02:17:34 +01:00
|
|
|
/* Update / Create UBO */
|
|
|
|
GPU_uniformbuffer_update(material->sss_profile, &kd);
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2017-11-14 02:17:34 +01:00
|
|
|
material->sss_samples = sample_ct;
|
|
|
|
material->sss_dirty = false;
|
2017-07-14 17:40:54 +02:00
|
|
|
}
|
2017-11-14 00:49:54 +01:00
|
|
|
return material->sss_profile;
|
2017-07-14 17:40:54 +02: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
|
|
|
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)
|
2015-03-23 15:29:42 -04:00
|
|
|
material->outlink = link;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_enable_alpha(GPUMaterial *material)
|
|
|
|
{
|
2015-03-23 15:29:42 -04:00
|
|
|
material->alpha = 1;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
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 */
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
bool 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))
|
2014-04-01 11:34:00 +11:00
|
|
|
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
|
|
|
|
2015-03-23 23:56:46 +01:00
|
|
|
return true;
|
2011-05-02 13:52:41 +00:00
|
|
|
}
|
|
|
|
|
2014-06-30 16:24:03 +06:00
|
|
|
bool GPU_material_use_new_shading_nodes(GPUMaterial *mat)
|
|
|
|
{
|
|
|
|
return BKE_scene_use_new_shading_nodes(mat->scene);
|
|
|
|
}
|
|
|
|
|
2016-06-07 10:33:32 +03:00
|
|
|
bool GPU_material_use_world_space_shading(GPUMaterial *mat)
|
|
|
|
{
|
|
|
|
return BKE_scene_use_world_space_shading(mat->scene);
|
|
|
|
}
|
|
|
|
|
2017-10-27 16:07:44 +02:00
|
|
|
bool GPU_material_use_domain_surface(GPUMaterial *mat)
|
|
|
|
{
|
|
|
|
return (mat->domain & GPU_DOMAIN_SURFACE);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GPU_material_use_domain_volume(GPUMaterial *mat)
|
|
|
|
{
|
|
|
|
return (mat->domain & GPU_DOMAIN_VOLUME);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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)
|
|
|
|
{
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *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
|
|
|
|
|
|
|
/* from get_lamp_visibility */
|
2015-03-23 15:29:42 -04: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;
|
2016-01-10 07:12:10 +11: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;
|
2016-01-10 07:12:10 +11: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
|
|
|
|
2015-03-23 15:29:42 -04: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:
|
2016-01-10 07:12:10 +11: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:
|
2016-01-10 07:12:10 +11: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:
|
2016-01-10 07:12:10 +11: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;
|
2016-03-13 02:00:12 +01:00
|
|
|
case LA_FALLOFF_INVCOEFFICIENTS:
|
|
|
|
GPU_link(mat, "lamp_falloff_invcoefficients",
|
|
|
|
GPU_dynamic_uniform(&lamp->coeff_const, GPU_DYNAMIC_LAMP_COEFFCONST, lamp->ob),
|
|
|
|
GPU_dynamic_uniform(&lamp->coeff_lin, GPU_DYNAMIC_LAMP_COEFFLIN, lamp->ob),
|
|
|
|
GPU_dynamic_uniform(&lamp->coeff_quad, GPU_DYNAMIC_LAMP_COEFFQUAD, lamp->ob), *dist, &visifac);
|
|
|
|
break;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_CURVE:
|
2015-03-23 15:29:42 -04:00
|
|
|
{
|
|
|
|
float *array;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
curvemapping_initialize(lamp->curfalloff);
|
|
|
|
curvemapping_table_RGBA(lamp->curfalloff, &array, &size);
|
2016-01-10 07:12:10 +11: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;
|
2015-03-23 15:29:42 -04: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 (lamp->mode & LA_SPHERE)
|
2016-01-10 07:12:10 +11: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) {
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *inpr;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->mode & LA_SQUARE) {
|
2015-10-15 22:36:31 +11:00
|
|
|
mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_IMAT;
|
2016-01-10 07:12:10 +11: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),
|
2015-10-15 22:36:31 +11:00
|
|
|
GPU_dynamic_uniform((float *)lamp->spotvec, GPU_DYNAMIC_LAMP_SPOTSCALE, 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 {
|
2015-10-15 22:36:31 +11:00
|
|
|
mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_IMAT;
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "lamp_visibility_spot_circle",
|
|
|
|
GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob),
|
2015-10-15 22:36:31 +11:00
|
|
|
GPU_dynamic_uniform((float *)lamp->dynimat, GPU_DYNAMIC_LAMP_DYNIMAT, lamp->ob),
|
|
|
|
GPU_dynamic_uniform((float *)lamp->spotvec, GPU_DYNAMIC_LAMP_SPOTSCALE, 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
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "lamp_visibility_spot",
|
|
|
|
GPU_dynamic_uniform(&lamp->spotsi, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob),
|
2017-02-02 03:59:11 +01:00
|
|
|
GPU_dynamic_uniform(&lamp->spotbl, GPU_DYNAMIC_LAMP_SPOTBLEND, lamp->ob),
|
2016-01-10 07:12:10 +11:00
|
|
|
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)
|
|
|
|
{
|
2016-01-07 16:32:02 -05:00
|
|
|
float xsize = 0.5f * lar->area_size, ysize = 0.5f * lar->area_sizey;
|
2010-03-22 09:30:00 +00:00
|
|
|
|
|
|
|
/* make it smaller, so area light can be multisampled */
|
2016-01-07 16:32:02 -05:00
|
|
|
float multifac = 1.0f / sqrtf((float)lar->ray_totsamp);
|
2010-03-22 09:30:00 +00:00
|
|
|
xsize *= multifac;
|
|
|
|
ysize *= multifac;
|
|
|
|
|
|
|
|
/* corner vectors */
|
2015-03-23 15:29:42 -04:00
|
|
|
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];
|
2010-03-22 09:30:00 +00:00
|
|
|
|
|
|
|
/* corner vectors */
|
2015-03-23 15:29:42 -04:00
|
|
|
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];
|
2010-03-22 09:30:00 +00:00
|
|
|
|
|
|
|
/* corner vectors */
|
2015-03-23 15:29:42 -04:00
|
|
|
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];
|
2010-03-22 09:30:00 +00:00
|
|
|
|
|
|
|
/* corner vectors */
|
2015-03-23 15:29:42 -04:00
|
|
|
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];
|
2010-03-22 09:30:00 +00:00
|
|
|
/* only for correction button size, matrix size works on energy */
|
2015-03-23 15:29:42 -04:00
|
|
|
lar->areasize = lar->dist * lar->dist / (4.0f * 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
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
static void ramp_blend(
|
|
|
|
GPUMaterial *mat, GPUNodeLink *fac, GPUNodeLink *col1, GPUNodeLink *col2, int type,
|
|
|
|
GPUNodeLink **r_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
|
|
|
{
|
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
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, names[type], fac, col1, col2, r_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
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
static void do_colorband_blend(
|
|
|
|
GPUMaterial *mat, ColorBand *coba, GPUNodeLink *fac, float rampfac, int type,
|
|
|
|
GPUNodeLink *incol, GPUNodeLink **r_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
|
|
|
{
|
|
|
|
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 */
|
2016-01-10 07:12:10 +11:00
|
|
|
ramp_blend(mat, fac, incol, col, type, r_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
|
|
|
}
|
|
|
|
|
|
|
|
static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff)
|
|
|
|
{
|
2015-03-23 15:29:42 -04:00
|
|
|
Material *ma = shi->mat;
|
|
|
|
GPUMaterial *mat = shi->gpumat;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_RAMPS)) {
|
|
|
|
if (ma->ramp_col) {
|
2016-01-10 07:12:10 +11:00
|
|
|
if (ma->rampin_col == MA_RAMP_IN_RESULT) {
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *fac;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
static void add_to_diffuse(
|
|
|
|
GPUMaterial *mat, Material *ma, GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *rgb,
|
|
|
|
GPUNodeLink **r_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 *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 */
|
2016-01-10 07:12:10 +11: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) {
|
2015-03-23 15:29:42 -04:00
|
|
|
case MA_RAMP_IN_ENERGY:
|
|
|
|
GPU_link(mat, "ramp_rgbtobw", rgb, &fac);
|
|
|
|
break;
|
|
|
|
case MA_RAMP_IN_SHADER:
|
2016-01-10 07:12:10 +11:00
|
|
|
fac = is;
|
2015-03-23 15:29:42 -04:00
|
|
|
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;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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 */
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "shade_madd", *r_diff, rgb, addcol, r_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)
|
|
|
|
{
|
2015-03-23 15:29:42 -04:00
|
|
|
Material *ma = shi->mat;
|
|
|
|
GPUMaterial *mat = shi->gpumat;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_RAMPS) &&
|
2015-03-23 15:29:42 -04:00
|
|
|
ma->ramp_spec && ma->rampin_spec == MA_RAMP_IN_RESULT)
|
2012-05-20 19:49:27 +00:00
|
|
|
{
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *fac;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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)
|
|
|
|
{
|
2015-03-23 15:29:42 -04:00
|
|
|
Material *ma = shi->mat;
|
|
|
|
GPUMaterial *mat = shi->gpumat;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 *fac, *tmp;
|
|
|
|
|
|
|
|
*spec = shi->specrgb;
|
|
|
|
|
|
|
|
/* MA_RAMP_IN_RESULT is exception */
|
2015-03-23 15:29:42 -04: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) {
|
2015-03-23 15:29:42 -04: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;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2016-01-07 16:32:02 -05:00
|
|
|
for (int i = 0; i < MAX_MTEX; ++i) {
|
|
|
|
MTex *mtex = lamp->la->mtex[i];
|
2012-05-01 02:50:17 +00:00
|
|
|
|
2016-09-30 07:40:17 +02:00
|
|
|
if (mtex && mtex->tex && (mtex->tex->type & TEX_IMAGE) && mtex->tex->ima) {
|
2012-05-01 02:50:17 +00:00
|
|
|
mat->dynproperty |= DYN_LAMP_PERSMAT;
|
|
|
|
|
2016-01-08 16:42:47 +11:00
|
|
|
float one = 1.0f;
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *tex_rgb;
|
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
GPU_link(mat, "shade_light_texture",
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_builtin(GPU_VIEW_POSITION),
|
|
|
|
GPU_image(mtex->tex->ima, &mtex->tex->iuser, false),
|
|
|
|
GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
|
|
|
|
&tex_rgb);
|
2015-03-23 15:29:42 -04:00
|
|
|
texture_rgb_blend(mat, tex_rgb, *rgb, GPU_uniform(&one), GPU_uniform(&mtex->colfac), mtex->blendtype, rgb);
|
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
|
|
|
static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *lamp)
|
|
|
|
{
|
2015-03-23 15:29:42 -04:00
|
|
|
Material *ma = shi->mat;
|
|
|
|
GPUMaterial *mat = shi->gpumat;
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *lv, *dist, *is, *inp, *i;
|
2015-03-23 15:29:42 -04:00
|
|
|
GPUNodeLink *outcol, *specfac, *t, *shadfac = NULL, *lcol;
|
2016-01-08 16:42:47 +11: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
|
|
|
|
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;
|
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *vn = shi->vn;
|
|
|
|
GPUNodeLink *view = shi->view;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUNodeLink *visifac = lamp_get_visibility(mat, lamp, &lv, &dist);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
#if 0
|
|
|
|
if (ma->mode & MA_TANGENT_V)
|
|
|
|
GPU_link(mat, "shade_tangent_v", lv, 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
|
|
|
|
|
|
|
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) {
|
2015-03-23 15:29:42 -04: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
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_CO;
|
|
|
|
GPU_link(mat, "shade_inp_area",
|
|
|
|
GPU_builtin(GPU_VIEW_POSITION),
|
|
|
|
GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob),
|
|
|
|
GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), vn,
|
|
|
|
GPU_uniform((float *)area),
|
|
|
|
GPU_uniform(&areasize),
|
|
|
|
GPU_uniform(&lamp->k), &inp);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
is = inp; /* Lambert */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_SHADERS)) {
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ma->diff_shader == MA_DIFF_ORENNAYAR)
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view,
|
|
|
|
GPU_uniform(&ma->roughness), &is);
|
2015-03-23 15:29:42 -04:00
|
|
|
else if (ma->diff_shader == MA_DIFF_TOON)
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "shade_diffuse_toon", vn, lv, view,
|
|
|
|
GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
|
2015-03-23 15:29:42 -04:00
|
|
|
else if (ma->diff_shader == MA_DIFF_MINNAERT)
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "shade_diffuse_minnaert", inp, vn, view,
|
|
|
|
GPU_uniform(&ma->darkness), &is);
|
2015-03-23 15:29:42 -04:00
|
|
|
else if (ma->diff_shader == MA_DIFF_FRESNEL)
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "shade_diffuse_fresnel", vn, lv, view,
|
|
|
|
GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_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
|
|
|
|
2014-10-07 11:12:00 +02:00
|
|
|
GPU_link(mat, "set_rgb", 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);
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "shade_mul_value_v3",
|
|
|
|
GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob), lcol, &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 */
|
2015-03-23 15:29:42 -04:00
|
|
|
/* done in shade_visifac now, GPU_link(mat, "mtex_value_clamp_positive", i, &i); */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_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",
|
2016-01-10 07:12:10 +11:00
|
|
|
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",
|
2016-01-10 07:12:10 +11:00
|
|
|
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);
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lamp->mode & LA_ONLYSHADOW) {
|
2014-05-30 16:57:15 +09:00
|
|
|
GPUNodeLink *shadrgb;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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,
|
2014-05-30 16:57:15 +09:00
|
|
|
GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob),
|
|
|
|
GPU_uniform(lamp->shadow_color), &shadrgb);
|
2008-09-05 15:08:01 +00:00
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
if (!(lamp->mode & LA_NO_DIFF)) {
|
2014-05-30 16:57:15 +09:00
|
|
|
GPU_link(mat, "shade_only_shadow_diffuse", shadrgb, shi->rgb,
|
2016-01-10 07:12:10 +11:00
|
|
|
shr->diff, &shr->diff);
|
2012-05-01 02:50:17 +00:00
|
|
|
}
|
2008-09-05 15:08:01 +00:00
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
if (!(lamp->mode & LA_NO_SPEC)) {
|
2014-05-30 16:57:15 +09:00
|
|
|
GPU_link(mat, "shade_only_shadow_specular", shadrgb, shi->specrgb,
|
2016-01-10 07:12:10 +11:00
|
|
|
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);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 {
|
2016-01-10 07:12:10 +11: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);
|
2016-01-10 07:12:10 +11: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);
|
2016-01-10 07:12:10 +11:00
|
|
|
}
|
|
|
|
else if (ma->spec_shader == MA_SPEC_BLINN) {
|
|
|
|
GPU_link(mat, "shade_blinn_spec", vn, lv, view,
|
|
|
|
GPU_uniform(&ma->refrac), shi->har, &specfac);
|
|
|
|
}
|
|
|
|
else if (ma->spec_shader == MA_SPEC_WARDISO) {
|
|
|
|
GPU_link(mat, "shade_wardiso_spec", vn, lv, view,
|
|
|
|
GPU_uniform(&ma->rms), &specfac);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "shade_toon_spec", vn, lv, view,
|
|
|
|
GPU_uniform(&ma->param[2]), GPU_uniform(&ma->param[3]), &specfac);
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-03-23 15:29:42 -04: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);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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)
|
|
|
|
{
|
2017-02-15 14:40:41 +01:00
|
|
|
Base *base;
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (SETLOOPER(shi->gpumat->scene, sce_iter, base)) {
|
2016-01-07 16:32:02 -05:00
|
|
|
Object *ob = base->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
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ob->type == OB_LAMP) {
|
2016-01-07 16:32:02 -05:00
|
|
|
GPULamp *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) {
|
2013-12-26 17:24:42 +06:00
|
|
|
ListBase *lb = object_duplilist(G.main->eval_ctx, shi->gpumat->scene, ob);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
for (DupliObject *dob = lb->first; dob; dob = dob->next) {
|
2011-02-20 15:48:01 +00:00
|
|
|
Object *ob_iter = dob->ob;
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ob_iter->type == OB_LAMP) {
|
2014-01-23 10:20:42 +01:00
|
|
|
float omat[4][4];
|
|
|
|
copy_m4_m4(omat, ob_iter->obmat);
|
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
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
GPULamp *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);
|
2014-01-23 10:20:42 +01:00
|
|
|
|
|
|
|
copy_m4_m4(ob_iter->obmat, omat);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free_object_duplilist(lb);
|
|
|
|
}
|
|
|
|
}
|
2014-05-30 16:57:15 +09:00
|
|
|
|
|
|
|
/* prevent only shadow lamps from producing negative colors.*/
|
|
|
|
GPU_link(shi->gpumat, "shade_clamp_positive", shr->spec, &shr->spec);
|
|
|
|
GPU_link(shi->gpumat, "shade_clamp_positive", shr->diff, &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
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
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
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (blendtype) {
|
2016-01-10 07:12:10 +11: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;
|
|
|
|
case MTEX_SOFT_LIGHT:
|
|
|
|
GPU_link(mat, "mtex_rgb_soft", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_LIN_LIGHT:
|
|
|
|
GPU_link(mat, "mtex_rgb_linear", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GPU_link(mat, "set_rgb_zero", &in);
|
|
|
|
break;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11: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) {
|
2016-01-10 07:12:10 +11:00
|
|
|
case MTEX_BLEND:
|
|
|
|
GPU_link(mat, "mtex_value_blend", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_MUL:
|
|
|
|
GPU_link(mat, "mtex_value_mul", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_SCREEN:
|
|
|
|
GPU_link(mat, "mtex_value_screen", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_SUB:
|
|
|
|
GPU_link(mat, "mtex_value_sub", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_ADD:
|
|
|
|
GPU_link(mat, "mtex_value_add", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_DIV:
|
|
|
|
GPU_link(mat, "mtex_value_div", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_DIFF:
|
|
|
|
GPU_link(mat, "mtex_value_diff", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_DARK:
|
|
|
|
GPU_link(mat, "mtex_value_dark", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
case MTEX_LIGHT:
|
|
|
|
GPU_link(mat, "mtex_value_light", out, tex, fact, facg, in);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GPU_link(mat, "set_value_zero", &in);
|
|
|
|
break;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 do_material_tex(GPUShadeInput *shi)
|
|
|
|
{
|
2015-03-23 15:29:42 -04:00
|
|
|
Material *ma = shi->mat;
|
|
|
|
GPUMaterial *mat = shi->gpumat;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 *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;
|
2016-01-08 16:42:47 +11:00
|
|
|
float one = 1.0f;
|
2016-01-07 16:32:02 -05:00
|
|
|
int rgbnor, talpha;
|
2014-04-01 11:34:00 +11:00
|
|
|
bool init_done = false;
|
2015-03-23 15:29:42 -04:00
|
|
|
int iBumpSpacePrev = 0; /* Not necessary, quieting gcc warning. */
|
2011-02-07 21:57:40 +00:00
|
|
|
GPUNodeLink *vNorg, *vNacc, *fPrevMagnitude;
|
2015-03-23 15:29:42 -04:00
|
|
|
int iFirstTimeNMap = 1;
|
2016-01-07 16:32:02 -05:00
|
|
|
bool found_deriv_map = 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
|
|
|
|
|
|
|
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);
|
2015-03-23 15:29:42 -04:00
|
|
|
#if 0
|
|
|
|
GPU_link(mat, "texco_tangent", GPU_attribute(CD_TANGENT, ""), &texco_tangent);
|
|
|
|
#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
|
|
|
GPU_link(mat, "texco_global", GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
|
|
|
|
GPU_builtin(GPU_VIEW_POSITION), &texco_global);
|
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
orn = texco_norm;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* go over texture slots */
|
2016-01-07 16:32:02 -05:00
|
|
|
for (int 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 */
|
2015-03-23 15:29:42 -04: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]) {
|
2015-03-23 15:29:42 -04:00
|
|
|
mtex = 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
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
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 */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (mtex->texco == TEXCO_ORCO)
|
|
|
|
texco = texco_orco;
|
|
|
|
else if (mtex->texco == TEXCO_OBJECT)
|
|
|
|
texco = texco_object;
|
|
|
|
else if (mtex->texco == TEXCO_NORM)
|
|
|
|
texco = orn;
|
|
|
|
else if (mtex->texco == TEXCO_TANGENT)
|
|
|
|
texco = texco_object;
|
|
|
|
else if (mtex->texco == TEXCO_GLOB)
|
|
|
|
texco = texco_global;
|
|
|
|
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);
|
2015-03-23 15:29:42 -04:00
|
|
|
texco = shi->ref;
|
2011-06-20 09:08:41 +00:00
|
|
|
}
|
2015-03-23 15:29:42 -04:00
|
|
|
else if (mtex->texco == TEXCO_UV) {
|
2012-03-24 06:38:07 +00:00
|
|
|
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
|
|
|
}
|
2015-03-23 15:29:42 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
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);
|
|
|
|
|
2016-01-08 16:42:47 +11:00
|
|
|
float ofs[3] = {
|
2016-01-07 16:32:02 -05:00
|
|
|
mtex->ofs[0] + 0.5f - 0.5f * mtex->size[0],
|
|
|
|
mtex->ofs[1] + 0.5f - 0.5f * mtex->size[1],
|
|
|
|
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;
|
|
|
|
|
2016-02-05 04:28:16 +11:00
|
|
|
if (tex && tex->ima &&
|
|
|
|
((tex->type == TEX_IMAGE) ||
|
|
|
|
((tex->type == TEX_ENVMAP) && (mtex->texco == TEXCO_REFL))))
|
|
|
|
{
|
|
|
|
if (tex->type == TEX_IMAGE) {
|
|
|
|
GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, false), &tin, &trgb);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "mtex_cube_map_refl",
|
|
|
|
GPU_cube_map(tex->ima, &tex->iuser, false), shi->view, shi->vn,
|
|
|
|
GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
|
|
|
|
GPU_builtin(GPU_VIEW_MATRIX), &tin, &trgb);
|
|
|
|
}
|
2015-03-23 15:29:42 -04:00
|
|
|
rgbnor = TEX_RGB;
|
2008-09-05 20:34:35 +00:00
|
|
|
|
2013-03-04 13:18:14 +00:00
|
|
|
talpha = ((tex->imaflag & TEX_USEALPHA) && tex->ima && (tex->ima->flag & IMA_IGNORE_ALPHA) == 0);
|
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 */
|
2016-03-21 14:36:33 +03:00
|
|
|
if (mtex->mapto & (MAP_COL | MAP_COLSPEC | MAP_COLMIR)) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 */
|
2016-01-10 07:12:10 +11: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
|
|
|
|
2016-02-05 04:28:16 +11:00
|
|
|
if ((tex->type == TEX_IMAGE) ||
|
|
|
|
((tex->type == TEX_ENVMAP) && (mtex->texco == TEXCO_REFL)))
|
|
|
|
{
|
|
|
|
if (GPU_material_do_color_management(mat)) {
|
2010-08-15 09:34:18 +00:00
|
|
|
GPU_link(mat, "srgb_to_linearrgb", tcol, &tcol);
|
2016-02-05 04:28:16 +11: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 (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);
|
|
|
|
}
|
2016-03-21 14:36:33 +03:00
|
|
|
|
2016-03-23 04:47:16 +11:00
|
|
|
if (mtex->mapto & MAP_COLMIR) {
|
2016-03-21 14:36:33 +03:00
|
|
|
GPUNodeLink *colmirfac;
|
|
|
|
|
|
|
|
if (mtex->mirrfac == 1.0f) colmirfac = stencil;
|
|
|
|
else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->mirrfac), stencil, &colmirfac);
|
|
|
|
|
|
|
|
/* exception for envmap only */
|
|
|
|
if (tex->type == TEX_ENVMAP && mtex->blendtype == MTEX_BLEND) {
|
|
|
|
GPU_link(mat, "mtex_mirror", tcol, shi->refcol, tin, colmirfac, &shi->refcol);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
texture_rgb_blend(mat, tcol, shi->mir, tin, colmirfac, mtex->blendtype, &shi->mir);
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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)) {
|
2015-03-23 15:29:42 -04:00
|
|
|
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 */
|
2014-04-01 11:34:00 +11: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;
|
2016-01-10 07:12:10 +11:00
|
|
|
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);
|
2011-02-14 18:18:46 +00:00
|
|
|
iFirstTimeNMap = 0;
|
|
|
|
}
|
2012-03-07 04:53:43 +00:00
|
|
|
else { /* otherwise use accumulated perturbations */
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "mtex_nspace_tangent",
|
|
|
|
GPU_attribute(CD_TANGENT, ""), shi->vn, tnor, &newnor);
|
2011-02-14 18:18:46 +00:00
|
|
|
}
|
2013-10-01 03:56:02 +00:00
|
|
|
}
|
|
|
|
else if (mtex->normapspace == MTEX_NSPACE_OBJECT) {
|
2013-09-20 11:55:43 +00:00
|
|
|
/* transform normal by object then view matrix */
|
2014-10-21 15:00:12 +02:00
|
|
|
GPU_link(mat, "mtex_nspace_object", tnor, &newnor);
|
2013-10-01 03:56:02 +00:00
|
|
|
}
|
|
|
|
else if (mtex->normapspace == MTEX_NSPACE_WORLD) {
|
2013-09-20 11:55:43 +00:00
|
|
|
/* transform normal by view matrix */
|
|
|
|
GPU_link(mat, "mtex_nspace_world", GPU_builtin(GPU_VIEW_MATRIX), tnor, &newnor);
|
2011-02-14 18:18:46 +00:00
|
|
|
}
|
2012-03-07 04:53:43 +00:00
|
|
|
else {
|
2013-09-20 11:55:43 +00:00
|
|
|
/* no transform, normal in camera space */
|
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
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
float 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
|
|
|
}
|
2016-01-10 07:12:10 +11:00
|
|
|
else if (found_deriv_map ||
|
|
|
|
(mtex->texflag & (MTEX_3TAP_BUMP | MTEX_5TAP_BUMP | MTEX_BICUBIC_BUMP)))
|
|
|
|
{
|
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-09-22 05:36:52 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
float imag_tspace_dimension_x = 1024.0f; /* only used for texture space variant */
|
2011-09-22 05:36:52 +00:00
|
|
|
float aspect = 1.0f;
|
2011-01-29 12:01:11 +00:00
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
GPUNodeLink *vR1, *vR2;
|
|
|
|
GPUNodeLink *dBs, *dBt, *fDet;
|
2011-12-09 23:26:06 +00:00
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
float hScale = 0.1f; /* compatibility adjustment factor for all bumpspace types */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (mtex->texflag & MTEX_BUMP_TEXTURESPACE)
|
|
|
|
hScale = 13.0f; /* factor for scaling texspace bumps */
|
2016-01-07 16:32:02 -05:00
|
|
|
else if (found_deriv_map)
|
2011-12-09 23:26:06 +00:00
|
|
|
hScale = 1.0f;
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
/* resolve texture resolution */
|
|
|
|
if ((mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map) {
|
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL);
|
2016-01-07 16:32:02 -05:00
|
|
|
ima_x = 512.0f; ima_y = 512.0f; /* prevent calling textureSize, glsl 1.3 only */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf) {
|
2015-03-23 15:29:42 -04:00
|
|
|
ima_x = ibuf->x;
|
|
|
|
ima_y = ibuf->y;
|
|
|
|
aspect = (float)ima_y / ima_x;
|
2011-12-09 23:26:06 +00:00
|
|
|
}
|
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
|
|
|
|
2015-03-23 15:29:42 -04: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. */
|
2016-01-07 16:32:02 -05:00
|
|
|
float norfac = -hScale * mtex->norfac;
|
2012-03-07 04:53:43 +00:00
|
|
|
if (found_deriv_map) {
|
2015-03-23 15:29:42 -04: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);
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (!init_done) {
|
|
|
|
/* copy shi->vn to vNorg and vNacc, set magnitude to 1 */
|
2011-02-07 21:57:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_normals_init", shi->vn, &vNorg, &vNacc, &fPrevMagnitude);
|
|
|
|
iBumpSpacePrev = 0;
|
2014-04-01 11:34:00 +11:00
|
|
|
init_done = true;
|
2011-02-07 21:57:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// find current bump space
|
2015-03-23 15:29:42 -04:00
|
|
|
if (mtex->texflag & MTEX_BUMP_OBJECTSPACE)
|
2011-02-07 21:57:40 +00:00
|
|
|
iBumpSpace = 1;
|
2015-03-23 15:29:42 -04: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
|
2015-03-23 15:29:42 -04:00
|
|
|
iBumpSpace = 4; /* ViewSpace */
|
2011-02-07 21:57:40 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
/* re-initialize if bump space changed */
|
|
|
|
if (iBumpSpacePrev != iBumpSpace) {
|
2015-03-10 15:26:55 +01:00
|
|
|
GPUNodeLink *surf_pos = GPU_builtin(GPU_VIEW_POSITION);
|
|
|
|
|
2015-03-23 15:29:42 -04: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,
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_builtin(GPU_VIEW_MATRIX),
|
|
|
|
GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
|
|
|
|
GPU_builtin(GPU_OBJECT_MATRIX),
|
|
|
|
GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
|
2012-04-29 17:11:40 +00:00
|
|
|
fPrevMagnitude, vNacc,
|
|
|
|
&fPrevMagnitude, &vNacc,
|
|
|
|
&vR1, &vR2, &fDet);
|
2011-02-07 21:57:40 +00:00
|
|
|
|
2015-03-23 15:29:42 -04: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",
|
2016-01-10 07:12:10 +11:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser, true),
|
|
|
|
GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac,
|
2015-03-23 15:29:42 -04:00
|
|
|
&dBs, &dBt);
|
2011-08-22 19:57:54 +00:00
|
|
|
}
|
2015-03-23 15:29:42 -04:00
|
|
|
else if (mtex->texflag & MTEX_3TAP_BUMP)
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_tap3",
|
2014-04-01 11:34:00 +11:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser, true), tnorfac,
|
2015-03-23 15:29:42 -04:00
|
|
|
&dBs, &dBt);
|
|
|
|
else if (mtex->texflag & MTEX_5TAP_BUMP)
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_tap5",
|
2014-04-01 11:34:00 +11:00
|
|
|
texco, GPU_image(tex->ima, &tex->iuser, true), tnorfac,
|
2015-03-23 15:29:42 -04:00
|
|
|
&dBs, &dBt);
|
|
|
|
else if (mtex->texflag & MTEX_BICUBIC_BUMP) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GPU_bicubic_bump_support()) {
|
2012-04-29 17:11:40 +00:00
|
|
|
GPU_link(mat, "mtex_bump_bicubic",
|
2014-04-01 11:34:00 +11: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",
|
2014-04-01 11:34:00 +11: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
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (mtex->texflag & MTEX_BUMP_TEXTURESPACE) {
|
|
|
|
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,
|
2014-04-01 11:34:00 +11:00
|
|
|
GPU_image(tex->ima, &tex->iuser, true), texco,
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_uniform(&imag_tspace_dimension_x),
|
|
|
|
GPU_uniform(&imag_tspace_dimension_y), vNacc,
|
2015-03-23 15:29:42 -04:00
|
|
|
&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,
|
2015-03-23 15:29:42 -04:00
|
|
|
&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);
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
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);
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
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);
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
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);
|
2016-01-10 07:12:10 +11: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);
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
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);
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
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)
|
|
|
|
{
|
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;
|
|
|
|
|
2016-05-21 16:13:09 +02:00
|
|
|
GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->r, GPU_DYNAMIC_MAT_DIFFRGB, ma), &shi->rgb);
|
|
|
|
GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->specr, GPU_DYNAMIC_MAT_SPECRGB, ma), &shi->specrgb);
|
|
|
|
GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&ma->mirr, GPU_DYNAMIC_MAT_MIR, ma), &shi->mir);
|
2016-03-21 14:36:33 +03:00
|
|
|
GPU_link(mat, "set_rgba_zero", &shi->refcol);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_norm", GPU_builtin(GPU_VIEW_NORMAL), &shi->vn);
|
2012-07-26 08:57:41 +00:00
|
|
|
|
2014-01-17 16:28:53 +09:00
|
|
|
if (mat->alpha)
|
2016-05-21 16:13:09 +02:00
|
|
|
GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->alpha, GPU_DYNAMIC_MAT_ALPHA, ma), &shi->alpha);
|
2012-07-26 08:57:41 +00:00
|
|
|
else
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&one), &shi->alpha);
|
|
|
|
|
2016-05-21 16:13:09 +02:00
|
|
|
GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->ref, GPU_DYNAMIC_MAT_REF, ma), &shi->refl);
|
|
|
|
GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->spec, GPU_DYNAMIC_MAT_SPEC, ma), &shi->spec);
|
|
|
|
GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->emit, GPU_DYNAMIC_MAT_EMIT, ma), &shi->emit);
|
|
|
|
GPU_link(mat, "set_value", GPU_dynamic_uniform((float *)&ma->har, GPU_DYNAMIC_MAT_HARD, ma), &shi->har);
|
|
|
|
GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->amb, GPU_DYNAMIC_MAT_AMB, ma), &shi->amb);
|
2014-11-09 15:22:44 +01:00
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&ma->spectra), &shi->spectra);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_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);
|
|
|
|
}
|
|
|
|
|
2015-03-23 22:32:49 +01:00
|
|
|
void GPU_mist_update_enable(short enable)
|
|
|
|
{
|
|
|
|
GPUWorld.mistenabled = (float)enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_mist_update_values(int type, float start, float dist, float inten, float color[3])
|
|
|
|
{
|
|
|
|
GPUWorld.mistype = (float)type;
|
|
|
|
GPUWorld.miststart = start;
|
|
|
|
GPUWorld.mistdistance = dist;
|
|
|
|
GPUWorld.mistintensity = inten;
|
|
|
|
copy_v3_v3(GPUWorld.mistcol, color);
|
|
|
|
GPUWorld.mistcol[3] = 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_horizon_update_color(float color[3])
|
|
|
|
{
|
|
|
|
copy_v3_v3(GPUWorld.horicol, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_ambient_update_color(float color[3])
|
|
|
|
{
|
|
|
|
copy_v3_v3(GPUWorld.ambcol, color);
|
|
|
|
GPUWorld.ambcol[3] = 1.0f;
|
|
|
|
}
|
|
|
|
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
void GPU_zenith_update_color(float color[3])
|
|
|
|
{
|
|
|
|
copy_v3_v3(GPUWorld.zencol, color);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
|
|
|
|
{
|
2015-03-23 15:29:42 -04:00
|
|
|
GPUMaterial *mat = shi->gpumat;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 *emit, *ulinfac, *ulogfac, *mistfac;
|
2015-03-23 15:29:42 -04:00
|
|
|
Material *ma = shi->mat;
|
|
|
|
World *world = mat->scene->world;
|
2015-03-23 22:32:49 +01:00
|
|
|
float linfac, logfac;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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(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 ((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) {
|
2016-01-10 07:12:10 +11:00
|
|
|
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 */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (world->exp != 0.0f || world->range != 1.0f) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
/* environment lighting */
|
2016-07-08 00:48:03 +10:00
|
|
|
if (!(mat->scene->gm.flag & GAME_GLSL_NO_ENV_LIGHTING) &&
|
|
|
|
(world->mode & WO_ENV_LIGHT) &&
|
|
|
|
(mat->scene->r.mode & R_SHADOW) &&
|
|
|
|
!BKE_scene_use_new_shading_nodes(mat->scene))
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
{
|
|
|
|
if ((world->ao_env_energy != 0.0f) && (GPU_link_changed(shi->amb) || ma->amb != 0.0f) &&
|
2016-07-08 00:48:03 +10:00
|
|
|
(GPU_link_changed(shi->refl) || ma->ref != 0.0f))
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
{
|
|
|
|
if (world->aocolor != WO_AOPLAIN) {
|
2016-07-14 13:37:49 +10:00
|
|
|
if (!(is_zero_v3(&world->horr) & is_zero_v3(&world->zenr))) {
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
GPUNodeLink *fcol, *f;
|
|
|
|
GPU_link(mat, "math_multiply", shi->amb, shi->refl, &f);
|
|
|
|
GPU_link(mat, "math_multiply", f, GPU_uniform(&world->ao_env_energy), &f);
|
|
|
|
GPU_link(mat, "shade_mul_value", f, shi->rgb, &fcol);
|
2016-07-08 00:48:03 +10:00
|
|
|
GPU_link(mat, "env_apply", shr->combined,
|
|
|
|
GPU_dynamic_uniform(GPUWorld.horicol, GPU_DYNAMIC_HORIZON_COLOR, NULL),
|
|
|
|
GPU_dynamic_uniform(GPUWorld.zencol, GPU_DYNAMIC_ZENITH_COLOR, NULL), fcol,
|
|
|
|
GPU_builtin(GPU_VIEW_MATRIX), shi->vn, &shr->combined);
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPUNodeLink *f;
|
|
|
|
GPU_link(mat, "math_multiply", shi->amb, shi->refl, &f);
|
|
|
|
GPU_link(mat, "math_multiply", f, GPU_uniform(&world->ao_env_energy), &f);
|
|
|
|
GPU_link(mat, "shade_maddf", shr->combined, f, shi->rgb, &shr->combined);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* ambient color */
|
2015-03-23 22:32:49 +01:00
|
|
|
if (GPU_link_changed(shi->amb) || ma->amb != 0.0f) {
|
|
|
|
GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb),
|
|
|
|
GPU_dynamic_uniform(GPUWorld.ambcol, GPU_DYNAMIC_AMBIENT_COLOR, NULL),
|
|
|
|
&shr->combined);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
if (ma->mode & MA_TRANSP && (ma->mode & (MA_ZTRANSP | MA_RAYTRANSP))) {
|
|
|
|
if (GPU_link_changed(shi->spectra) || ma->spectra != 0.0f) {
|
2014-11-09 15:22:44 +01:00
|
|
|
GPU_link(mat, "alpha_spec_correction", shr->spec, shi->spectra,
|
2016-01-10 07:12:10 +11:00
|
|
|
shi->alpha, &shr->alpha);
|
|
|
|
}
|
2014-11-09 15:22:44 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-03-21 14:36:33 +03:00
|
|
|
if (GPU_link_changed(shi->refcol))
|
|
|
|
GPU_link(mat, "shade_add_mirror", shi->mir, shi->refcol, shr->combined, &shr->combined);
|
|
|
|
|
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);
|
|
|
|
|
2015-03-23 22:32:49 +01:00
|
|
|
if (!(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
|
|
|
GPU_link(mat, "shade_mist_factor", GPU_builtin(GPU_VIEW_POSITION),
|
2015-03-23 22:32:49 +01:00
|
|
|
GPU_dynamic_uniform(&GPUWorld.mistenabled, GPU_DYNAMIC_MIST_ENABLE, NULL),
|
|
|
|
GPU_dynamic_uniform(&GPUWorld.miststart, GPU_DYNAMIC_MIST_START, NULL),
|
|
|
|
GPU_dynamic_uniform(&GPUWorld.mistdistance, GPU_DYNAMIC_MIST_DISTANCE, NULL),
|
|
|
|
GPU_dynamic_uniform(&GPUWorld.mistype, GPU_DYNAMIC_MIST_TYPE, NULL),
|
|
|
|
GPU_dynamic_uniform(&GPUWorld.mistintensity, GPU_DYNAMIC_MIST_INTENSITY, NULL), &mistfac);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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, "mix_blend", mistfac, shr->combined,
|
2015-03-23 22:32:49 +01:00
|
|
|
GPU_dynamic_uniform(GPUWorld.mistcol, GPU_DYNAMIC_MIST_COLOR, NULL), &shr->combined);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2014-01-17 16:28:53 +09:00
|
|
|
if (!mat->alpha) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (world && (GPU_link_changed(shr->alpha) || ma->alpha != 1.0f))
|
2015-03-23 22:32:49 +01:00
|
|
|
GPU_link(mat, "shade_world_mix", GPU_dynamic_uniform(GPUWorld.horicol, GPU_DYNAMIC_HORIZON_COLOR, NULL),
|
|
|
|
shr->combined, &shr->combined);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_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;
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "node_bsdf_diffuse",
|
|
|
|
GPU_uniform(&ma->r), GPU_uniform(&roughness), GPU_builtin(GPU_VIEW_NORMAL), &outlink);
|
2012-12-03 08:31:16 +00:00
|
|
|
|
|
|
|
return outlink;
|
|
|
|
}
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
static GPUNodeLink *gpu_material_preview_matcap(GPUMaterial *mat, Material *ma)
|
|
|
|
{
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
|
2014-03-29 11:40:26 +02:00
|
|
|
/* some explanations here:
|
|
|
|
* matcap normal holds the normal remapped to the 0.0 - 1.0 range. To take advantage of flat shading, we abuse
|
|
|
|
* the built in secondary color of opengl. Color is just the regular color, which should include mask value too.
|
|
|
|
* This also needs flat shading so we use the primary opengl color built-in */
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "material_preview_matcap", GPU_uniform(&ma->r), GPU_image_preview(ma->preview),
|
|
|
|
GPU_opengl_builtin(GPU_MATCAP_NORMAL), GPU_opengl_builtin(GPU_COLOR), &outlink);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
return outlink;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* new solid draw mode with glsl matcaps */
|
2015-07-20 16:08:06 +02:00
|
|
|
GPUMaterial *GPU_material_matcap(Scene *scene, Material *ma, bool use_opensubdiv)
|
2013-01-22 11:18:41 +00:00
|
|
|
{
|
|
|
|
GPUMaterial *mat;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
LinkData *link;
|
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
for (link = ma->gpumaterial.first; link; link = link->next) {
|
2016-01-10 07:12:10 +11:00
|
|
|
GPUMaterial *current_material = (GPUMaterial *)link->data;
|
2015-07-20 16:08:06 +02:00
|
|
|
if (current_material->scene == scene &&
|
|
|
|
current_material->is_opensubdiv == use_opensubdiv)
|
|
|
|
{
|
|
|
|
return current_material;
|
|
|
|
}
|
|
|
|
}
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
/* allocate material */
|
|
|
|
mat = GPU_material_construct_begin(ma);
|
|
|
|
mat->scene = scene;
|
2014-11-24 17:18:56 +01:00
|
|
|
mat->type = GPU_MATERIAL_TYPE_MESH;
|
2015-07-20 16:08:06 +02:00
|
|
|
mat->is_opensubdiv = use_opensubdiv;
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
if (ma->preview && ma->preview->rect[0]) {
|
|
|
|
outlink = gpu_material_preview_matcap(mat, ma);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outlink = gpu_material_diffuse_bsdf(mat, ma);
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_material_output_link(mat, outlink);
|
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
gpu_material_construct_end(mat, "matcap_pass");
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
/* note that even if building the shader fails in some way, we still keep
|
|
|
|
* it to avoid trying to compile again and again, and simple do not use
|
|
|
|
* the actual shader on drawing */
|
|
|
|
|
|
|
|
link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
|
|
|
|
link->data = mat;
|
|
|
|
BLI_addtail(&ma->gpumaterial, link);
|
|
|
|
|
|
|
|
return mat;
|
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
static void do_world_tex(GPUShadeInput *shi, struct World *wo, GPUNodeLink **hor, GPUNodeLink **zen, GPUNodeLink **blend)
|
|
|
|
{
|
|
|
|
GPUMaterial *mat = shi->gpumat;
|
|
|
|
GPUNodeLink *texco, *tin, *trgb, *stencil, *tcol, *zenfac;
|
|
|
|
MTex *mtex;
|
|
|
|
Tex *tex;
|
|
|
|
float ofs[3], zero = 0.0f;
|
|
|
|
int tex_nr, rgbnor;
|
|
|
|
|
|
|
|
GPU_link(mat, "set_value_one", &stencil);
|
|
|
|
/* go over texture slots */
|
|
|
|
for (tex_nr = 0; tex_nr < MAX_MTEX; tex_nr++) {
|
|
|
|
if (wo->mtex[tex_nr]) {
|
|
|
|
mtex = wo->mtex[tex_nr];
|
|
|
|
tex = mtex->tex;
|
|
|
|
if (tex == NULL || !tex->ima || (tex->type != TEX_IMAGE && tex->type != TEX_ENVMAP))
|
|
|
|
continue;
|
|
|
|
/* which coords */
|
|
|
|
if (mtex->texco == TEXCO_VIEW || mtex->texco == TEXCO_GLOB) {
|
|
|
|
if (tex->type == TEX_IMAGE)
|
|
|
|
texco = GPU_builtin(GPU_VIEW_POSITION);
|
|
|
|
else if (tex->type == TEX_ENVMAP)
|
|
|
|
GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &texco);
|
|
|
|
}
|
|
|
|
else if (mtex->texco == TEXCO_EQUIRECTMAP || mtex->texco == TEXCO_ANGMAP) {
|
|
|
|
if ((tex->type == TEX_IMAGE && wo->skytype & WO_SKYREAL) || tex->type == TEX_ENVMAP)
|
|
|
|
GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &texco);
|
|
|
|
else
|
|
|
|
texco = GPU_builtin(GPU_VIEW_POSITION);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
GPU_link(mat, "texco_norm", texco, &texco);
|
|
|
|
if (tex->type == TEX_IMAGE && !(wo->skytype & WO_SKYREAL)) {
|
|
|
|
GPU_link(mat, "mtex_2d_mapping", texco, &texco);
|
|
|
|
}
|
|
|
|
if (mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f) {
|
|
|
|
float size[3] = { mtex->size[0], mtex->size[1], mtex->size[2] };
|
|
|
|
if (tex->type == TEX_ENVMAP) {
|
|
|
|
size[1] = mtex->size[2];
|
|
|
|
size[2] = mtex->size[1];
|
|
|
|
}
|
|
|
|
GPU_link(mat, "mtex_mapping_size", texco, GPU_uniform(size), &texco);
|
|
|
|
}
|
|
|
|
ofs[0] = mtex->ofs[0] + 0.5f - 0.5f * mtex->size[0];
|
|
|
|
if (tex->type == TEX_ENVMAP) {
|
|
|
|
ofs[1] = -mtex->ofs[2] + 0.5f - 0.5f * mtex->size[2];
|
|
|
|
ofs[2] = mtex->ofs[1] + 0.5f - 0.5f * mtex->size[1];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ofs[1] = mtex->ofs[1] + 0.5f - 0.5f * mtex->size[1];
|
|
|
|
ofs[2] = 0.0;
|
|
|
|
}
|
|
|
|
if (ofs[0] != 0.0f || ofs[1] != 0.0f || ofs[2] != 0.0f)
|
|
|
|
GPU_link(mat, "mtex_mapping_ofs", texco, GPU_uniform(ofs), &texco);
|
|
|
|
if (mtex->texco == TEXCO_EQUIRECTMAP) {
|
|
|
|
GPU_link(mat, "node_tex_environment_equirectangular", texco, GPU_image(tex->ima, &tex->iuser, false), &trgb);
|
|
|
|
}
|
|
|
|
else if (mtex->texco == TEXCO_ANGMAP) {
|
|
|
|
GPU_link(mat, "node_tex_environment_mirror_ball", texco, GPU_image(tex->ima, &tex->iuser, false), &trgb);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (tex->type == TEX_ENVMAP)
|
|
|
|
GPU_link(mat, "mtex_cube_map", texco, GPU_cube_map(tex->ima, &tex->iuser, false), &tin, &trgb);
|
|
|
|
else if (tex->type == TEX_IMAGE)
|
|
|
|
GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, false), &tin, &trgb);
|
|
|
|
}
|
|
|
|
rgbnor = TEX_RGB;
|
|
|
|
if (tex->type == TEX_IMAGE || tex->type == TEX_ENVMAP)
|
|
|
|
if (GPU_material_do_color_management(mat))
|
|
|
|
GPU_link(mat, "srgb_to_linearrgb", trgb, &trgb);
|
|
|
|
/* texture output */
|
|
|
|
if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
|
|
|
|
GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
|
|
|
|
rgbnor -= TEX_RGB;
|
|
|
|
}
|
|
|
|
if (mtex->texflag & MTEX_NEGATIVE) {
|
|
|
|
if (rgbnor & TEX_RGB)
|
|
|
|
GPU_link(mat, "mtex_rgb_invert", trgb, &trgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_value_invert", tin, &tin);
|
|
|
|
}
|
|
|
|
if (mtex->texflag & MTEX_STENCIL) {
|
|
|
|
if (rgbnor & TEX_RGB)
|
|
|
|
GPU_link(mat, "mtex_rgb_stencil", stencil, trgb, &stencil, &trgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_value_stencil", stencil, tin, &stencil, &tin);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (rgbnor & TEX_RGB)
|
|
|
|
GPU_link(mat, "mtex_alpha_multiply_value", trgb, stencil, &trgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "math_multiply", stencil, tin, &tin);
|
|
|
|
}
|
|
|
|
/* color mapping */
|
|
|
|
if (mtex->mapto & (WOMAP_HORIZ + WOMAP_ZENUP + WOMAP_ZENDOWN)) {
|
|
|
|
if ((rgbnor & TEX_RGB) == 0)
|
|
|
|
GPU_link(mat, "set_rgb", GPU_uniform(&mtex->r), &trgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "mtex_alpha_from_col", trgb, &tin);
|
|
|
|
GPU_link(mat, "set_rgb", trgb, &tcol);
|
|
|
|
if (mtex->mapto & WOMAP_HORIZ) {
|
|
|
|
texture_rgb_blend(mat, tcol, *hor, tin, GPU_uniform(&mtex->colfac), mtex->blendtype, hor);
|
|
|
|
}
|
|
|
|
if (mtex->mapto & (WOMAP_ZENUP + WOMAP_ZENDOWN)) {
|
|
|
|
GPU_link(mat, "set_value_zero", &zenfac);
|
|
|
|
if (wo->skytype & WO_SKYREAL) {
|
|
|
|
if (mtex->mapto & WOMAP_ZENUP) {
|
|
|
|
if (mtex->mapto & WOMAP_ZENDOWN) {
|
|
|
|
GPU_link(mat, "world_zen_mapping", shi->view, GPU_uniform(&mtex->zenupfac),
|
2016-01-28 17:23:12 +11:00
|
|
|
GPU_uniform(&mtex->zendownfac), &zenfac);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "world_zen_mapping", shi->view, GPU_uniform(&mtex->zenupfac),
|
2016-01-28 17:23:12 +11:00
|
|
|
GPU_uniform(&zero), &zenfac);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
}
|
|
|
|
}
|
2016-01-28 17:23:12 +11:00
|
|
|
else if (mtex->mapto & WOMAP_ZENDOWN) {
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
GPU_link(mat, "world_zen_mapping", shi->view, GPU_uniform(&zero),
|
2016-01-28 17:23:12 +11:00
|
|
|
GPU_uniform(&mtex->zendownfac), &zenfac);
|
|
|
|
}
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (mtex->mapto & WOMAP_ZENUP)
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&mtex->zenupfac), &zenfac);
|
|
|
|
else if (mtex->mapto & WOMAP_ZENDOWN)
|
|
|
|
GPU_link(mat, "set_value", GPU_uniform(&mtex->zendownfac), &zenfac);
|
|
|
|
}
|
|
|
|
texture_rgb_blend(mat, tcol, *zen, tin, zenfac, mtex->blendtype, zen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mtex->mapto & WOMAP_BLEND && wo->skytype & WO_SKYBLEND) {
|
|
|
|
if (rgbnor & TEX_RGB)
|
|
|
|
GPU_link(mat, "mtex_rgbtoint", trgb, &tin);
|
|
|
|
texture_value_blend(mat, GPU_uniform(&mtex->def_var), *blend, tin, GPU_uniform(&mtex->blendfac), mtex->blendtype, blend);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
static void gpu_material_old_world(struct GPUMaterial *mat, struct World *wo)
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
{
|
|
|
|
GPUShadeInput shi;
|
|
|
|
GPUShadeResult shr;
|
|
|
|
GPUNodeLink *hor, *zen, *ray, *blend;
|
|
|
|
|
|
|
|
shi.gpumat = mat;
|
|
|
|
|
|
|
|
for (int i = 0; i < MAX_MTEX; i++) {
|
|
|
|
if (wo->mtex[i] && wo->mtex[i]->tex) {
|
|
|
|
wo->skytype |= WO_SKYTEX;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((wo->skytype & (WO_SKYBLEND + WO_SKYTEX)) == 0) {
|
|
|
|
GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&wo->horr, GPU_DYNAMIC_HORIZON_COLOR, NULL), &shr.combined);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "set_rgb_zero", &shi.rgb);
|
|
|
|
GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &ray);
|
|
|
|
if (wo->skytype & WO_SKYPAPER)
|
|
|
|
GPU_link(mat, "world_paper_view", GPU_builtin(GPU_VIEW_POSITION), &shi.view);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "shade_view", ray, &shi.view);
|
|
|
|
if (wo->skytype & WO_SKYBLEND) {
|
|
|
|
if (wo->skytype & WO_SKYPAPER) {
|
|
|
|
if (wo->skytype & WO_SKYREAL)
|
|
|
|
GPU_link(mat, "world_blend_paper_real", GPU_builtin(GPU_VIEW_POSITION), &blend);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "world_blend_paper", GPU_builtin(GPU_VIEW_POSITION), &blend);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (wo->skytype & WO_SKYREAL)
|
|
|
|
GPU_link(mat, "world_blend_real", ray, &blend);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "world_blend", ray, &blend);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "set_value_zero", &blend);
|
|
|
|
}
|
|
|
|
GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&wo->horr, GPU_DYNAMIC_HORIZON_COLOR, NULL), &hor);
|
|
|
|
GPU_link(mat, "set_rgb", GPU_dynamic_uniform(&wo->zenr, GPU_DYNAMIC_ZENITH_COLOR, NULL), &zen);
|
|
|
|
do_world_tex(&shi, wo, &hor, &zen, &blend);
|
|
|
|
if (wo->skytype & WO_SKYBLEND)
|
|
|
|
GPU_link(mat, "node_mix_shader", blend, hor, zen, &shi.rgb);
|
|
|
|
else
|
|
|
|
GPU_link(mat, "set_rgb", hor, &shi.rgb);
|
|
|
|
GPU_link(mat, "set_rgb", shi.rgb, &shr.combined);
|
|
|
|
}
|
|
|
|
GPU_material_output_link(mat, shr.combined);
|
|
|
|
}
|
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
GPUMaterial *GPU_material_world(struct Scene *scene, struct World *wo)
|
|
|
|
{
|
|
|
|
LinkData *link;
|
|
|
|
GPUMaterial *mat;
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
for (link = wo->gpumaterial.first; link; link = link->next)
|
2016-01-10 07:12:10 +11:00
|
|
|
if (((GPUMaterial *)link->data)->scene == scene)
|
2014-11-24 17:18:56 +01:00
|
|
|
return link->data;
|
|
|
|
|
|
|
|
/* allocate material */
|
|
|
|
mat = GPU_material_construct_begin(NULL);
|
|
|
|
mat->scene = scene;
|
|
|
|
mat->type = GPU_MATERIAL_TYPE_WORLD;
|
|
|
|
|
|
|
|
/* create nodes */
|
2017-04-12 20:18:44 +10:00
|
|
|
if (BKE_scene_use_new_shading_nodes(scene) && wo->nodetree && wo->use_nodes) {
|
2014-11-24 17:18:56 +01:00
|
|
|
ntreeGPUMaterialNodes(wo->nodetree, mat, NODE_NEW_SHADING);
|
2017-04-12 20:18:44 +10:00
|
|
|
}
|
2014-11-24 17:18:56 +01:00
|
|
|
else {
|
2017-04-12 20:18:44 +10:00
|
|
|
gpu_material_old_world(mat, wo);
|
2014-11-24 17:18:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GPU_material_do_color_management(mat))
|
|
|
|
if (mat->outlink)
|
|
|
|
GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink);
|
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
gpu_material_construct_end(mat, wo->id.name);
|
2014-11-24 17:18:56 +01:00
|
|
|
|
|
|
|
/* note that even if building the shader fails in some way, we still keep
|
|
|
|
* it to avoid trying to compile again and again, and simple do not use
|
|
|
|
* the actual shader on drawing */
|
|
|
|
|
|
|
|
link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
|
|
|
|
link->data = mat;
|
|
|
|
BLI_addtail(&wo->gpumaterial, link);
|
|
|
|
|
|
|
|
return mat;
|
|
|
|
}
|
|
|
|
|
2017-06-28 10:50:33 +10:00
|
|
|
GPUMaterial *GPU_material_from_nodetree_find(
|
|
|
|
ListBase *gpumaterials, const void *engine_type, int options)
|
2017-04-27 22:27:09 +02:00
|
|
|
{
|
2017-06-28 10:50:33 +10:00
|
|
|
for (LinkData *link = gpumaterials->first; link; link = link->next) {
|
2017-04-27 22:27:09 +02:00
|
|
|
GPUMaterial *current_material = (GPUMaterial *)link->data;
|
2017-06-28 10:50:33 +10:00
|
|
|
if (current_material->engine_type == engine_type &&
|
2017-04-27 22:27:09 +02:00
|
|
|
current_material->options == options)
|
|
|
|
{
|
|
|
|
return current_material;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-28 10:50:33 +10:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: This is supposed to replace GPU_material_from_blender/_world in the future
|
|
|
|
*
|
|
|
|
* \note Caller must use #GPU_material_from_nodetree_find to re-use existing materials,
|
|
|
|
* This is enforced since constructing other arguments to this function may be expensive
|
|
|
|
* so only do this when they are needed.
|
|
|
|
*/
|
|
|
|
GPUMaterial *GPU_material_from_nodetree(
|
|
|
|
Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options,
|
|
|
|
const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines)
|
|
|
|
{
|
|
|
|
GPUMaterial *mat;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
LinkData *link;
|
2017-10-27 16:07:44 +02:00
|
|
|
bool has_volume_output, has_surface_output;
|
2017-06-28 10:50:33 +10:00
|
|
|
|
|
|
|
/* Caller must re-use materials. */
|
|
|
|
BLI_assert(GPU_material_from_nodetree_find(gpumaterials, engine_type, options) == NULL);
|
|
|
|
|
2017-04-27 22:27:09 +02:00
|
|
|
/* allocate material */
|
|
|
|
mat = GPU_material_construct_begin(NULL); /* TODO remove GPU_material_construct_begin */
|
2017-05-01 18:09:50 +02:00
|
|
|
mat->scene = scene;
|
2017-06-28 10:50:33 +10:00
|
|
|
mat->engine_type = engine_type;
|
2017-04-27 22:27:09 +02:00
|
|
|
mat->options = options;
|
|
|
|
|
2017-10-16 16:36:44 -02:00
|
|
|
ntreeGPUMaterialNodes(ntree, mat, NODE_NEW_SHADING | NODE_NEWER_SHADING);
|
2017-10-27 16:07:44 +02:00
|
|
|
ntreeGPUMaterialDomain(ntree, &has_surface_output, &has_volume_output);
|
|
|
|
|
|
|
|
if (has_surface_output) {
|
|
|
|
mat->domain |= GPU_DOMAIN_SURFACE;
|
|
|
|
}
|
|
|
|
if (has_volume_output) {
|
|
|
|
mat->domain |= GPU_DOMAIN_VOLUME;
|
|
|
|
}
|
2017-04-27 22:27:09 +02:00
|
|
|
|
|
|
|
/* Let Draw manager finish the construction. */
|
|
|
|
if (mat->outlink) {
|
|
|
|
outlink = mat->outlink;
|
2017-06-28 09:37:44 +10:00
|
|
|
mat->pass = GPU_generate_pass_new(
|
2017-07-14 17:40:54 +02:00
|
|
|
mat, &mat->nodes, outlink, &mat->attribs, vert_code, geom_code, frag_lib, defines);
|
2017-04-27 22:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* note that even if building the shader fails in some way, we still keep
|
|
|
|
* it to avoid trying to compile again and again, and simple do not use
|
|
|
|
* the actual shader on drawing */
|
|
|
|
|
|
|
|
link = MEM_callocN(sizeof(LinkData), "GPUMaterialLink");
|
|
|
|
link->data = mat;
|
|
|
|
BLI_addtail(gpumaterials, link);
|
|
|
|
|
|
|
|
return mat;
|
|
|
|
}
|
2014-11-24 17:18:56 +01:00
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma, bool use_opensubdiv)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 *mat;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
LinkData *link;
|
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
for (link = ma->gpumaterial.first; link; link = link->next) {
|
2016-01-10 07:12:10 +11:00
|
|
|
GPUMaterial *current_material = (GPUMaterial *)link->data;
|
2015-07-20 16:08:06 +02:00
|
|
|
if (current_material->scene == scene &&
|
|
|
|
current_material->is_opensubdiv == use_opensubdiv)
|
|
|
|
{
|
|
|
|
return current_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
|
|
|
|
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;
|
2014-11-24 17:18:56 +01:00
|
|
|
mat->type = GPU_MATERIAL_TYPE_MESH;
|
2015-07-20 16:08:06 +02:00
|
|
|
mat->is_opensubdiv = use_opensubdiv;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2014-01-17 16:28:53 +09:00
|
|
|
/* render pipeline option */
|
2015-12-15 02:07:26 +01:00
|
|
|
bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
|
|
|
|
if (!new_shading_nodes && (ma->mode & MA_TRANSP))
|
|
|
|
GPU_material_enable_alpha(mat);
|
|
|
|
else if (new_shading_nodes && ma->alpha < 1.0f)
|
2014-01-17 16:28:53 +09:00
|
|
|
GPU_material_enable_alpha(mat);
|
|
|
|
|
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 */
|
2015-12-15 02:07:26 +01:00
|
|
|
if (new_shading_nodes)
|
2014-02-14 15:11:19 +01:00
|
|
|
ntreeGPUMaterialNodes(ma->nodetree, mat, NODE_NEW_SHADING);
|
|
|
|
else
|
|
|
|
ntreeGPUMaterialNodes(ma->nodetree, mat, NODE_OLD_SHADING);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 {
|
2015-12-15 02:07:26 +01:00
|
|
|
if (new_shading_nodes) {
|
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
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
gpu_material_construct_end(mat, ma->id.name);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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-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;
|
2014-11-24 17:18:56 +01:00
|
|
|
World *wo;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
extern Material defmaterial;
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
for (ma = G.main->mat.first; ma; ma = ma->id.next)
|
2014-11-24 17:18:56 +01:00
|
|
|
GPU_material_free(&ma->gpumaterial);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
for (wo = G.main->world.first; wo; wo = wo->id.next)
|
2014-12-18 02:14:51 +01:00
|
|
|
GPU_material_free(&wo->gpumaterial);
|
2014-11-24 17:18:56 +01:00
|
|
|
|
|
|
|
GPU_material_free(&defmaterial.gpumaterial);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-03-23 15:29:42 -04: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 */
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
GPUNodeLink *GPU_lamp_get_data(
|
|
|
|
GPUMaterial *mat, GPULamp *lamp,
|
|
|
|
GPUNodeLink **r_col, GPUNodeLink **r_lv, GPUNodeLink **r_dist, GPUNodeLink **r_shadow, GPUNodeLink **r_energy)
|
2013-11-25 20:58:23 +09:00
|
|
|
{
|
|
|
|
GPUNodeLink *visifac;
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
*r_col = GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob);
|
|
|
|
*r_energy = GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob);
|
|
|
|
visifac = lamp_get_visibility(mat, lamp, r_lv, r_dist);
|
2015-01-27 16:34:27 +01:00
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
shade_light_textures(mat, lamp, r_col);
|
2013-11-25 20:58:23 +09:00
|
|
|
|
|
|
|
if (GPU_lamp_has_shadow_buffer(lamp)) {
|
|
|
|
GPUNodeLink *vn, *inp;
|
|
|
|
|
|
|
|
GPU_link(mat, "shade_norm", GPU_builtin(GPU_VIEW_NORMAL), &vn);
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "shade_inp", vn, *r_lv, &inp);
|
2013-11-25 20:58:23 +09:00
|
|
|
mat->dynproperty |= DYN_LAMP_PERSMAT;
|
|
|
|
|
|
|
|
if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
|
|
|
|
GPU_link(mat, "shadows_only_vsm",
|
2015-02-11 18:38:41 +11:00
|
|
|
GPU_builtin(GPU_VIEW_POSITION),
|
|
|
|
GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
|
2015-02-11 18:38:41 +11:00
|
|
|
GPU_uniform(&lamp->bias), GPU_uniform(&lamp->la->bleedbias),
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_uniform(lamp->shadow_color), inp, r_shadow);
|
2013-11-25 20:58:23 +09:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_link(mat, "shadows_only",
|
2015-02-11 18:38:41 +11:00
|
|
|
GPU_builtin(GPU_VIEW_POSITION),
|
|
|
|
GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
|
|
|
|
GPU_uniform(&lamp->bias), GPU_uniform(lamp->shadow_color), inp, r_shadow);
|
2013-11-25 20:58:23 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_link(mat, "set_rgb_one", r_shadow);
|
2013-11-25 20:58:23 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ensure shadow buffer and lamp textures will be updated */
|
|
|
|
add_user_list(&mat->lamps, lamp);
|
|
|
|
|
|
|
|
return visifac;
|
|
|
|
}
|
|
|
|
|
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 },
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
{ GPU_LOC_TO_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_LOCTOVIEWMAT, GPU_DATA_16F },
|
|
|
|
{ GPU_INVERSE_LOC_TO_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_LOCTOVIEWIMAT, GPU_DATA_16F },
|
2011-09-09 11:55:38 +00:00
|
|
|
{ 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;
|
|
|
|
GPUInput *input;
|
2016-01-07 16:32:02 -05:00
|
|
|
int liblen, fraglen;
|
2011-09-09 11:55:38 +00:00
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
/* TODO(sergey): How to determine whether we need OSD or not here? */
|
|
|
|
GPUMaterial *mat = GPU_material_from_blender(scene, ma, false);
|
2016-01-10 07:12:10 +11:00
|
|
|
GPUPass *pass = (mat) ? mat->pass : NULL;
|
2011-09-09 11:55:38 +00:00
|
|
|
|
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) {
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUInputUniform *uniform = MEM_callocN(sizeof(GPUInputUniform), "GPUInputUniform");
|
2011-09-09 11:55:38 +00:00
|
|
|
|
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) {
|
2016-01-10 07:12:10 +11:00
|
|
|
case GPU_SHADOW2D:
|
|
|
|
uniform->type = GPU_DYNAMIC_SAMPLER_2DSHADOW;
|
|
|
|
uniform->lamp = input->dynamicdata;
|
|
|
|
break;
|
|
|
|
case GPU_TEX2D:
|
|
|
|
if (GPU_texture_opengl_bindcode(input->tex)) {
|
|
|
|
uniform->type = GPU_DYNAMIC_SAMPLER_2DBUFFER;
|
|
|
|
glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(input->tex));
|
|
|
|
uniform->texsize = GPU_texture_width(input->tex) * GPU_texture_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, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPU_NONE:
|
2017-10-27 22:35:48 +02:00
|
|
|
case GPU_TEX3D:
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
case GPU_TEXCUBE:
|
2016-01-10 07:12:10 +11:00
|
|
|
case GPU_FLOAT:
|
|
|
|
case GPU_VEC2:
|
|
|
|
case GPU_VEC3:
|
|
|
|
case GPU_VEC4:
|
|
|
|
case GPU_MAT3:
|
|
|
|
case GPU_MAT4:
|
2017-07-03 21:39:52 +02:00
|
|
|
case GPU_CLOSURE:
|
2016-01-10 07:12:10 +11:00
|
|
|
case GPU_ATTRIB:
|
|
|
|
break;
|
2011-09-09 11:55:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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) {
|
2016-01-10 07:12:10 +11:00
|
|
|
case GPU_FLOAT:
|
|
|
|
uniform->datatype = GPU_DATA_1F;
|
|
|
|
break;
|
|
|
|
case GPU_VEC2:
|
|
|
|
uniform->datatype = GPU_DATA_2F;
|
|
|
|
break;
|
|
|
|
case GPU_VEC3:
|
|
|
|
uniform->datatype = GPU_DATA_3F;
|
|
|
|
break;
|
|
|
|
case GPU_VEC4:
|
|
|
|
uniform->datatype = GPU_DATA_4F;
|
|
|
|
break;
|
|
|
|
case GPU_MAT3:
|
|
|
|
uniform->datatype = GPU_DATA_9F;
|
|
|
|
break;
|
|
|
|
case GPU_MAT4:
|
|
|
|
uniform->datatype = GPU_DATA_16F;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPU_NONE:
|
2017-07-03 21:39:52 +02:00
|
|
|
case GPU_CLOSURE:
|
2016-01-10 07:12:10 +11:00
|
|
|
case GPU_TEX2D:
|
2017-10-27 22:35:48 +02:00
|
|
|
case GPU_TEX3D:
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
case GPU_TEXCUBE:
|
2016-01-10 07:12:10 +11:00
|
|
|
case GPU_SHADOW2D:
|
|
|
|
case GPU_ATTRIB:
|
|
|
|
break;
|
2011-09-09 11:55:38 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 08:08:27 +10:00
|
|
|
if (GPU_DYNAMIC_GROUP_FROM_TYPE(uniform->type) == GPU_DYNAMIC_GROUP_LAMP)
|
2011-09-09 11:55:38 +00:00
|
|
|
uniform->lamp = input->dynamicdata;
|
2016-05-21 16:13:09 +02:00
|
|
|
|
|
|
|
if (GPU_DYNAMIC_GROUP_FROM_TYPE(uniform->type) == GPU_DYNAMIC_GROUP_MAT)
|
|
|
|
uniform->material = input->dynamicdata;
|
2011-09-09 11:55:38 +00:00
|
|
|
}
|
|
|
|
|
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 */
|
2016-01-07 16:32:02 -05:00
|
|
|
for (int i = 0; builtins[i].gputype; i++) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mat->builtins & builtins[i].gputype) {
|
2016-01-07 16:32:02 -05:00
|
|
|
GPUInputUniform *uniform = MEM_callocN(sizeof(GPUInputUniform), "GPUInputUniform");
|
2011-09-09 11:55:38 +00:00
|
|
|
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);
|
2015-03-23 15:29:42 -04:00
|
|
|
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);
|
2015-03-23 15:29:42 -04:00
|
|
|
shader->fragment[liblen + fraglen] = 0;
|
2011-09-09 11:55:38 +00:00
|
|
|
|
|
|
|
// export the attribute
|
2016-01-07 16:32:02 -05:00
|
|
|
for (int i = 0; i < mat->attribs.totlayer; i++) {
|
|
|
|
GPUInputAttribute *attribute = MEM_callocN(sizeof(GPUInputAttribute), "GPUInputAttribute");
|
2011-09-09 11:55:38 +00:00
|
|
|
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) {
|
2016-01-10 07:12:10 +11: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;
|
2011-09-09 11:55:38 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
/* export the vertex shader */
|
2011-09-09 11:55:38 +00:00
|
|
|
shader->vertex = BLI_strdup(pass->vertexcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return shader;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_free_shader_export(GPUShaderExport *shader)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (shader == NULL)
|
2011-09-09 11:55:38 +00:00
|
|
|
return;
|
|
|
|
|
2016-01-07 16:32:02 -05:00
|
|
|
for (GPUInputUniform *uniform = shader->uniforms.first; uniform; uniform = uniform->next)
|
2012-03-24 06:38:07 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
#ifdef WITH_OPENSUBDIV
|
|
|
|
void GPU_material_update_fvar_offset(GPUMaterial *gpu_material,
|
|
|
|
DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
GPUPass *pass = gpu_material->pass;
|
|
|
|
GPUShader *shader = (pass != NULL ? pass->shader : NULL);
|
|
|
|
ListBase *inputs = (pass != NULL ? &pass->inputs : NULL);
|
|
|
|
GPUInput *input;
|
|
|
|
|
|
|
|
if (shader == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_shader_bind(shader);
|
|
|
|
|
|
|
|
for (input = inputs->first;
|
|
|
|
input != NULL;
|
|
|
|
input = input->next)
|
|
|
|
{
|
|
|
|
if (input->source == GPU_SOURCE_ATTRIB &&
|
|
|
|
input->attribtype == CD_MTFACE)
|
|
|
|
{
|
|
|
|
char name[64];
|
|
|
|
/* TODO(sergey): This will work for until names are
|
|
|
|
* consistent, we'll need to solve this somehow in the future.
|
|
|
|
*/
|
|
|
|
int layer_index;
|
|
|
|
int location;
|
|
|
|
|
|
|
|
if (input->attribname[0] != '\0') {
|
|
|
|
layer_index = CustomData_get_named_layer(&dm->loopData,
|
|
|
|
CD_MLOOPUV,
|
|
|
|
input->attribname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
layer_index = CustomData_get_active_layer(&dm->loopData,
|
|
|
|
CD_MLOOPUV);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_snprintf(name, sizeof(name),
|
|
|
|
"fvar%d_offset",
|
|
|
|
input->attribid);
|
|
|
|
location = GPU_shader_get_uniform(shader, name);
|
2016-07-22 16:12:03 +02:00
|
|
|
GPU_shader_uniform_int(shader, location, layer_index);
|
2015-07-20 16:08:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_shader_unbind();
|
|
|
|
}
|
|
|
|
#endif
|