Compare commits

...

3 Commits

Author SHA1 Message Date
kayomn 0b19b97293 Various editor and editor GUI fixes 2023-01-16 18:54:06 +00:00
kayomn 9982cae13b Add cobbled limestone terrain 2023-01-16 18:25:35 +00:00
kayomn b800041173 Add more style appropriate terrain assets 2023-01-16 17:44:14 +00:00
37 changed files with 567 additions and 64 deletions

BIN
editor.scn (Stored with Git LFS)

Binary file not shown.

View File

@ -53,31 +53,7 @@ func _init() -> void:
func clear(clear_color: Color) -> void:
_image.fill(clear_color)
##
##
##
func erase(point: Vector2i, mask: Image, scale: float, intensity: float, delta: float) -> void:
var draw_area := _get_draw_area(point, mask, scale)
if draw_area.has_area():
var mask_ratio := mask.get_size() / draw_area.size
for y in draw_area.size.y:
var brush_mask_y := int(y * mask_ratio.y)
for x in draw_area.size.x:
var terrain_map_coord := draw_area.position + Vector2i(x, y)
var pixel := _image.get_pixelv(terrain_map_coord)
var mask_intensity_delta := intensity *\
delta * mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a
_image.set_pixelv(terrain_map_coord, Color(
lerpf(pixel.r, 0.0, mask_intensity_delta),
lerpf(pixel.g, 0.0, mask_intensity_delta),
lerpf(pixel.b, 0.0, mask_intensity_delta),
pixel.a))
if instance != null:
instance.terrain_map.update(_image)
##
@ -98,9 +74,10 @@ func lower(point: Vector2i, mask: Image, scale: float, intensity: float, delta:
_image.set_pixelv(terrain_map_coord, Color(pixel.r, pixel.g, pixel.b,
lerpf(pixel.a, pixel.a - (intensity *
mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a), delta)))
mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a), delta)).clamp())
instance.terrain_map.update(_image)
if instance != null:
instance.terrain_map.update(_image)
##
##
@ -118,12 +95,45 @@ func paint_blue(point: Vector2i, mask: Image, scale: float, intensity: float, de
var terrain_map_coord := draw_area.position + Vector2i(x, y)
var pixel := _image.get_pixelv(terrain_map_coord)
_image.set_pixelv(terrain_map_coord, Color(
pixel.r, pixel.g, lerpf(pixel.b, intensity, delta *\
mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a),
pixel.a))
var mask_intensity_delta := intensity *\
delta * mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a
instance.terrain_map.update(_image)
_image.set_pixelv(terrain_map_coord, Color(
lerpf(pixel.r, 0.0, mask_intensity_delta),
lerpf(pixel.g, 0.0, mask_intensity_delta),
lerpf(pixel.b, 1.0, mask_intensity_delta),
pixel.a).clamp())
if instance != null:
instance.terrain_map.update(_image)
##
##
##
func paint_erase(point: Vector2i, mask: Image, scale: float, intensity: float, delta: float) -> void:
var draw_area := _get_draw_area(point, mask, scale)
if draw_area.has_area():
var mask_ratio := mask.get_size() / draw_area.size
for y in draw_area.size.y:
var brush_mask_y := int(y * mask_ratio.y)
for x in draw_area.size.x:
var terrain_map_coord := draw_area.position + Vector2i(x, y)
var pixel := _image.get_pixelv(terrain_map_coord)
var mask_intensity_delta := intensity *\
delta * mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a
_image.set_pixelv(terrain_map_coord, Color(
lerpf(pixel.r, 0.0, mask_intensity_delta),
lerpf(pixel.g, 0.0, mask_intensity_delta),
lerpf(pixel.b, 0.0, mask_intensity_delta),
pixel.a).clamp())
if instance != null:
instance.terrain_map.update(_image)
##
##
@ -141,12 +151,17 @@ func paint_green(point: Vector2i, mask: Image, scale: float, intensity: float, d
var terrain_map_coord := draw_area.position + Vector2i(x, y)
var pixel := _image.get_pixelv(terrain_map_coord)
_image.set_pixelv(terrain_map_coord, Color(
pixel.r, lerpf(pixel.g, intensity, delta *\
mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a),
pixel.b, pixel.a))
var mask_intensity_delta := intensity *\
delta * mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a
instance.terrain_map.update(_image)
_image.set_pixelv(terrain_map_coord, Color(
lerpf(pixel.r, 0.0, mask_intensity_delta),
lerpf(pixel.g, 1.0, mask_intensity_delta),
lerpf(pixel.b, 0.0, mask_intensity_delta),
pixel.a).clamp())
if instance != null:
instance.terrain_map.update(_image)
##
##
@ -164,12 +179,17 @@ func paint_red(point: Vector2i, mask: Image, scale: float, intensity: float, del
var terrain_map_coord := draw_area.position + Vector2i(x, y)
var pixel := _image.get_pixelv(terrain_map_coord)
_image.set_pixelv(terrain_map_coord, Color(
lerpf(pixel.r, intensity, delta *\
mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a),
pixel.g, pixel.b, pixel.a))
var mask_intensity_delta := intensity *\
delta * mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a
instance.terrain_map.update(_image)
_image.set_pixelv(terrain_map_coord, Color(
lerpf(pixel.r, 1.0, mask_intensity_delta),
lerpf(pixel.g, 0.0, mask_intensity_delta),
lerpf(pixel.b, 0.0, mask_intensity_delta),
pixel.a).clamp())
if instance != null:
instance.terrain_map.update(_image)
##
##
@ -189,9 +209,10 @@ func raise(point: Vector2i, mask: Image, scale: float, intensity: float, delta:
_image.set_pixelv(terrain_map_coord, Color(pixel.r, pixel.g, pixel.b,
lerpf(pixel.a, pixel.a + (intensity *
mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a), delta)))
mask.get_pixel(int(x * mask_ratio.x), brush_mask_y).a), delta)).clamp())
instance.terrain_map.update(_image)
if instance != null:
instance.terrain_map.update(_image)
##
## Samples the color value in the editable terrain at the worldspace [code]point[/code], returning
@ -226,6 +247,7 @@ func smooth(point: Vector2i, mask: Image, scale: float, level: float, delta: flo
_image.set_pixelv(terrain_map_coord, Color(pixel.r, pixel.g, pixel.b,
lerpf(pixel.a, level, delta * mask.get_pixel(
int(x * mask_ratio.x), brush_mask_y).a)))
int(x * mask_ratio.x), brush_mask_y).a)).clamp())
instance.terrain_map.update(_image)
if instance != null:
instance.terrain_map.update(_image)

BIN
editor/menus_theme.res (Stored with Git LFS)

Binary file not shown.

View File

@ -27,7 +27,7 @@ _global_script_classes=[{
"base": "GeometryInstance3D",
"class": &"TerrainInstance3D",
"language": &"GDScript",
"path": "res://terrain_instance_3d.gd"
"path": "res://terrain/terrain_instance_3d.gd"
}]
_global_script_class_icons={
"EditableTerrain": "",

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

Binary file not shown.

View File

@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://cb4ldm1dda1bo"
path="res://.godot/imported/desert_sand_depth.png-add0a002b33efe8fd04b2cf4bf524515.ctex"
uid="uid://jcmf7j3qo6ea"
path="res://.godot/imported/arid_grass_albedo.png-cac7ceff15cf65e54d8ee36a70e05853.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"]
source_file="res://terrain/arid_grass_albedo.png"
dest_files=["res://.godot/imported/arid_grass_albedo.png-cac7ceff15cf65e54d8ee36a70e05853.ctex"]
[params]

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

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://co0jompch208v"
path="res://.godot/imported/arid_grass_displacement.png-66c8c71a36e11168aed23cd0531ba7bd.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/arid_grass_displacement.png"
dest_files=["res://.godot/imported/arid_grass_displacement.png-66c8c71a36e11168aed23cd0531ba7bd.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/arid_grass_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://bh141jkgbmya8"
path="res://.godot/imported/arid_grass_normal.png-6cfb96e0a0b1eac890998accab9c7109.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/arid_grass_normal.png"
dest_files=["res://.godot/imported/arid_grass_normal.png-6cfb96e0a0b1eac890998accab9c7109.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/arid_grass_roughness.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://jdq8kwjo3uap"
path="res://.godot/imported/arid_grass_roughness.png-8ff0f34a3348350d0edc5e43b43bcd0e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/arid_grass_roughness.png"
dest_files=["res://.godot/imported/arid_grass_roughness.png-8ff0f34a3348350d0edc5e43b43bcd0e.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/cobbled_limestone_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://cs06oiwrord6t"
path="res://.godot/imported/cobbled_limestone_albedo.png-cbafb40d3c6fc43ce00d68cb02456536.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/cobbled_limestone_albedo.png"
dest_files=["res://.godot/imported/cobbled_limestone_albedo.png-cbafb40d3c6fc43ce00d68cb02456536.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/cobbled_limestone_displacement.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://mkxbjfwdwkaq"
path="res://.godot/imported/cobbled_limestone_displacement.png-8e8b27438ff815a9d58d4a490e04203c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/cobbled_limestone_displacement.png"
dest_files=["res://.godot/imported/cobbled_limestone_displacement.png-8e8b27438ff815a9d58d4a490e04203c.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/cobbled_limestone_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://ukk0161x3eg2"
path="res://.godot/imported/cobbled_limestone_normal.png-4d7b2eb9c070e06256eb42d408ff4a14.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/cobbled_limestone_normal.png"
dest_files=["res://.godot/imported/cobbled_limestone_normal.png-4d7b2eb9c070e06256eb42d408ff4a14.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/cobbled_limestone_roughness.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bcybapft8tl2x"
path="res://.godot/imported/cobbled_limestone_roughness.png-f78cac7004d15ddc2a00fd10f74b8c10.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/cobbled_limestone_roughness.png"
dest_files=["res://.godot/imported/cobbled_limestone_roughness.png-f78cac7004d15ddc2a00fd10f74b8c10.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_albedo.png (Stored with Git LFS)

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bdacir1igfinb"
path="res://.godot/imported/desert_sand_displacement.png-3674eb6c274d21b1ddd14b8c6ce982fe.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/desert_sand_displacement.png"
dest_files=["res://.godot/imported/desert_sand_displacement.png-3674eb6c274d21b1ddd14b8c6ce982fe.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)

Binary file not shown.

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

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bwkcsnjetn5wr"
path="res://.godot/imported/desert_sand_roughness.png-c85e29a6965b06eac0c712e74b047821.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/desert_sand_roughness.png"
dest_files=["res://.godot/imported/desert_sand_roughness.png-c85e29a6965b06eac0c712e74b047821.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/dry_mud_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://eqbk8dx3px02"
path="res://.godot/imported/dry_mud_albedo.png-0fe12d446fc4e93e2a42ccc9303ac693.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/dry_mud_albedo.png"
dest_files=["res://.godot/imported/dry_mud_albedo.png-0fe12d446fc4e93e2a42ccc9303ac693.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/dry_mud_displacement.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bwqtubithbfsy"
path="res://.godot/imported/dry_mud_displacement.png-459305492d2f8cba90344ad67808cc02.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/dry_mud_displacement.png"
dest_files=["res://.godot/imported/dry_mud_displacement.png-459305492d2f8cba90344ad67808cc02.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/dry_mud_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://c86r5niid1hp1"
path="res://.godot/imported/dry_mud_normal.png-bbedc7a55f837a837bfdab39fcbc7272.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/dry_mud_normal.png"
dest_files=["res://.godot/imported/dry_mud_normal.png-bbedc7a55f837a837bfdab39fcbc7272.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/dry_mud_roughness.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://7xnkstxa6q65"
path="res://.godot/imported/dry_mud_roughness.png-0d5a4572411f8d454ef69ed8b252672b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/dry_mud_roughness.png"
dest_files=["res://.godot/imported/dry_mud_roughness.png-0d5a4572411f8d454ef69ed8b252672b.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

@ -164,6 +164,6 @@ var max_height := 100.0:
max_height = max(value, 0.0)
func _init() -> void:
self._material.shader = preload("res://terrain_shader.gdshader")
self._material.shader = preload("res://terrain/terrain_shader.gdshader")
self._mesh.surface_set_material(0, self._material)

View File

@ -23,7 +23,7 @@ uniform vec2 SIZE;
uniform sampler2D TERRAIN_MAP : hint_default_transparent, repeat_disable;
void fragment() {
vec2 uv = UV * SIZE;
vec2 uv = UV * (SIZE / 2.0);
vec2 uv_alt = uv * -0.25;
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);