/**************************************************************************/1/* noise_texture_3d.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "noise.h"3334#include "core/object/ref_counted.h"35#include "scene/resources/gradient.h"36#include "scene/resources/texture.h"3738class NoiseTexture3D : public Texture3D {39GDCLASS(NoiseTexture3D, Texture3D);4041private:42Thread noise_thread;4344bool first_time = true;45bool update_queued = false;46bool regen_queued = false;4748mutable RID texture;49uint32_t flags = 0;5051int width = 64;52int height = 64;53int depth = 64;54bool invert = false;55bool seamless = false;56real_t seamless_blend_skirt = 0.1;57bool normalize = true;5859Ref<Gradient> color_ramp;60Ref<Noise> noise;6162Image::Format format = Image::FORMAT_L8;6364void _thread_done(const TypedArray<Image> &p_data);65static void _thread_function(void *p_ud);6667void _queue_update();68TypedArray<Image> _generate_texture();69void _update_texture();70void _set_texture_data(const TypedArray<Image> &p_data);7172Ref<Image> _modulate_with_gradient(Ref<Image> p_image, Ref<Gradient> p_gradient);7374protected:75static void _bind_methods();76void _validate_property(PropertyInfo &p_property) const;7778public:79void set_noise(Ref<Noise> p_noise);80Ref<Noise> get_noise();8182void set_width(int p_width);83void set_height(int p_height);84void set_depth(int p_depth);8586void set_invert(bool p_invert);87bool get_invert() const;8889void set_seamless(bool p_seamless);90bool get_seamless();9192void set_seamless_blend_skirt(real_t p_blend_skirt);93real_t get_seamless_blend_skirt();9495void set_normalize(bool p_normalize);96bool is_normalized() const;9798void set_color_ramp(const Ref<Gradient> &p_gradient);99Ref<Gradient> get_color_ramp() const;100101virtual int get_width() const override;102virtual int get_height() const override;103virtual int get_depth() const override;104105virtual bool has_mipmaps() const override;106107virtual RID get_rid() const override;108109virtual Vector<Ref<Image>> get_data() const override;110virtual Image::Format get_format() const override;111112NoiseTexture3D();113virtual ~NoiseTexture3D();114};115116117