-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Restored and renamed the preview_2d to TexturePreviewComponent + Restored noise, combiners and blend nodes + Exposed the spinbox custom step + Fixed a bug from d9773e1 affecting dropdown components
- Loading branch information
1 parent
b8f2ec1
commit 6e456c7
Showing
25 changed files
with
670 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class_name NoiseAdd | ||
extends NoiseCombiner | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
if z == null: | ||
return clamp(noise_a.get_noise_2d(x, y) + noise_b.get_noise_2d(x, y), -1.0, 1.0) | ||
else: | ||
return clamp(noise_a.get_noise_3d(x, y, z) + noise_b.get_noise_3d(x, y, z), -1.0, 1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class_name NoiseBlend | ||
extends NoiseCombiner | ||
|
||
|
||
var blend_amount: float = 0.5: | ||
set(val): | ||
blend_amount = clamp(val, 0.0, 1.0) | ||
|
||
|
||
func _init(noise1: ProtonNoise = null, noise2: ProtonNoise = null, amount := 0.0): | ||
super(noise1, noise2) | ||
blend_amount = amount | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
var val1 = 0.0 | ||
var val2 = 0.0 | ||
|
||
if z == null: | ||
val1 = noise_a.get_noise_2d(x, y) | ||
val2 = noise_b.get_noise_2d(x, y) | ||
else: | ||
val1 = noise_a.get_noise_3d(x, y, z) | ||
val2 = noise_b.get_noise_3d(x, y, z) | ||
|
||
return lerp(val1, val2, blend_amount) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class_name NoiseCombiner | ||
extends ProtonNoise | ||
|
||
|
||
var noise_a: ProtonNoise | ||
var noise_b: ProtonNoise | ||
|
||
|
||
func _init(n1: ProtonNoise = null, n2: ProtonNoise = null): | ||
noise_a = n1 | ||
noise_b = n2 | ||
|
||
|
||
func get_noise_2d(x:float, y:float) -> float: | ||
return _combine_noise(x, y) | ||
|
||
|
||
func get_noise_2dv(v: Vector2) -> float: | ||
return _combine_noise(v.x, v.y) | ||
|
||
|
||
func get_noise_3d(x: float, y: float, z: float) -> float: | ||
return _combine_noise(x, y, z) | ||
|
||
|
||
func get_noise_3dv(v: Vector3) -> float: | ||
return _combine_noise(v.x, v.y, v.z) | ||
|
||
|
||
func _combine_noise(x:float, y: float, z = null) -> float: | ||
if z == null: | ||
return noise_b.get_noise_2d(x, y) | ||
|
||
else: | ||
return noise_b.get_noise_3d(x, y, z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class_name NoiseDivide | ||
extends NoiseCombiner | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
if z == null: | ||
return clamp(noise_a.get_noise_2d(x, y) / max(0.001, noise_a.get_noise_2d(x, y)), -1.0, 1.0) | ||
else: | ||
return clamp(noise_a.get_noise_3d(x, y, z) / max(0.001, noise_b.get_noise_3d(x, y, z)), -1.0, 1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class_name NoiseMax | ||
extends NoiseCombiner | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
if z == null: | ||
return max(noise_a.get_noise_2d(x, y), noise_b.get_noise_2d(x, y)) | ||
else: | ||
return max(noise_a.get_noise_3d(x, y, z), noise_b.get_noise_3d(x, y, z)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class_name NoiseMin | ||
extends NoiseCombiner | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
if z == null: | ||
return min(noise_a.get_noise_2d(x, y), noise_b.get_noise_2d(x, y)) | ||
else: | ||
return min(noise_a.get_noise_3d(x, y, z), noise_b.get_noise_3d(x, y, z)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class_name NoiseMultiply | ||
extends NoiseCombiner | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
if z == null: | ||
return noise_a.get_noise_2d(x, y) * noise_b.get_noise_2d(x, y) | ||
else: | ||
return noise_a.get_noise_3d(x, y, z) * noise_b.get_noise_3d(x, y, z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class_name NoiseOverlay | ||
extends NoiseCombiner | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
var a | ||
var b | ||
if z == null: | ||
a = noise_a.get_noise_2d(x, y) | ||
b = noise_b.get_noise_2d(x, y) | ||
else: | ||
a = noise_a.get_noise_3d(x, y, z) | ||
b = noise_b.get_noise_3d(x, y, z) | ||
|
||
if a < 0.5: | ||
return 2 * a * b | ||
|
||
return 1 - 2 * (1 - a) * (1 - b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class_name NoiseScreen | ||
extends NoiseCombiner | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
var a | ||
var b | ||
if z == null: | ||
a = noise_a.get_noise_2d(x, y) | ||
b = noise_b.get_noise_2d(x, y) | ||
else: | ||
a = noise_a.get_noise_3d(x, y, z) | ||
b = noise_b.get_noise_3d(x, y, z) | ||
|
||
return 1 - (1 - a) * (1 - b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class_name NoiseSubstract | ||
extends NoiseCombiner | ||
|
||
|
||
func _combine_noise(x: float, y: float, z = null) -> float: | ||
if z == null: | ||
return clamp(noise_a.get_noise_2d(x, y) - noise_b.get_noise_2d(x, y), -1.0, 1.0) | ||
else: | ||
return clamp(noise_a.get_noise_3d(x, y, z) - noise_b.get_noise_3d(x, y, z), -1.0, 1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
class_name ProtonNoise | ||
extends RefCounted | ||
|
||
|
||
var curve: Curve | ||
|
||
|
||
func get_noise_2d(_x: float, _y: float) -> float: | ||
return 0.0 | ||
|
||
|
||
func get_noise_2dv(_v: Vector2) -> float: | ||
return 0.0 | ||
|
||
|
||
func get_noise_3d(_x: float, _y: float, _z: float) -> float: | ||
return 0.0 | ||
|
||
|
||
func get_noise_3dv(_v: Vector3) -> float: | ||
return 0.0 | ||
|
||
|
||
func get_image(width: int, height: int, scale = 1.0, offset = Vector2()) -> Image: | ||
var bytes = PackedByteArray() | ||
bytes.resize(width * height * 3) | ||
|
||
var color | ||
var val = 0 | ||
var i = 0 | ||
|
||
for y in height: | ||
for x in width: | ||
val = get_noise_2d( | ||
offset.x + (x * scale), | ||
offset.y + (y * scale) | ||
) * 0.5 + 0.5 | ||
color = Color(val, val, val) | ||
bytes[i] = color.r8 | ||
bytes[i + 1] = color.g8 | ||
bytes[i + 2] = color.b8 | ||
i += 3 | ||
|
||
return Image.create_from_data(width, height, false, Image.FORMAT_RGB8, bytes) | ||
|
||
|
||
func apply_curve(noise_value: float) -> float: | ||
if not curve is Curve: | ||
return noise_value | ||
|
||
return clamp( | ||
curve.sample_baked(noise_value * 0.5 + 0.5) * 2.0 - 1.0, | ||
-1.0, | ||
1.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extends ProtonNoise | ||
class_name ProtonNoiseFast | ||
|
||
|
||
var _fast_noise: FastNoiseLite | ||
|
||
|
||
func _init(): | ||
_fast_noise = FastNoiseLite.new() | ||
|
||
|
||
func get_noise_2d(x: float, y: float) -> float: | ||
return apply_curve(_fast_noise.get_noise_2d(x, y)) | ||
|
||
|
||
func get_noise_2dv(v: Vector2) -> float: | ||
return apply_curve(_fast_noise.get_noise_2dv(v)) | ||
|
||
|
||
func get_noise_3d(x: float, y: float, z: float) -> float: | ||
return apply_curve(_fast_noise.get_noise_3d(x, y, z)) | ||
|
||
|
||
func get_noise_3dv(v: Vector3) -> float: | ||
return apply_curve(_fast_noise.get_noise_3dv(v)) | ||
|
||
|
||
func get_noise_object() -> FastNoiseLite: | ||
return _fast_noise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.