forked from bartvdbraak/blender
Cycles: add Principled Volume shader.
Similar to the Principled BSDF, this should make it easier to set up volume materials. Smoke and fire can be rendererd with just a single principled volume node, the appropriate attributes will be used when available. The node also works for simpler homogeneous volumes like water or mist. Differential Revision: https://developer.blender.org/D3033
This commit is contained in:
parent
acd619d7c9
commit
0aec2dcd3a
@ -566,6 +566,10 @@ static ShaderNode *add_node(Scene *scene,
|
|||||||
else if(b_node.is_a(&RNA_ShaderNodeVolumeAbsorption)) {
|
else if(b_node.is_a(&RNA_ShaderNodeVolumeAbsorption)) {
|
||||||
node = new AbsorptionVolumeNode();
|
node = new AbsorptionVolumeNode();
|
||||||
}
|
}
|
||||||
|
else if(b_node.is_a(&RNA_ShaderNodeVolumePrincipled)) {
|
||||||
|
PrincipledVolumeNode *principled = new PrincipledVolumeNode();
|
||||||
|
node = principled;
|
||||||
|
}
|
||||||
else if(b_node.is_a(&RNA_ShaderNodeNewGeometry)) {
|
else if(b_node.is_a(&RNA_ShaderNodeNewGeometry)) {
|
||||||
node = new GeometryNode();
|
node = new GeometryNode();
|
||||||
}
|
}
|
||||||
@ -1024,6 +1028,10 @@ static void add_nodes(Scene *scene,
|
|||||||
for(b_node->internal_links.begin(b_link); b_link != b_node->internal_links.end(); ++b_link) {
|
for(b_node->internal_links.begin(b_link); b_link != b_node->internal_links.end(); ++b_link) {
|
||||||
BL::NodeSocket to_socket(b_link->to_socket());
|
BL::NodeSocket to_socket(b_link->to_socket());
|
||||||
SocketType::Type to_socket_type = convert_socket_type(to_socket);
|
SocketType::Type to_socket_type = convert_socket_type(to_socket);
|
||||||
|
if (to_socket_type == SocketType::UNDEFINED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ConvertNode *proxy = new ConvertNode(to_socket_type, to_socket_type, true);
|
ConvertNode *proxy = new ConvertNode(to_socket_type, to_socket_type, true);
|
||||||
|
|
||||||
input_map[b_link->from_socket().ptr.data] = proxy->inputs[0];
|
input_map[b_link->from_socket().ptr.data] = proxy->inputs[0];
|
||||||
@ -1047,6 +1055,10 @@ static void add_nodes(Scene *scene,
|
|||||||
*/
|
*/
|
||||||
for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
|
for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
|
||||||
SocketType::Type input_type = convert_socket_type(*b_input);
|
SocketType::Type input_type = convert_socket_type(*b_input);
|
||||||
|
if (input_type == SocketType::UNDEFINED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ConvertNode *proxy = new ConvertNode(input_type, input_type, true);
|
ConvertNode *proxy = new ConvertNode(input_type, input_type, true);
|
||||||
graph->add(proxy);
|
graph->add(proxy);
|
||||||
|
|
||||||
@ -1059,6 +1071,10 @@ static void add_nodes(Scene *scene,
|
|||||||
}
|
}
|
||||||
for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
|
for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
|
||||||
SocketType::Type output_type = convert_socket_type(*b_output);
|
SocketType::Type output_type = convert_socket_type(*b_output);
|
||||||
|
if (output_type == SocketType::UNDEFINED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ConvertNode *proxy = new ConvertNode(output_type, output_type, true);
|
ConvertNode *proxy = new ConvertNode(output_type, output_type, true);
|
||||||
graph->add(proxy);
|
graph->add(proxy);
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ set(SRC_OSL
|
|||||||
node_hair_info.osl
|
node_hair_info.osl
|
||||||
node_scatter_volume.osl
|
node_scatter_volume.osl
|
||||||
node_absorption_volume.osl
|
node_absorption_volume.osl
|
||||||
|
node_principled_volume.osl
|
||||||
node_holdout.osl
|
node_holdout.osl
|
||||||
node_hsv.osl
|
node_hsv.osl
|
||||||
node_image_texture.osl
|
node_image_texture.osl
|
||||||
|
94
intern/cycles/kernel/shaders/node_principled_volume.osl
Normal file
94
intern/cycles/kernel/shaders/node_principled_volume.osl
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2013 Blender Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stdosl.h"
|
||||||
|
|
||||||
|
shader node_principled_volume(
|
||||||
|
color Color = color(0.5, 0.5, 0.5),
|
||||||
|
float Density = 1.0,
|
||||||
|
float Anisotropy = 0.0,
|
||||||
|
color AbsorptionColor = color(0.0, 0.0, 0.0),
|
||||||
|
float EmissionStrength = 0.0,
|
||||||
|
color EmissionColor = color(1.0, 1.0, 1.0),
|
||||||
|
float BlackbodyIntensity = 0.0,
|
||||||
|
color BlackbodyTint = color(1.0, 1.0, 1.0),
|
||||||
|
float Temperature = 1500.0,
|
||||||
|
string DensityAttribute = "geom:density",
|
||||||
|
string ColorAttribute = "geom:color",
|
||||||
|
string TemperatureAttribute = "geom:temperature",
|
||||||
|
output closure color Volume = 0)
|
||||||
|
{
|
||||||
|
/* Compute density. */
|
||||||
|
float primitive_density = 1.0;
|
||||||
|
float density = max(Density, 0.0);
|
||||||
|
|
||||||
|
if(density > 1e-5) {
|
||||||
|
if(getattribute(DensityAttribute, primitive_density)) {
|
||||||
|
density = max(density * primitive_density, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(density > 1e-5) {
|
||||||
|
/* Compute scattering color. */
|
||||||
|
color scatter_color = Color;
|
||||||
|
color primitive_color;
|
||||||
|
if(getattribute(ColorAttribute, primitive_color)) {
|
||||||
|
scatter_color *= primitive_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add scattering and absorption closures. */
|
||||||
|
color scatter_coeff = scatter_color;
|
||||||
|
color absorption_coeff = max(1.0 - scatter_color, 0.0) * max(1.0 - AbsorptionColor, 0.0);
|
||||||
|
Volume = scatter_coeff * density * henyey_greenstein(Anisotropy) +
|
||||||
|
absorption_coeff * density * absorption();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute emission. */
|
||||||
|
float emission_strength = max(EmissionStrength, 0.0);
|
||||||
|
float blackbody_intensity = BlackbodyIntensity;
|
||||||
|
|
||||||
|
if(emission_strength > 1e-5) {
|
||||||
|
Volume += emission_strength * EmissionColor * emission();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blackbody_intensity > 1e-3) {
|
||||||
|
float T = Temperature;
|
||||||
|
|
||||||
|
/* Add temperature from attribute if available. */
|
||||||
|
float temperature;
|
||||||
|
if(getattribute(TemperatureAttribute, temperature)) {
|
||||||
|
T *= max(temperature, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
T = max(T, 0.0);
|
||||||
|
|
||||||
|
/* Stefan-Boltzman law. */
|
||||||
|
float T4 = (T * T) * (T * T);
|
||||||
|
float sigma = 5.670373e-8 * 1e-6 / M_PI;
|
||||||
|
float intensity = sigma * mix(1.0, T4, blackbody_intensity);
|
||||||
|
|
||||||
|
if(intensity > 1e-5) {
|
||||||
|
color bb = blackbody(T);
|
||||||
|
float l = luminance(bb);
|
||||||
|
|
||||||
|
if(l != 0.0) {
|
||||||
|
bb *= BlackbodyTint * intensity / l;
|
||||||
|
Volume += bb * emission();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -334,7 +334,10 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_a
|
|||||||
break;
|
break;
|
||||||
# if NODES_FEATURE(NODE_FEATURE_VOLUME)
|
# if NODES_FEATURE(NODE_FEATURE_VOLUME)
|
||||||
case NODE_CLOSURE_VOLUME:
|
case NODE_CLOSURE_VOLUME:
|
||||||
svm_node_closure_volume(kg, sd, stack, node, type, path_flag);
|
svm_node_closure_volume(kg, sd, stack, node, type);
|
||||||
|
break;
|
||||||
|
case NODE_PRINCIPLED_VOLUME:
|
||||||
|
svm_node_principled_volume(kg, sd, stack, node, type, path_flag, &offset);
|
||||||
break;
|
break;
|
||||||
# endif /* NODES_FEATURE(NODE_FEATURE_VOLUME) */
|
# endif /* NODES_FEATURE(NODE_FEATURE_VOLUME) */
|
||||||
# ifdef __EXTRA_NODES__
|
# ifdef __EXTRA_NODES__
|
||||||
|
@ -794,7 +794,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ShaderType shader_type, int path_flag)
|
ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ShaderType shader_type)
|
||||||
{
|
{
|
||||||
#ifdef __VOLUME__
|
#ifdef __VOLUME__
|
||||||
/* Only sum extinction for volumes, variable is shared with surface transparency. */
|
/* Only sum extinction for volumes, variable is shared with surface transparency. */
|
||||||
@ -802,19 +802,20 @@ ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint type, param1_offset, param2_offset;
|
uint type, density_offset, anisotropy_offset;
|
||||||
|
|
||||||
uint mix_weight_offset;
|
uint mix_weight_offset;
|
||||||
decode_node_uchar4(node.y, &type, ¶m1_offset, ¶m2_offset, &mix_weight_offset);
|
decode_node_uchar4(node.y, &type, &density_offset, &anisotropy_offset, &mix_weight_offset);
|
||||||
float mix_weight = (stack_valid(mix_weight_offset)? stack_load_float(stack, mix_weight_offset): 1.0f);
|
float mix_weight = (stack_valid(mix_weight_offset)? stack_load_float(stack, mix_weight_offset): 1.0f);
|
||||||
|
|
||||||
if(mix_weight == 0.0f)
|
if(mix_weight == 0.0f) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float param1 = (stack_valid(param1_offset))? stack_load_float(stack, param1_offset): __uint_as_float(node.z);
|
float density = (stack_valid(density_offset))? stack_load_float(stack, density_offset): __uint_as_float(node.z);
|
||||||
|
density = mix_weight * fmaxf(density, 0.0f);
|
||||||
|
|
||||||
/* Compute scattering coefficient. */
|
/* Compute scattering coefficient. */
|
||||||
float density = mix_weight * fmaxf(param1, 0.0f);
|
|
||||||
float3 weight = sd->svm_closure_weight;
|
float3 weight = sd->svm_closure_weight;
|
||||||
|
|
||||||
if(type == CLOSURE_VOLUME_ABSORPTION_ID) {
|
if(type == CLOSURE_VOLUME_ABSORPTION_ID) {
|
||||||
@ -825,11 +826,11 @@ ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float
|
|||||||
|
|
||||||
/* Add closure for volume scattering. */
|
/* Add closure for volume scattering. */
|
||||||
if(type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID) {
|
if(type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID) {
|
||||||
float param2 = (stack_valid(param2_offset))? stack_load_float(stack, param2_offset): __uint_as_float(node.w);
|
|
||||||
HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc(sd, sizeof(HenyeyGreensteinVolume), weight);
|
HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc(sd, sizeof(HenyeyGreensteinVolume), weight);
|
||||||
|
|
||||||
if(volume) {
|
if(volume) {
|
||||||
volume->g = param2; /* g */
|
float anisotropy = (stack_valid(anisotropy_offset))? stack_load_float(stack, anisotropy_offset): __uint_as_float(node.w);
|
||||||
|
volume->g = anisotropy; /* g */
|
||||||
sd->flag |= volume_henyey_greenstein_setup(volume);
|
sd->flag |= volume_henyey_greenstein_setup(volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -839,6 +840,106 @@ ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ccl_device void svm_node_principled_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ShaderType shader_type, int path_flag, int *offset)
|
||||||
|
{
|
||||||
|
#ifdef __VOLUME__
|
||||||
|
uint4 value_node = read_node(kg, offset);
|
||||||
|
uint4 attr_node = read_node(kg, offset);
|
||||||
|
|
||||||
|
/* Only sum extinction for volumes, variable is shared with surface transparency. */
|
||||||
|
if(shader_type != SHADER_TYPE_VOLUME) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint density_offset, anisotropy_offset, absorption_color_offset, mix_weight_offset;
|
||||||
|
decode_node_uchar4(node.y, &density_offset, &anisotropy_offset, &absorption_color_offset, &mix_weight_offset);
|
||||||
|
float mix_weight = (stack_valid(mix_weight_offset)? stack_load_float(stack, mix_weight_offset): 1.0f);
|
||||||
|
|
||||||
|
if(mix_weight == 0.0f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute density. */
|
||||||
|
float primitive_density = 1.0f;
|
||||||
|
float density = (stack_valid(density_offset))? stack_load_float(stack, density_offset): __uint_as_float(value_node.x);
|
||||||
|
density = mix_weight * fmaxf(density, 0.0f);
|
||||||
|
|
||||||
|
if(density > CLOSURE_WEIGHT_CUTOFF) {
|
||||||
|
/* Density and color attribute lookup if available. */
|
||||||
|
const AttributeDescriptor attr_density = find_attribute(kg, sd, attr_node.x);
|
||||||
|
if(attr_density.offset != ATTR_STD_NOT_FOUND) {
|
||||||
|
primitive_density = primitive_attribute_float(kg, sd, attr_density, NULL, NULL);
|
||||||
|
density = fmaxf(density * primitive_density, 0.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(density > CLOSURE_WEIGHT_CUTOFF) {
|
||||||
|
/* Compute scattering color. */
|
||||||
|
float3 color = sd->svm_closure_weight;
|
||||||
|
|
||||||
|
const AttributeDescriptor attr_color = find_attribute(kg, sd, attr_node.y);
|
||||||
|
if(attr_color.offset != ATTR_STD_NOT_FOUND) {
|
||||||
|
color *= primitive_attribute_float3(kg, sd, attr_color, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add closure for volume scattering. */
|
||||||
|
HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc(sd, sizeof(HenyeyGreensteinVolume), color * density);
|
||||||
|
if(volume) {
|
||||||
|
float anisotropy = (stack_valid(anisotropy_offset))? stack_load_float(stack, anisotropy_offset): __uint_as_float(value_node.y);
|
||||||
|
volume->g = anisotropy;
|
||||||
|
sd->flag |= volume_henyey_greenstein_setup(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add extinction weight. */
|
||||||
|
float3 zero = make_float3(0.0f, 0.0f, 0.0f);
|
||||||
|
float3 one = make_float3(1.0f, 1.0f, 1.0f);
|
||||||
|
float3 absorption_color = stack_load_float3(stack, absorption_color_offset);
|
||||||
|
float3 absorption = max(one - color, zero) * max(one - absorption_color, zero);
|
||||||
|
volume_extinction_setup(sd, (color + absorption) * density);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute emission. */
|
||||||
|
if(path_flag & PATH_RAY_SHADOW) {
|
||||||
|
/* Don't need emission for shadows. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint emission_offset, emission_color_offset, blackbody_offset, temperature_offset;
|
||||||
|
decode_node_uchar4(node.z, &emission_offset, &emission_color_offset, &blackbody_offset, &temperature_offset);
|
||||||
|
float emission = (stack_valid(emission_offset))? stack_load_float(stack, emission_offset): __uint_as_float(value_node.z);
|
||||||
|
float blackbody = (stack_valid(blackbody_offset))? stack_load_float(stack, blackbody_offset): __uint_as_float(value_node.w);
|
||||||
|
|
||||||
|
if(emission > CLOSURE_WEIGHT_CUTOFF) {
|
||||||
|
float3 emission_color = stack_load_float3(stack, emission_color_offset);
|
||||||
|
emission_setup(sd, emission * emission_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blackbody > CLOSURE_WEIGHT_CUTOFF) {
|
||||||
|
float T = stack_load_float(stack, temperature_offset);
|
||||||
|
|
||||||
|
/* Add flame temperature from attribute if available. */
|
||||||
|
const AttributeDescriptor attr_temperature = find_attribute(kg, sd, attr_node.z);
|
||||||
|
if(attr_temperature.offset != ATTR_STD_NOT_FOUND) {
|
||||||
|
float temperature = primitive_attribute_float(kg, sd, attr_temperature, NULL, NULL);
|
||||||
|
T *= fmaxf(temperature, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
T = fmaxf(T, 0.0f);
|
||||||
|
|
||||||
|
/* Stefan-Boltzmann law. */
|
||||||
|
float T4 = sqr(sqr(T));
|
||||||
|
float sigma = 5.670373e-8f * 1e-6f / M_PI_F;
|
||||||
|
float intensity = sigma * mix(1.0f, T4, blackbody);
|
||||||
|
|
||||||
|
if(intensity > CLOSURE_WEIGHT_CUTOFF) {
|
||||||
|
float3 blackbody_tint = stack_load_float3(stack, node.w);
|
||||||
|
float3 bb = blackbody_tint * intensity * svm_math_blackbody_color(T);
|
||||||
|
emission_setup(sd, bb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
|
ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
|
||||||
{
|
{
|
||||||
uint mix_weight_offset = node.y;
|
uint mix_weight_offset = node.y;
|
||||||
|
@ -135,6 +135,7 @@ typedef enum ShaderNodeType {
|
|||||||
NODE_BEVEL,
|
NODE_BEVEL,
|
||||||
NODE_DISPLACEMENT,
|
NODE_DISPLACEMENT,
|
||||||
NODE_VECTOR_DISPLACEMENT,
|
NODE_VECTOR_DISPLACEMENT,
|
||||||
|
NODE_PRINCIPLED_VOLUME,
|
||||||
} ShaderNodeType;
|
} ShaderNodeType;
|
||||||
|
|
||||||
typedef enum NodeAttributeType {
|
typedef enum NodeAttributeType {
|
||||||
|
@ -2844,6 +2844,120 @@ void ScatterVolumeNode::compile(OSLCompiler& compiler)
|
|||||||
compiler.add(this, "node_scatter_volume");
|
compiler.add(this, "node_scatter_volume");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Principled Volume Closure */
|
||||||
|
|
||||||
|
NODE_DEFINE(PrincipledVolumeNode)
|
||||||
|
{
|
||||||
|
NodeType* type = NodeType::add("principled_volume", create, NodeType::SHADER);
|
||||||
|
|
||||||
|
SOCKET_IN_STRING(density_attribute, "Density Attribute", ustring());
|
||||||
|
SOCKET_IN_STRING(color_attribute, "Color Attribute", ustring());
|
||||||
|
SOCKET_IN_STRING(temperature_attribute, "Temperature Attribute", ustring());
|
||||||
|
|
||||||
|
SOCKET_IN_COLOR(color, "Color", make_float3(0.5f, 0.5f, 0.5f));
|
||||||
|
SOCKET_IN_FLOAT(density, "Density", 1.0f);
|
||||||
|
SOCKET_IN_FLOAT(anisotropy, "Anisotropy", 0.0f);
|
||||||
|
SOCKET_IN_COLOR(absorption_color, "Absorption Color", make_float3(0.0f, 0.0f, 0.0f));
|
||||||
|
SOCKET_IN_FLOAT(emission_strength, "Emission Strength", 0.0f);
|
||||||
|
SOCKET_IN_COLOR(emission_color, "Emission Color", make_float3(1.0f, 1.0f, 1.0f));
|
||||||
|
SOCKET_IN_FLOAT(blackbody_intensity, "Blackbody Intensity", 0.0f);
|
||||||
|
SOCKET_IN_COLOR(blackbody_tint, "Blackbody Tint", make_float3(1.0f, 1.0f, 1.0f));
|
||||||
|
SOCKET_IN_FLOAT(temperature, "Temperature", 1500.0f);
|
||||||
|
SOCKET_IN_FLOAT(volume_mix_weight, "VolumeMixWeight", 0.0f, SocketType::SVM_INTERNAL);
|
||||||
|
|
||||||
|
SOCKET_OUT_CLOSURE(volume, "Volume");
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrincipledVolumeNode::PrincipledVolumeNode()
|
||||||
|
: VolumeNode(node_type)
|
||||||
|
{
|
||||||
|
closure = CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrincipledVolumeNode::attributes(Shader *shader, AttributeRequestSet *attributes)
|
||||||
|
{
|
||||||
|
if(shader->has_volume) {
|
||||||
|
ShaderInput *density_in = input("Density");
|
||||||
|
ShaderInput *blackbody_in = input("Blackbody Intensity");
|
||||||
|
|
||||||
|
if(density_in->link || density > 0.0f) {
|
||||||
|
attributes->add_standard(density_attribute);
|
||||||
|
attributes->add_standard(color_attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(blackbody_in->link || blackbody_intensity > 0.0f) {
|
||||||
|
attributes->add_standard(temperature_attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes->add(ATTR_STD_GENERATED_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderNode::attributes(shader, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrincipledVolumeNode::compile(SVMCompiler& compiler)
|
||||||
|
{
|
||||||
|
ShaderInput *color_in = input("Color");
|
||||||
|
ShaderInput *density_in = input("Density");
|
||||||
|
ShaderInput *anisotropy_in = input("Anisotropy");
|
||||||
|
ShaderInput *absorption_color_in = input("Absorption Color");
|
||||||
|
ShaderInput *emission_in = input("Emission Strength");
|
||||||
|
ShaderInput *emission_color_in = input("Emission Color");
|
||||||
|
ShaderInput *blackbody_in = input("Blackbody Intensity");
|
||||||
|
ShaderInput *blackbody_tint_in = input("Blackbody Tint");
|
||||||
|
ShaderInput *temperature_in = input("Temperature");
|
||||||
|
|
||||||
|
if(color_in->link)
|
||||||
|
compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(color_in));
|
||||||
|
else
|
||||||
|
compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color);
|
||||||
|
|
||||||
|
compiler.add_node(NODE_PRINCIPLED_VOLUME,
|
||||||
|
compiler.encode_uchar4(
|
||||||
|
compiler.stack_assign_if_linked(density_in),
|
||||||
|
compiler.stack_assign_if_linked(anisotropy_in),
|
||||||
|
compiler.stack_assign(absorption_color_in),
|
||||||
|
compiler.closure_mix_weight_offset()),
|
||||||
|
compiler.encode_uchar4(
|
||||||
|
compiler.stack_assign_if_linked(emission_in),
|
||||||
|
compiler.stack_assign(emission_color_in),
|
||||||
|
compiler.stack_assign_if_linked(blackbody_in),
|
||||||
|
compiler.stack_assign(temperature_in)),
|
||||||
|
compiler.stack_assign(blackbody_tint_in));
|
||||||
|
|
||||||
|
int attr_density = compiler.attribute_standard(density_attribute);
|
||||||
|
int attr_color = compiler.attribute_standard(color_attribute);
|
||||||
|
int attr_temperature = compiler.attribute_standard(temperature_attribute);
|
||||||
|
|
||||||
|
compiler.add_node(
|
||||||
|
__float_as_int(density),
|
||||||
|
__float_as_int(anisotropy),
|
||||||
|
__float_as_int(emission_strength),
|
||||||
|
__float_as_int(blackbody_intensity));
|
||||||
|
|
||||||
|
compiler.add_node(
|
||||||
|
attr_density,
|
||||||
|
attr_color,
|
||||||
|
attr_temperature);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrincipledVolumeNode::compile(OSLCompiler& compiler)
|
||||||
|
{
|
||||||
|
if(Attribute::name_standard(density_attribute.c_str())) {
|
||||||
|
density_attribute = ustring("geom:" + density_attribute.string());
|
||||||
|
}
|
||||||
|
if(Attribute::name_standard(color_attribute.c_str())) {
|
||||||
|
color_attribute = ustring("geom:" + color_attribute.string());
|
||||||
|
}
|
||||||
|
if(Attribute::name_standard(temperature_attribute.c_str())) {
|
||||||
|
temperature_attribute = ustring("geom:" + temperature_attribute.string());
|
||||||
|
}
|
||||||
|
|
||||||
|
compiler.add(this, "node_principled_volume");
|
||||||
|
}
|
||||||
|
|
||||||
/* Hair BSDF Closure */
|
/* Hair BSDF Closure */
|
||||||
|
|
||||||
NODE_DEFINE(HairBsdfNode)
|
NODE_DEFINE(HairBsdfNode)
|
||||||
|
@ -561,6 +561,25 @@ public:
|
|||||||
float anisotropy;
|
float anisotropy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PrincipledVolumeNode : public VolumeNode {
|
||||||
|
public:
|
||||||
|
SHADER_NODE_CLASS(PrincipledVolumeNode)
|
||||||
|
void attributes(Shader *shader, AttributeRequestSet *attributes);
|
||||||
|
bool has_attribute_dependency() { return true; }
|
||||||
|
|
||||||
|
ustring density_attribute;
|
||||||
|
ustring color_attribute;
|
||||||
|
ustring temperature_attribute;
|
||||||
|
|
||||||
|
float anisotropy;
|
||||||
|
float3 absorption_color;
|
||||||
|
float emission_strength;
|
||||||
|
float3 emission_color;
|
||||||
|
float blackbody_intensity;
|
||||||
|
float3 blackbody_tint;
|
||||||
|
float temperature;
|
||||||
|
};
|
||||||
|
|
||||||
class HairBsdfNode : public BsdfNode {
|
class HairBsdfNode : public BsdfNode {
|
||||||
public:
|
public:
|
||||||
SHADER_NODE_CLASS(HairBsdfNode)
|
SHADER_NODE_CLASS(HairBsdfNode)
|
||||||
|
@ -387,102 +387,16 @@ class QuickSmoke(Operator):
|
|||||||
node_out = nodes.new(type='ShaderNodeOutputMaterial')
|
node_out = nodes.new(type='ShaderNodeOutputMaterial')
|
||||||
node_out.location = grid_location(6, 1)
|
node_out.location = grid_location(6, 1)
|
||||||
|
|
||||||
# Add shader 1
|
# Add Principled Volume
|
||||||
node_add_shader_1 = nodes.new(type='ShaderNodeAddShader')
|
node_principled = nodes.new(type='ShaderNodeVolumePrincipled')
|
||||||
node_add_shader_1.location = grid_location(5, 1)
|
node_principled.location = grid_location(4, 1)
|
||||||
links.new(node_add_shader_1.outputs["Shader"],
|
links.new(node_principled.outputs["Volume"],
|
||||||
node_out.inputs["Volume"])
|
node_out.inputs["Volume"])
|
||||||
|
|
||||||
if self.style in {'SMOKE', 'FIRE', 'BOTH'}:
|
node_principled.inputs["Density"].default_value = 5.0
|
||||||
# Smoke
|
|
||||||
|
|
||||||
# Add shader 2
|
|
||||||
node_add_shader_2 = nodes.new(type='ShaderNodeAddShader')
|
|
||||||
node_add_shader_2.location = grid_location(4, 2)
|
|
||||||
links.new(node_add_shader_2.outputs["Shader"],
|
|
||||||
node_add_shader_1.inputs[0])
|
|
||||||
|
|
||||||
# Volume scatter
|
|
||||||
node_scatter = nodes.new(type='ShaderNodeVolumeScatter')
|
|
||||||
node_scatter.location = grid_location(3, 3)
|
|
||||||
links.new(node_scatter.outputs["Volume"],
|
|
||||||
node_add_shader_2.inputs[0])
|
|
||||||
|
|
||||||
# Volume absorption
|
|
||||||
node_absorption = nodes.new(type='ShaderNodeVolumeAbsorption')
|
|
||||||
node_absorption.location = grid_location(3, 2)
|
|
||||||
links.new(node_absorption.outputs["Volume"],
|
|
||||||
node_add_shader_2.inputs[1])
|
|
||||||
|
|
||||||
# Density Multiplier
|
|
||||||
node_densmult = nodes.new(type='ShaderNodeMath')
|
|
||||||
node_densmult.location = grid_location(2, 2)
|
|
||||||
node_densmult.operation = 'MULTIPLY'
|
|
||||||
node_densmult.inputs[1].default_value = 5.0
|
|
||||||
links.new(node_densmult.outputs["Value"],
|
|
||||||
node_scatter.inputs["Density"])
|
|
||||||
links.new(node_densmult.outputs["Value"],
|
|
||||||
node_absorption.inputs["Density"])
|
|
||||||
|
|
||||||
# Attribute "density"
|
|
||||||
node_attrib_density = nodes.new(type='ShaderNodeAttribute')
|
|
||||||
node_attrib_density.attribute_name = "density"
|
|
||||||
node_attrib_density.location = grid_location(1, 2)
|
|
||||||
links.new(node_attrib_density.outputs["Fac"],
|
|
||||||
node_densmult.inputs[0])
|
|
||||||
|
|
||||||
# Attribute "color"
|
|
||||||
node_attrib_color = nodes.new(type='ShaderNodeAttribute')
|
|
||||||
node_attrib_color.attribute_name = "color"
|
|
||||||
node_attrib_color.location = grid_location(2, 3)
|
|
||||||
links.new(node_attrib_color.outputs["Color"],
|
|
||||||
node_scatter.inputs["Color"])
|
|
||||||
links.new(node_attrib_color.outputs["Color"],
|
|
||||||
node_absorption.inputs["Color"])
|
|
||||||
|
|
||||||
if self.style in {'FIRE', 'BOTH'}:
|
if self.style in {'FIRE', 'BOTH'}:
|
||||||
# Fire
|
node_principled.inputs["Blackbody Intensity"].default_value = 1.0
|
||||||
|
|
||||||
# Emission
|
|
||||||
node_emission = nodes.new(type='ShaderNodeEmission')
|
|
||||||
node_emission.inputs["Color"].default_value = (0.8, 0.1, 0.01, 1.0)
|
|
||||||
node_emission.location = grid_location(4, 1)
|
|
||||||
links.new(node_emission.outputs["Emission"],
|
|
||||||
node_add_shader_1.inputs[1])
|
|
||||||
|
|
||||||
# Flame strength multiplier
|
|
||||||
node_flame_strength_mult = nodes.new(type='ShaderNodeMath')
|
|
||||||
node_flame_strength_mult.location = grid_location(3, 1)
|
|
||||||
node_flame_strength_mult.operation = 'MULTIPLY'
|
|
||||||
node_flame_strength_mult.inputs[1].default_value = 2.5
|
|
||||||
links.new(node_flame_strength_mult.outputs["Value"],
|
|
||||||
node_emission.inputs["Strength"])
|
|
||||||
|
|
||||||
# Color ramp Flame
|
|
||||||
node_flame_ramp = nodes.new(type='ShaderNodeValToRGB')
|
|
||||||
node_flame_ramp.location = grid_location(1, 1)
|
|
||||||
ramp = node_flame_ramp.color_ramp
|
|
||||||
ramp.interpolation = 'EASE'
|
|
||||||
|
|
||||||
# orange
|
|
||||||
elem = ramp.elements.new(0.5)
|
|
||||||
elem.color = (1.0, 0.128, 0.0, 1.0)
|
|
||||||
|
|
||||||
# yellow
|
|
||||||
elem = ramp.elements.new(0.9)
|
|
||||||
elem.color = (0.9, 0.6, 0.1, 1.0)
|
|
||||||
|
|
||||||
links.new(node_flame_ramp.outputs["Color"],
|
|
||||||
node_emission.inputs["Color"])
|
|
||||||
|
|
||||||
# Attribute "flame"
|
|
||||||
node_attrib_flame = nodes.new(type='ShaderNodeAttribute')
|
|
||||||
node_attrib_flame.attribute_name = "flame"
|
|
||||||
node_attrib_flame.location = grid_location(0, 1)
|
|
||||||
links.new(node_attrib_flame.outputs["Fac"],
|
|
||||||
node_flame_ramp.inputs["Fac"])
|
|
||||||
links.new(node_attrib_flame.outputs["Fac"],
|
|
||||||
node_flame_strength_mult.inputs[0])
|
|
||||||
|
|
||||||
# Blender Internal
|
# Blender Internal
|
||||||
else:
|
else:
|
||||||
|
@ -244,6 +244,7 @@ shader_node_categories = [
|
|||||||
NodeItem("ShaderNodeHoldout", poll=object_shader_nodes_poll),
|
NodeItem("ShaderNodeHoldout", poll=object_shader_nodes_poll),
|
||||||
NodeItem("ShaderNodeVolumeAbsorption"),
|
NodeItem("ShaderNodeVolumeAbsorption"),
|
||||||
NodeItem("ShaderNodeVolumeScatter"),
|
NodeItem("ShaderNodeVolumeScatter"),
|
||||||
|
NodeItem("ShaderNodeVolumePrincipled"),
|
||||||
]),
|
]),
|
||||||
ShaderNewNodeCategory("SH_NEW_TEXTURE", "Texture", items=[
|
ShaderNewNodeCategory("SH_NEW_TEXTURE", "Texture", items=[
|
||||||
NodeItem("ShaderNodeTexImage"),
|
NodeItem("ShaderNodeTexImage"),
|
||||||
|
@ -792,6 +792,7 @@ struct ShadeResult;
|
|||||||
#define SH_NODE_BEVEL 197
|
#define SH_NODE_BEVEL 197
|
||||||
#define SH_NODE_DISPLACEMENT 198
|
#define SH_NODE_DISPLACEMENT 198
|
||||||
#define SH_NODE_VECTOR_DISPLACEMENT 199
|
#define SH_NODE_VECTOR_DISPLACEMENT 199
|
||||||
|
#define SH_NODE_VOLUME_PRINCIPLED 200
|
||||||
|
|
||||||
/* custom defines options for Material node */
|
/* custom defines options for Material node */
|
||||||
#define SH_NODE_MAT_DIFF 1
|
#define SH_NODE_MAT_DIFF 1
|
||||||
|
@ -3616,6 +3616,7 @@ static void registerShaderNodes(void)
|
|||||||
register_node_type_sh_holdout();
|
register_node_type_sh_holdout();
|
||||||
register_node_type_sh_volume_absorption();
|
register_node_type_sh_volume_absorption();
|
||||||
register_node_type_sh_volume_scatter();
|
register_node_type_sh_volume_scatter();
|
||||||
|
register_node_type_sh_volume_principled();
|
||||||
register_node_type_sh_subsurface_scattering();
|
register_node_type_sh_subsurface_scattering();
|
||||||
register_node_type_sh_mix_shader();
|
register_node_type_sh_mix_shader();
|
||||||
register_node_type_sh_add_shader();
|
register_node_type_sh_add_shader();
|
||||||
|
@ -210,6 +210,7 @@ set(SRC
|
|||||||
shader/nodes/node_shader_tex_wave.c
|
shader/nodes/node_shader_tex_wave.c
|
||||||
shader/nodes/node_shader_volume_scatter.c
|
shader/nodes/node_shader_volume_scatter.c
|
||||||
shader/nodes/node_shader_volume_absorption.c
|
shader/nodes/node_shader_volume_absorption.c
|
||||||
|
shader/nodes/node_shader_volume_principled.c
|
||||||
shader/nodes/node_shader_uvAlongStroke.c
|
shader/nodes/node_shader_uvAlongStroke.c
|
||||||
shader/nodes/node_shader_uvmap.c
|
shader/nodes/node_shader_uvmap.c
|
||||||
shader/node_shader_tree.c
|
shader/node_shader_tree.c
|
||||||
|
@ -114,6 +114,7 @@ void register_node_type_sh_emission(void);
|
|||||||
void register_node_type_sh_holdout(void);
|
void register_node_type_sh_holdout(void);
|
||||||
void register_node_type_sh_volume_absorption(void);
|
void register_node_type_sh_volume_absorption(void);
|
||||||
void register_node_type_sh_volume_scatter(void);
|
void register_node_type_sh_volume_scatter(void);
|
||||||
|
void register_node_type_sh_volume_principled(void);
|
||||||
void register_node_type_sh_bsdf_hair(void);
|
void register_node_type_sh_bsdf_hair(void);
|
||||||
void register_node_type_sh_subsurface_scattering(void);
|
void register_node_type_sh_subsurface_scattering(void);
|
||||||
void register_node_type_sh_mix_shader(void);
|
void register_node_type_sh_mix_shader(void);
|
||||||
|
@ -92,6 +92,7 @@ DefNode( ShaderNode, SH_NODE_BSDF_HAIR, def_hair, "BS
|
|||||||
DefNode( ShaderNode, SH_NODE_SUBSURFACE_SCATTERING, def_sh_subsurface, "SUBSURFACE_SCATTERING",SubsurfaceScattering,"Subsurface Scattering","")
|
DefNode( ShaderNode, SH_NODE_SUBSURFACE_SCATTERING, def_sh_subsurface, "SUBSURFACE_SCATTERING",SubsurfaceScattering,"Subsurface Scattering","")
|
||||||
DefNode( ShaderNode, SH_NODE_VOLUME_ABSORPTION, 0, "VOLUME_ABSORPTION", VolumeAbsorption, "Volume Absorption", "" )
|
DefNode( ShaderNode, SH_NODE_VOLUME_ABSORPTION, 0, "VOLUME_ABSORPTION", VolumeAbsorption, "Volume Absorption", "" )
|
||||||
DefNode( ShaderNode, SH_NODE_VOLUME_SCATTER, 0, "VOLUME_SCATTER", VolumeScatter, "Volume Scatter", "" )
|
DefNode( ShaderNode, SH_NODE_VOLUME_SCATTER, 0, "VOLUME_SCATTER", VolumeScatter, "Volume Scatter", "" )
|
||||||
|
DefNode( ShaderNode, SH_NODE_VOLUME_PRINCIPLED, 0, "PRINCIPLED_VOLUME", VolumePrincipled, "Principled Volume", "" )
|
||||||
DefNode( ShaderNode, SH_NODE_EMISSION, 0, "EMISSION", Emission, "Emission", "" )
|
DefNode( ShaderNode, SH_NODE_EMISSION, 0, "EMISSION", Emission, "Emission", "" )
|
||||||
DefNode( ShaderNode, SH_NODE_NEW_GEOMETRY, 0, "NEW_GEOMETRY", NewGeometry, "Geometry", "" )
|
DefNode( ShaderNode, SH_NODE_NEW_GEOMETRY, 0, "NEW_GEOMETRY", NewGeometry, "Geometry", "" )
|
||||||
DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LIGHT_PATH", LightPath, "Light Path", "" )
|
DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LIGHT_PATH", LightPath, "Light Path", "" )
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): none yet.
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../node_shader_util.h"
|
||||||
|
|
||||||
|
/* **************** OUTPUT ******************** */
|
||||||
|
|
||||||
|
static bNodeSocketTemplate sh_node_volume_principled_in[] = {
|
||||||
|
{ SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
|
||||||
|
{ SOCK_STRING, 1, N_("Color Attribute"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
||||||
|
{ SOCK_FLOAT, 1, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
|
||||||
|
{ SOCK_STRING, 1, N_("Density Attribute"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
||||||
|
{ SOCK_FLOAT, 1, N_("Anisotropy"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_FACTOR},
|
||||||
|
{ SOCK_RGBA, 1, N_("Absorption Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
||||||
|
{ SOCK_FLOAT, 1, N_("Emission Strength"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1000.0f},
|
||||||
|
{ SOCK_RGBA, 1, N_("Emission Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
|
||||||
|
{ SOCK_FLOAT, 1, N_("Blackbody Intensity"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
|
||||||
|
{ SOCK_RGBA, 1, N_("Blackbody Tint"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
|
||||||
|
{ SOCK_FLOAT, 1, N_("Temperature"), 1000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6500.0f},
|
||||||
|
{ SOCK_STRING, 1, N_("Temperature Attribute"),0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
||||||
|
{ -1, 0, "" }
|
||||||
|
};
|
||||||
|
|
||||||
|
static bNodeSocketTemplate sh_node_volume_principled_out[] = {
|
||||||
|
{ SOCK_SHADER, 0, N_("Volume")},
|
||||||
|
{ -1, 0, "" }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void node_shader_init_volume_principled(bNodeTree *UNUSED(ntree), bNode *node)
|
||||||
|
{
|
||||||
|
for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
|
||||||
|
if (STREQ(sock->name, "Density Attribute")) {
|
||||||
|
strcpy(((bNodeSocketValueString *)sock->default_value)->value, "density");
|
||||||
|
}
|
||||||
|
else if (STREQ(sock->name, "Temperature Attribute")) {
|
||||||
|
strcpy(((bNodeSocketValueString *)sock->default_value)->value, "temperature");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int node_shader_gpu_volume_principled(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* node type definition */
|
||||||
|
void register_node_type_sh_volume_principled(void)
|
||||||
|
{
|
||||||
|
static bNodeType ntype;
|
||||||
|
|
||||||
|
sh_node_type_base(&ntype, SH_NODE_VOLUME_PRINCIPLED, "Principled Volume", NODE_CLASS_SHADER, 0);
|
||||||
|
node_type_compatibility(&ntype, NODE_NEW_SHADING);
|
||||||
|
node_type_socket_templates(&ntype, sh_node_volume_principled_in, sh_node_volume_principled_out);
|
||||||
|
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
|
||||||
|
node_type_init(&ntype, node_shader_init_volume_principled);
|
||||||
|
node_type_storage(&ntype, "", NULL, NULL);
|
||||||
|
node_type_gpu(&ntype, node_shader_gpu_volume_principled);
|
||||||
|
|
||||||
|
nodeRegisterType(&ntype);
|
||||||
|
}
|
||||||
|
|
@ -32,7 +32,7 @@
|
|||||||
static bNodeSocketTemplate sh_node_volume_scatter_in[] = {
|
static bNodeSocketTemplate sh_node_volume_scatter_in[] = {
|
||||||
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
|
{ SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
|
||||||
{ SOCK_FLOAT, 1, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
|
{ SOCK_FLOAT, 1, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
|
||||||
{ SOCK_FLOAT, 1, N_("Anisotropy"),0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f},
|
{ SOCK_FLOAT, 1, N_("Anisotropy"),0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_FACTOR},
|
||||||
{ -1, 0, "" }
|
{ -1, 0, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user