Add cobbled limestone terrain

This commit is contained in:
kayomn 2023-01-16 18:25:35 +00:00
parent b800041173
commit 9982cae13b
9 changed files with 317 additions and 0 deletions

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

View File

@ -0,0 +1,169 @@
@tool
class_name TerrainInstance3D extends GeometryInstance3D
const _DETAIL := 2
var _mesh := PlaneMesh.new()
var _material := ShaderMaterial.new()
##
##
##
@export
var size: Vector2i = Vector2i.ZERO:
get:
return size
set(value):
var width := maxi(value.x, 0)
var height := maxi(value.y, 0)
if (width != size.x) or (height != size.y):
if (width == 0) and (height == 0):
RenderingServer.instance_set_base(self.get_instance(), RID())
else:
self._mesh.subdivide_width = width * _DETAIL
self._mesh.subdivide_depth = height * _DETAIL
self._mesh.size = value
self._material.set_shader_parameter("SIZE", Vector2(value))
RenderingServer.instance_set_base(self.get_instance(), self._mesh)
size = value
##
##
##
@export
var albedo_map: Texture2D = null:
get:
return albedo_map
set(value):
self._material.set_shader_parameter("ALBEDO_MAP_0", value)
albedo_map = value
##
##
##
@export
var albedo_map_b: Texture2D = null:
get:
return albedo_map_b
set(value):
self._material.set_shader_parameter("ALBEDO_MAP_B", value)
albedo_map_b = value
##
##
##
@export
var albedo_map_g: Texture2D = null:
get:
return albedo_map_g
set(value):
self._material.set_shader_parameter("ALBEDO_MAP_G", value)
albedo_map_g = value
##
##
##
@export
var albedo_map_r: Texture2D = null:
get:
return albedo_map_r
set(value):
self._material.set_shader_parameter("ALBEDO_MAP_R", value)
albedo_map_r = value
##
##
##
@export
var normal_map: Texture2D = null:
get:
return normal_map
set(value):
self._material.set_shader_parameter("NORMAL_MAP_0", value)
normal_map = value
##
##
##
@export
var normal_map_b: Texture2D = null:
get:
return normal_map_b
set(value):
self._material.set_shader_parameter("NORMAL_MAP_B", value)
normal_map_b = value
##
##
##
@export
var normal_map_g: Texture2D = null:
get:
return normal_map_g
set(value):
self._material.set_shader_parameter("NORMAL_MAP_G", value)
normal_map_g = value
##
##
##
@export
var normal_map_r: Texture2D = null:
get:
return normal_map_r
set(value):
self._material.set_shader_parameter("NORMAL_MAP_R", value)
normal_map_r = value
##
##
##
@export
var terrain_map: Texture2D = null:
get:
return terrain_map
set(value):
self._material.set_shader_parameter("TERRAIN_MAP", value)
terrain_map = value
##
##
##
@export
var max_height := 100.0:
get:
return max_height
set(value):
self._material.set_shader_parameter("MAX_HEIGHT", value)
max_height = max(value, 0.0)
func _init() -> void:
self._material.shader = preload("res://terrain_shader.gdshader")
self._mesh.surface_set_material(0, self._material)