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
|
|
|
* 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
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \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_material_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_math.h"
|
2018-07-20 20:06:39 +02:00
|
|
|
#include "BLI_listbase.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2018-08-02 18:31:38 +02:00
|
|
|
#include "BLI_string.h"
|
2011-01-07 18:36:47 +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 "BKE_main.h"
|
|
|
|
#include "BKE_node.h"
|
|
|
|
#include "BKE_scene.h"
|
2011-01-07 19:18:31 +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 "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
|
|
|
|
2018-03-05 00:54:31 +01:00
|
|
|
#include "DRW_engine.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"
|
|
|
|
|
|
|
|
/* Structs */
|
2018-08-10 15:13:39 +02:00
|
|
|
#define MAX_COLOR_BAND 128
|
|
|
|
|
|
|
|
typedef struct GPUColorBandBuilder {
|
|
|
|
float pixels[MAX_COLOR_BAND][CM_TABLE + 1][4];
|
|
|
|
int current_layer;
|
|
|
|
} GPUColorBandBuilder;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 {
|
2019-02-27 12:02:02 +11:00
|
|
|
Scene *scene; /* DEPRECATED was only useful for lights. */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
Material *ma;
|
|
|
|
|
2019-01-23 14:15:43 +11:00
|
|
|
eGPUMaterialStatus status;
|
2017-04-27 22:27:09 +02:00
|
|
|
|
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...) */
|
2018-06-04 09:09:12 +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
|
|
|
/* for creating the material */
|
|
|
|
ListBase nodes;
|
|
|
|
GPUNodeLink *outlink;
|
|
|
|
|
|
|
|
/* for binding the material */
|
|
|
|
GPUPass *pass;
|
2018-03-11 23:43:09 +01:00
|
|
|
ListBase inputs; /* GPUInput */
|
2019-01-29 07:46:25 +11:00
|
|
|
GPUVertAttrLayers attrs;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
int 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;
|
|
|
|
|
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;
|
|
|
|
|
2018-08-03 18:53:36 +02:00
|
|
|
/* Only used by Eevee to know which bsdf are used. */
|
|
|
|
int flag;
|
|
|
|
|
2018-03-05 00:54:31 +01:00
|
|
|
/* Used by 2.8 pipeline */
|
2017-07-14 17:40:54 +02:00
|
|
|
GPUUniformBuffer *ubo; /* UBOs for shader uniforms. */
|
2018-03-05 00:54:31 +01:00
|
|
|
|
|
|
|
/* Eevee SSS */
|
2017-11-14 00:49:54 +01:00
|
|
|
GPUUniformBuffer *sss_profile; /* UBO containing SSS profile. */
|
2017-11-22 04:51:21 +01:00
|
|
|
GPUTexture *sss_tex_profile; /* Texture containing SSS profile. */
|
2018-06-07 18:43:43 +02:00
|
|
|
float sss_enabled;
|
|
|
|
float sss_radii[3];
|
2017-11-14 02:17:34 +01:00
|
|
|
int sss_samples;
|
2018-06-07 18:43:43 +02:00
|
|
|
short int sss_falloff;
|
|
|
|
float sss_sharpness;
|
2017-11-14 00:49:54 +01:00
|
|
|
bool sss_dirty;
|
2018-08-02 18:31:38 +02:00
|
|
|
|
2018-08-10 15:13:39 +02:00
|
|
|
GPUTexture *coba_tex; /* 1D Texture array containing all color bands. */
|
|
|
|
GPUColorBandBuilder *coba_builder;
|
|
|
|
|
2018-08-02 18:31:38 +02:00
|
|
|
#ifndef NDEBUG
|
|
|
|
char name[64];
|
|
|
|
#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
|
|
|
};
|
|
|
|
|
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),
|
2019-01-15 23:57:49 +11:00
|
|
|
GPU_DOMAIN_SSS = (1 << 2),
|
2017-10-27 16:07:44 +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
|
|
|
/* Functions */
|
|
|
|
|
2018-09-24 18:46:51 +02:00
|
|
|
/* Returns the address of the future pointer to coba_tex */
|
2018-08-10 15:13:39 +02:00
|
|
|
GPUTexture **gpu_material_ramp_texture_row_set(GPUMaterial *mat, int size, float *pixels, float *row)
|
|
|
|
{
|
|
|
|
/* In order to put all the colorbands into one 1D array texture,
|
|
|
|
* we need them to be the same size. */
|
|
|
|
BLI_assert(size == CM_TABLE + 1);
|
2018-09-10 09:56:14 +02:00
|
|
|
UNUSED_VARS_NDEBUG(size);
|
2018-08-10 15:13:39 +02:00
|
|
|
|
|
|
|
if (mat->coba_builder == NULL) {
|
|
|
|
mat->coba_builder = MEM_mallocN(sizeof(GPUColorBandBuilder), "GPUColorBandBuilder");
|
|
|
|
mat->coba_builder->current_layer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int layer = mat->coba_builder->current_layer;
|
|
|
|
*row = (float)layer;
|
|
|
|
|
|
|
|
if (*row == MAX_COLOR_BAND) {
|
|
|
|
printf("Too many color band in shader! Remove some Curve, Black Body or Color Ramp Node.\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float *dst = (float *)mat->coba_builder->pixels[layer];
|
|
|
|
memcpy(dst, pixels, sizeof(float) * (CM_TABLE + 1) * 4);
|
|
|
|
mat->coba_builder->current_layer += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &mat->coba_tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gpu_material_ramp_texture_build(GPUMaterial *mat)
|
|
|
|
{
|
|
|
|
if (mat->coba_builder == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GPUColorBandBuilder *builder = mat->coba_builder;
|
|
|
|
|
2019-03-20 18:17:16 +11:00
|
|
|
mat->coba_tex = GPU_texture_create_1d_array(CM_TABLE + 1, builder->current_layer, GPU_RGBA16F,
|
2018-08-10 15:13:39 +02:00
|
|
|
(float *)builder->pixels, NULL);
|
|
|
|
|
|
|
|
MEM_freeN(builder);
|
|
|
|
mat->coba_builder = NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-08 16:11:34 +02:00
|
|
|
static void gpu_material_free_single(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
|
|
|
{
|
2018-06-08 16:11:34 +02:00
|
|
|
/* Cancel / wait any pending lazy compilation. */
|
|
|
|
DRW_deferred_shader_remove(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
|
|
|
|
2018-06-08 16:11:34 +02:00
|
|
|
GPU_pass_free_nodes(&material->nodes);
|
|
|
|
GPU_inputs_free(&material->inputs);
|
2018-03-05 00:54:31 +01:00
|
|
|
|
2018-08-10 15:13:39 +02:00
|
|
|
if (material->pass != NULL) {
|
2018-06-08 16:11:34 +02:00
|
|
|
GPU_pass_release(material->pass);
|
2018-08-10 15:13:39 +02:00
|
|
|
}
|
2018-06-08 16:11:34 +02:00
|
|
|
if (material->ubo != NULL) {
|
|
|
|
GPU_uniformbuffer_free(material->ubo);
|
|
|
|
}
|
|
|
|
if (material->sss_tex_profile != NULL) {
|
|
|
|
GPU_texture_free(material->sss_tex_profile);
|
|
|
|
}
|
|
|
|
if (material->sss_profile != NULL) {
|
|
|
|
GPU_uniformbuffer_free(material->sss_profile);
|
|
|
|
}
|
2018-08-10 15:13:39 +02:00
|
|
|
if (material->coba_tex != NULL) {
|
|
|
|
GPU_texture_free(material->coba_tex);
|
|
|
|
}
|
2018-06-08 16:11:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_material_free(ListBase *gpumaterial)
|
|
|
|
{
|
|
|
|
for (LinkData *link = gpumaterial->first; link; link = link->next) {
|
|
|
|
GPUMaterial *material = link->data;
|
2018-07-19 15:48:13 +02:00
|
|
|
gpu_material_free_single(material);
|
|
|
|
MEM_freeN(material);
|
2018-06-08 16:11:34 +02:00
|
|
|
}
|
|
|
|
BLI_freelistN(gpumaterial);
|
|
|
|
}
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2019-01-23 14:15:43 +11:00
|
|
|
eGPUBuiltin GPU_get_material_builtins(GPUMaterial *material)
|
2017-04-14 18:13:44 +03:00
|
|
|
{
|
|
|
|
return material->builtins;
|
|
|
|
}
|
|
|
|
|
2013-11-25 20:58:23 +09:00
|
|
|
Scene *GPU_material_scene(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
return material->scene;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2018-03-11 23:43:09 +01:00
|
|
|
ListBase *GPU_material_get_inputs(GPUMaterial *material)
|
|
|
|
{
|
|
|
|
return &material->inputs;
|
|
|
|
}
|
|
|
|
|
2018-06-08 15:54:11 +02:00
|
|
|
GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material)
|
2017-07-14 17:40:54 +02:00
|
|
|
{
|
|
|
|
return material->ubo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create dynamic UBO from parameters
|
2018-12-12 12:17:42 +11:00
|
|
|
*
|
|
|
|
* \param inputs: Items are #LinkData, data is #GPUInput (`BLI_genericNodeN(GPUInput)`).
|
2017-07-14 17:40:54 +02:00
|
|
|
*/
|
2018-06-07 19:40:47 +02:00
|
|
|
void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs)
|
2017-07-14 17:40:54 +02:00
|
|
|
{
|
|
|
|
material->ubo = GPU_uniformbuffer_dynamic_create(inputs, NULL);
|
|
|
|
}
|
|
|
|
|
2017-11-14 00:49:54 +01:00
|
|
|
/* 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];
|
2017-11-22 04:51:21 +01:00
|
|
|
float param[3], max_radius;
|
|
|
|
int samples;
|
2017-11-14 00:49:54 +01:00
|
|
|
} GPUSssKernelData;
|
|
|
|
|
2017-11-22 04:51:21 +01:00
|
|
|
static void sss_calculate_offsets(GPUSssKernelData *kd, int count, float exponent)
|
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;
|
2017-11-22 04:51:21 +01:00
|
|
|
float ofs = sign * fabsf(powf(o, exponent));
|
2017-11-14 00:49:54 +01:00
|
|
|
kd->kernel[i][3] = ofs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-22 04:51:21 +01:00
|
|
|
#define GAUSS_TRUNCATE 12.46f
|
|
|
|
static float gaussian_profile(float r, float radius)
|
|
|
|
{
|
|
|
|
const float v = radius * radius * (0.25f * 0.25f);
|
|
|
|
const float Rm = sqrtf(v * GAUSS_TRUNCATE);
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2017-12-04 17:19:34 +11:00
|
|
|
if (r >= Rm) {
|
2017-11-22 04:51:21 +01:00
|
|
|
return 0.0f;
|
2017-12-04 17:19:34 +11:00
|
|
|
}
|
2017-11-22 04:51:21 +01:00
|
|
|
return expf(-r * r / (2.0f * v)) / (2.0f * M_PI * v);
|
2017-11-14 00:49:54 +01:00
|
|
|
}
|
|
|
|
|
2017-11-16 21:28:40 +01:00
|
|
|
#define BURLEY_TRUNCATE 16.0f
|
2017-11-22 04:51:21 +01:00
|
|
|
#define BURLEY_TRUNCATE_CDF 0.9963790093708328f // cdf(BURLEY_TRUNCATE)
|
2017-11-16 21:28:40 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-11-17 02:00:48 +01:00
|
|
|
static float cubic_profile(float r, float radius, float sharpness)
|
|
|
|
{
|
|
|
|
float Rm = radius * (1.0f + sharpness);
|
|
|
|
|
2017-12-04 17:19:34 +11:00
|
|
|
if (r >= Rm) {
|
2017-11-17 02:00:48 +01:00
|
|
|
return 0.0f;
|
2017-12-04 17:19:34 +11:00
|
|
|
}
|
2017-11-17 02:00:48 +01:00
|
|
|
/* custom variation with extra sharpness, to match the previous code */
|
2017-12-04 17:19:34 +11:00
|
|
|
const float y = 1.0f / (1.0f + sharpness);
|
2017-11-17 02:00:48 +01:00
|
|
|
float Rmy, ry, ryinv;
|
|
|
|
|
|
|
|
Rmy = powf(Rm, y);
|
|
|
|
ry = powf(r, y);
|
2017-12-04 17:19:34 +11:00
|
|
|
ryinv = (r > 0.0f) ? powf(r, y - 1.0f) : 0.0f;
|
2017-11-17 02:00:48 +01:00
|
|
|
|
2017-12-04 17:19:34 +11:00
|
|
|
const float Rmy5 = (Rmy * Rmy) * (Rmy * Rmy) * Rmy;
|
2017-11-17 02:00:48 +01:00
|
|
|
const float f = Rmy - ry;
|
2017-12-04 17:19:34 +11:00
|
|
|
const float num = f * (f * f) * (y * ryinv);
|
2017-11-17 02:00:48 +01:00
|
|
|
|
|
|
|
return (10.0f * num) / (Rmy5 * M_PI);
|
|
|
|
}
|
|
|
|
|
2017-11-22 04:51:21 +01:00
|
|
|
static float eval_profile(float r, short falloff_type, float sharpness, float param)
|
|
|
|
{
|
|
|
|
r = fabsf(r);
|
|
|
|
|
2018-02-09 20:36:37 +01:00
|
|
|
if (falloff_type == SHD_SUBSURFACE_BURLEY ||
|
|
|
|
falloff_type == SHD_SUBSURFACE_RANDOM_WALK)
|
|
|
|
{
|
2017-11-22 04:51:21 +01:00
|
|
|
return burley_profile(r, param) / BURLEY_TRUNCATE_CDF;
|
|
|
|
}
|
|
|
|
else if (falloff_type == SHD_SUBSURFACE_CUBIC) {
|
|
|
|
return cubic_profile(r, param, sharpness);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return gaussian_profile(r, param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Resolution for each sample of the precomputed kernel profile */
|
|
|
|
#define INTEGRAL_RESOLUTION 32
|
|
|
|
static float eval_integral(float x0, float x1, short falloff_type, float sharpness, float param)
|
2017-11-17 02:00:48 +01:00
|
|
|
{
|
|
|
|
const float range = x1 - x0;
|
|
|
|
const float step = range / INTEGRAL_RESOLUTION;
|
|
|
|
float integral = 0.0f;
|
|
|
|
|
2017-12-04 17:19:34 +11:00
|
|
|
for (int i = 0; i < INTEGRAL_RESOLUTION; ++i) {
|
2017-11-17 02:00:48 +01:00
|
|
|
float x = x0 + range * ((float)i + 0.5f) / (float)INTEGRAL_RESOLUTION;
|
2017-11-22 04:51:21 +01:00
|
|
|
float y = eval_profile(x, falloff_type, sharpness, param);
|
2017-11-17 02:00:48 +01:00
|
|
|
integral += y * step;
|
|
|
|
}
|
|
|
|
|
|
|
|
return integral;
|
|
|
|
}
|
2017-11-22 04:51:21 +01:00
|
|
|
#undef INTEGRAL_RESOLUTION
|
2017-11-17 02:00:48 +01:00
|
|
|
|
2017-11-22 04:51:21 +01:00
|
|
|
static void compute_sss_kernel(
|
2018-07-08 13:14:49 +02:00
|
|
|
GPUSssKernelData *kd, float radii[3], int sample_len, int falloff_type, float sharpness)
|
2017-11-16 21:28:40 +01:00
|
|
|
{
|
2017-11-22 04:51:21 +01:00
|
|
|
float rad[3];
|
|
|
|
/* Minimum radius */
|
|
|
|
rad[0] = MAX2(radii[0], 1e-15f);
|
|
|
|
rad[1] = MAX2(radii[1], 1e-15f);
|
|
|
|
rad[2] = MAX2(radii[2], 1e-15f);
|
2017-11-16 21:28:40 +01:00
|
|
|
|
|
|
|
/* Christensen-Burley fitting */
|
|
|
|
float l[3], d[3];
|
|
|
|
|
2018-02-09 20:36:37 +01:00
|
|
|
if (falloff_type == SHD_SUBSURFACE_BURLEY ||
|
|
|
|
falloff_type == SHD_SUBSURFACE_RANDOM_WALK)
|
|
|
|
{
|
2017-11-22 04:51:21 +01:00
|
|
|
mul_v3_v3fl(l, rad, 0.25f * M_1_PI);
|
2017-11-16 21:28:40 +01:00
|
|
|
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);
|
2017-11-22 04:51:21 +01:00
|
|
|
mul_v3_v3fl(rad, d, BURLEY_TRUNCATE);
|
|
|
|
kd->max_radius = MAX3(rad[0], rad[1], rad[2]);
|
|
|
|
|
|
|
|
copy_v3_v3(kd->param, d);
|
2017-11-16 21:28:40 +01:00
|
|
|
}
|
2017-11-17 02:00:48 +01:00
|
|
|
else if (falloff_type == SHD_SUBSURFACE_CUBIC) {
|
2017-11-22 04:51:21 +01:00
|
|
|
copy_v3_v3(kd->param, rad);
|
|
|
|
mul_v3_fl(rad, 1.0f + sharpness);
|
|
|
|
kd->max_radius = MAX3(rad[0], rad[1], rad[2]);
|
2017-11-17 02:00:48 +01:00
|
|
|
}
|
2017-11-22 04:51:21 +01:00
|
|
|
else {
|
|
|
|
kd->max_radius = MAX3(rad[0], rad[1], rad[2]);
|
2017-11-16 21:28:40 +01:00
|
|
|
|
2017-11-22 04:51:21 +01:00
|
|
|
copy_v3_v3(kd->param, rad);
|
|
|
|
}
|
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] */
|
2018-07-08 13:14:49 +02:00
|
|
|
sss_calculate_offsets(kd, sample_len, SSS_EXPONENT);
|
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 */
|
2018-07-08 13:14:49 +02:00
|
|
|
for (int i = 0; i < sample_len; i++) {
|
2017-11-14 00:49:54 +01:00
|
|
|
float x0, x1;
|
|
|
|
|
|
|
|
if (i == 0) {
|
2017-11-20 22:04:14 +01:00
|
|
|
x0 = kd->kernel[0][3] - fabsf(kd->kernel[0][3] - kd->kernel[1][3]) / 2.0f;
|
2017-11-14 00:49:54 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
x0 = (kd->kernel[i - 1][3] + kd->kernel[i][3]) / 2.0f;
|
|
|
|
}
|
|
|
|
|
2018-07-08 13:14:49 +02:00
|
|
|
if (i == sample_len - 1) {
|
|
|
|
x1 = kd->kernel[sample_len - 1][3] + fabsf(kd->kernel[sample_len - 2][3] - kd->kernel[sample_len - 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-22 04:51:21 +01:00
|
|
|
x0 *= kd->max_radius;
|
|
|
|
x1 *= kd->max_radius;
|
|
|
|
|
|
|
|
kd->kernel[i][0] = eval_integral(x0, x1, falloff_type, sharpness, kd->param[0]);
|
|
|
|
kd->kernel[i][1] = eval_integral(x0, x1, falloff_type, sharpness, kd->param[1]);
|
|
|
|
kd->kernel[i][2] = eval_integral(x0, x1, falloff_type, sharpness, kd->param[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 */
|
2018-07-08 13:14:49 +02:00
|
|
|
for (int j = 0; j < sample_len; j++) {
|
2017-11-22 04:51:21 +01:00
|
|
|
kd->kernel[j][i] /= sum[i];
|
2017-11-16 21:28:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Avoid 0 kernel sum. */
|
2018-07-08 13:14:49 +02:00
|
|
|
kd->kernel[sample_len / 2][i] = 1.0f;
|
2017-11-16 21:28:40 +01:00
|
|
|
}
|
2017-11-14 00:49:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Put center sample at the start of the array (to sample first) */
|
|
|
|
float tmpv[4];
|
2018-07-08 13:14:49 +02:00
|
|
|
copy_v4_v4(tmpv, kd->kernel[sample_len / 2]);
|
|
|
|
for (int i = sample_len / 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-22 04:51:21 +01:00
|
|
|
|
2018-07-08 13:14:49 +02:00
|
|
|
kd->samples = sample_len;
|
2017-11-22 04:51:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define INTEGRAL_RESOLUTION 512
|
|
|
|
static void compute_sss_translucence_kernel(
|
|
|
|
const GPUSssKernelData *kd, int resolution, short falloff_type, float sharpness, float **output)
|
|
|
|
{
|
|
|
|
float (*texels)[4];
|
|
|
|
texels = MEM_callocN(sizeof(float) * 4 * resolution, "compute_sss_translucence_kernel");
|
|
|
|
*output = (float *)texels;
|
|
|
|
|
|
|
|
/* Last texel should be black, hence the - 1. */
|
|
|
|
for (int i = 0; i < resolution - 1; ++i) {
|
|
|
|
/* Distance from surface. */
|
|
|
|
float d = kd->max_radius * ((float)i + 0.00001f) / ((float)resolution);
|
|
|
|
|
2018-09-24 18:46:51 +02:00
|
|
|
/* For each distance d we compute the radiance incoming from an hypothetic parallel plane. */
|
2017-11-22 04:51:21 +01:00
|
|
|
/* Compute radius of the footprint on the hypothetic plane */
|
|
|
|
float r_fp = sqrtf(kd->max_radius * kd->max_radius - d * d);
|
|
|
|
float r_step = r_fp / INTEGRAL_RESOLUTION;
|
|
|
|
float area_accum = 0.0f;
|
|
|
|
for (float r = 0.0f; r < r_fp; r += r_step) {
|
|
|
|
/* Compute distance to the "shading" point through the medium. */
|
|
|
|
/* r_step * 0.5f to put sample between the area borders */
|
|
|
|
float dist = hypotf(r + r_step * 0.5f, d);
|
|
|
|
|
|
|
|
float profile[3];
|
|
|
|
profile[0] = eval_profile(dist, falloff_type, sharpness, kd->param[0]);
|
|
|
|
profile[1] = eval_profile(dist, falloff_type, sharpness, kd->param[1]);
|
|
|
|
profile[2] = eval_profile(dist, falloff_type, sharpness, kd->param[2]);
|
|
|
|
|
2018-09-24 18:46:51 +02:00
|
|
|
/* Since the profile and configuration are radially symmetrical we
|
2017-11-22 04:51:21 +01:00
|
|
|
* can just evaluate it once and weight it accordingly */
|
|
|
|
float r_next = r + r_step;
|
|
|
|
float disk_area = (M_PI * r_next * r_next) - (M_PI * r * r);
|
|
|
|
|
|
|
|
mul_v3_fl(profile, disk_area);
|
|
|
|
add_v3_v3(texels[i], profile);
|
|
|
|
area_accum += disk_area;
|
|
|
|
}
|
|
|
|
/* Normalize over the disk. */
|
|
|
|
mul_v3_fl(texels[i], 1.0f / (area_accum));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Normalize */
|
|
|
|
for (int j = resolution - 2; j > 0; j--) {
|
|
|
|
texels[j][0] /= (texels[0][0] > 0.0f) ? texels[0][0] : 1.0f;
|
|
|
|
texels[j][1] /= (texels[0][1] > 0.0f) ? texels[0][1] : 1.0f;
|
|
|
|
texels[j][2] /= (texels[0][2] > 0.0f) ? texels[0][2] : 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First texel should be white */
|
|
|
|
texels[0][0] = (texels[0][0] > 0.0f) ? 1.0f : 0.0f;
|
|
|
|
texels[0][1] = (texels[0][1] > 0.0f) ? 1.0f : 0.0f;
|
|
|
|
texels[0][2] = (texels[0][2] > 0.0f) ? 1.0f : 0.0f;
|
|
|
|
|
|
|
|
/* dim the last few texels for smoother transition */
|
|
|
|
mul_v3_fl(texels[resolution - 2], 0.25f);
|
|
|
|
mul_v3_fl(texels[resolution - 3], 0.5f);
|
|
|
|
mul_v3_fl(texels[resolution - 4], 0.75f);
|
2017-11-14 00:49:54 +01:00
|
|
|
}
|
2017-11-22 04:51:21 +01:00
|
|
|
#undef INTEGRAL_RESOLUTION
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2018-06-07 18:43:43 +02:00
|
|
|
void GPU_material_sss_profile_create(GPUMaterial *material, float radii[3], short *falloff_type, float *sharpness)
|
2017-11-14 00:49:54 +01:00
|
|
|
{
|
2018-06-07 18:43:43 +02:00
|
|
|
copy_v3_v3(material->sss_radii, radii);
|
|
|
|
material->sss_falloff = (falloff_type) ? *falloff_type : 0.0;
|
|
|
|
material->sss_sharpness = (sharpness) ? *sharpness : 0.0;
|
2017-11-14 00:49:54 +01:00
|
|
|
material->sss_dirty = true;
|
2018-06-07 18:43:43 +02:00
|
|
|
material->sss_enabled = true;
|
2017-11-14 00:49:54 +01:00
|
|
|
|
|
|
|
/* Update / Create UBO */
|
|
|
|
if (material->sss_profile == NULL) {
|
|
|
|
material->sss_profile = GPU_uniformbuffer_create(sizeof(GPUSssKernelData), NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-08 13:14:49 +02:00
|
|
|
struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int sample_len, GPUTexture **tex_profile)
|
2017-11-14 00:49:54 +01:00
|
|
|
{
|
2018-06-07 18:43:43 +02:00
|
|
|
if (!material->sss_enabled)
|
2017-11-14 02:17:34 +01:00
|
|
|
return NULL;
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2018-07-08 13:14:49 +02:00
|
|
|
if (material->sss_dirty || (material->sss_samples != sample_len)) {
|
2017-11-14 02:17:34 +01:00
|
|
|
GPUSssKernelData kd;
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2018-06-07 18:43:43 +02:00
|
|
|
float sharpness = material->sss_sharpness;
|
2017-11-17 02:00:48 +01:00
|
|
|
|
2017-11-22 04:51:21 +01:00
|
|
|
/* XXX Black magic but it seems to fit. Maybe because we integrate -1..1 */
|
|
|
|
sharpness *= 0.5f;
|
|
|
|
|
2018-07-08 13:14:49 +02:00
|
|
|
compute_sss_kernel(&kd, material->sss_radii, sample_len, material->sss_falloff, sharpness);
|
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-22 04:51:21 +01:00
|
|
|
/* Update / Create Tex */
|
|
|
|
float *translucence_profile;
|
2018-06-07 18:43:43 +02:00
|
|
|
compute_sss_translucence_kernel(&kd, 64, material->sss_falloff, sharpness, &translucence_profile);
|
2017-11-22 04:51:21 +01:00
|
|
|
|
|
|
|
if (material->sss_tex_profile != NULL) {
|
|
|
|
GPU_texture_free(material->sss_tex_profile);
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:17:16 +11:00
|
|
|
material->sss_tex_profile = GPU_texture_create_1d(64, GPU_RGBA16F, translucence_profile, NULL);
|
2017-11-22 04:51:21 +01:00
|
|
|
|
|
|
|
MEM_freeN(translucence_profile);
|
|
|
|
|
2018-07-08 13:14:49 +02:00
|
|
|
material->sss_samples = sample_len;
|
2017-11-14 02:17:34 +01:00
|
|
|
material->sss_dirty = false;
|
2017-07-14 17:40:54 +02:00
|
|
|
}
|
2017-11-22 04:51:21 +01:00
|
|
|
|
|
|
|
if (tex_profile != NULL) {
|
|
|
|
*tex_profile = material->sss_tex_profile;
|
|
|
|
}
|
2017-11-14 00:49:54 +01:00
|
|
|
return material->sss_profile;
|
2017-07-14 17:40:54 +02:00
|
|
|
}
|
|
|
|
|
2018-11-05 20:09:04 +01:00
|
|
|
struct GPUUniformBuffer *GPU_material_create_sss_profile_ubo(void)
|
|
|
|
{
|
|
|
|
return GPU_uniformbuffer_create(sizeof(GPUSssKernelData), NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2017-11-22 04:51:21 +01:00
|
|
|
#undef SSS_EXPONENT
|
|
|
|
#undef SSS_SAMPLES
|
|
|
|
|
2019-01-29 07:46:25 +11:00
|
|
|
void GPU_material_vertex_attrs(GPUMaterial *material, GPUVertAttrLayers *r_attrs)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2019-01-29 07:46:25 +11:00
|
|
|
*r_attrs = material->attrs;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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_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_add_node(GPUMaterial *material, GPUNode *node)
|
|
|
|
{
|
|
|
|
BLI_addtail(&material->nodes, node);
|
|
|
|
}
|
|
|
|
|
2018-03-05 00:54:31 +01:00
|
|
|
/* Return true if the material compilation has not yet begin or begin. */
|
2019-01-23 14:15:43 +11:00
|
|
|
eGPUMaterialStatus GPU_material_status(GPUMaterial *mat)
|
2018-03-05 00:54:31 +01:00
|
|
|
{
|
|
|
|
return mat->status;
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-01-23 14:15:43 +11:00
|
|
|
void GPU_material_flag_set(GPUMaterial *mat, eGPUMatFlag flag)
|
2018-08-03 18:53:36 +02:00
|
|
|
{
|
|
|
|
mat->flag |= flag;
|
|
|
|
}
|
|
|
|
|
2019-01-23 14:15:43 +11:00
|
|
|
bool GPU_material_flag_get(GPUMaterial *mat, eGPUMatFlag flag)
|
2018-08-03 18:53:36 +02:00
|
|
|
{
|
|
|
|
return (mat->flag & flag);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \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(
|
2018-06-07 11:58:15 +02:00
|
|
|
Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options,
|
2018-08-02 18:31:38 +02:00
|
|
|
const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines, const char *name)
|
2017-06-28 10:50:33 +10:00
|
|
|
{
|
|
|
|
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 */
|
2018-09-20 14:47:10 +00:00
|
|
|
GPUMaterial *mat = MEM_callocN(sizeof(GPUMaterial), "GPUMaterial");
|
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;
|
2018-08-02 18:31:38 +02:00
|
|
|
#ifndef NDEBUG
|
|
|
|
BLI_snprintf(mat->name, sizeof(mat->name), "%s", name);
|
|
|
|
#else
|
|
|
|
UNUSED_VARS(name);
|
|
|
|
#endif
|
2017-04-27 22:27:09 +02:00
|
|
|
|
2018-08-01 19:25:58 +02:00
|
|
|
/* localize tree to create links for reroute and mute */
|
|
|
|
bNodeTree *localtree = ntreeLocalize(ntree);
|
|
|
|
ntreeGPUMaterialNodes(localtree, mat, &has_surface_output, &has_volume_output);
|
2017-10-27 16:07:44 +02:00
|
|
|
|
2018-08-10 15:13:39 +02:00
|
|
|
gpu_material_ramp_texture_build(mat);
|
|
|
|
|
2017-10-27 16:07:44 +02:00
|
|
|
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
|
|
|
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
if (mat->outlink) {
|
2019-01-29 07:46:25 +11:00
|
|
|
/* Prune the unused nodes and extract attributes before compiling so the
|
2018-03-05 00:54:31 +01:00
|
|
|
* generated VBOs are ready to accept the future shader. */
|
|
|
|
GPU_nodes_prune(&mat->nodes, mat->outlink);
|
2019-01-29 07:46:25 +11:00
|
|
|
GPU_nodes_get_vertex_attrs(&mat->nodes, &mat->attrs);
|
2018-06-07 11:58:15 +02:00
|
|
|
/* Create source code and search pass cache for an already compiled version. */
|
2018-09-19 19:34:00 +02:00
|
|
|
mat->pass = GPU_generate_pass(
|
2018-07-18 23:09:31 +10:00
|
|
|
mat,
|
|
|
|
mat->outlink,
|
2019-01-29 07:46:25 +11:00
|
|
|
&mat->attrs,
|
2018-07-18 23:09:31 +10:00
|
|
|
&mat->nodes,
|
2018-10-09 17:32:13 +02:00
|
|
|
&mat->builtins,
|
2018-07-18 23:09:31 +10:00
|
|
|
vert_code,
|
|
|
|
geom_code,
|
|
|
|
frag_lib,
|
|
|
|
defines);
|
2018-06-07 11:58:15 +02:00
|
|
|
|
|
|
|
if (mat->pass == NULL) {
|
|
|
|
/* We had a cache hit and the shader has already failed to compile. */
|
|
|
|
mat->status = GPU_MAT_FAILED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPUShader *sh = GPU_pass_shader_get(mat->pass);
|
|
|
|
if (sh != NULL) {
|
|
|
|
/* We had a cache hit and the shader is already compiled. */
|
|
|
|
mat->status = GPU_MAT_SUCCESS;
|
|
|
|
GPU_nodes_extract_dynamic_inputs(sh, &mat->inputs, &mat->nodes);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mat->status = GPU_MAT_QUEUED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mat->status = GPU_MAT_FAILED;
|
2017-04-27 22:27:09 +02:00
|
|
|
}
|
|
|
|
|
2018-08-01 19:25:58 +02:00
|
|
|
/* Only free after GPU_pass_shader_get where GPUUniformBuffer
|
|
|
|
* read data from the local tree. */
|
2018-12-14 15:20:33 +01:00
|
|
|
ntreeFreeLocalTree(localtree);
|
2018-08-01 19:25:58 +02:00
|
|
|
MEM_freeN(localtree);
|
|
|
|
|
2017-04-27 22:27:09 +02:00
|
|
|
/* note that even if building the shader fails in some way, we still keep
|
2018-06-07 11:58:15 +02:00
|
|
|
* it to avoid trying to compile again and again, and simply do not use
|
2017-04-27 22:27:09 +02:00
|
|
|
* 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
|
|
|
|
2018-06-07 11:58:15 +02:00
|
|
|
void GPU_material_compile(GPUMaterial *mat)
|
2018-03-05 00:54:31 +01:00
|
|
|
{
|
2018-06-07 11:58:15 +02:00
|
|
|
/* Only run once! */
|
|
|
|
BLI_assert(mat->status == GPU_MAT_QUEUED);
|
|
|
|
BLI_assert(mat->pass);
|
|
|
|
|
|
|
|
/* NOTE: The shader may have already been compiled here since we are
|
|
|
|
* sharing GPUShader across GPUMaterials. In this case it's a no-op. */
|
2018-08-02 18:31:38 +02:00
|
|
|
#ifndef NDEBUG
|
|
|
|
GPU_pass_compile(mat->pass, mat->name);
|
|
|
|
#else
|
|
|
|
GPU_pass_compile(mat->pass, __func__);
|
|
|
|
#endif
|
|
|
|
|
2018-06-07 11:58:15 +02:00
|
|
|
GPUShader *sh = GPU_pass_shader_get(mat->pass);
|
|
|
|
|
|
|
|
if (sh != NULL) {
|
|
|
|
mat->status = GPU_MAT_SUCCESS;
|
|
|
|
GPU_nodes_extract_dynamic_inputs(sh, &mat->inputs, &mat->nodes);
|
2018-03-05 00:54:31 +01:00
|
|
|
}
|
2018-03-13 03:49:04 +01:00
|
|
|
else {
|
|
|
|
mat->status = GPU_MAT_FAILED;
|
2018-06-07 11:58:15 +02:00
|
|
|
GPU_pass_free_nodes(&mat->nodes);
|
|
|
|
GPU_pass_release(mat->pass);
|
|
|
|
mat->pass = NULL;
|
2018-03-13 03:49:04 +01:00
|
|
|
}
|
2018-03-05 00:54:31 +01:00
|
|
|
}
|
|
|
|
|
2018-06-25 12:32:48 +02:00
|
|
|
void GPU_materials_free(Main *bmain)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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
|
|
|
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;
|
|
|
|
|
2019-03-08 09:29:17 +11:00
|
|
|
for (ma = bmain->materials.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
|
|
|
|
2019-03-08 09:29:17 +11:00
|
|
|
for (wo = bmain->worlds.first; wo; wo = wo->id.next)
|
2014-12-18 02:14:51 +01:00
|
|
|
GPU_material_free(&wo->gpumaterial);
|
2018-06-04 09:09:12 +02:00
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
GPU_material_free(&defmaterial.gpumaterial);
|
2011-09-09 11:55:38 +00:00
|
|
|
}
|