2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2005 Blender Foundation. All rights reserved. */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup gpu
|
2011-02-21 06:58:46 +00:00
|
|
|
*/
|
|
|
|
|
2020-08-07 09:50:34 +02:00
|
|
|
#pragma once
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2022-06-01 14:38:06 +10:00
|
|
|
#include "DNA_customdata_types.h" /* for eCustomDataType */
|
2021-12-25 11:14:02 +01:00
|
|
|
#include "DNA_image_types.h"
|
2011-09-09 11:55:38 +00:00
|
|
|
#include "DNA_listBase.h"
|
|
|
|
|
2014-10-07 15:46:19 -05:00
|
|
|
#include "BLI_sys_types.h" /* for bool */
|
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
#include "GPU_shader.h" /* for GPUShaderCreateInfo */
|
2020-06-03 13:35:15 +02:00
|
|
|
#include "GPU_texture.h" /* for eGPUSamplerState */
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
Materials: add custom object properties as uniform attributes.
This patch allows the user to type a property name into the
Attribute node, which will then output the value of the property
for each individual object, allowing to e.g. customize shaders
by object without duplicating the shader.
In order to make supporting this easier for Eevee, it is necessary
to explicitly choose whether the attribute is varying or uniform
via a dropdown option of the Attribute node. The dropdown also
allows choosing whether instancing should be taken into account.
The Cycles design treats all attributes as one common namespace,
so the Blender interface converts the enum to a name prefix that
can't be entered using keyboard.
In Eevee, the attributes are provided to the shader via a UBO indexed
with resource_id, similar to the existing Object Info data. Unlike it,
however, it is necessary to maintain a separate buffer for every
requested combination of attributes.
This is done using a hash table with the attribute set as the key,
as it is expected that technically different but similar materials
may use the same set of attributes. In addition, in order to minimize
wasted memory, a sparse UBO pool is implemented, so that chunks that
don't contain any data don't have to be allocated.
The back-end Cycles code is already refactored and committed by Brecht.
Differential Revision: https://developer.blender.org/D2057
2020-08-05 19:14:40 +03:00
|
|
|
struct GHash;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct GPUMaterial;
|
|
|
|
struct GPUNode;
|
|
|
|
struct GPUNodeLink;
|
|
|
|
struct GPUNodeStack;
|
|
|
|
struct GPUTexture;
|
2020-08-20 23:09:37 +02:00
|
|
|
struct GPUUniformBuf;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 Image;
|
|
|
|
struct ImageUser;
|
2017-07-14 17:40:54 +02:00
|
|
|
struct ListBase;
|
2018-06-25 12:32:48 +02:00
|
|
|
struct Main;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 Material;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct Scene;
|
2017-07-14 17:40:54 +02:00
|
|
|
struct bNode;
|
2017-04-27 22:27:09 +02:00
|
|
|
struct bNodeTree;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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-28 21:08:24 +11:00
|
|
|
typedef struct GPUMaterial 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
|
|
|
typedef struct GPUNode GPUNode;
|
|
|
|
typedef struct GPUNodeLink GPUNodeLink;
|
2017-04-03 15:38:00 +02:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/* Functions to create GPU Materials 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
|
|
|
|
2019-01-23 14:15:43 +11:00
|
|
|
typedef enum eGPUType {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Keep in sync with GPU_DATATYPE_STR */
|
|
|
|
/* The value indicates the number of elements in each type */
|
|
|
|
GPU_NONE = 0,
|
|
|
|
GPU_FLOAT = 1,
|
|
|
|
GPU_VEC2 = 2,
|
|
|
|
GPU_VEC3 = 3,
|
|
|
|
GPU_VEC4 = 4,
|
|
|
|
GPU_MAT3 = 9,
|
|
|
|
GPU_MAT4 = 16,
|
2020-02-27 13:55:29 +01:00
|
|
|
GPU_MAX_CONSTANT_DATA = GPU_MAT4,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* Values not in GPU_DATATYPE_STR */
|
|
|
|
GPU_TEX1D_ARRAY = 1001,
|
|
|
|
GPU_TEX2D = 1002,
|
Fix T73133: UDIM texture count in Eevee is limited by OpenGL
Based on @fclem's suggestion in D6421, this commit implements support for
storing all tiles of a UDIM texture in a single 2D array texture on the GPU.
Previously, Eevee was binding one OpenGL texture per tile, quickly running
into hardware limits with nontrivial UDIM texture sets.
Workbench meanwhile had no UDIM support at all, as reusing the per-tile
approach would require splitting the mesh by tile as well as texture.
With this commit, both Workbench as well as Eevee now support huge numbers
of tiles, with the eventual limits being GPU memory and ultimately
GL_MAX_ARRAY_TEXTURE_LAYERS, which tends to be in the 1000s on modern GPUs.
Initially my plan was to have one array texture per unique size, but managing
the different textures and keeping everything consistent ended up being way
too complex.
Therefore, we now use a simpler version that allocates a texture that
is large enough to fit the largest tile and then packs all tiles into as many
layers as necessary.
As a result, each UDIM texture only binds two textures (one for the actual
images, one for metadata) regardless of how many tiles are used.
Note that this rolls back per-tile GPUTextures, meaning that we again have
per-Image GPUTextures like we did before the original UDIM commit,
but now with four instead of two types.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D6456
2020-01-14 00:33:21 +01:00
|
|
|
GPU_TEX2D_ARRAY = 1003,
|
|
|
|
GPU_TEX3D = 1004,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* GLSL Struct types */
|
Fix T73133: UDIM texture count in Eevee is limited by OpenGL
Based on @fclem's suggestion in D6421, this commit implements support for
storing all tiles of a UDIM texture in a single 2D array texture on the GPU.
Previously, Eevee was binding one OpenGL texture per tile, quickly running
into hardware limits with nontrivial UDIM texture sets.
Workbench meanwhile had no UDIM support at all, as reusing the per-tile
approach would require splitting the mesh by tile as well as texture.
With this commit, both Workbench as well as Eevee now support huge numbers
of tiles, with the eventual limits being GPU memory and ultimately
GL_MAX_ARRAY_TEXTURE_LAYERS, which tends to be in the 1000s on modern GPUs.
Initially my plan was to have one array texture per unique size, but managing
the different textures and keeping everything consistent ended up being way
too complex.
Therefore, we now use a simpler version that allocates a texture that
is large enough to fit the largest tile and then packs all tiles into as many
layers as necessary.
As a result, each UDIM texture only binds two textures (one for the actual
images, one for metadata) regardless of how many tiles are used.
Note that this rolls back per-tile GPUTextures, meaning that we again have
per-Image GPUTextures like we did before the original UDIM commit,
but now with four instead of two types.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D6456
2020-01-14 00:33:21 +01:00
|
|
|
GPU_CLOSURE = 1007,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* Opengl Attributes */
|
|
|
|
GPU_ATTR = 3001,
|
2019-01-23 14:15:43 +11:00
|
|
|
} eGPUType;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
typedef enum eGPUMaterialFlag {
|
2019-04-17 06:17:24 +02:00
|
|
|
GPU_MATFLAG_DIFFUSE = (1 << 0),
|
2022-04-14 18:47:58 +02:00
|
|
|
GPU_MATFLAG_SUBSURFACE = (1 << 1),
|
|
|
|
GPU_MATFLAG_GLOSSY = (1 << 2),
|
|
|
|
GPU_MATFLAG_REFRACT = (1 << 3),
|
|
|
|
GPU_MATFLAG_EMISSION = (1 << 4),
|
|
|
|
GPU_MATFLAG_TRANSPARENT = (1 << 5),
|
|
|
|
GPU_MATFLAG_HOLDOUT = (1 << 6),
|
|
|
|
GPU_MATFLAG_SHADER_TO_RGBA = (1 << 7),
|
|
|
|
GPU_MATFLAG_AO = (1 << 8),
|
|
|
|
|
|
|
|
GPU_MATFLAG_OBJECT_INFO = (1 << 10),
|
|
|
|
GPU_MATFLAG_AOV = (1 << 11),
|
|
|
|
|
|
|
|
GPU_MATFLAG_BARYCENTRIC = (1 << 20),
|
|
|
|
|
|
|
|
/* Tells the render engine the material was just compiled or updated. */
|
|
|
|
GPU_MATFLAG_UPDATED = (1 << 29),
|
|
|
|
|
|
|
|
/* HACK(fclem) Tells the environment texture node to not bail out if empty. */
|
|
|
|
GPU_MATFLAG_LOOKDEV_HACK = (1 << 30),
|
|
|
|
} eGPUMaterialFlag;
|
|
|
|
|
|
|
|
ENUM_OPERATORS(eGPUMaterialFlag, GPU_MATFLAG_LOOKDEV_HACK);
|
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
|
|
|
typedef struct GPUNodeStack {
|
2019-04-17 06:17:24 +02:00
|
|
|
eGPUType type;
|
|
|
|
float vec[4];
|
|
|
|
struct GPUNodeLink *link;
|
|
|
|
bool hasinput;
|
|
|
|
bool hasoutput;
|
|
|
|
short sockettype;
|
|
|
|
bool end;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
} GPUNodeStack;
|
|
|
|
|
2019-01-23 14:15:43 +11:00
|
|
|
typedef enum eGPUMaterialStatus {
|
2019-04-17 06:17:24 +02:00
|
|
|
GPU_MAT_FAILED = 0,
|
2022-04-14 18:47:58 +02:00
|
|
|
GPU_MAT_CREATED,
|
2019-04-17 06:17:24 +02:00
|
|
|
GPU_MAT_QUEUED,
|
|
|
|
GPU_MAT_SUCCESS,
|
2019-01-23 14:15:43 +11:00
|
|
|
} eGPUMaterialStatus;
|
2015-05-21 08:08:27 +10:00
|
|
|
|
2022-04-19 12:01:16 +02:00
|
|
|
typedef enum eGPUDefaultValue {
|
|
|
|
GPU_DEFAULT_0 = 0,
|
|
|
|
GPU_DEFAULT_1,
|
|
|
|
} eGPUDefaultValue;
|
2020-09-03 15:26:52 +02:00
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
typedef struct GPUCodegenOutput {
|
|
|
|
char *attr_load;
|
2022-04-20 09:16:24 +10:00
|
|
|
/* Node-tree functions calls. */
|
2022-04-14 18:47:58 +02:00
|
|
|
char *displacement;
|
|
|
|
char *surface;
|
|
|
|
char *volume;
|
|
|
|
char *thickness;
|
|
|
|
char *material_functions;
|
|
|
|
|
|
|
|
GPUShaderCreateInfo *create_info;
|
|
|
|
} GPUCodegenOutput;
|
|
|
|
|
|
|
|
typedef void (*GPUCodegenCallbackFn)(void *thunk, GPUMaterial *mat, GPUCodegenOutput *codegen);
|
2020-07-30 13:55:13 +02:00
|
|
|
|
2020-02-27 13:55:29 +01:00
|
|
|
GPUNodeLink *GPU_constant(const float *num);
|
|
|
|
GPUNodeLink *GPU_uniform(const float *num);
|
2022-06-01 14:38:06 +10:00
|
|
|
GPUNodeLink *GPU_attribute(GPUMaterial *mat, eCustomDataType type, const char *name);
|
2022-04-19 12:01:16 +02:00
|
|
|
GPUNodeLink *GPU_attribute_with_default(GPUMaterial *mat,
|
2022-06-01 14:38:06 +10:00
|
|
|
eCustomDataType type,
|
2022-04-19 12:01:16 +02:00
|
|
|
const char *name,
|
|
|
|
eGPUDefaultValue default_value);
|
Materials: add custom object properties as uniform attributes.
This patch allows the user to type a property name into the
Attribute node, which will then output the value of the property
for each individual object, allowing to e.g. customize shaders
by object without duplicating the shader.
In order to make supporting this easier for Eevee, it is necessary
to explicitly choose whether the attribute is varying or uniform
via a dropdown option of the Attribute node. The dropdown also
allows choosing whether instancing should be taken into account.
The Cycles design treats all attributes as one common namespace,
so the Blender interface converts the enum to a name prefix that
can't be entered using keyboard.
In Eevee, the attributes are provided to the shader via a UBO indexed
with resource_id, similar to the existing Object Info data. Unlike it,
however, it is necessary to maintain a separate buffer for every
requested combination of attributes.
This is done using a hash table with the attribute set as the key,
as it is expected that technically different but similar materials
may use the same set of attributes. In addition, in order to minimize
wasted memory, a sparse UBO pool is implemented, so that chunks that
don't contain any data don't have to be allocated.
The back-end Cycles code is already refactored and committed by Brecht.
Differential Revision: https://developer.blender.org/D2057
2020-08-05 19:14:40 +03:00
|
|
|
GPUNodeLink *GPU_uniform_attribute(GPUMaterial *mat, const char *name, bool use_dupli);
|
2020-06-03 13:35:15 +02:00
|
|
|
GPUNodeLink *GPU_image(GPUMaterial *mat,
|
|
|
|
struct Image *ima,
|
|
|
|
struct ImageUser *iuser,
|
|
|
|
eGPUSamplerState sampler_state);
|
|
|
|
GPUNodeLink *GPU_image_tiled(GPUMaterial *mat,
|
|
|
|
struct Image *ima,
|
|
|
|
struct ImageUser *iuser,
|
|
|
|
eGPUSamplerState sampler_state);
|
2020-02-27 13:55:29 +01:00
|
|
|
GPUNodeLink *GPU_image_tiled_mapping(GPUMaterial *mat, struct Image *ima, struct ImageUser *iuser);
|
2020-09-04 20:59:13 +02:00
|
|
|
GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *row);
|
2022-04-19 12:01:16 +02:00
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
/**
|
|
|
|
* Create an implementation defined differential calculation of a float function.
|
|
|
|
* The given function should return a float.
|
|
|
|
* The result will be a vec2 containing dFdx and dFdy result of that function.
|
|
|
|
*/
|
|
|
|
GPUNodeLink *GPU_differentiate_float_function(const char *function_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
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool GPU_link(GPUMaterial *mat, const char *name, ...);
|
2019-04-17 06:17:24 +02:00
|
|
|
bool GPU_stack_link(GPUMaterial *mat,
|
|
|
|
struct bNode *node,
|
|
|
|
const char *name,
|
|
|
|
GPUNodeStack *in,
|
|
|
|
GPUNodeStack *out,
|
|
|
|
...);
|
2020-08-20 23:09:37 +02:00
|
|
|
GPUNodeLink *GPU_uniformbuf_link_out(struct GPUMaterial *mat,
|
|
|
|
struct bNode *node,
|
|
|
|
struct GPUNodeStack *stack,
|
2022-01-07 11:38:08 +11:00
|
|
|
int index);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
void GPU_material_output_surface(GPUMaterial *material, GPUNodeLink *link);
|
|
|
|
void GPU_material_output_volume(GPUMaterial *material, GPUNodeLink *link);
|
|
|
|
void GPU_material_output_displacement(GPUMaterial *material, GPUNodeLink *link);
|
|
|
|
void GPU_material_output_thickness(GPUMaterial *material, GPUNodeLink *link);
|
|
|
|
|
2020-12-04 08:13:54 +01:00
|
|
|
void GPU_material_add_output_link_aov(GPUMaterial *material, GPUNodeLink *link, int hash);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
/**
|
|
|
|
* Wrap a part of the material graph into a function. You need then need to call the function by
|
|
|
|
* using something like #GPU_differentiate_float_function.
|
|
|
|
* \note This replace the link by a constant to break the link with the main graph.
|
|
|
|
* \param return_type: sub function return type. Output is cast to this type.
|
|
|
|
* \param link: link to use as the sub function output.
|
|
|
|
* \return the name of the generated function.
|
|
|
|
*/
|
|
|
|
char *GPU_material_split_sub_function(GPUMaterial *material,
|
|
|
|
eGPUType return_type,
|
|
|
|
GPUNodeLink **link);
|
|
|
|
|
|
|
|
bool GPU_material_sss_profile_create(GPUMaterial *material, float radii[3]);
|
2020-08-20 23:09:37 +02:00
|
|
|
struct GPUUniformBuf *GPU_material_sss_profile_get(GPUMaterial *material,
|
|
|
|
int sample_len,
|
|
|
|
struct GPUTexture **tex_profile);
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
* High level functions to create and use GPU materials.
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
GPUMaterial *GPU_material_from_nodetree_find(struct ListBase *gpumaterials,
|
|
|
|
const void *engine_type,
|
|
|
|
int options);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
* \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.
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
GPUMaterial *GPU_material_from_nodetree(struct Scene *scene,
|
2019-05-11 14:37:27 +02:00
|
|
|
struct Material *ma,
|
2019-04-17 06:17:24 +02:00
|
|
|
struct bNodeTree *ntree,
|
|
|
|
struct ListBase *gpumaterials,
|
2020-07-30 13:55:13 +02:00
|
|
|
const char *name,
|
2022-04-14 18:47:58 +02:00
|
|
|
uint64_t shader_uuid,
|
|
|
|
bool is_volume_shader,
|
|
|
|
bool is_lookdev,
|
|
|
|
GPUCodegenCallbackFn callback,
|
|
|
|
void *thunk);
|
|
|
|
|
2018-06-07 11:58:15 +02:00
|
|
|
void GPU_material_compile(GPUMaterial *mat);
|
2014-11-24 17:18:56 +01:00
|
|
|
void GPU_material_free(struct 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
|
|
|
|
2022-04-20 14:35:07 +02:00
|
|
|
void GPU_material_acquire(GPUMaterial *mat);
|
|
|
|
void GPU_material_release(GPUMaterial *mat);
|
|
|
|
|
2018-06-25 12:32:48 +02:00
|
|
|
void GPU_materials_free(struct 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
|
|
|
|
2013-11-25 20:58:23 +09:00
|
|
|
struct Scene *GPU_material_scene(GPUMaterial *material);
|
2017-04-27 22:27:09 +02:00
|
|
|
struct GPUPass *GPU_material_get_pass(GPUMaterial *material);
|
2020-06-02 16:58:07 +02:00
|
|
|
struct GPUShader *GPU_material_get_shader(GPUMaterial *material);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
* Return can be NULL if it's a world material.
|
|
|
|
*/
|
2019-05-11 14:37:27 +02:00
|
|
|
struct Material *GPU_material_get_material(GPUMaterial *material);
|
2021-12-09 20:01:47 +11: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);
|
2022-04-14 18:47:58 +02:00
|
|
|
void GPU_material_status_set(GPUMaterial *mat, eGPUMaterialStatus 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
|
|
|
|
2020-08-20 23:09:37 +02:00
|
|
|
struct GPUUniformBuf *GPU_material_uniform_buffer_get(GPUMaterial *material);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
* Create dynamic UBO from parameters
|
|
|
|
*
|
|
|
|
* \param inputs: Items are #LinkData, data is #GPUInput (`BLI_genericNodeN(GPUInput)`).
|
|
|
|
*/
|
2018-06-07 19:40:47 +02:00
|
|
|
void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs);
|
2020-08-20 23:09:37 +02:00
|
|
|
struct GPUUniformBuf *GPU_material_create_sss_profile_ubo(void);
|
2017-07-14 17:40:54 +02:00
|
|
|
|
2020-03-11 14:58:19 +01:00
|
|
|
bool GPU_material_has_surface_output(GPUMaterial *mat);
|
|
|
|
bool GPU_material_has_volume_output(GPUMaterial *mat);
|
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag);
|
|
|
|
bool GPU_material_flag_get(const GPUMaterial *mat, eGPUMaterialFlag flag);
|
|
|
|
eGPUMaterialFlag GPU_material_flag(const GPUMaterial *mat);
|
|
|
|
bool GPU_material_recalc_flag_get(GPUMaterial *mat);
|
|
|
|
uint64_t GPU_material_uuid_get(GPUMaterial *mat);
|
2018-08-03 18:53:36 +02:00
|
|
|
|
2018-06-07 11:58:15 +02:00
|
|
|
void GPU_pass_cache_init(void);
|
2018-03-11 23:43:09 +01:00
|
|
|
void GPU_pass_cache_garbage_collect(void);
|
|
|
|
void GPU_pass_cache_free(void);
|
|
|
|
|
2020-02-14 10:47:20 +01:00
|
|
|
/* Requested Material Attributes and Textures */
|
|
|
|
|
|
|
|
typedef struct GPUMaterialAttribute {
|
|
|
|
struct GPUMaterialAttribute *next, *prev;
|
2022-06-01 14:38:06 +10:00
|
|
|
int type; /* eCustomDataType */
|
2022-04-19 12:01:16 +02:00
|
|
|
char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
|
|
|
|
char input_name[12 + 1]; /* GPU_MAX_SAFE_ATTR_NAME + 1 */
|
2020-02-27 13:55:29 +01:00
|
|
|
eGPUType gputype;
|
2022-04-19 12:01:16 +02:00
|
|
|
eGPUDefaultValue default_value; /* Only for volumes attributes. */
|
2020-02-14 10:47:20 +01:00
|
|
|
int id;
|
2020-02-27 13:55:29 +01:00
|
|
|
int users;
|
2020-02-14 10:47:20 +01:00
|
|
|
} GPUMaterialAttribute;
|
|
|
|
|
|
|
|
typedef struct GPUMaterialTexture {
|
|
|
|
struct GPUMaterialTexture *next, *prev;
|
|
|
|
struct Image *ima;
|
2021-12-25 11:14:02 +01:00
|
|
|
struct ImageUser iuser;
|
|
|
|
bool iuser_available;
|
2020-02-14 10:47:20 +01:00
|
|
|
struct GPUTexture **colorband;
|
2020-02-27 13:55:29 +01:00
|
|
|
char sampler_name[32]; /* Name of sampler in GLSL. */
|
|
|
|
char tiled_mapping_name[32]; /* Name of tile mapping sampler in GLSL. */
|
|
|
|
int users;
|
2020-06-03 13:35:15 +02:00
|
|
|
int sampler_state; /* eGPUSamplerState */
|
2020-02-14 10:47:20 +01:00
|
|
|
} GPUMaterialTexture;
|
|
|
|
|
|
|
|
ListBase GPU_material_attributes(GPUMaterial *material);
|
|
|
|
ListBase GPU_material_textures(GPUMaterial *material);
|
|
|
|
|
Materials: add custom object properties as uniform attributes.
This patch allows the user to type a property name into the
Attribute node, which will then output the value of the property
for each individual object, allowing to e.g. customize shaders
by object without duplicating the shader.
In order to make supporting this easier for Eevee, it is necessary
to explicitly choose whether the attribute is varying or uniform
via a dropdown option of the Attribute node. The dropdown also
allows choosing whether instancing should be taken into account.
The Cycles design treats all attributes as one common namespace,
so the Blender interface converts the enum to a name prefix that
can't be entered using keyboard.
In Eevee, the attributes are provided to the shader via a UBO indexed
with resource_id, similar to the existing Object Info data. Unlike it,
however, it is necessary to maintain a separate buffer for every
requested combination of attributes.
This is done using a hash table with the attribute set as the key,
as it is expected that technically different but similar materials
may use the same set of attributes. In addition, in order to minimize
wasted memory, a sparse UBO pool is implemented, so that chunks that
don't contain any data don't have to be allocated.
The back-end Cycles code is already refactored and committed by Brecht.
Differential Revision: https://developer.blender.org/D2057
2020-08-05 19:14:40 +03:00
|
|
|
typedef struct GPUUniformAttr {
|
|
|
|
struct GPUUniformAttr *next, *prev;
|
|
|
|
|
|
|
|
/* Meaningful part of the attribute set key. */
|
|
|
|
char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
|
|
|
|
bool use_dupli;
|
|
|
|
|
|
|
|
/* Helper fields used by code generation. */
|
|
|
|
short id;
|
|
|
|
int users;
|
|
|
|
} GPUUniformAttr;
|
|
|
|
|
|
|
|
typedef struct GPUUniformAttrList {
|
|
|
|
ListBase list; /* GPUUniformAttr */
|
|
|
|
|
|
|
|
/* List length and hash code precomputed for fast lookup and comparison. */
|
|
|
|
unsigned int count, hash_code;
|
|
|
|
} GPUUniformAttrList;
|
|
|
|
|
|
|
|
GPUUniformAttrList *GPU_material_uniform_attributes(GPUMaterial *material);
|
|
|
|
|
|
|
|
struct GHash *GPU_uniform_attr_list_hash_new(const char *info);
|
|
|
|
void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, GPUUniformAttrList *src);
|
|
|
|
void GPU_uniform_attr_list_free(GPUUniformAttrList *set);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|