30 b.add_output<
decl::Color>(
"Color"_ustr).no_muted_links();
73 NodeTexSky *tex = MEM_new<NodeTexSky>(
"NodeTexSky");
101 float ctheta =
cosf(theta);
102 float cgamma =
cosf(gamma);
104 return (1.0 + lam[0] *
expf(lam[1] / ctheta)) *
105 (1.0 + lam[2] *
expf(lam[3] * gamma) + lam[4] * cgamma * cgamma);
110 float theta = sun_angles[0];
111 float theta2 = theta * theta;
112 float theta3 = theta2 * theta;
115 float chi = (4.0f / 9.0f -
T / 120.0f) * (
M_PI - 2.0f * theta);
117 sunsky->
radiance[0] = (4.0453f *
T - 4.9710f) *
tanf(chi) - 0.2155f *
T + 2.4192f;
120 sunsky->
radiance[1] = (0.00166f * theta3 - 0.00375f * theta2 + 0.00209f * theta) *
T2 +
121 (-0.02903f * theta3 + 0.06377f * theta2 - 0.03202f * theta + 0.00394f) *
123 (0.11693f * theta3 - 0.21196f * theta2 + 0.06052f * theta + 0.25886f);
125 sunsky->
radiance[2] = (0.00275f * theta3 - 0.00610f * theta2 + 0.00317f * theta) *
T2 +
126 (-0.04214f * theta3 + 0.08970f * theta2 - 0.04153f * theta + 0.00516f) *
128 (0.15346f * theta3 - 0.26756f * theta2 + 0.06670f * theta + 0.26688f);
130 sunsky->
config_Y[0] = (0.1787f *
T - 1.4630f);
131 sunsky->
config_Y[1] = (-0.3554f *
T + 0.4275f);
132 sunsky->
config_Y[2] = (-0.0227f *
T + 5.3251f);
133 sunsky->
config_Y[3] = (0.1206f *
T - 2.5771f);
134 sunsky->
config_Y[4] = (-0.0670f *
T + 0.3703f);
136 sunsky->
config_x[0] = (-0.0193f *
T - 0.2592f);
137 sunsky->
config_x[1] = (-0.0665f *
T + 0.0008f);
138 sunsky->
config_x[2] = (-0.0004f *
T + 0.2125f);
139 sunsky->
config_x[3] = (-0.0641f *
T - 0.8989f);
140 sunsky->
config_x[4] = (-0.0033f *
T + 0.0452f);
142 sunsky->
config_y[0] = (-0.0167f *
T - 0.2608f);
143 sunsky->
config_y[1] = (-0.0950f *
T + 0.0092f);
144 sunsky->
config_y[2] = (-0.0079f *
T + 0.2102f);
145 sunsky->
config_y[3] = (-0.0441f *
T - 1.6537f);
146 sunsky->
config_y[4] = (-0.0109f *
T + 0.0529f);
157 float new_sun_elevation = sun_elevation;
158 float new_sun_rotation = sun_rotation;
161 new_sun_elevation =
fmodf(new_sun_elevation, 2.0f *
M_PI);
164 new_sun_elevation -=
copysignf(2.0f, new_sun_elevation) *
M_PI;
168 if (new_sun_elevation >=
M_PI / 2.0f || new_sun_elevation <= -
M_PI / 2.0f) {
169 new_sun_elevation =
copysignf(
M_PI, new_sun_elevation) - new_sun_elevation;
170 new_sun_rotation +=
M_PI;
174 new_sun_rotation =
fmodf(new_sun_rotation, 2.0f *
M_PI);
176 if (new_sun_rotation < 0.0f) {
177 new_sun_rotation += 2.0f *
M_PI;
179 new_sun_rotation = 2.0f *
M_PI - new_sun_rotation;
181 sun_elevation = new_sun_elevation;
182 sun_rotation = new_sun_rotation;
206 "node_tex_sky_preetham",
224 sun_angles[0] = fmin(
M_PI_2, sun_angles[0]);
228 float config_x07[8], config_y07[8], config_z07[8], config_xyz8[3];
229 for (
int i = 0; i < 8; ++i) {
234 for (
int i = 0; i < 3; ++i) {
238 for (
int i = 0; i < 3; i++) {
246 "node_tex_sky_hosekwilkie",
271 float pixel_bottom[3];
324 const float sun_params[4] = {sun_elevation,
332 "node_tex_sky_nishita",
390 ntype.
declare = file_ns::node_declare;
393 ntype.
initfunc = file_ns::node_shader_init_tex_sky;
396 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_sky;
397 ntype.
updatefunc = file_ns::node_shader_update_sky;
#define NODE_CLASS_TEXTURE
const bke::bNodeType & node_type() const
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeTree & node_tree() const
const bNodeSocket & other_socket() const
eNodeSocketInOut in_out() const
void update_and_connect_available_socket(bNode &new_node, UString socket_name)
bNode & add_node(UString idname)
Vector< SocketDeclaration * > outputs
void node_register_type(bNodeType &ntype)
void node_set_socket_availability(bNodeTree &ntree, bNodeSocket &sock, bool is_available)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void sky_precompute_old(SkyModelPreetham *sunsky, const float sun_angles[], float turbidity)
static void node_shader_init_tex_sky(bNodeTree *, bNode *node)
static void node_shader_buts_tex_sky(ui::Layout &layout, bContext *, PointerRNA *ptr)
static int node_shader_gpu_tex_sky(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sky_simplify_elevation_rotation(float &sun_elevation, float &sun_rotation)
static void node_shader_update_sky(bNodeTree *ntree, bNode *node)
static float sky_perez_function(const float *lam, float theta, float gamma)
static void node_declare(NodeDeclarationBuilder &b)
void search_link_ops_for_declarations(GatherLinkSearchOpParams ¶ms, Span< SocketDeclaration * > declarations)
@ ITEM_R_SPLIT_EMPTY_NAME
void register_node_type_sh_tex_sky()
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
int RNA_enum_get(PointerRNA *ptr, const char *name)
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
@ GPU_SAMPLER_FILTERING_LINEAR
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GPUNodeLink * GPU_uniform(const float *num)
GPUNodeLink * GPU_constant(const float *num)
void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *)
void node_shader_gpu_default_tex_coord(GPUMaterial *mat, bNode *node, GPUNodeLink **link)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void get_XYZ_to_RGB_for_gpu(XYZ_to_RGB *data)
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
GPUNodeLink * GPU_image_sky(GPUMaterial *mat, int width, int height, const float *pixels, float *layer, GPUSamplerState sampler_state)
@ SHD_SKY_SINGLE_SCATTERING
@ SHD_SKY_MULTIPLE_SCATTERING
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
color xyz_to_rgb(float x, float y, float z)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void SKY_arhosekskymodelstate_free(SKY_ArHosekSkyModelState *state)
SKY_ArHosekSkyModelState * SKY_arhosek_xyz_skymodelstate_alloc_init(const double turbidity, const double albedo, const double elevation)
void SKY_multiple_scattering_precompute_texture(float *pixels, int stride, int width, int height, float sun_elevation, float altitude, float air_density, float aerosol_density, float ozone_density)
void SKY_single_scattering_precompute_sun(float sun_elevation, float angular_diameter, float altitude, float air_density, float aerosol_density, float r_pixel_bottom[3], float r_pixel_top[3])
void SKY_single_scattering_precompute_texture(float *pixels, int stride, int width, int height, float sun_elevation, float altitude, float air_density, float aerosol_density, float ozone_density)
void SKY_multiple_scattering_precompute_sun(float sun_elevation, float angular_diameter, float altitude, float air_density, float aerosol_density, float ozone_density, float r_pixel_bottom[3], float r_pixel_top[3])
float SKY_earth_intersection_angle(float altitude)
SKY_ArHosekSkyModelConfiguration configs[11]
ColorMapping color_mapping
bke::bNodeTreeType * typeinfo
static constexpr int _160
bool(*) validate_link(eNodeSocketDatatype from, eNodeSocketDatatype to)
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
void(*) updatefunc(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
nodes::NodeDeclaration * static_declaration
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & column(bool align)