27 b.add_input<
decl::Color>(
"Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
31 .default_value({0.5f, 0.5f})
35 "The position of the source of the rays in normalized coordinates. 0 means lower left "
36 "corner and 1 means upper right corner")
37 .compositor_expects_single_value();
44 "The length of rays relative to the size of the image. 0 means no rays and 1 means the "
45 "rays cover the full extent of the image")
46 .compositor_expects_single_value();
69 if (this->
context().use_gpu()) {
110 output.allocate_texture(domain);
112 const int2 input_size = domain.
size;
126 float2 vector_to_source = source - coordinates;
127 float2 step_vector = vector_to_source / unbounded_steps;
129 float accumulated_weight = 0.0f;
132 float2 position = coordinates +
i * step_vector;
136 if (position.x < 0.0f || position.y < 0.0f || position.x > 1.0f || position.y > 1.0f) {
140 float4 sample_color =
input.sample_bilinear_zero(position);
146 accumulated_weight += weight;
147 accumulated_color += sample_color * weight;
150 accumulated_color /= accumulated_weight != 0.0f ? accumulated_weight : 1.0f;
151 output.store_pixel(texel, accumulated_color);
181 ntype.
ui_description =
"Create sun beams based on image brightness";
184 ntype.
declare = file_ns::cmp_node_sunbeams_declare;
#define NODE_CLASS_OP_FILTER
#define CMP_NODE_SUNBEAMS
void GPU_shader_uniform_2fv(GPUShader *sh, const char *name, const float data[2])
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_texture_extend_mode(GPUTexture *texture, GPUSamplerExtendMode extend_mode)
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
void GPU_texture_filter_mode(GPUTexture *texture, bool use_filter)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
GPUShader * get_shader(const char *info_name, ResultPrecision precision)
NodeOperation(Context &context, DNode node)
Result & get_result(StringRef identifier)
Context & context() const
Result & get_input(StringRef identifier) const
virtual Domain compute_domain()
void share_data(const Result &source)
T get_single_value_default(const T &default_value) const
void allocate_texture(Domain domain, bool from_pool=true)
void unbind_as_texture() const
void bind_as_texture(GPUShader *shader, const char *texture_name) const
const Domain & domain() const
void bind_as_image(GPUShader *shader, const char *image_name, bool read=false) const
void unbind_as_image() const
void execute_cpu(const int max_steps)
void execute_gpu(const int max_steps)
NodeOperation(Context &context, DNode node)
void node_register_type(bNodeType &ntype)
void compute_dispatch_threads_at_least(GPUShader *shader, int2 threads_range, int2 local_size=int2(16))
void parallel_for(const int2 range, const Function &function)
T clamp(const T &a, const T &min, const T &max)
T distance(const T &a, const T &b)
T length(const VecBase< T, Size > &a)
T min(const T &a, const T &b)
T max(const T &a, const T &b)
static void cmp_node_sunbeams_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
static void register_node_type_cmp_sunbeams()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGetCompositorOperationFunction get_compositor_operation
const char * enum_name_legacy
NodeDeclareFunction declare