Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_sky.c
| Show All 37 Lines | static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| BKE_texture_colormapping_default(&tex->base.color_mapping); | BKE_texture_colormapping_default(&tex->base.color_mapping); | ||||
| tex->sun_direction[0] = 0.0f; | tex->sun_direction[0] = 0.0f; | ||||
| tex->sun_direction[1] = 0.0f; | tex->sun_direction[1] = 0.0f; | ||||
| tex->sun_direction[2] = 1.0f; | tex->sun_direction[2] = 1.0f; | ||||
| tex->turbidity = 2.2f; | tex->turbidity = 2.2f; | ||||
| tex->ground_albedo = 0.3f; | tex->ground_albedo = 0.3f; | ||||
| tex->sun_disc = true; | tex->sun_disc = true; | ||||
| tex->sun_size = DEG2RADF(0.545); | tex->sun_size = DEG2RADF(0.545); | ||||
| tex->sun_intensity = 1.0f; | |||||
| tex->sun_elevation = M_PI_2; | tex->sun_elevation = M_PI_2; | ||||
| tex->sun_rotation = 0.0f; | tex->sun_rotation = 0.0f; | ||||
| tex->altitude = 0; | tex->altitude = 0.0f; | ||||
| tex->air_density = 1.0f; | tex->air_density = 1.0f; | ||||
| tex->dust_density = 1.0f; | tex->dust_density = 1.0f; | ||||
| tex->ozone_density = 1.0f; | tex->ozone_density = 1.0f; | ||||
| tex->sky_model = SHD_SKY_NISHITA; | tex->sky_model = SHD_SKY_NISHITA; | ||||
| node->storage = tex; | node->storage = tex; | ||||
| } | } | ||||
| static int node_shader_gpu_tex_sky(GPUMaterial *mat, | static int node_shader_gpu_tex_sky(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| GPUNodeStack *in, | GPUNodeStack *in, | ||||
| GPUNodeStack *out) | GPUNodeStack *out) | ||||
| { | { | ||||
| if (!in[0].link) { | if (!in[0].link) { | ||||
| in[0].link = GPU_attribute(mat, CD_ORCO, ""); | in[0].link = GPU_attribute(mat, CD_ORCO, ""); | ||||
| } | } | ||||
| node_shader_gpu_tex_mapping(mat, node, in, out); | node_shader_gpu_tex_mapping(mat, node, in, out); | ||||
| return GPU_stack_link(mat, node, "node_tex_sky", in, out); | return GPU_stack_link(mat, node, "node_tex_sky", in, out); | ||||
| } | } | ||||
| static void node_shader_update_sky(bNodeTree *UNUSED(ntree), bNode *node) | |||||
| { | |||||
| bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector"); | |||||
| NodeTexSky *tex = (NodeTexSky *)node->storage; | |||||
| nodeSetSocketAvailability(sockVector, !(tex->sky_model == 2 && tex->sun_disc == 1)); | |||||
| } | |||||
| /* node type definition */ | /* node type definition */ | ||||
| void register_node_type_sh_tex_sky(void) | void register_node_type_sh_tex_sky(void) | ||||
| { | { | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_TEX_SKY, "Sky Texture", NODE_CLASS_TEXTURE, 0); | sh_node_type_base(&ntype, SH_NODE_TEX_SKY, "Sky Texture", NODE_CLASS_TEXTURE, 0); | ||||
| node_type_socket_templates(&ntype, sh_node_tex_sky_in, sh_node_tex_sky_out); | node_type_socket_templates(&ntype, sh_node_tex_sky_in, sh_node_tex_sky_out); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); | node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); | ||||
| node_type_init(&ntype, node_shader_init_tex_sky); | node_type_init(&ntype, node_shader_init_tex_sky); | ||||
| node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage); | node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_gpu(&ntype, node_shader_gpu_tex_sky); | node_type_gpu(&ntype, node_shader_gpu_tex_sky); | ||||
| /* remove Vector input for Nishita */ | |||||
| node_type_update(&ntype, node_shader_update_sky); | |||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||