|
Blender
V2.93
|
#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"#include "BLI_ghash.h"#include "BLI_listbase.h"#include "BLI_math.h"#include "BLI_string.h"#include "BLI_string_utils.h"#include "BLI_utildefines.h"#include "BKE_main.h"#include "BKE_material.h"#include "BKE_node.h"#include "BKE_scene.h"#include "GPU_material.h"#include "GPU_shader.h"#include "GPU_texture.h"#include "GPU_uniform_buffer.h"#include "DRW_engine.h"#include "gpu_codegen.h"#include "gpu_node_graph.h"Go to the source code of this file.
Classes | |
| struct | GPUColorBandBuilder |
| struct | GPUMaterial |
| struct | GPUSssKernelData |
Macros | |
| #define | MAX_COLOR_BAND 128 |
| #define | SSS_SAMPLES 65 |
| #define | SSS_EXPONENT 2.0f /* Importance sampling exponent */ |
| #define | GAUSS_TRUNCATE 12.46f |
| #define | BURLEY_TRUNCATE 16.0f |
| #define | BURLEY_TRUNCATE_CDF 0.9963790093708328f |
| #define | INTEGRAL_RESOLUTION 32 |
| #define | INTEGRAL_RESOLUTION 512 |
Typedefs | |
| typedef struct GPUColorBandBuilder | GPUColorBandBuilder |
| typedef struct GPUSssKernelData | GPUSssKernelData |
Enumerations | |
| enum | { GPU_USE_SURFACE_OUTPUT = (1 << 0) , GPU_USE_VOLUME_OUTPUT = (1 << 1) } |
Manages materials, lights and textures.
Definition in file gpu_material.c.
| #define BURLEY_TRUNCATE 16.0f |
Definition at line 281 of file gpu_material.c.
| #define BURLEY_TRUNCATE_CDF 0.9963790093708328f |
Definition at line 282 of file gpu_material.c.
| #define GAUSS_TRUNCATE 12.46f |
Definition at line 269 of file gpu_material.c.
| #define INTEGRAL_RESOLUTION 32 |
Definition at line 439 of file gpu_material.c.
| #define INTEGRAL_RESOLUTION 512 |
Definition at line 439 of file gpu_material.c.
| #define MAX_COLOR_BAND 128 |
Definition at line 58 of file gpu_material.c.
| #define SSS_EXPONENT 2.0f /* Importance sampling exponent */ |
Definition at line 247 of file gpu_material.c.
| #define SSS_SAMPLES 65 |
Definition at line 246 of file gpu_material.c.
| typedef struct GPUColorBandBuilder GPUColorBandBuilder |
| typedef struct GPUSssKernelData GPUSssKernelData |
| anonymous enum |
| Enumerator | |
|---|---|
| GPU_USE_SURFACE_OUTPUT | |
| GPU_USE_VOLUME_OUTPUT | |
Definition at line 113 of file gpu_material.c.
Definition at line 283 of file gpu_material.c.
Referenced by eval_profile().
|
static |
Definition at line 344 of file gpu_material.c.
References A, BURLEY_TRUNCATE, copy_v3_v3(), copy_v4_v4(), ELEM, eval_integral(), fabsf, GPUSssKernelData::kernel, l, M_1_PI, MAX2, MAX3, GPUSssKernelData::max_radius, mul_v3_fl(), mul_v3_v3fl(), GPUSssKernelData::param, GPUSssKernelData::samples, SHD_SUBSURFACE_BURLEY, SHD_SUBSURFACE_CUBIC, SHD_SUBSURFACE_RANDOM_WALK, sss_calculate_offsets(), SSS_EXPONENT, and sum().
Referenced by GPU_material_sss_profile_get().
|
static |
Definition at line 440 of file gpu_material.c.
References add_v3_v3(), eval_profile(), float(), hypotf, INTEGRAL_RESOLUTION, M_PI, GPUSssKernelData::max_radius, MEM_callocN, mul_v3_fl(), output, GPUSssKernelData::param, r, and sqrtf.
Referenced by GPU_material_sss_profile_get().
Definition at line 290 of file gpu_material.c.
References M_PI, powf, r, and y.
Referenced by eval_profile().
|
static |
Definition at line 328 of file gpu_material.c.
References eval_profile(), float(), INTEGRAL_RESOLUTION, x, and y.
Referenced by compute_sss_kernel().
Definition at line 312 of file gpu_material.c.
References burley_profile(), BURLEY_TRUNCATE_CDF, cubic_profile(), ELEM, fabsf, gaussian_profile(), r, SHD_SUBSURFACE_BURLEY, SHD_SUBSURFACE_CUBIC, and SHD_SUBSURFACE_RANDOM_WALK.
Referenced by compute_sss_translucence_kernel(), and eval_integral().
Definition at line 270 of file gpu_material.c.
References expf, GAUSS_TRUNCATE, M_PI, r, sqrtf, and v.
Referenced by eval_profile().
| void GPU_material_add_output_link_aov | ( | GPUMaterial * | material, |
| GPUNodeLink * | link, | ||
| int | hash | ||
| ) |
Definition at line 600 of file gpu_material.c.
References BLI_addtail(), hash, GPUNodeGraphOutputLink::hash, material, MEM_callocN, and GPUNodeGraphOutputLink::outlink.
Referenced by node_shader_gpu_output_aov().
| ListBase GPU_material_attributes | ( | GPUMaterial * | material | ) |
Definition at line 572 of file gpu_material.c.
References material.
Referenced by curve_cd_calc_used_gpu_layers(), and mesh_cd_calc_used_gpu_layers().
| void GPU_material_compile | ( | GPUMaterial * | mat | ) |
Definition at line 775 of file gpu_material.c.
References BLI_assert, GPU_MAT_FAILED, GPU_MAT_QUEUED, GPU_MAT_SUCCESS, gpu_node_graph_free(), gpu_node_graph_free_nodes(), GPU_pass_compile(), GPU_pass_release(), GPU_pass_shader_get(), GPUMaterial::graph, GPUMaterial::name, NULL, GPUMaterial::pass, and GPUMaterial::status.
Referenced by drw_deferred_shader_add(), drw_deferred_shader_compilation_exec(), and drw_deferred_shader_compilation_free().
| struct GPUUniformBuf* GPU_material_create_sss_profile_ubo | ( | void | ) |
Definition at line 564 of file gpu_material.c.
References GPU_uniformbuf_create.
| bool GPU_material_flag_get | ( | GPUMaterial * | mat, |
| eGPUMatFlag | flag | ||
| ) |
Definition at line 646 of file gpu_material.c.
References GPUMaterial::flag.
Referenced by EEVEE_material_bind_resources(), eevee_material_post_eval(), GPU_material_from_nodetree(), and material_opaque().
| void GPU_material_flag_set | ( | GPUMaterial * | mat, |
| eGPUMatFlag | flag | ||
| ) |
Definition at line 641 of file gpu_material.c.
References GPUMaterial::flag.
Referenced by node_shader_gpu_ambient_occlusion(), node_shader_gpu_bsdf_anisotropic(), node_shader_gpu_bsdf_diffuse(), node_shader_gpu_bsdf_glass(), node_shader_gpu_bsdf_glossy(), node_shader_gpu_bsdf_principled(), node_shader_gpu_bsdf_refraction(), node_shader_gpu_bsdf_toon(), node_shader_gpu_bsdf_translucent(), node_shader_gpu_bsdf_velvet(), node_shader_gpu_eevee_specular(), node_shader_gpu_geometry(), node_shader_gpu_shadertorgb(), node_shader_gpu_subsurface_scattering(), and node_shader_gpu_wireframe().
| void GPU_material_free | ( | ListBase * | gpumaterial | ) |
Definition at line 192 of file gpu_material.c.
References BLI_freelistN(), gpu_material_free_single(), LISTBASE_FOREACH, material, and MEM_freeN.
Referenced by BKE_material_copybuf_paste(), BKE_material_defaults_free_gpu(), BKE_material_eval(), BKE_world_eval(), ED_node_set_active(), GPU_materials_free(), material_free_data(), and world_free_data().
|
static |
Definition at line 166 of file gpu_material.c.
References BLI_gset_free(), DRW_deferred_shader_remove, gpu_node_graph_free(), GPU_pass_release(), GPU_texture_free(), GPU_uniformbuf_free(), material, and NULL.
Referenced by GPU_material_free().
| GPUMaterial* GPU_material_from_nodetree | ( | Scene * | scene, |
| struct Material * | ma, | ||
| struct bNodeTree * | ntree, | ||
| ListBase * | gpumaterials, | ||
| const void * | engine_type, | ||
| const int | options, | ||
| const bool | is_volume_shader, | ||
| const char * | vert_code, | ||
| const char * | geom_code, | ||
| const char * | frag_lib, | ||
| const char * | defines, | ||
| const char * | name, | ||
| GPUMaterialEvalCallbackFn | callback | ||
| ) |
Definition at line 670 of file gpu_material.c.
References BLI_addtail(), BLI_assert, BLI_ghashutil_ptrcmp(), BLI_ghashutil_ptrhash(), BLI_gset_new(), BLI_snprintf(), BLI_string_joinN, callback, LinkData::data, GPUMaterial::engine_type, GPU_generate_pass(), GPU_MAT_FAILED, GPU_MAT_QUEUED, GPU_MAT_SUCCESS, GPU_material_flag_get(), GPU_material_from_nodetree_find(), gpu_material_ramp_texture_build(), GPU_MATFLAG_SSS, gpu_node_graph_free(), gpu_node_graph_free_nodes(), GPU_pass_shader_get(), GPUMaterial::graph, GPUMaterial::has_surface_output, GPUMaterial::has_volume_output, bNodeTree::id, GPUMaterial::is_volume_shader, GPUMaterial::ma, MEM_callocN, MEM_freeN, GPUMaterial::name, ntree, ntreeFreeLocalTree, ntreeGPUMaterialNodes, ntreeLocalize, NULL, options, GPUMaterial::options, GPUNodeGraph::outlink, GPUMaterial::pass, ID::py_instance, scene, GPUMaterial::scene, GPUMaterial::status, UNUSED_VARS, and GPUMaterial::used_libraries.
Referenced by DRW_shader_create_from_material(), and DRW_shader_create_from_world().
| GPUMaterial* GPU_material_from_nodetree_find | ( | ListBase * | gpumaterials, |
| const void * | engine_type, | ||
| int | options | ||
| ) |
Definition at line 651 of file gpu_material.c.
References GPUMaterial::engine_type, if(), LISTBASE_FOREACH, NULL, options, and GPUMaterial::options.
Referenced by DRW_shader_create_from_material(), DRW_shader_create_from_world(), DRW_shader_find_from_material(), DRW_shader_find_from_world(), and GPU_material_from_nodetree().
| Material* GPU_material_get_material | ( | GPUMaterial * | material | ) |
Definition at line 218 of file gpu_material.c.
References material.
Referenced by node_shader_gpu_object_info(), and node_shader_gpu_output_material().
| GPUPass* GPU_material_get_pass | ( | GPUMaterial * | material | ) |
Definition at line 207 of file gpu_material.c.
References material.
Referenced by DRW_shgroup_material_create().
| GPUShader* GPU_material_get_shader | ( | GPUMaterial * | material | ) |
Definition at line 212 of file gpu_material.c.
References GPU_pass_shader_get(), material, and NULL.
Referenced by eevee_lookdev_hdri_preview_init(), material_opaque(), material_shadow(), and material_transparent().
| bool GPU_material_has_surface_output | ( | GPUMaterial * | mat | ) |
Definition at line 626 of file gpu_material.c.
References GPUMaterial::has_surface_output.
Referenced by EEVEE_materials_cache_populate().
| bool GPU_material_has_volume_output | ( | GPUMaterial * | mat | ) |
Definition at line 631 of file gpu_material.c.
References GPUMaterial::has_volume_output.
Referenced by EEVEE_materials_cache_populate(), and EEVEE_volumes_cache_init().
| bool GPU_material_is_volume_shader | ( | GPUMaterial * | mat | ) |
Definition at line 636 of file gpu_material.c.
References GPUMaterial::is_volume_shader.
Referenced by node_shader_gpu_attribute().
| GPUNodeGraph* gpu_material_node_graph | ( | GPUMaterial * | material | ) |
Definition at line 608 of file gpu_material.c.
References material.
Referenced by GPU_attribute(), GPU_color_band(), GPU_image(), GPU_image_tiled(), GPU_image_tiled_mapping(), GPU_link(), GPU_stack_link(), GPU_uniform_attribute(), and GPU_volume_grid().
| void GPU_material_output_link | ( | GPUMaterial * | material, |
| GPUNodeLink * | link | ||
| ) |
Definition at line 593 of file gpu_material.c.
References material.
Referenced by node_shader_gpu_output_material(), and node_shader_gpu_output_world().
|
static |
Definition at line 151 of file gpu_material.c.
References CM_TABLE, GPUMaterial::coba_builder, GPUMaterial::coba_tex, GPUColorBandBuilder::current_layer, GPU_RGBA16F, GPU_texture_create_1d_array(), MEM_freeN, NULL, and GPUColorBandBuilder::pixels.
Referenced by GPU_material_from_nodetree().
| GPUTexture** gpu_material_ramp_texture_row_set | ( | GPUMaterial * | mat, |
| int | size, | ||
| float * | pixels, | ||
| float * | row | ||
| ) |
Definition at line 121 of file gpu_material.c.
References BLI_assert, CM_TABLE, GPUMaterial::coba_builder, GPUMaterial::coba_tex, GPUColorBandBuilder::current_layer, float(), MAX_COLOR_BAND, MEM_mallocN, NULL, GPUColorBandBuilder::pixels, size(), and UNUSED_VARS_NDEBUG.
Referenced by GPU_color_band().
| Scene* GPU_material_scene | ( | GPUMaterial * | material | ) |
Definition at line 202 of file gpu_material.c.
References material.
Referenced by DRW_deferred_shader_remove().
| void GPU_material_sss_profile_create | ( | GPUMaterial * | material, |
| float | radii[3], | ||
| const short * | falloff_type, | ||
| const float * | sharpness | ||
| ) |
Definition at line 502 of file gpu_material.c.
References copy_v3_v3(), GPU_uniformbuf_create, material, and NULL.
Referenced by node_shader_gpu_bsdf_principled(), and node_shader_gpu_subsurface_scattering().
| struct GPUUniformBuf* GPU_material_sss_profile_get | ( | GPUMaterial * | material, |
| int | sample_len, | ||
| GPUTexture ** | tex_profile | ||
| ) |
Definition at line 519 of file gpu_material.c.
References compute_sss_kernel(), compute_sss_translucence_kernel(), GPU_RGBA16F, GPU_texture_create_1d(), GPU_texture_free(), GPU_uniformbuf_update(), material, MEM_freeN, and NULL.
Referenced by EEVEE_subsurface_add_pass().
| eGPUMaterialStatus GPU_material_status | ( | GPUMaterial * | mat | ) |
Definition at line 619 of file gpu_material.c.
References GPUMaterial::status.
Referenced by drw_deferred_shader_compilation_exec(), DRW_shader_create_from_material(), DRW_shader_create_from_world(), DRW_shader_find_from_material(), DRW_shader_find_from_world(), EEVEE_material_get(), and EEVEE_volumes_cache_object_add().
| ListBase GPU_material_textures | ( | GPUMaterial * | material | ) |
Definition at line 577 of file gpu_material.c.
References material.
Referenced by DRW_shgroup_add_material_resources().
| GPUUniformAttrList* GPU_material_uniform_attributes | ( | GPUMaterial * | material | ) |
Definition at line 587 of file gpu_material.c.
References GPUUniformAttrList::count, material, and NULL.
Referenced by DRW_shgroup_add_material_resources().
| void GPU_material_uniform_buffer_create | ( | GPUMaterial * | material, |
| ListBase * | inputs | ||
| ) |
Create dynamic UBO from parameters
Definition at line 233 of file gpu_material.c.
References GPU_uniformbuf_create_from_list(), inputs, and material.
Referenced by codegen_process_uniforms_functions().
| GPUUniformBuf* GPU_material_uniform_buffer_get | ( | GPUMaterial * | material | ) |
Definition at line 223 of file gpu_material.c.
References material.
Referenced by DRW_shgroup_add_material_resources().
| GSet* gpu_material_used_libraries | ( | GPUMaterial * | material | ) |
Definition at line 613 of file gpu_material.c.
References material.
Referenced by GPU_generate_pass(), GPU_link(), and GPU_stack_link().
| ListBase GPU_material_volume_grids | ( | GPUMaterial * | material | ) |
Definition at line 582 of file gpu_material.c.
References material.
Referenced by EEVEE_volumes_cache_init(), and EEVEE_volumes_cache_object_add().
| void GPU_materials_free | ( | Main * | bmain | ) |
Definition at line 805 of file gpu_material.c.
References BKE_material_defaults_free_gpu(), GPU_material_free(), LISTBASE_FOREACH, Main::materials, and Main::worlds.
Referenced by outliner_id_remap_exec().
|
static |
Definition at line 258 of file gpu_material.c.
References count, fabsf, float(), powf, and KDL::sign().
Referenced by compute_sss_kernel().