/**************************************************************************/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/texture.h"3637class NoiseTexture3D : public Texture3D {38GDCLASS(NoiseTexture3D, Texture3D);3940private:41Thread noise_thread;4243bool first_time = true;44bool update_queued = false;45bool regen_queued = false;4647mutable RID texture;48uint32_t flags = 0;4950int width = 64;51int height = 64;52int depth = 64;53bool invert = false;54bool seamless = false;55real_t seamless_blend_skirt = 0.1;56bool normalize = true;5758Ref<Gradient> color_ramp;59Ref<Noise> noise;6061Image::Format format = Image::FORMAT_L8;6263void _thread_done(const TypedArray<Image> &p_data);64static void _thread_function(void *p_ud);6566void _queue_update();67TypedArray<Image> _generate_texture();68void _update_texture();69void _set_texture_data(const TypedArray<Image> &p_data);7071Ref<Image> _modulate_with_gradient(Ref<Image> p_image, Ref<Gradient> p_gradient);7273protected:74static void _bind_methods();75void _validate_property(PropertyInfo &p_property) const;7677public:78void set_noise(Ref<Noise> p_noise);79Ref<Noise> get_noise();8081void set_width(int p_width);82void set_height(int p_height);83void set_depth(int p_depth);8485void set_invert(bool p_invert);86bool get_invert() const;8788void set_seamless(bool p_seamless);89bool get_seamless();9091void set_seamless_blend_skirt(real_t p_blend_skirt);92real_t get_seamless_blend_skirt();9394void set_normalize(bool p_normalize);95bool is_normalized() const;9697void set_color_ramp(const Ref<Gradient> &p_gradient);98Ref<Gradient> get_color_ramp() const;99100virtual int get_width() const override;101virtual int get_height() const override;102virtual int get_depth() const override;103104virtual bool has_mipmaps() const override;105106virtual RID get_rid() const override;107108virtual Vector<Ref<Image>> get_data() const override;109virtual Image::Format get_format() const override;110111NoiseTexture3D();112virtual ~NoiseTexture3D();113};114115116