mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Set up a base ocean layer for the world.
This commit is contained in:
parent
a3f4ddd852
commit
d252a2e977
@ -38,3 +38,26 @@ func remove_content_entry(entry : WorldGenBaseResource) -> void:
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
func generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
var p : Vector2 = Vector2(chunk.get_position_x(), chunk.get_position_z())
|
||||
|
||||
var raycast : WorldGenRaycast = get_hit_stack(p)
|
||||
|
||||
if raycast.size() == 0:
|
||||
_generate_terra_chunk_fallback(chunk, pseed, spawn_mobs)
|
||||
return
|
||||
|
||||
_generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
|
||||
|
||||
while raycast.next():
|
||||
raycast.get_resource()._generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
|
||||
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
pass
|
||||
|
||||
func _generate_terra_chunk_fallback(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 1)
|
||||
chunk.set_voxel(1, 0, 0, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
|
7
game/materials/liquid_material_shadermat.tres
Normal file
7
game/materials/liquid_material_shadermat.tres
Normal file
@ -0,0 +1,7 @@
|
||||
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://shaders/liquid.tres" type="Shader" id=2]
|
||||
|
||||
[resource]
|
||||
shader = ExtResource( 2 )
|
||||
shader_param/albedo = Color( 1, 1, 1, 0.662745 )
|
@ -52,7 +52,7 @@ world_height = 100.0
|
||||
library = ExtResource( 1 )
|
||||
level_generator = ExtResource( 3 )
|
||||
voxel_scale = 3.0
|
||||
build_flags = 510
|
||||
build_flags = 511
|
||||
num_lods = 5
|
||||
script = ExtResource( 2 )
|
||||
test_prop = ExtResource( 5 )
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_resource type="TerrainLibraryMergerPCM" load_steps=13 format=2]
|
||||
[gd_resource type="TerrainLibraryMergerPCM" load_steps=15 format=2]
|
||||
|
||||
[ext_resource path="res://materials/8_standard_material_prop_notex.tres" type="Material" id=1]
|
||||
[ext_resource path="res://materials/6_standard_material_prop_nouv2.tres" type="Material" id=2]
|
||||
@ -7,7 +7,8 @@
|
||||
[ext_resource path="res://textures/world/stone/stone_1_albedo.png" type="Texture" id=5]
|
||||
[ext_resource path="res://materials/7_standard_material_notex.tres" type="Material" id=6]
|
||||
[ext_resource path="res://materials/5_standard_material_nouv2.tres" type="Material" id=7]
|
||||
[ext_resource path="res://materials/liquid_material.tres.tres" type="Material" id=8]
|
||||
[ext_resource path="res://materials/liquid_material_shadermat.tres" type="Material" id=8]
|
||||
[ext_resource path="res://textures/world/liquid/water_albedo.png" type="Texture" id=9]
|
||||
|
||||
[sub_resource type="TerrainSurfaceMerger" id=1]
|
||||
texture_top = ExtResource( 3 )
|
||||
@ -29,9 +30,14 @@ texture_top = ExtResource( 5 )
|
||||
texture_bottom = ExtResource( 5 )
|
||||
texture_side = ExtResource( 5 )
|
||||
|
||||
[sub_resource type="TerrainSurfaceMerger" id=5]
|
||||
texture_top = ExtResource( 9 )
|
||||
texture_bottom = ExtResource( 9 )
|
||||
texture_side = ExtResource( 9 )
|
||||
|
||||
[resource]
|
||||
materials = [ ExtResource( 7 ), ExtResource( 7 ), ExtResource( 7 ), ExtResource( 7 ), ExtResource( 6 ) ]
|
||||
liquid_materials = [ ExtResource( 8 ) ]
|
||||
prop_materials = [ ExtResource( 2 ), ExtResource( 2 ), ExtResource( 2 ), ExtResource( 2 ), ExtResource( 1 ) ]
|
||||
texture_flags = 1
|
||||
terra_surfaces = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ]
|
||||
terra_surfaces = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ]
|
||||
|
@ -119,12 +119,13 @@ func gen_terra_chunk(chunk: TerrainChunk, rng : RandomNumberGenerator) -> void:
|
||||
val *= val
|
||||
val *= 20.0
|
||||
val += abs(sdet.get_noise_2d(vx * 0.8, vz * 0.8)) * 20
|
||||
val += 100
|
||||
|
||||
chunk.set_voxel(val, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
if val < 50:
|
||||
if val < 150:
|
||||
chunk.set_voxel(2, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_TYPE)
|
||||
elif val > 90:
|
||||
elif val > 190:
|
||||
chunk.set_voxel(4, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_TYPE)
|
||||
else:
|
||||
if chunk.position_x == 0 && chunk.position_z == 0:
|
||||
|
88
game/scripts/world_generator/worlds/ocean_base_world.gd
Normal file
88
game/scripts/world_generator/worlds/ocean_base_world.gd
Normal file
@ -0,0 +1,88 @@
|
||||
tool
|
||||
extends "res://addons/world_generator/resources/world_gen_world.gd"
|
||||
|
||||
export(int) var base_iso_level : int = 0
|
||||
export(int) var water_iso_level : int = 100
|
||||
export(int) var water_surface_id : int = 5
|
||||
export(FastnoiseNoiseParams) var base_noise : FastnoiseNoiseParams = null
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_slot_int("get_base_iso_level", "set_base_iso_level", "Base Isolevel")
|
||||
inspector.add_slot_int("get_water_iso_level", "set_water_iso_level", "Water Isolevel")
|
||||
inspector.add_slot_int("get_water_surface_id", "set_water_surface_id", "Water Surface ID")
|
||||
|
||||
inspector.add_slot_resource("get_base_noise_params", "set_base_noise_params", "Base Noise Params", "FastnoiseNoiseParams")
|
||||
|
||||
|
||||
func generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
var p : Vector2 = Vector2(chunk.get_position_x(), chunk.get_position_z())
|
||||
|
||||
var raycast : WorldGenRaycast = get_hit_stack(p)
|
||||
|
||||
_generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
|
||||
|
||||
while raycast.next():
|
||||
raycast.get_resource()._generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
|
||||
|
||||
_generate_terra_chunk_ocean(chunk, pseed, spawn_mobs)
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
_generate_terra_chunk_fallback(chunk, pseed, spawn_mobs)
|
||||
|
||||
func _generate_terra_chunk_fallback(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, base_iso_level)
|
||||
#chunk.set_voxel(1, 0, 0, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
func _generate_terra_chunk_ocean(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
if !chunk.channel_is_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE):
|
||||
return
|
||||
|
||||
if !chunk.channel_is_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL):
|
||||
return
|
||||
|
||||
var ensured_channels : bool = false
|
||||
|
||||
for x in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
for z in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
var iso_level : int = chunk.get_voxel(x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
if iso_level < water_iso_level:
|
||||
if !ensured_channels:
|
||||
ensured_channels = true
|
||||
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_LIQUID_TYPE, 0)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_LIQUID_ISOLEVEL, 0)
|
||||
|
||||
chunk.set_voxel(water_surface_id, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_LIQUID_TYPE)
|
||||
chunk.set_voxel(water_iso_level, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_LIQUID_ISOLEVEL)
|
||||
|
||||
func get_base_iso_level() -> int:
|
||||
return base_iso_level
|
||||
|
||||
func set_base_iso_level(ed : int) -> void:
|
||||
base_iso_level = ed
|
||||
emit_changed()
|
||||
|
||||
func get_water_iso_level() -> int:
|
||||
return water_iso_level
|
||||
|
||||
func set_water_iso_level(ed : int) -> void:
|
||||
water_iso_level = ed
|
||||
emit_changed()
|
||||
|
||||
func get_water_surface_id() -> int:
|
||||
return water_surface_id
|
||||
|
||||
func set_water_surface_id(ed : int) -> void:
|
||||
water_surface_id = ed
|
||||
emit_changed()
|
||||
|
||||
func get_base_noise_params() -> FastnoiseNoiseParams:
|
||||
return base_noise
|
||||
|
||||
func set_base_noise_params(ed : FastnoiseNoiseParams) -> void:
|
||||
base_noise = ed
|
||||
emit_changed()
|
18
game/shaders/liquid.tres
Normal file
18
game/shaders/liquid.tres
Normal file
@ -0,0 +1,18 @@
|
||||
[gd_resource type="Shader" format=2]
|
||||
|
||||
[resource]
|
||||
code = "// NOTE: Shader automatically converted from Godot Engine 3.5.beta's SpatialMaterial.
|
||||
|
||||
shader_type spatial;
|
||||
render_mode async_visible,blend_mix,depth_draw_opaque,cull_disabled,unshaded,vertex_lighting,shadows_disabled;
|
||||
uniform vec4 albedo : hint_color;
|
||||
uniform sampler2D texture_albedo : hint_albedo;
|
||||
|
||||
void fragment() {
|
||||
vec2 base_uv = UV;
|
||||
vec4 albedo_tex = texture(texture_albedo,base_uv);
|
||||
albedo_tex *= COLOR;
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb;
|
||||
ALPHA = albedo.a * albedo_tex.a;
|
||||
}
|
||||
"
|
4
game/worlds/test_world/noises/base_ocean_noise.tres
Normal file
4
game/worlds/test_world/noises/base_ocean_noise.tres
Normal file
@ -0,0 +1,4 @@
|
||||
[gd_resource type="FastnoiseNoiseParams" format=2]
|
||||
|
||||
[resource]
|
||||
resource_name = "Ocean Floor Noise"
|
@ -1,6 +1,6 @@
|
||||
[gd_resource type="Resource" load_steps=13 format=2]
|
||||
[gd_resource type="Resource" load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://addons/world_generator/resources/world_gen_world.gd" type="Script" id=1]
|
||||
[ext_resource path="res://scripts/world_generator/worlds/ocean_base_world.gd" type="Script" id=1]
|
||||
[ext_resource path="res://scripts/world_generator/subzones/spawner.gd" type="Script" id=2]
|
||||
[ext_resource path="res://scripts/world_generator/continents/test_continent.gd" type="Script" id=3]
|
||||
[ext_resource path="res://worlds/test_world/dungeons/dung_teleporter.tscn" type="PackedScene" id=4]
|
||||
@ -9,6 +9,7 @@
|
||||
[ext_resource path="res://scripts/world_generator/zones/test_zone.gd" type="Script" id=7]
|
||||
[ext_resource path="res://entity_classes/naturalist/entities/4_naturalist_vendor.tres" type="EntityData" id=8]
|
||||
[ext_resource path="res://entity_classes/naturalist/entities/3_naturalist_trainer.tres" type="EntityData" id=9]
|
||||
[ext_resource path="res://worlds/test_world/noises/base_ocean_noise.tres" type="FastnoiseNoiseParams" id=10]
|
||||
|
||||
[sub_resource type="Resource" id=2]
|
||||
resource_name = "Spawner"
|
||||
@ -41,3 +42,7 @@ script = ExtResource( 1 )
|
||||
rect = Rect2( -250, -250, 500, 500 )
|
||||
locked = false
|
||||
continents = [ SubResource( 1 ) ]
|
||||
base_iso_level = 0
|
||||
water_iso_level = 100
|
||||
water_surface_id = 5
|
||||
base_noise = ExtResource( 10 )
|
||||
|
Loading…
Reference in New Issue
Block a user