Skip to content

Commit

Permalink
added a pack of noise textures, implemented the shader to blend textu…
Browse files Browse the repository at this point in the history
…res into the terrain and updated the README with the new changes
  • Loading branch information
ninetailsrabbit committed Oct 31, 2024
1 parent ec645e5 commit 90e2467
Show file tree
Hide file tree
Showing 582 changed files with 10,006 additions and 64 deletions.
85 changes: 33 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<br>

- [📦 Installation](#-installation)
- [](#)
- [Getting started 📝](#getting-started-)
- [Parameters 🗻](#parameters-)
- [Mesh resolution](#mesh-resolution)
Expand All @@ -44,8 +43,6 @@ To better understand what branch to choose from for which Godot version, please

---

## ![](images/terrainy_showcase.gif)

# Getting started 📝

Creating a new terrain is as easy as adding the `Terrainy` node into your scene.
Expand Down Expand Up @@ -75,14 +72,16 @@ The width size of the mesh (x) in godot units (meters)

### Max terrain height

The maximum height (y) at which this terrain can be generated in godot units (meters)
The maximum height (y) at which this terrain can be generated in godot units (meters). The noises values are in a range of _(0, 1)_. So if the noise value in a specific vertex point it's `0.5` the height returned for a `max_terrain_height` of 50 the result will be `50 * 0.5 = 25`

### Target Mesh

The target `MeshInstance3D` where the mesh will be generated. If no `Mesh` for it is defined, a new `PlaneMesh` is created by default.

It only supports `PlaneMesh` `QuadMesh`, `BoxMesh` and `PrismMesh`, otherwise, the `Mesh` will be deleted and a `PlaneMesh` will be assigned for terrain generation.

**The final mesh will always end up as a result in an `ArrayMesh`.**

### Terrain Material

This is the material that will be applied to the Terrain. Take a look on [Shader material](#shader-material) examples to get a detailed terrain surface mixing textures.
Expand All @@ -91,13 +90,34 @@ This is the material that will be applied to the Terrain. Take a look on [Shader

This is a [FastNoiseLite](https://docs.godotengine.org/en/stable/classes/class_fastnoiselite.html#fastnoiselite) instance. Noise values are perfect to generate a variety of surfaces, higher frequencies tend to generate more mountainous terrain.

Play with the parameters and different types of noise to get the result you want, take into account that if this noise is defined the `noise_texture` will be ignored.
Play with the parameters and different types of noise to get the result you want, take into account that if this `noise` variable is defined, the `noise_texture` will be ignored.

### Noise texture

Use a texture as noise to generate the terrain. **If a noise is defined, this texture will be ignored.**

You can find a lot of ready noise textures from this itch asset store page [https://screamingbrainstudios.itch.io/noise-texture-pack](https://screamingbrainstudios.itch.io/noise-texture-pack)
Use a texture as noise to generate the terrain. **If a `noise` is defined, this texture will be ignored.**

You can find a lot of ready noise textures inside the addon in this path `addons/ninetailsrabbit.terrainy/assets/SBS - Noise Texture Pack - 256x256` folder from [ScreamingBrainStudios](https://screamingbrai.nstudios.itch.io/noise-texture-pack)

This textures are divided into categories:

- Cracks
- Craters
- Gabor
- Grainy
- Manifold
- Marble
- Melt
- Milky
- Perlin
- Spokes
- Streak
- Super Noise
- Super Perlin
- Swirl
- Techno
- Turbulence
- Vein
- Voronoi

# Shader materials 🏞️

Expand All @@ -107,51 +127,12 @@ This can be useful for some cases where you don't need a lot of detail but if yo

## Albedo terrain mix

This shader can be found on [https://godotshaders.com/shader/albedo-terrain-mix-shader/](https://godotshaders.com/shader/albedo-terrain-mix-shader/)

I paste it here just for backup purposes in case **GodotShaders** is gone. I modified the `uv_size` to support a higher value range, which will be necessary if you use low-poly textures.

```csharp
shader_type spatial;

uniform sampler2D source_texture_mask : source_color;
uniform sampler2D source_texture_black : source_color;
uniform sampler2D source_texture_red : source_color;
uniform sampler2D source_texture_green : source_color;
uniform sampler2D source_texture_blue : source_color;

uniform float uv_size : hint_range(0.01, 100.0, 0.01) = 1.0;

void fragment() {

vec2 UV_Scaled = UV * uv_size;

// texture_rgbmask UV is not scaled.
vec3 texture_rgbmask = texture(source_texture_mask, UV).rgb;
vec3 texture_black = texture(source_texture_black, UV_Scaled).rgb;
vec3 texture_red = texture(source_texture_red, UV_Scaled).rgb;
vec3 texture_green = texture(source_texture_green, UV_Scaled).rgb;
vec3 texture_blue = texture(source_texture_blue, UV_Scaled).rgb;

float summed_texture_channels = (
texture_rgbmask.r +
texture_rgbmask.g +
texture_rgbmask.b);

vec3 mixed_terrain = clamp(
( texture_rgbmask.r * texture_red +
texture_rgbmask.g * texture_green +
texture_rgbmask.b * texture_blue) /
summed_texture_channels,
vec3(0.0), vec3(1.0) // Clamp min, max values.
);

ALBEDO = mix(mixed_terrain,texture_black,1.0 - summed_texture_channels);
This addons comes with a modified shader from [DiztyNinja](https://www.youtube.com/@ditzyninja) that can be used on `terrain_material` exported parameter.

} // Fragment end
With this shader you can mix a total of 3 textures that represents a surface based on the height of the terrain where grass represents the `top surface`, the rock represents the `medium surface` and the sand represents the `bottom_surface`.

```
Play around with the parameters until you get the result you want.

There is a well explained tutorial of the creator, He uses a terrain already imported from blender, **it works the same with a mesh generated by this plugin.**
You can see an example here using textures from [https://ambientcg.com/](https://ambientcg.com/)

[![albedo_mix_youtube_tutorial](http://img.youtube.com/vi/MaVweI30Qo4/0.jpg)](http://www.youtube.com/watch?v=MaVweI30Qo4 "Albedo mix shader tutorial")
![terrain_shader_example](images/terrain_shader.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c4joxtaacktkr"
path="res://.godot/imported/Cracks_01-256x256.png-a4d8f016290bfc6efca8cdd35c177e58.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/ninetailsrabbit.terrainy/assets/SBS - Noise Texture Pack - 256x256/256x256/Cracks/Cracks_01-256x256.png"
dest_files=["res://.godot/imported/Cracks_01-256x256.png-a4d8f016290bfc6efca8cdd35c177e58.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c4hx60rt7kii1"
path="res://.godot/imported/Cracks_02-256x256.png-ee911564cb46350b56892e69002c4ae9.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/ninetailsrabbit.terrainy/assets/SBS - Noise Texture Pack - 256x256/256x256/Cracks/Cracks_02-256x256.png"
dest_files=["res://.godot/imported/Cracks_02-256x256.png-ee911564cb46350b56892e69002c4ae9.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://5ijpbjnvo15p"
path="res://.godot/imported/Cracks_03-256x256.png-a7f89aef9308393ffac1e69015606d9a.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/ninetailsrabbit.terrainy/assets/SBS - Noise Texture Pack - 256x256/256x256/Cracks/Cracks_03-256x256.png"
dest_files=["res://.godot/imported/Cracks_03-256x256.png-a7f89aef9308393ffac1e69015606d9a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ch4doqvlnnu28"
path="res://.godot/imported/Cracks_04-256x256.png-be2e81eb349fe1a234489de0932a4e07.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/ninetailsrabbit.terrainy/assets/SBS - Noise Texture Pack - 256x256/256x256/Cracks/Cracks_04-256x256.png"
dest_files=["res://.godot/imported/Cracks_04-256x256.png-be2e81eb349fe1a234489de0932a4e07.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bktva4muxn5rg"
path="res://.godot/imported/Cracks_05-256x256.png-afa6cef195684c9a4991346cd98f3793.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/ninetailsrabbit.terrainy/assets/SBS - Noise Texture Pack - 256x256/256x256/Cracks/Cracks_05-256x256.png"
dest_files=["res://.godot/imported/Cracks_05-256x256.png-afa6cef195684c9a4991346cd98f3793.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c7k12xj4ss4k"
path="res://.godot/imported/Cracks_06-256x256.png-3fa1b872fc3de3bc986bcd40fa573166.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/ninetailsrabbit.terrainy/assets/SBS - Noise Texture Pack - 256x256/256x256/Cracks/Cracks_06-256x256.png"
dest_files=["res://.godot/imported/Cracks_06-256x256.png-3fa1b872fc3de3bc986bcd40fa573166.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://chyh02smfd7yx"
path="res://.godot/imported/Cracks_07-256x256.png-d4616befefbbdcae0ebd2d38326a193a.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/ninetailsrabbit.terrainy/assets/SBS - Noise Texture Pack - 256x256/256x256/Cracks/Cracks_07-256x256.png"
dest_files=["res://.godot/imported/Cracks_07-256x256.png-d4616befefbbdcae0ebd2d38326a193a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 90e2467

Please sign in to comment.