Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_sky.c
- This file was moved from source/blender/nodes/shader/nodes/node_shader_tex_sky.cc.
| Show All 11 Lines | |||||
| * You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| * | * | ||||
| * The Original Code is Copyright (C) 2005 Blender Foundation. | * The Original Code is Copyright (C) 2005 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| #include "node_shader_util.hh" | #include "../node_shader_util.h" | ||||
| #include "sky_model.h" | #include "sky_model.h" | ||||
| /* **************** OUTPUT ******************** */ | /* **************** OUTPUT ******************** */ | ||||
| namespace blender::nodes::node_shader_tex_sky_cc { | |||||
| static bNodeSocketTemplate sh_node_tex_sky_in[] = { | static bNodeSocketTemplate sh_node_tex_sky_in[] = { | ||||
| {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, | {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static bNodeSocketTemplate sh_node_tex_sky_out[] = { | static bNodeSocketTemplate sh_node_tex_sky_out[] = { | ||||
| {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_NO_INTERNAL_LINK}, | {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_NO_INTERNAL_LINK}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeTexSky *tex = (NodeTexSky *)MEM_callocN(sizeof(NodeTexSky), "NodeTexSky"); | NodeTexSky *tex = MEM_callocN(sizeof(NodeTexSky), "NodeTexSky"); | ||||
| BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); | BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); | ||||
| 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.545f); | tex->sun_size = DEG2RADF(0.545f); | ||||
| tex->sun_intensity = 1.0f; | tex->sun_intensity = 1.0f; | ||||
| tex->sun_elevation = DEG2RADF(15.0f); | tex->sun_elevation = DEG2RADF(15.0f); | ||||
| tex->sun_rotation = 0.0f; | tex->sun_rotation = 0.0f; | ||||
| tex->altitude = 0.0f; | 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; | ||||
| } | } | ||||
| struct SkyModelPreetham { | typedef struct SkyModelPreetham { | ||||
| float config_Y[5], config_x[5], config_y[5]; /* named after xyY color space */ | float config_Y[5], config_x[5], config_y[5]; /* named after xyY color space */ | ||||
| float radiance[3]; | float radiance[3]; | ||||
| }; | } SkyModelPreetham; | ||||
| static float sky_perez_function(const float *lam, float theta, float gamma) | static float sky_perez_function(const float *lam, float theta, float gamma) | ||||
| { | { | ||||
| float ctheta = cosf(theta); | float ctheta = cosf(theta); | ||||
| float cgamma = cosf(gamma); | float cgamma = cosf(gamma); | ||||
| return (1.0 + lam[0] * expf(lam[1] / ctheta)) * | return (1.0 + lam[0] * expf(lam[1] / ctheta)) * | ||||
| (1.0 + lam[2] * expf(lam[3] * gamma) + lam[4] * cgamma * cgamma); | (1.0 + lam[2] * expf(lam[3] * gamma) + lam[4] * cgamma * cgamma); | ||||
| ▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | |||||
| static void node_shader_update_sky(bNodeTree *ntree, bNode *node) | static void node_shader_update_sky(bNodeTree *ntree, bNode *node) | ||||
| { | { | ||||
| bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector"); | bNodeSocket *sockVector = nodeFindSocket(node, SOCK_IN, "Vector"); | ||||
| NodeTexSky *tex = (NodeTexSky *)node->storage; | NodeTexSky *tex = (NodeTexSky *)node->storage; | ||||
| nodeSetSocketAvailability(ntree, sockVector, !(tex->sky_model == 2 && tex->sun_disc == 1)); | nodeSetSocketAvailability(ntree, sockVector, !(tex->sky_model == 2 && tex->sun_disc == 1)); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_sky_cc | |||||
| /* node type definition */ | /* node type definition */ | ||||
| void register_node_type_sh_tex_sky() | void register_node_type_sh_tex_sky(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_sky_cc; | |||||
| 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, file_ns::sh_node_tex_sky_in, file_ns::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, file_ns::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, file_ns::node_shader_gpu_tex_sky); | node_type_gpu(&ntype, node_shader_gpu_tex_sky); | ||||
| /* remove Vector input for Nishita */ | /* remove Vector input for Nishita */ | ||||
| node_type_update(&ntype, file_ns::node_shader_update_sky); | node_type_update(&ntype, node_shader_update_sky); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||