2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2005 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00: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
|
|
|
|
2024-02-12 19:33:44 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
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"
|
|
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_shader.hh" /* for GPUShaderCreateInfo */
|
|
|
|
|
#include "GPU_texture.hh" /* for GPUSamplerState */
|
2020-06-03 13:35:15 +02:00
|
|
|
|
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 GPUNodeLink;
|
|
|
|
|
struct GPUNodeStack;
|
2024-02-01 10:40:24 -05:00
|
|
|
struct GPUPass;
|
2025-07-22 09:48:10 +02:00
|
|
|
namespace blender::gpu {
|
|
|
|
|
class Texture;
|
|
|
|
|
}
|
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
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
/**
|
|
|
|
|
* High level functions to create and use GPU materials.
|
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
enum eGPUMaterialEngine {
|
|
|
|
|
GPU_MAT_EEVEE,
|
|
|
|
|
GPU_MAT_COMPOSITOR,
|
|
|
|
|
GPU_MAT_ENGINE_MAX,
|
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
enum eGPUMaterialStatus {
|
|
|
|
|
GPU_MAT_FAILED = 0,
|
|
|
|
|
GPU_MAT_QUEUED,
|
|
|
|
|
GPU_MAT_SUCCESS,
|
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
/* GPU_MAT_OPTIMIZATION_SKIP for cases where we do not
|
|
|
|
|
* plan to perform optimization on a given material. */
|
|
|
|
|
enum eGPUMaterialOptimizationStatus {
|
|
|
|
|
GPU_MAT_OPTIMIZATION_SKIP = 0,
|
|
|
|
|
GPU_MAT_OPTIMIZATION_QUEUED,
|
|
|
|
|
GPU_MAT_OPTIMIZATION_SUCCESS,
|
2024-02-01 10:40:24 -05: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
|
|
|
|
2024-02-01 10:40:24 -05:00
|
|
|
enum eGPUMaterialFlag {
|
2018-08-03 18:53:36 +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),
|
2024-02-24 00:00:11 +01:00
|
|
|
/* Signals the presence of multiple reflection closures. */
|
Cycles: Rework Principled BSDF Clearcoat
- Adds tint control, which simulates volumetric absorption inside the coating.
This results in angle-dependent saturation and affects all underlying layers
(diffuse, subsurface, metallic, transmission). It provides a physically-based
alternative to ad-hoc effects such as tinted specular highlights.
- Renames the component from "Clearcoat" to "Coat", since it's no longer
necessarily clear now. This matches naming in e.g. other renderers or OpenPBR.
- Adds an explicit Coat IOR input, in preparation for future smarter IOR logic
around the interaction between Coat and main IOR. This used to be hardcoded
to 1.5.
- Removes hardcoded 0.25 weight multiplier, and adds versioning code to update
existing files accordingly. OBJ import/export still applies the factor.
- Replaces the GTR1 microfacet component with regular GGX. This removes a corner
case in the Microfacet code, solves #53038, and makes us more consistent with
other standard surface shaders. The original Disney BSDF used GTR1, but it
doesn't appear that it caught on in the industry.
Co-authored-by: Weizhen Huang <weizhen@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/110993
2023-09-13 00:03:11 +02:00
|
|
|
GPU_MATFLAG_COAT = (1 << 9),
|
2023-12-13 02:19:19 +01:00
|
|
|
GPU_MATFLAG_TRANSLUCENT = (1 << 10),
|
2022-04-14 18:47:58 +02:00
|
|
|
|
2023-12-13 02:19:19 +01:00
|
|
|
GPU_MATFLAG_VOLUME_SCATTER = (1 << 16),
|
|
|
|
|
GPU_MATFLAG_VOLUME_ABSORPTION = (1 << 17),
|
2023-11-22 21:17:59 +01:00
|
|
|
|
2023-12-13 02:19:19 +01:00
|
|
|
GPU_MATFLAG_OBJECT_INFO = (1 << 18),
|
|
|
|
|
GPU_MATFLAG_AOV = (1 << 19),
|
2022-04-14 18:47:58 +02:00
|
|
|
|
|
|
|
|
GPU_MATFLAG_BARYCENTRIC = (1 << 20),
|
|
|
|
|
|
|
|
|
|
/* Tells the render engine the material was just compiled or updated. */
|
|
|
|
|
GPU_MATFLAG_UPDATED = (1 << 29),
|
2024-02-01 10:40:24 -05:00
|
|
|
};
|
2025-05-22 17:53:22 +02:00
|
|
|
ENUM_OPERATORS(eGPUMaterialFlag, GPU_MATFLAG_UPDATED);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
using GPUCodegenCallbackFn = void (*)(void *thunk,
|
|
|
|
|
GPUMaterial *mat,
|
|
|
|
|
struct GPUCodegenOutput *codegen);
|
2024-05-15 16:01:05 +02:00
|
|
|
/**
|
|
|
|
|
* Should return an already compiled pass if it's functionally equivalent to the one being
|
|
|
|
|
* compiled.
|
|
|
|
|
*/
|
|
|
|
|
using GPUMaterialPassReplacementCallbackFn = GPUPass *(*)(void *thunk, GPUMaterial *mat);
|
2020-07-30 13:55:13 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
/** WARNING: gpumaterials thread safety must be ensured by the caller. */
|
2024-04-30 19:44:06 +02:00
|
|
|
GPUMaterial *GPU_material_from_nodetree(
|
|
|
|
|
Material *ma,
|
|
|
|
|
bNodeTree *ntree,
|
|
|
|
|
ListBase *gpumaterials,
|
|
|
|
|
const char *name,
|
|
|
|
|
eGPUMaterialEngine engine,
|
|
|
|
|
uint64_t shader_uuid,
|
2025-05-22 17:53:22 +02:00
|
|
|
bool deferred_compilation,
|
2024-04-30 19:44:06 +02:00
|
|
|
GPUCodegenCallbackFn callback,
|
|
|
|
|
void *thunk,
|
2024-05-15 16:01:05 +02:00
|
|
|
GPUMaterialPassReplacementCallbackFn pass_replacement_cb = nullptr);
|
2022-04-14 18:47:58 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
/* A callback passed to GPU_material_from_callbacks to construct the material graph by adding and
|
|
|
|
|
* linking the necessary GPU material nodes. */
|
|
|
|
|
using ConstructGPUMaterialFn = void (*)(void *thunk, 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
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
/* Construct a GPU material from a set of callbacks. See the callback types for more information.
|
|
|
|
|
* The given thunk will be passed as the first parameter of each callback. */
|
|
|
|
|
GPUMaterial *GPU_material_from_callbacks(eGPUMaterialEngine engine,
|
|
|
|
|
ConstructGPUMaterialFn construct_function_cb,
|
|
|
|
|
GPUCodegenCallbackFn generate_code_function_cb,
|
|
|
|
|
void *thunk);
|
2024-06-07 16:11:50 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
void GPU_material_free_single(GPUMaterial *material);
|
|
|
|
|
void GPU_material_free(ListBase *gpumaterial);
|
2022-04-20 14:35:07 +02:00
|
|
|
|
2024-02-01 10:40:24 -05: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
|
|
|
|
2024-02-01 10:40:24 -05:00
|
|
|
GPUPass *GPU_material_get_pass(GPUMaterial *material);
|
2023-02-27 21:44:59 +11:00
|
|
|
/** Return the most optimal shader configuration for the given material. */
|
2024-02-01 10:40:24 -05:00
|
|
|
GPUShader *GPU_material_get_shader(GPUMaterial *material);
|
2022-09-22 17:27:51 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
const char *GPU_material_get_name(GPUMaterial *material);
|
2023-02-14 21:51:03 +01:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
2024-03-23 01:24:18 +01:00
|
|
|
* Return can be null if it's a world material.
|
2021-12-09 20:01:47 +11:00
|
|
|
*/
|
2024-02-01 10:40:24 -05:00
|
|
|
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);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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-09-22 17:27:51 +02:00
|
|
|
/**
|
2023-08-05 13:46:22 +10:00
|
|
|
* Return status for asynchronous optimization jobs.
|
2022-09-22 17:27:51 +02:00
|
|
|
*/
|
|
|
|
|
eGPUMaterialOptimizationStatus GPU_material_optimization_status(GPUMaterial *mat);
|
|
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
uint64_t GPU_material_compilation_timestamp(GPUMaterial *mat);
|
2023-02-14 21:51:03 +01:00
|
|
|
|
2024-02-01 10:40:24 -05:00
|
|
|
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);
|
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);
|
2023-11-07 15:28:07 +01:00
|
|
|
bool GPU_material_has_displacement_output(GPUMaterial *mat);
|
2020-03-11 14:58:19 +01:00
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
bool GPU_material_flag_get(const GPUMaterial *mat, eGPUMaterialFlag flag);
|
2025-05-22 17:53:22 +02:00
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
uint64_t GPU_material_uuid_get(GPUMaterial *mat);
|
2018-08-03 18:53:36 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
struct GPULayerAttr {
|
|
|
|
|
GPULayerAttr *next, *prev;
|
|
|
|
|
|
|
|
|
|
/* Meaningful part of the attribute set key. */
|
|
|
|
|
char name[256]; /* Multiple MAX_CUSTOMDATA_LAYER_NAME */
|
2025-05-23 03:58:32 +00:00
|
|
|
/** Hash of `name[68]`. */
|
2025-05-22 17:53:22 +02:00
|
|
|
uint32_t hash_code;
|
|
|
|
|
|
|
|
|
|
/* Helper fields used by code generation. */
|
|
|
|
|
int users;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ListBase *GPU_material_layer_attributes(const GPUMaterial *material);
|
2018-03-11 23:43:09 +01:00
|
|
|
|
2020-02-14 10:47:20 +01:00
|
|
|
/* Requested Material Attributes and Textures */
|
|
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
enum eGPUType {
|
|
|
|
|
/* 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,
|
|
|
|
|
GPU_MAX_CONSTANT_DATA = GPU_MAT4,
|
|
|
|
|
|
|
|
|
|
/* Values not in GPU_DATATYPE_STR */
|
|
|
|
|
GPU_TEX1D_ARRAY = 1001,
|
|
|
|
|
GPU_TEX2D = 1002,
|
|
|
|
|
GPU_TEX2D_ARRAY = 1003,
|
|
|
|
|
GPU_TEX3D = 1004,
|
|
|
|
|
|
|
|
|
|
/* GLSL Struct types */
|
|
|
|
|
GPU_CLOSURE = 1007,
|
|
|
|
|
|
|
|
|
|
/* Opengl Attributes */
|
|
|
|
|
GPU_ATTR = 3001,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum eGPUDefaultValue {
|
|
|
|
|
GPU_DEFAULT_0 = 0,
|
|
|
|
|
GPU_DEFAULT_1,
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-01 10:40:24 -05:00
|
|
|
struct GPUMaterialAttribute {
|
|
|
|
|
GPUMaterialAttribute *next, *prev;
|
2025-05-23 03:58:32 +00:00
|
|
|
int type; /* eCustomDataType */
|
|
|
|
|
char name[/*MAX_CUSTOMDATA_LAYER_NAME*/ 68];
|
|
|
|
|
char input_name[/*GPU_MAX_SAFE_ATTR_NAME + 1*/ 12 + 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;
|
2022-07-26 08:37:08 -05:00
|
|
|
/**
|
|
|
|
|
* If true, the corresponding attribute is the specified default color attribute on the mesh,
|
|
|
|
|
* if it exists. In that case the type and name data can vary per geometry, so it will not be
|
|
|
|
|
* valid here.
|
|
|
|
|
*/
|
|
|
|
|
bool is_default_color;
|
2023-06-28 17:17:31 +02:00
|
|
|
/**
|
|
|
|
|
* If true, the attribute is the length of hair particles and curves.
|
|
|
|
|
*/
|
|
|
|
|
bool is_hair_length;
|
2024-02-01 10:40:24 -05:00
|
|
|
};
|
2020-02-14 10:47:20 +01:00
|
|
|
|
2024-02-01 10:40:24 -05:00
|
|
|
struct GPUMaterialTexture {
|
|
|
|
|
GPUMaterialTexture *next, *prev;
|
|
|
|
|
Image *ima;
|
|
|
|
|
ImageUser iuser;
|
2021-12-25 11:14:02 +01:00
|
|
|
bool iuser_available;
|
2025-07-22 09:48:10 +02:00
|
|
|
blender::gpu::Texture **colorband;
|
|
|
|
|
blender::gpu::Texture **sky;
|
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;
|
2023-04-04 15:16:07 +02:00
|
|
|
GPUSamplerState sampler_state;
|
2024-02-01 10:40:24 -05:00
|
|
|
};
|
2020-02-14 10:47:20 +01:00
|
|
|
|
2023-11-30 19:54:06 -05:00
|
|
|
ListBase GPU_material_attributes(const GPUMaterial *material);
|
2020-02-14 10:47:20 +01:00
|
|
|
ListBase GPU_material_textures(GPUMaterial *material);
|
|
|
|
|
|
2024-02-01 10:40:24 -05:00
|
|
|
struct GPUUniformAttr {
|
|
|
|
|
GPUUniformAttr *next, *prev;
|
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
|
|
|
|
|
|
|
|
/* Meaningful part of the attribute set key. */
|
2025-05-23 03:58:32 +00:00
|
|
|
char name[/*MAX_CUSTOMDATA_LAYER_NAME*/ 68];
|
|
|
|
|
/** Hash of `name[MAX_CUSTOMDATA_LAYER_NAME] + use_dupli`. */
|
2022-09-01 13:35:04 +02:00
|
|
|
uint32_t hash_code;
|
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
|
|
|
bool use_dupli;
|
|
|
|
|
|
|
|
|
|
/* Helper fields used by code generation. */
|
|
|
|
|
short id;
|
|
|
|
|
int users;
|
2024-02-01 10:40:24 -05:00
|
|
|
};
|
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
|
|
|
|
2024-02-01 10:40:24 -05:00
|
|
|
struct GPUUniformAttrList {
|
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
|
|
|
ListBase list; /* GPUUniformAttr */
|
|
|
|
|
|
|
|
|
|
/* List length and hash code precomputed for fast lookup and comparison. */
|
|
|
|
|
unsigned int count, hash_code;
|
2024-02-01 10:40:24 -05:00
|
|
|
};
|
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
|
|
|
|
2022-09-02 19:01:12 +02:00
|
|
|
const GPUUniformAttrList *GPU_material_uniform_attributes(const 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
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
/* Functions to create GPU Materials nodes. */
|
|
|
|
|
/* TODO: Move to its own header. */
|
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
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
struct GPUNodeStack {
|
|
|
|
|
eGPUType type;
|
|
|
|
|
float vec[4];
|
|
|
|
|
GPUNodeLink *link;
|
|
|
|
|
bool hasinput;
|
|
|
|
|
bool hasoutput;
|
|
|
|
|
short sockettype;
|
|
|
|
|
bool end;
|
|
|
|
|
};
|
Attribute Node: support accessing attributes of View Layer and Scene.
The attribute node already allows accessing attributes associated
with objects and meshes, which allows changing the behavior of the
same material between different objects or instances. The same idea
can be extended to an even more global level of layers and scenes.
Currently view layers provide an option to replace all materials
with a different one. However, since the same material will be applied
to all objects in the layer, varying the behavior between layers while
preserving distinct materials requires duplicating objects.
Providing access to properties of layers and scenes via the attribute
node enables making materials with built-in switches or settings that
can be controlled globally at the view layer level. This is probably
most useful for complex NPR shading and compositing. Like with objects,
the node can also access built-in scene properties, like render resolution
or FOV of the active camera. Lookup is also attempted in World, similar
to how the Object mode checks the Mesh datablock.
In Cycles this mode is implemented by replacing the attribute node with
the attribute value during sync, allowing constant folding to take the
values into account. This means however that materials that use this
feature have to be re-synced upon any changes to scene, world or camera.
The Eevee version uses a new uniform buffer containing a sorted array
mapping name hashes to values, with binary search lookup. The array
is limited to 512 entries, which is effectively limitless even
considering it is shared by all materials in the scene; it is also
just 16KB of memory so no point trying to optimize further.
The buffer has to be rebuilt when new attributes are detected in a
material, so the draw engine keeps a table of recently seen attribute
names to minimize the chance of extra rebuilds mid-draw.
Differential Revision: https://developer.blender.org/D15941
2022-09-12 00:30:58 +03:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
struct GPUCodegenOutput {
|
|
|
|
|
std::string attr_load;
|
|
|
|
|
/* Node-tree functions calls. */
|
|
|
|
|
std::string displacement;
|
|
|
|
|
std::string surface;
|
|
|
|
|
std::string volume;
|
|
|
|
|
std::string thickness;
|
|
|
|
|
std::string composite;
|
|
|
|
|
std::string material_functions;
|
Attribute Node: support accessing attributes of View Layer and Scene.
The attribute node already allows accessing attributes associated
with objects and meshes, which allows changing the behavior of the
same material between different objects or instances. The same idea
can be extended to an even more global level of layers and scenes.
Currently view layers provide an option to replace all materials
with a different one. However, since the same material will be applied
to all objects in the layer, varying the behavior between layers while
preserving distinct materials requires duplicating objects.
Providing access to properties of layers and scenes via the attribute
node enables making materials with built-in switches or settings that
can be controlled globally at the view layer level. This is probably
most useful for complex NPR shading and compositing. Like with objects,
the node can also access built-in scene properties, like render resolution
or FOV of the active camera. Lookup is also attempted in World, similar
to how the Object mode checks the Mesh datablock.
In Cycles this mode is implemented by replacing the attribute node with
the attribute value during sync, allowing constant folding to take the
values into account. This means however that materials that use this
feature have to be re-synced upon any changes to scene, world or camera.
The Eevee version uses a new uniform buffer containing a sorted array
mapping name hashes to values, with binary search lookup. The array
is limited to 512 entries, which is effectively limitless even
considering it is shared by all materials in the scene; it is also
just 16KB of memory so no point trying to optimize further.
The buffer has to be rebuilt when new attributes are detected in a
material, so the draw engine keeps a table of recently seen attribute
names to minimize the chance of extra rebuilds mid-draw.
Differential Revision: https://developer.blender.org/D15941
2022-09-12 00:30:58 +03:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
GPUShaderCreateInfo *create_info;
|
2024-02-01 10:40:24 -05:00
|
|
|
};
|
Attribute Node: support accessing attributes of View Layer and Scene.
The attribute node already allows accessing attributes associated
with objects and meshes, which allows changing the behavior of the
same material between different objects or instances. The same idea
can be extended to an even more global level of layers and scenes.
Currently view layers provide an option to replace all materials
with a different one. However, since the same material will be applied
to all objects in the layer, varying the behavior between layers while
preserving distinct materials requires duplicating objects.
Providing access to properties of layers and scenes via the attribute
node enables making materials with built-in switches or settings that
can be controlled globally at the view layer level. This is probably
most useful for complex NPR shading and compositing. Like with objects,
the node can also access built-in scene properties, like render resolution
or FOV of the active camera. Lookup is also attempted in World, similar
to how the Object mode checks the Mesh datablock.
In Cycles this mode is implemented by replacing the attribute node with
the attribute value during sync, allowing constant folding to take the
values into account. This means however that materials that use this
feature have to be re-synced upon any changes to scene, world or camera.
The Eevee version uses a new uniform buffer containing a sorted array
mapping name hashes to values, with binary search lookup. The array
is limited to 512 entries, which is effectively limitless even
considering it is shared by all materials in the scene; it is also
just 16KB of memory so no point trying to optimize further.
The buffer has to be rebuilt when new attributes are detected in a
material, so the draw engine keeps a table of recently seen attribute
names to minimize the chance of extra rebuilds mid-draw.
Differential Revision: https://developer.blender.org/D15941
2022-09-12 00:30:58 +03:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
GPUNodeLink *GPU_constant(const float *num);
|
|
|
|
|
GPUNodeLink *GPU_uniform(const float *num);
|
|
|
|
|
GPUNodeLink *GPU_attribute(GPUMaterial *mat, eCustomDataType type, const char *name);
|
|
|
|
|
/**
|
|
|
|
|
* Add a GPU attribute that refers to the default color attribute on a geometry.
|
|
|
|
|
* The name, type, and domain are unknown and do not depend on the material.
|
|
|
|
|
*/
|
|
|
|
|
GPUNodeLink *GPU_attribute_default_color(GPUMaterial *mat);
|
|
|
|
|
/**
|
|
|
|
|
* Add a GPU attribute that refers to the approximate length of curves/hairs.
|
|
|
|
|
*/
|
|
|
|
|
GPUNodeLink *GPU_attribute_hair_length(GPUMaterial *mat);
|
|
|
|
|
GPUNodeLink *GPU_attribute_with_default(GPUMaterial *mat,
|
|
|
|
|
eCustomDataType type,
|
|
|
|
|
const char *name,
|
|
|
|
|
eGPUDefaultValue default_value);
|
|
|
|
|
GPUNodeLink *GPU_uniform_attribute(GPUMaterial *mat,
|
|
|
|
|
const char *name,
|
|
|
|
|
bool use_dupli,
|
|
|
|
|
uint32_t *r_hash);
|
|
|
|
|
GPUNodeLink *GPU_layer_attribute(GPUMaterial *mat, const char *name);
|
|
|
|
|
GPUNodeLink *GPU_image(GPUMaterial *mat,
|
|
|
|
|
Image *ima,
|
|
|
|
|
ImageUser *iuser,
|
|
|
|
|
GPUSamplerState sampler_state);
|
|
|
|
|
void GPU_image_tiled(GPUMaterial *mat,
|
|
|
|
|
Image *ima,
|
|
|
|
|
ImageUser *iuser,
|
|
|
|
|
GPUSamplerState sampler_state,
|
|
|
|
|
GPUNodeLink **r_image_tiled_link,
|
|
|
|
|
GPUNodeLink **r_image_tiled_mapping_link);
|
|
|
|
|
GPUNodeLink *GPU_image_sky(GPUMaterial *mat,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
const float *pixels,
|
|
|
|
|
float *layer,
|
|
|
|
|
GPUSamplerState sampler_state);
|
|
|
|
|
GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *r_row);
|
Attribute Node: support accessing attributes of View Layer and Scene.
The attribute node already allows accessing attributes associated
with objects and meshes, which allows changing the behavior of the
same material between different objects or instances. The same idea
can be extended to an even more global level of layers and scenes.
Currently view layers provide an option to replace all materials
with a different one. However, since the same material will be applied
to all objects in the layer, varying the behavior between layers while
preserving distinct materials requires duplicating objects.
Providing access to properties of layers and scenes via the attribute
node enables making materials with built-in switches or settings that
can be controlled globally at the view layer level. This is probably
most useful for complex NPR shading and compositing. Like with objects,
the node can also access built-in scene properties, like render resolution
or FOV of the active camera. Lookup is also attempted in World, similar
to how the Object mode checks the Mesh datablock.
In Cycles this mode is implemented by replacing the attribute node with
the attribute value during sync, allowing constant folding to take the
values into account. This means however that materials that use this
feature have to be re-synced upon any changes to scene, world or camera.
The Eevee version uses a new uniform buffer containing a sorted array
mapping name hashes to values, with binary search lookup. The array
is limited to 512 entries, which is effectively limitless even
considering it is shared by all materials in the scene; it is also
just 16KB of memory so no point trying to optimize further.
The buffer has to be rebuilt when new attributes are detected in a
material, so the draw engine keeps a table of recently seen attribute
names to minimize the chance of extra rebuilds mid-draw.
Differential Revision: https://developer.blender.org/D15941
2022-09-12 00:30:58 +03:00
|
|
|
|
2025-05-22 17:53:22 +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, const float filter_width);
|
2022-07-29 08:37:57 +02:00
|
|
|
|
2025-05-22 17:53:22 +02:00
|
|
|
bool GPU_link(GPUMaterial *mat, const char *name, ...);
|
|
|
|
|
bool GPU_stack_link(GPUMaterial *mat,
|
|
|
|
|
const bNode *node,
|
|
|
|
|
const char *name,
|
|
|
|
|
GPUNodeStack *in,
|
|
|
|
|
GPUNodeStack *out,
|
|
|
|
|
...);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
void GPU_material_add_output_link_aov(GPUMaterial *material, GPUNodeLink *link, int hash);
|
|
|
|
|
|
|
|
|
|
void GPU_material_add_output_link_composite(GPUMaterial *material, GPUNodeLink *link);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
|
|
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag);
|
|
|
|
|
eGPUMaterialFlag GPU_material_flag(const GPUMaterial *mat);
|
|
|
|
|
|
|
|
|
|
GHash *GPU_uniform_attr_list_hash_new(const char *info);
|
|
|
|
|
void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, const GPUUniformAttrList *src);
|
|
|
|
|
void GPU_uniform_attr_list_free(GPUUniformAttrList *set);
|