mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Now the transvoxel mesher bakes alternative uv coordinates into uv2 so it can inetrpolate between different voxel surfaces near seams (based on COLOR.a).
This commit is contained in:
parent
c34569a658
commit
d30e33a122
2
HEADS
2
HEADS
@ -1 +1 @@
|
|||||||
{"engine": {"3.2": "8a0f94a688f18a9565a21657bf44791550aec96a", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "09372b146936fda509f5c23a522e998d12f38e13"}, "entity_spell_system": {"master": "0bdf71c431b62b24d56c1fc178dbcb792e5dca3d"}, "ui_extensions": {"master": "38acc650db260a831dc26ca96fe9d9a087230bdc"}, "voxelman": {"master": "3a8310c51fe87c4ab046c1f86a92ddb80fb2768a"}, "texture_packer": {"master": "b17c174906f84de93d84aa60d010ffe603efaa28"}, "fastnoise": {"master": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e"}, "mesh_data_resource": {"master": "4bda19b12be2c2a79a6121de6d22e48f3934e726"}, "procedural_animations": {"master": "00f6c128bd0e9799b7f7f86e118ed68277fbe27d"}, "fast_quadratic_mesh_simplifier": {"master": "d3f3a829eff40a93464f6b321c13ce26d44e11e3"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "prop_tool": {"master": "df438053ebc900966f8f842fc65f0264f1271d49"}}
|
{"engine": {"3.2": "8a0f94a688f18a9565a21657bf44791550aec96a", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "09372b146936fda509f5c23a522e998d12f38e13"}, "entity_spell_system": {"master": "0bdf71c431b62b24d56c1fc178dbcb792e5dca3d"}, "ui_extensions": {"master": "38acc650db260a831dc26ca96fe9d9a087230bdc"}, "voxelman": {"master": "201ea0ce1f7e170affc911be60128ca807b246aa"}, "texture_packer": {"master": "b17c174906f84de93d84aa60d010ffe603efaa28"}, "fastnoise": {"master": "41b7ea05a1f7aa2b8ecddaa1fd739e64d6970f7e"}, "mesh_data_resource": {"master": "4bda19b12be2c2a79a6121de6d22e48f3934e726"}, "procedural_animations": {"master": "00f6c128bd0e9799b7f7f86e118ed68277fbe27d"}, "fast_quadratic_mesh_simplifier": {"master": "d3f3a829eff40a93464f6b321c13ce26d44e11e3"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "prop_tool": {"master": "df438053ebc900966f8f842fc65f0264f1271d49"}}
|
File diff suppressed because one or more lines are too long
23
game/data/materials/3_standard_character_material.tres
Normal file
23
game/data/materials/3_standard_character_material.tres
Normal file
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
[gd_scene load_steps=37 format=2]
|
[gd_scene load_steps=37 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://data/models/armature.dae" type="PackedScene" id=1]
|
[ext_resource path="res://data/models/armature.dae" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://data/materials/1_standard_material.tres" type="Material" id=2]
|
[ext_resource path="res://data/materials/3_standard_character_material.tres" type="Material" id=2]
|
||||||
[ext_resource path="res://player/CharacterSkeletonGD.gd" type="Script" id=3]
|
[ext_resource path="res://player/CharacterSkeletonGD.gd" type="Script" id=3]
|
||||||
[ext_resource path="res://player/CharacterSkeletonAttachPoint.gd" type="Script" id=4]
|
[ext_resource path="res://player/CharacterSkeletonAttachPoint.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://test_weapons/sword_i.mesh" type="ArrayMesh" id=5]
|
[ext_resource path="res://test_weapons/sword_i.mesh" type="ArrayMesh" id=5]
|
||||||
@ -210,7 +210,7 @@ bones/19/bound_children = [ NodePath("RightHandAttachment") ]
|
|||||||
skin = SubResource( 1 )
|
skin = SubResource( 1 )
|
||||||
|
|
||||||
[node name="LeftHandAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="1"]
|
[node name="LeftHandAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="1"]
|
||||||
transform = Transform( 0.103496, -0.988074, -0.113867, 0.0567376, -0.108407, 0.992451, -0.993007, -0.109178, 0.0448429, 0.269912, 0.765141, -0.009432 )
|
transform = Transform( 0.103553, -0.988238, -0.11234, 0.0563584, -0.106903, 0.99262, -0.993022, -0.109123, 0.044628, 0.270796, 0.763348, -0.00915292 )
|
||||||
bone_name = "left_hand"
|
bone_name = "left_hand"
|
||||||
|
|
||||||
[node name="LeftHandAP" type="Spatial" parent="armature/Armature/Skeleton/LeftHandAttachment"]
|
[node name="LeftHandAP" type="Spatial" parent="armature/Armature/Skeleton/LeftHandAttachment"]
|
||||||
@ -218,7 +218,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.04, -0.09 )
|
|||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="RightHandAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="2"]
|
[node name="RightHandAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="2"]
|
||||||
transform = Transform( -0.0414053, -0.998491, 0.0355513, -0.126356, 0.0405158, 0.991109, -0.991131, 0.0365534, -0.127846, -0.27264, 0.76424, -0.00749165 )
|
transform = Transform( -0.0415039, -0.998438, 0.0367427, -0.126411, 0.0417122, 0.991033, -0.991123, 0.0364982, -0.127949, -0.273113, 0.764931, -0.00762625 )
|
||||||
bone_name = "right_hand"
|
bone_name = "right_hand"
|
||||||
|
|
||||||
[node name="RightHandAP" type="Spatial" parent="armature/Armature/Skeleton/RightHandAttachment"]
|
[node name="RightHandAP" type="Spatial" parent="armature/Armature/Skeleton/RightHandAttachment"]
|
||||||
@ -234,7 +234,7 @@ transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0
|
|||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="NeckAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="4"]
|
[node name="NeckAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="4"]
|
||||||
transform = Transform( 0.999969, -0.000741187, 0.00780003, 0.0078302, 0.0731273, -0.997236, 0.000168743, 0.997322, 0.0731345, 0.00109308, 1.31594, 7.40913e-05 )
|
transform = Transform( 0.999966, -0.00104017, 0.00817554, 0.00822331, 0.073102, -0.997213, 0.000439647, 0.997323, 0.0731128, 0.00129018, 1.31429, 9.11438e-05 )
|
||||||
bone_name = "neck"
|
bone_name = "neck"
|
||||||
|
|
||||||
[node name="TorsoAP" type="Spatial" parent="armature/Armature/Skeleton/NeckAttachment"]
|
[node name="TorsoAP" type="Spatial" parent="armature/Armature/Skeleton/NeckAttachment"]
|
||||||
@ -242,7 +242,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.04, -0.09 )
|
|||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="RightHipAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="5"]
|
[node name="RightHipAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="5"]
|
||||||
transform = Transform( 0.999694, 1.49325e-08, -0.0247482, -0.0247482, 4.7167e-07, -0.999694, -3.25495e-09, 1, 4.71895e-07, 0.0026686, 0.774437, 1.07684e-09 )
|
transform = Transform( 0.999802, 1.49329e-08, -0.0198917, -0.0198917, 4.71706e-07, -0.999802, -5.54689e-09, 1, 4.7191e-07, 0.00459351, 0.772787, 1.86265e-09 )
|
||||||
bone_name = "pelvis"
|
bone_name = "pelvis"
|
||||||
|
|
||||||
[node name="Spatial" type="Spatial" parent="armature/Armature/Skeleton/RightHipAttachment"]
|
[node name="Spatial" type="Spatial" parent="armature/Armature/Skeleton/RightHipAttachment"]
|
||||||
@ -255,7 +255,7 @@ material/0 = null
|
|||||||
material/1 = null
|
material/1 = null
|
||||||
|
|
||||||
[node name="BoneAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="6"]
|
[node name="BoneAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="6"]
|
||||||
transform = Transform( 0.999967, -4.25729e-05, 0.00810519, 0.00810198, -0.00106443, -0.999911, 5.11901e-05, 1, -0.00106458, 0.00261359, 1.12836, -0.000125621 )
|
transform = Transform( 0.999964, -0.000312868, 0.00850185, 0.00849509, -0.00108792, -0.999886, 0.0003221, 0.999999, -0.00108623, 0.00288511, 1.12671, -0.000112632 )
|
||||||
bone_name = "spine_2"
|
bone_name = "spine_2"
|
||||||
|
|
||||||
[node name="Spatial" type="Spatial" parent="armature/Armature/Skeleton/BoneAttachment"]
|
[node name="Spatial" type="Spatial" parent="armature/Armature/Skeleton/BoneAttachment"]
|
||||||
|
@ -8,7 +8,18 @@ uniform sampler2D texture_albedo : hint_albedo;
|
|||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
vec2 base_uv = UV;
|
vec2 base_uv = UV;
|
||||||
vec4 albedo_tex = texture(texture_albedo,base_uv);
|
vec2 base_uv2 = UV2;
|
||||||
|
|
||||||
|
vec4 albedo_tex = texture(texture_albedo, base_uv);
|
||||||
|
vec4 albedo_tex2 = texture(texture_albedo, base_uv2);
|
||||||
|
|
||||||
|
float ratio = COLOR.a;
|
||||||
|
|
||||||
|
albedo_tex *= ratio;
|
||||||
|
albedo_tex2 *= 1.0 - ratio;
|
||||||
|
|
||||||
|
albedo_tex += albedo_tex2;
|
||||||
|
|
||||||
albedo_tex *= COLOR;
|
albedo_tex *= COLOR;
|
||||||
ALBEDO = albedo.rgb * albedo_tex.rgb;
|
ALBEDO = albedo.rgb * albedo_tex.rgb;
|
||||||
}
|
}
|
||||||
|
17
game/data/shaders/4_standard_character_shader.tres
Normal file
17
game/data/shaders/4_standard_character_shader.tres
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[gd_resource type="Shader" format=2]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
code = "shader_type spatial;
|
||||||
|
render_mode blend_mix,depth_draw_opaque,cull_back,specular_disabled,vertex_lighting;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
"
|
@ -56,7 +56,8 @@ adjustment_enabled = true
|
|||||||
[node name="World" type="VoxelWorld" groups=[
|
[node name="World" type="VoxelWorld" groups=[
|
||||||
"save",
|
"save",
|
||||||
]]
|
]]
|
||||||
max_concurrent_generations = 4
|
use_threads = false
|
||||||
|
max_concurrent_generations = 1
|
||||||
library = ExtResource( 2 )
|
library = ExtResource( 2 )
|
||||||
level_generator = SubResource( 1 )
|
level_generator = SubResource( 1 )
|
||||||
chunk_spawn_range = 3
|
chunk_spawn_range = 3
|
||||||
|
@ -207,13 +207,15 @@ func _build_phase(phase):
|
|||||||
generate_random_ao()
|
generate_random_ao()
|
||||||
bake_lights()
|
bake_lights()
|
||||||
set_physics_process_internal(true)
|
set_physics_process_internal(true)
|
||||||
|
return false
|
||||||
elif phase == VoxelChunk.BUILD_PHASE_PROP_MESH:
|
elif phase == VoxelChunk.BUILD_PHASE_PROP_MESH:
|
||||||
set_physics_process_internal(true)
|
set_physics_process_internal(true)
|
||||||
|
return false
|
||||||
elif phase == VoxelChunk.BUILD_PHASE_FINALIZE:
|
elif phase == VoxelChunk.BUILD_PHASE_FINALIZE:
|
||||||
._build_phase(phase)
|
|
||||||
notification(NOTIFICATION_TRANSFORM_CHANGED)
|
notification(NOTIFICATION_TRANSFORM_CHANGED)
|
||||||
|
return ._build_phase(phase)
|
||||||
else:
|
else:
|
||||||
._build_phase(phase)
|
return ._build_phase(phase)
|
||||||
|
|
||||||
func _prop_added(prop):
|
func _prop_added(prop):
|
||||||
pass
|
pass
|
||||||
|
@ -53,6 +53,49 @@ var lod_data : Array = [
|
|||||||
|
|
||||||
const TEXTURE_SCALE = 4
|
const TEXTURE_SCALE = 4
|
||||||
|
|
||||||
|
func get_voxel_type_array(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> Array:
|
||||||
|
var arr : Array = [
|
||||||
|
buffer.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
|
||||||
|
buffer.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
|
||||||
|
buffer.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
|
||||||
|
buffer.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
|
||||||
|
buffer.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
|
||||||
|
buffer.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
|
||||||
|
buffer.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
|
||||||
|
buffer.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
|
]
|
||||||
|
|
||||||
|
return arr
|
||||||
|
|
||||||
|
func get_case_code_from_arr(data : Array) -> int:
|
||||||
|
var case_code : int = 0
|
||||||
|
|
||||||
|
if (data[0] != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_000
|
||||||
|
|
||||||
|
if (data[1] != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_010
|
||||||
|
|
||||||
|
if (data[2] != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_001
|
||||||
|
|
||||||
|
if (data[3] != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_011
|
||||||
|
|
||||||
|
if (data[4] != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_100
|
||||||
|
|
||||||
|
if (data[5] != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_110
|
||||||
|
|
||||||
|
if (data[6] != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_101
|
||||||
|
|
||||||
|
if (data[7] != 0):
|
||||||
|
case_code = case_code | VOXEL_ENTRY_MASK_111
|
||||||
|
|
||||||
|
return case_code
|
||||||
|
|
||||||
func get_case_code(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
|
func get_case_code(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
|
||||||
var case_code : int = 0
|
var case_code : int = 0
|
||||||
|
|
||||||
@ -148,7 +191,8 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
for z in range(0, z_size, lod_size):
|
for z in range(0, z_size, lod_size):
|
||||||
for x in range(0, x_size, lod_size):
|
for x in range(0, x_size, lod_size):
|
||||||
|
|
||||||
var case_code : int = get_case_code(buffer, x, y, z, lod_size)
|
var type_arr : Array = get_voxel_type_array(buffer, x, y, z, lod_size)
|
||||||
|
var case_code : int = get_case_code_from_arr(type_arr)
|
||||||
|
|
||||||
if case_code == 0 or case_code == 255:
|
if case_code == 0 or case_code == 255:
|
||||||
continue
|
continue
|
||||||
@ -166,9 +210,62 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
|
|
||||||
var temp_verts : Array = Array()
|
var temp_verts : Array = Array()
|
||||||
|
|
||||||
var type_id : int = get_voxel_type(buffer, x, y, z, lod_size)
|
var carr : Dictionary
|
||||||
|
|
||||||
var surface : VoxelSurface = library.get_voxel_surface(type_id)
|
for t in type_arr:
|
||||||
|
if carr.has(t):
|
||||||
|
carr[t] += 1
|
||||||
|
else:
|
||||||
|
carr[t] = 1
|
||||||
|
|
||||||
|
var type_id1 : int = -1
|
||||||
|
var type_id1c : int = -1
|
||||||
|
var type_id2 : int = -1
|
||||||
|
var type_id2c : int = -1
|
||||||
|
|
||||||
|
for k in carr.keys():
|
||||||
|
if k == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var c : int = carr[k]
|
||||||
|
|
||||||
|
if type_id1c == -1:
|
||||||
|
type_id1 = k
|
||||||
|
type_id1c = c
|
||||||
|
continue
|
||||||
|
|
||||||
|
if c > type_id1c:
|
||||||
|
type_id1 = k
|
||||||
|
type_id1c = c
|
||||||
|
|
||||||
|
for k in carr.keys():
|
||||||
|
if k == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var c : int = carr[k]
|
||||||
|
|
||||||
|
if type_id2c == -1:
|
||||||
|
type_id2 = k
|
||||||
|
type_id2c = c
|
||||||
|
continue
|
||||||
|
|
||||||
|
if c > type_id2c and k != type_id1:
|
||||||
|
type_id2 = k
|
||||||
|
type_id2c = c
|
||||||
|
|
||||||
|
var surface_ratio : float = 1
|
||||||
|
|
||||||
|
if type_id1 != type_id2:
|
||||||
|
surface_ratio = float(type_id1c) / float(type_id2c) / 8.0
|
||||||
|
|
||||||
|
var surface1 : VoxelSurface = library.get_voxel_surface(type_id1)
|
||||||
|
var surface2 : VoxelSurface = library.get_voxel_surface(type_id2)
|
||||||
|
|
||||||
|
if type_id1 == 0:
|
||||||
|
print(type_id1)
|
||||||
|
|
||||||
|
if type_id2 == 0:
|
||||||
|
print("asd" + str(type_id2))
|
||||||
|
|
||||||
for i in range(vertex_count):
|
for i in range(vertex_count):
|
||||||
var fv : int = get_regular_vertex_data_first_vertex(case_code, i)
|
var fv : int = get_regular_vertex_data_first_vertex(case_code, i)
|
||||||
@ -177,15 +274,14 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
|
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
|
||||||
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
|
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
|
||||||
|
|
||||||
var type0 : int = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
var type : int = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
# var type1 : int = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
|
||||||
|
|
||||||
var fill : int = 0
|
var fill : int = 0
|
||||||
|
|
||||||
var vert_pos : Vector3
|
var vert_pos : Vector3
|
||||||
var vert_dir : Vector3
|
var vert_dir : Vector3
|
||||||
|
|
||||||
if type0 == 0:
|
if type == 0:
|
||||||
fill = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
fill = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
vert_pos = get_regular_vertex_second_position(case_code, i)
|
vert_pos = get_regular_vertex_second_position(case_code, i)
|
||||||
@ -202,11 +298,6 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
|
|
||||||
temp_verts.append(vert_pos)
|
temp_verts.append(vert_pos)
|
||||||
|
|
||||||
# if regular_uv_entries.size() > uvs[i]:
|
|
||||||
# add_uv(Vector2(regular_uv_entries[uvs[i]][0], regular_uv_entries[uvs[i]][1]));
|
|
||||||
|
|
||||||
# add_uv(Vector2(0, 0))
|
|
||||||
|
|
||||||
var temp_normals : Array = Array()
|
var temp_normals : Array = Array()
|
||||||
|
|
||||||
#warning-ignore:unused_variable
|
#warning-ignore:unused_variable
|
||||||
@ -252,10 +343,6 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
var by : float = abs(normal.y)
|
var by : float = abs(normal.y)
|
||||||
var bz : float = abs(normal.z)
|
var bz : float = abs(normal.z)
|
||||||
|
|
||||||
# if case_code == 7 and cvi == 0:
|
|
||||||
# print(str(bx) + " " + str(by) + " " + str(bz))
|
|
||||||
# add_uv(surface.transform_uv(VoxelSurface.VOXEL_SIDE_SIDE, Vector2(s.z, t.z)))
|
|
||||||
|
|
||||||
if (bx + 0.0001 > by and bx + 0.0001 > bz):
|
if (bx + 0.0001 > by and bx + 0.0001 > bz):
|
||||||
var uv : Vector2 = Vector2(s.x, t.x)
|
var uv : Vector2 = Vector2(s.x, t.x)
|
||||||
var umargin : Rect2 = uv_margin
|
var umargin : Rect2 = uv_margin
|
||||||
@ -265,7 +352,8 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
uv.x += umargin.position.x
|
uv.x += umargin.position.x
|
||||||
uv.y += umargin.position.y
|
uv.y += umargin.position.y
|
||||||
|
|
||||||
add_uv(surface.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
add_uv(surface1.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
||||||
|
add_uv2(surface2.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
||||||
elif (bz + 0.0001 > bx and bz + 0.0001 > by):
|
elif (bz + 0.0001 > bx and bz + 0.0001 > by):
|
||||||
var uv : Vector2 = Vector2(s.z, t.z)
|
var uv : Vector2 = Vector2(s.z, t.z)
|
||||||
var umargin : Rect2 = uv_margin
|
var umargin : Rect2 = uv_margin
|
||||||
@ -275,7 +363,8 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
uv.x += umargin.position.x
|
uv.x += umargin.position.x
|
||||||
uv.y += umargin.position.y
|
uv.y += umargin.position.y
|
||||||
|
|
||||||
add_uv(surface.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
add_uv(surface1.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
||||||
|
add_uv2(surface2.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
||||||
else:
|
else:
|
||||||
var uv : Vector2 = Vector2(s.y, t.y)
|
var uv : Vector2 = Vector2(s.y, t.y)
|
||||||
var umargin : Rect2 = uv_margin
|
var umargin : Rect2 = uv_margin
|
||||||
@ -285,10 +374,10 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
uv.x += umargin.position.x
|
uv.x += umargin.position.x
|
||||||
uv.y += umargin.position.y
|
uv.y += umargin.position.y
|
||||||
|
|
||||||
add_uv(surface.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_TOP, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
add_uv(surface1.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_TOP, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
||||||
|
add_uv2(surface2.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_TOP, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
|
||||||
|
|
||||||
for i in range(len(temp_verts)):
|
for i in range(len(temp_verts)):
|
||||||
|
|
||||||
var vert_pos : Vector3 = temp_verts[i] as Vector3
|
var vert_pos : Vector3 = temp_verts[i] as Vector3
|
||||||
|
|
||||||
vert_pos *= float(lod_size)
|
vert_pos *= float(lod_size)
|
||||||
@ -300,52 +389,12 @@ func add_buffer_normal(buffer : VoxelChunk) -> void:
|
|||||||
var vpy : int = int(vert_pos.y)
|
var vpy : int = int(vert_pos.y)
|
||||||
var vpz : int = int(vert_pos.z)
|
var vpz : int = int(vert_pos.z)
|
||||||
|
|
||||||
# var light : Color = Color(buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0)
|
add_color(Color(1, 1, 1, surface_ratio))
|
||||||
# var ao : float = (buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_AO) / 255.0) * ao_strength
|
|
||||||
# var rao : float = (buffer.get_voxel(vpx, vpy, vpz, VoxelChunk.DEFAULT_CHANNEL_RANDOM_AO) / 255.0)
|
|
||||||
# ao += rao
|
|
||||||
#
|
|
||||||
# light.r += base_light_value
|
|
||||||
# light.g += base_light_value
|
|
||||||
# light.b += base_light_value
|
|
||||||
#
|
|
||||||
# light.r -= ao
|
|
||||||
# light.g -= ao
|
|
||||||
# light.b -= ao
|
|
||||||
#
|
|
||||||
# light.r = clamp(light.r, 0, 1.0)
|
|
||||||
# light.g = clamp(light.g, 0, 1.0)
|
|
||||||
# light.b = clamp(light.b, 0, 1.0)
|
|
||||||
|
|
||||||
# if regular_cell_class == 11:
|
|
||||||
# print("asd")
|
|
||||||
# if case_code == 112 + 2:
|
|
||||||
## print(regular_cell_class)
|
|
||||||
## print("asd")
|
|
||||||
# light.r = 1
|
|
||||||
# light.g = 1
|
|
||||||
# light.b = 1
|
|
||||||
|
|
||||||
|
|
||||||
#add_color(light)
|
|
||||||
vert_pos *= float(voxel_scale)
|
vert_pos *= float(voxel_scale)
|
||||||
|
|
||||||
add_normal(normal)
|
add_normal(normal)
|
||||||
add_vertex(vert_pos)
|
add_vertex(vert_pos)
|
||||||
|
|
||||||
|
|
||||||
# if case_code == 7:
|
|
||||||
#
|
|
||||||
# #reset
|
|
||||||
# set_regular_vertex_data(case_code, 2, 0x3304)
|
|
||||||
#
|
|
||||||
# set_regular_vertex_data(case_code, 3, 0x2315)
|
|
||||||
# set_regular_vertex_data(case_code, 4, 0x4113)
|
|
||||||
# set_regular_vertex_data(case_code, 5, 0x1326)
|
|
||||||
#
|
|
||||||
# set_regular_vertex_data(case_code, 6, 0x3304)
|
|
||||||
# set_regular_vertex_data(case_code, 7, 0x2315)
|
|
||||||
# set_regular_vertex_data(case_code, 8, 0x2315)
|
|
||||||
|
|
||||||
func add_buffer_lod(buffer : VoxelChunk) -> void:
|
func add_buffer_lod(buffer : VoxelChunk) -> void:
|
||||||
if lod_data[CHUNK_INDEX_UP] < lod_size:
|
if lod_data[CHUNK_INDEX_UP] < lod_size:
|
||||||
@ -399,15 +448,14 @@ func generate_main_lod_mesh(buffer : VoxelChunk) -> void:
|
|||||||
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
|
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
|
||||||
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
|
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
|
||||||
|
|
||||||
var type0 : int = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
var type : int = buffer.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
||||||
# var type1 : int = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
|
|
||||||
|
|
||||||
var fill : int = 0
|
var fill : int = 0
|
||||||
|
|
||||||
var vert_pos : Vector3
|
var vert_pos : Vector3
|
||||||
var vert_dir : Vector3
|
var vert_dir : Vector3
|
||||||
|
|
||||||
if type0 == 0:
|
if type == 0:
|
||||||
fill = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
fill = buffer.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
|
||||||
|
|
||||||
vert_pos = get_regular_vertex_second_position(case_code, i)
|
vert_pos = get_regular_vertex_second_position(case_code, i)
|
||||||
@ -424,11 +472,6 @@ func generate_main_lod_mesh(buffer : VoxelChunk) -> void:
|
|||||||
|
|
||||||
temp_verts.append(vert_pos)
|
temp_verts.append(vert_pos)
|
||||||
|
|
||||||
# if regular_uv_entries.size() > uvs[i]:
|
|
||||||
# add_uv(Vector2(regular_uv_entries[uvs[i]][0], regular_uv_entries[uvs[i]][1]));
|
|
||||||
|
|
||||||
# add_uv(Vector2(0, 0))
|
|
||||||
|
|
||||||
var temp_normals : Array = Array()
|
var temp_normals : Array = Array()
|
||||||
|
|
||||||
#warning-ignore:unused_variable
|
#warning-ignore:unused_variable
|
||||||
|
@ -162,7 +162,6 @@ func add_light(x : int, y : int, z : int, size : int, color : Color) -> void:
|
|||||||
|
|
||||||
chunk.add_voxel_light(light)
|
chunk.add_voxel_light(light)
|
||||||
|
|
||||||
|
|
||||||
func setup_client_seed(pseed : int) -> void:
|
func setup_client_seed(pseed : int) -> void:
|
||||||
# _player_file_name = ""
|
# _player_file_name = ""
|
||||||
# _player = null
|
# _player = null
|
||||||
|
Loading…
Reference in New Issue
Block a user