Editor Terrain Brush #2

Merged
kayomn merged 27 commits from editor-terrain-brush into main 2023-01-19 01:51:25 +01:00
15 changed files with 183 additions and 72 deletions
Showing only changes of commit 1765ed9947 - Show all commits

View File

@ -1,14 +0,0 @@
[remap]
importer="image"
type="Image"
uid="uid://bbdh4btpg08do"
path="res://.godot/imported/brush_soft_mask.png-211f364dba674d8d697543d1b1246d6a.image"
[deps]
source_file="res://brush_soft_mask.png"
dest_files=["res://.godot/imported/brush_soft_mask.png-211f364dba674d8d697543d1b1246d6a.image"]
[params]

BIN
editor.scn (Stored with Git LFS)

Binary file not shown.

View File

@ -0,0 +1,14 @@
[remap]
importer="image"
type="Image"
uid="uid://bbdh4btpg08do"
path="res://.godot/imported/brush_soft_mask.png-cec601fece9e15b1942ebb0d73b51015.image"
[deps]
source_file="res://editor/brush_soft_mask.png"
dest_files=["res://.godot/imported/brush_soft_mask.png-cec601fece9e15b1942ebb0d73b51015.image"]
[params]

View File

@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bgpk15qrqxly8"
path.s3tc="res://.godot/imported/prototype_tiles_large_albedo.png-c3984e5db888f4b509766546fda5695b.s3tc.ctex"
path.etc2="res://.godot/imported/prototype_tiles_large_albedo.png-c3984e5db888f4b509766546fda5695b.etc2.ctex"
path.s3tc="res://.godot/imported/default_albedo.png-92a6d62c2ead547c4c35766bdeaf9065.s3tc.ctex"
path.etc2="res://.godot/imported/default_albedo.png-92a6d62c2ead547c4c35766bdeaf9065.etc2.ctex"
metadata={
"imported_formats": ["s3tc", "etc2"],
"vram_texture": true
@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://prototype_tiles_large_albedo.png"
dest_files=["res://.godot/imported/prototype_tiles_large_albedo.png-c3984e5db888f4b509766546fda5695b.s3tc.ctex", "res://.godot/imported/prototype_tiles_large_albedo.png-c3984e5db888f4b509766546fda5695b.etc2.ctex"]
source_file="res://terrain/default_albedo.png"
dest_files=["res://.godot/imported/default_albedo.png-92a6d62c2ead547c4c35766bdeaf9065.s3tc.ctex", "res://.godot/imported/default_albedo.png-92a6d62c2ead547c4c35766bdeaf9065.etc2.ctex"]
[params]

BIN
terrain/desert_sand_albedo.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b8cv4q43fsglu"
path="res://.godot/imported/desert_sand_albedo.png-5307ce3455129127b5c6f3a135f5cbc7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/desert_sand_albedo.png"
dest_files=["res://.godot/imported/desert_sand_albedo.png-5307ce3455129127b5c6f3a135f5cbc7.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
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

BIN
terrain/desert_sand_depth.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cb4ldm1dda1bo"
path="res://.godot/imported/desert_sand_depth.png-add0a002b33efe8fd04b2cf4bf524515.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/desert_sand_depth.png"
dest_files=["res://.godot/imported/desert_sand_depth.png-add0a002b33efe8fd04b2cf4bf524515.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
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

BIN
terrain/desert_sand_normal.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c40cc5b5sq4yu"
path="res://.godot/imported/desert_sand_normal.png-9b37ed7fc3712ce013db97500f604934.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/desert_sand_normal.png"
dest_files=["res://.godot/imported/desert_sand_normal.png-9b37ed7fc3712ce013db97500f604934.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
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

View File

@ -37,105 +37,105 @@ var size: Vector2i = Vector2i.ZERO:
##
##
@export
var layer_1_albedo: Texture2D = null:
var albedo_map: Texture2D = null:
get:
return layer_1_albedo
return albedo_map
set(value):
self._material.set_shader_parameter("LAYER_1_ALBEDO", value)
self._material.set_shader_parameter("ALBEDO_MAP_0", value)
layer_1_albedo = value
albedo_map = value
##
##
##
@export
var layer_1_normal_map: Texture2D = null:
var albedo_map_b: Texture2D = null:
get:
return layer_1_normal_map
return albedo_map_b
set(value):
self._material.set_shader_parameter("LAYER_1_NORMAL_MAP", value)
self._material.set_shader_parameter("ALBEDO_MAP_B", value)
layer_1_normal_map = value
albedo_map_b = value
##
##
##
@export
var layer_2_albedo: Texture2D = null:
var albedo_map_g: Texture2D = null:
get:
return layer_2_albedo
return albedo_map_g
set(value):
self._material.set_shader_parameter("LAYER_2_ALBEDO", value)
self._material.set_shader_parameter("ALBEDO_MAP_G", value)
layer_2_albedo = value
albedo_map_g = value
##
##
##
@export
var layer_2_normal_map: Texture2D = null:
var albedo_map_r: Texture2D = null:
get:
return layer_2_normal_map
return albedo_map_r
set(value):
self._material.set_shader_parameter("LAYER_2_NORMAL_MAP", value)
self._material.set_shader_parameter("ALBEDO_MAP_R", value)
layer_2_normal_map = value
albedo_map_r = value
##
##
##
@export
var layer_3_albedo: Texture2D = null:
var normal_map: Texture2D = null:
get:
return layer_3_albedo
return normal_map
set(value):
self._material.set_shader_parameter("LAYER_3_ALBEDO", value)
self._material.set_shader_parameter("NORMAL_MAP_0", value)
layer_3_albedo = value
normal_map = value
##
##
##
@export
var layer_3_normal_map: Texture2D = null:
var normal_map_b: Texture2D = null:
get:
return layer_3_normal_map
return normal_map_b
set(value):
self._material.set_shader_parameter("LAYER_3_NORMAL_MAP", value)
self._material.set_shader_parameter("NORMAL_MAP_B", value)
layer_3_normal_map = value
normal_map_b = value
##
##
##
@export
var layer_4_albedo: Texture2D = null:
var normal_map_g: Texture2D = null:
get:
return layer_4_albedo
return normal_map_g
set(value):
self._material.set_shader_parameter("LAYER_4_ALBEDO", value)
self._material.set_shader_parameter("NORMAL_MAP_G", value)
layer_4_albedo = value
normal_map_g = value
##
##
##
@export
var layer_4_normal_map: Texture2D = null:
var normal_map_r: Texture2D = null:
get:
return layer_4_normal_map
return normal_map_r
set(value):
self._material.set_shader_parameter("LAYER_4_NORMAL_MAP", value)
self._material.set_shader_parameter("ALBEDO_MAP_R", value)
layer_4_normal_map = value
normal_map_r = value
##
##

View File

@ -1,23 +1,23 @@
shader_type spatial;
uniform sampler2D LAYER_1_ALBEDO : hint_default_black;
uniform sampler2D ALBEDO_MAP_0 : hint_default_black;
uniform sampler2D LAYER_1_NORMAL_MAP : hint_default_black;
uniform sampler2D ALBEDO_MAP_R : hint_default_black;
uniform sampler2D LAYER_2_ALBEDO : hint_default_black;
uniform sampler2D ALBEDO_MAP_G : hint_default_black;
uniform sampler2D LAYER_2_NORMAL_MAP : hint_default_black;
uniform sampler2D LAYER_3_ALBEDO : hint_default_black;
uniform sampler2D LAYER_3_NORMAL_MAP : hint_default_black;
uniform sampler2D LAYER_4_ALBEDO : hint_default_black;
uniform sampler2D LAYER_4_NORMAL_MAP : hint_default_black;
uniform sampler2D ALBEDO_MAP_B : hint_default_black;
uniform float MAX_HEIGHT = 100.0;
uniform sampler2D NORMAL_MAP_0 : hint_default_black;
uniform sampler2D NORMAL_MAP_R : hint_default_black;
uniform sampler2D NORMAL_MAP_G : hint_default_black;
uniform sampler2D NORMAL_MAP_B : hint_default_black;
uniform vec2 SIZE;
uniform sampler2D TERRAIN_MAP : hint_default_transparent, repeat_disable;
@ -28,15 +28,15 @@ void fragment() {
vec3 splat_map = texture(TERRAIN_MAP, UV).rgb;
float blank = clamp(1.0 - splat_map.r - splat_map.g - splat_map.b, 0.0, 1.0);
ALBEDO = blank * 0.5 * (texture(LAYER_1_ALBEDO, uv).rgb + texture(LAYER_1_ALBEDO, uv_alt).rgb);
ALBEDO += splat_map.r * 0.5 * (texture(LAYER_2_ALBEDO, uv).rgb + texture(LAYER_2_ALBEDO, uv_alt).rgb);
ALBEDO += splat_map.g * 0.5 * (texture(LAYER_3_ALBEDO, uv).rgb + texture(LAYER_3_ALBEDO, uv_alt).rgb);
ALBEDO += splat_map.b * 0.5 * (texture(LAYER_4_ALBEDO, uv).rgb + texture(LAYER_4_ALBEDO, uv_alt).rgb);
ALBEDO = blank * 0.5 * (texture(ALBEDO_MAP_0, uv).rgb + texture(ALBEDO_MAP_0, uv_alt).rgb);
ALBEDO += splat_map.r * 0.5 * (texture(ALBEDO_MAP_R, uv).rgb + texture(ALBEDO_MAP_R, uv_alt).rgb);
ALBEDO += splat_map.g * 0.5 * (texture(ALBEDO_MAP_G, uv).rgb + texture(ALBEDO_MAP_G, uv_alt).rgb);
ALBEDO += splat_map.b * 0.5 * (texture(ALBEDO_MAP_B, uv).rgb + texture(ALBEDO_MAP_B, uv_alt).rgb);
NORMAL_MAP = blank * 0.5 * (texture(LAYER_1_NORMAL_MAP, uv).rgb + texture(LAYER_1_NORMAL_MAP, uv_alt).rgb);
NORMAL_MAP += splat_map.r * 0.5 * (texture(LAYER_1_NORMAL_MAP, uv).rgb + texture(LAYER_2_NORMAL_MAP, uv_alt).rgb);
NORMAL_MAP += splat_map.g * 0.5 * (texture(LAYER_2_NORMAL_MAP, uv).rgb + texture(LAYER_3_NORMAL_MAP, uv_alt).rgb);
NORMAL_MAP += splat_map.b * 0.5 * (texture(LAYER_3_NORMAL_MAP, uv).rgb + texture(LAYER_4_NORMAL_MAP, uv_alt).rgb);
NORMAL_MAP = blank * 0.5 * (texture(NORMAL_MAP_0, uv).rgb + texture(NORMAL_MAP_0, uv_alt).rgb);
NORMAL_MAP += splat_map.r * 0.5 * (texture(NORMAL_MAP_R, uv).rgb + texture(NORMAL_MAP_R, uv_alt).rgb);
NORMAL_MAP += splat_map.g * 0.5 * (texture(NORMAL_MAP_G, uv).rgb + texture(NORMAL_MAP_G, uv_alt).rgb);
NORMAL_MAP += splat_map.b * 0.5 * (texture(NORMAL_MAP_B, uv).rgb + texture(NORMAL_MAP_B, uv_alt).rgb);
}
float height(vec2 uv) {