EDIT modifiction de la rotation du personnage pour qu'elle prenne en compte les collisions et ajout d'animations basiques pour le personnage.

This commit is contained in:
osquallo 2020-03-26 10:39:29 +01:00
parent 60f5c2b9e6
commit a80cdba5eb
42 changed files with 846 additions and 100 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 KiB

View file

@ -0,0 +1,183 @@
/*
Realistic Water Shader for GODOT 3.1.1
Copyright (c) 2019 UnionBytes, Achim Menzel (alias AiYori)
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
-- UnionBytes <https://www.unionbytes.de/>
-- YouTube: <https://www.youtube.com/user/UnionBytes>
*/
// For this shader min. GODOT 3.1.1 is required, because 3.1 has a depth buffer bug!
shader_type spatial;
render_mode cull_back,diffuse_burley,specular_schlick_ggx, blend_mix;
// Wave settings:
uniform float wave_speed = 0.5; // Speed scale for the waves
uniform vec4 wave_a = vec4(1.0, 1.0, 0.35, 3.0); // xy = Direction, z = Steepness, w = Length
uniform vec4 wave_b = vec4(1.0, 0.6, 0.30, 1.55); // xy = Direction, z = Steepness, w = Length
uniform vec4 wave_c = vec4(1.0, 1.3, 0.25, 0.9); // xy = Direction, z = Steepness, w = Length
// Surface settings:
uniform vec2 sampler_scale = vec2(0.25, 0.25); // Scale for the sampler
uniform vec2 sampler_direction= vec2(0.05, 0.04); // Direction and speed for the sampler offset
uniform sampler2D uv_sampler : hint_aniso; // UV motion sampler for shifting the normalmap
uniform vec2 uv_sampler_scale = vec2(0.25, 0.25); // UV sampler scale
uniform float uv_sampler_strength = 0.04; // UV shifting strength
uniform sampler2D normalmap_a_sampler : hint_normal; // Normalmap sampler A
uniform sampler2D normalmap_b_sampler : hint_normal; // Normalmap sampler B
uniform sampler2D foam_sampler : hint_black; // Foam sampler
uniform float foam_level = 0.5; // Foam level -> distance from the object (0.0 - 0.5)
// Volume settings:
uniform float refraction = 0.075; // Refraction of the water
uniform vec4 color_deep : hint_color; // Color for deep places in the water, medium to dark blue
uniform vec4 color_shallow : hint_color; // Color for lower places in the water, bright blue - green
uniform float beers_law = 2.0; // Beers law value, regulates the blending size to the deep water level
uniform float depth_offset = -0.75; // Offset for the blending
// Projector for the water caustics:
uniform mat4 projector; // Projector matrix, mostly the matric of the sun / directlight
uniform sampler2DArray caustic_sampler : hint_black; // Caustic sampler, (Texture array with 16 Textures for the animation)
// Vertex -> Fragment:
varying float vertex_height; // Height of the water surface
varying vec3 vertex_normal; // Vertex normal -> Needed for refraction calculation
varying vec3 vertex_binormal; // Vertex binormal -> Needed for refraction calculation
varying vec3 vertex_tangent; // Vertex tangent -> Needed for refraction calculation
varying mat4 inv_mvp; // Inverse ModelViewProjection matrix -> Needed for caustic projection
// Wave function:
vec4 wave(vec4 parameter, vec2 position, float time, inout vec3 tangent, inout vec3 binormal)
{
float wave_steepness = parameter.z;
float wave_length = parameter.w;
float k = 2.0 * 3.14159265359 / wave_length;
float c = sqrt(9.8 / k);
vec2 d = normalize(parameter.xy);
float f = k * (dot(d, position) - c * time);
float a = wave_steepness / k;
tangent += normalize(vec3(1.0-d.x * d.x * (wave_steepness * sin(f)), d.x * (wave_steepness * cos(f)), -d.x * d.y * (wave_steepness * sin(f))));
binormal += normalize(vec3(-d.x * d.y * (wave_steepness * sin(f)), d.y * (wave_steepness * cos(f)), 1.0-d.y * d.y * (wave_steepness * sin(f))));
return vec4(d.x * (a * cos(f)), a * sin(f) * 0.25, d.y * (a * cos(f)), 0.0);
}
// Vertex shader:
void vertex()
{
float time = TIME * wave_speed;
vec4 vertex = vec4(VERTEX, 1.0);
vec3 vertex_position = (WORLD_MATRIX * vertex).xyz;
vertex_tangent = vec3(0.0, 0.0, 0.0);
vertex_binormal = vec3(0.0, 0.0, 0.0);
vertex += wave(wave_a, vertex_position.xz, time, vertex_tangent, vertex_binormal);
vertex += wave(wave_b, vertex_position.xz, time, vertex_tangent, vertex_binormal);
vertex += wave(wave_c, vertex_position.xz, time, vertex_tangent, vertex_binormal);
vertex_position = vertex.xyz;
vertex_height = (PROJECTION_MATRIX * MODELVIEW_MATRIX * vertex).z;
TANGENT = vertex_tangent;
BINORMAL = vertex_binormal;
vertex_normal = normalize(cross(vertex_binormal, vertex_tangent));
NORMAL = vertex_normal;
UV = vertex.xz * sampler_scale;
VERTEX = vertex.xyz;
inv_mvp = inverse(PROJECTION_MATRIX * MODELVIEW_MATRIX);
}
// Fragment shader:
void fragment()
{
// Calculation of the UV with the UV motion sampler
vec2 uv_offset = sampler_direction * TIME;
vec2 uv_sampler_uv = UV * uv_sampler_scale + uv_offset;
vec2 uv_sampler_uv_offset = uv_sampler_strength * texture(uv_sampler, uv_sampler_uv).rg * 2.0 - 1.0;
vec2 uv = UV + uv_sampler_uv_offset;
// Normalmap:
vec3 normalmap = texture(normalmap_a_sampler, uv - uv_offset*2.0).rgb * 0.75; // 75 % sampler A
normalmap += texture(normalmap_b_sampler, uv + uv_offset).rgb * 0.25; // 25 % sampler B
// Refraction UV:
vec3 ref_normalmap = normalmap * 2.0 - 1.0;
ref_normalmap = normalize(vertex_tangent*ref_normalmap.x + vertex_binormal*ref_normalmap.y + vertex_normal*ref_normalmap.z);
vec2 ref_uv = SCREEN_UV + (ref_normalmap.xy * refraction) / vertex_height;
// Ground depth:
float depth_raw = texture(DEPTH_TEXTURE, ref_uv).r * 2.0 - 1.0;
float depth = PROJECTION_MATRIX[3][2] / (depth_raw + PROJECTION_MATRIX[2][2]);
float depth_blend = exp((depth+VERTEX.z + depth_offset) * -beers_law);
depth_blend = clamp(1.0-depth_blend, 0.0, 1.0);
float depth_blend_pow = clamp(pow(depth_blend, 2.5), 0.0, 1.0);
// Ground color:
vec3 screen_color = textureLod(SCREEN_TEXTURE, ref_uv, depth_blend_pow * 2.5).rgb;
vec3 dye_color = mix(color_shallow.rgb, color_deep.rgb, depth_blend_pow);
vec3 color = mix(screen_color*dye_color, dye_color*0.25, depth_blend_pow*0.5);
// Caustic screen projection
vec4 caustic_screenPos = vec4(ref_uv*2.0-1.0, depth_raw, 1.0);
vec4 caustic_localPos = inv_mvp * caustic_screenPos;
caustic_localPos = vec4(caustic_localPos.xyz/caustic_localPos.w, caustic_localPos.w);
vec2 caustic_Uv = caustic_localPos.xz / vec2(1024.0) + 0.5;
vec4 caustic_color = texture(caustic_sampler, vec3(caustic_Uv*300.0, mod(TIME*14.0, 16.0)));
color *= 1.0 + pow(caustic_color.r, 1.50) * (1.0-depth_blend) * 6.0;
// Foam:
if(depth + VERTEX.z < foam_level && depth > vertex_height-0.1)
{
float foam_noise = clamp(pow(texture(foam_sampler, (uv*4.0) - uv_offset).r, 10.0)*40.0, 0.0, 0.2);
float foam_mix = clamp(pow((1.0-(depth + VERTEX.z) + foam_noise), 8.0) * foam_noise * 0.4, 0.0, 1.0);
color = mix(color, vec3(1.0), foam_mix);
}
// Set all values:
ALBEDO = color;
METALLIC = 0.1;
ROUGHNESS = 0.2;
SPECULAR = 0.2 + depth_blend_pow * 0.4;
NORMALMAP = normalmap;
NORMALMAP_DEPTH = 1.25;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View file

@ -1,5 +1,7 @@
extends Spatial extends Spatial
var Creature = preload( "res://ressources/scripts/creatures.gd" )
export(bool) var gravity_enabled = true export(bool) var gravity_enabled = true
var creature = null var creature = null
@ -15,10 +17,11 @@ func move( m_movment ):
if $model: if $model:
for child in $model.get_children(): for child in $model.get_children():
if child is KinematicBody: if child is KinematicBody:
child.translate( m_movment ) var spatial = Spatial.new()
# child.move_and_slide( m_movment, Vector3( 0.0, 1.0, 0.0 ) ) spatial.rotate( Vector3( 0.0, 1.0, 0.0 ), child.rotation.y )
spatial.translate( m_movment )
child.move_and_slide( spatial.translation*10.0, Vector3( 0.0, 1.0, 0.0 ), true )
spatial.queue_free()
func turn( m_rotation ): func turn( m_rotation ):
if $model: if $model:

View file

@ -0,0 +1,152 @@
extends Resource
#warning-ignore-all:unused_class_variable
const DIR_N = Vector3(0, 0, -1)
const DIR_NE = Vector3(1, 0, -1)
const DIR_E = Vector3(1, 0, 0)
const DIR_SE = Vector3(1, 0, 1)
const DIR_S = Vector3(0, 0, 1)
const DIR_SW = Vector3(-1, 0, 1)
const DIR_W = Vector3(-1, 0, 0)
const DIR_NW = Vector3(-1, 0, -1)
const DIR_ALL = [DIR_N, DIR_NE, DIR_E, DIR_SE, DIR_S, DIR_SW, DIR_W, DIR_NW]
var size = Vector3( 1, 1, 1 )
var coords = Vector3( 0, 0, 0 )
func _init( p_coords ):
if typeof(p_coords) == typeof(self):
p_coords = p_coords.coords
self.set_coords( p_coords )
func new_cell( p_coords ):
# Returns a new HexCell instance
return get_script().new( p_coords )
func set_coords( p_coords ):
self.coords = Vector3( int(p_coords.x), int(p_coords.y), int(p_coords.z) )
# self.coords = Vector3( floor(p_coords.x), floor(p_coords.y), floor(p_coords.z) )
func distance_to( p_coords ):
var a = p_coords.x - self.coords.x
var b = p_coords.y - self.coords.y
var c = p_coords.z - self.coords.z
var h = sqrt( a*a + b*b + c*c )
return int( h )
func cell_distance_to( p_coords ):
return max( abs(p_coords.x-self.coords.x), abs(p_coords.z-self.coords.z) )
func get_arc_area( p_distance, p_direction ):
var cells = Array()
if p_direction in [ DIR_N, DIR_S, DIR_E, DIR_W ]:
var old_x = 0
for x in range(1, p_distance):
var nb_z = old_x + x
for z in range( -ceil(nb_z/2)-1, floor(nb_z/2) ):
var cell = null
if p_direction == DIR_E:
cell = new_cell( self.coords+Vector3( x, 0, z+1 ) )
elif p_direction == DIR_W:
cell = new_cell( self.coords+Vector3( -x, 0, z+1 ) )
elif p_direction == DIR_N:
cell = new_cell( self.coords+Vector3( z+1, 0, -x ) )
elif p_direction == DIR_S:
cell = new_cell( self.coords+Vector3( z+1, 0, x ) )
if cell:
cells.push_back( cell )
old_x = x
else:
var old_x = 0
for x in range(1, p_distance+1):
for z in range( 0, p_distance ):
var cell = null
if p_direction == DIR_SW:
cell = new_cell( self.coords+Vector3( -x, 0, z+1 ) )
elif p_direction == DIR_NW:
cell = new_cell( self.coords+Vector3( -x, 0, -(z+1) ) )
elif p_direction == DIR_NE:
cell = new_cell( self.coords+Vector3( z+1, 0, -x ) )
elif p_direction == DIR_SE:
cell = new_cell( self.coords+Vector3( z+1, 0, x ) )
if cell:
cells.push_back( cell )
return cells
func get_ring( distance ):
var cells = Array()
for x in range( -distance+self.coords.x, distance+self.coords.x+1 ):
for z in range( -distance+self.coords.z, distance+self.coords.z+1 ):
var cell = new_cell( Vector3( x, 0, z ) )
if not cell.coords == self.coords and self.cell_distance_to( cell.coords ) == distance:
cells.push_back( cell )
return cells
func get_area( distance_max, distance_min = 0 ):
var cells = Array()
for x in range( -distance_max+self.coords.x, distance_max+self.coords.x+1 ):
for z in range( -distance_max+self.coords.z, distance_max+self.coords.z+1 ):
var cell = new_cell( Vector3( x, 0, z ) )
if not cell.coords == self.coords:
if self.cell_distance_to( cell.coords ) >= distance_min:
cells.push_back( cell )
return cells
func get_adjacent( direction ):
return self.new_cell(self.coords + direction)
func get_cells_adjacent():
var cells = Array()
for coord in DIR_ALL:
cells.append(new_cell(self.coords + coord))
return cells
static func get_dir_from_angle( p_angle ):
p_angle = int(p_angle) % 360
if p_angle < 0:
p_angle = 360 + p_angle
if (0 <= p_angle and p_angle < 22.5) or (337.5 <= p_angle and p_angle <= 360):
return DIR_N
elif 22.5 <= p_angle and p_angle < 67.5:
return DIR_NW
elif 67.5 <= p_angle and p_angle < 112.5:
return DIR_W
elif 112.5 <= p_angle and p_angle < 157.5:
return DIR_SW
elif 157.5 <= p_angle and p_angle < 202.5:
return DIR_S
elif 202.5 <= p_angle and p_angle < 247.5:
return DIR_SE
elif 247.5 <= p_angle and p_angle < 337.5:
return DIR_E
elif 292.5 <= p_angle and p_angle < 337.5:
return DIR_NE
return null
static func dir_to_str( p_dir ):
if p_dir == DIR_N:
return "N"
elif p_dir == DIR_NE:
return "NE"
elif p_dir == DIR_E:
return "E"
elif p_dir == DIR_SE:
return "SE"
elif p_dir == DIR_S:
return "S"
elif p_dir == DIR_SW:
return "SW"
elif p_dir == DIR_W:
return "W"
elif p_dir == DIR_NW:
return "NW"
else:
return "None"

View file

@ -0,0 +1,184 @@
extends Reference
var SquareCell = preload("./square_cell.gd")
var origin = Vector3( 0.0, 0.0, 0.0 )
var size = Vector3( 0, 0, 0 )
var cell_size = Vector3( 1.0, 1.0, 1.0 )
var path_cost_default = 10.0
var cells_cost = {}
var obstacles = []
var barrieres = {}
func _init( p_size = Vector2( 100, 100 ), p_origin = Vector3( 0.0, 0.0, 0.0 ) ):
self.origin = p_origin
self.size = p_size
func set_size( p_size ):
self.size = p_size
func get_cell_coords( cell ):
var cell_coords = Vector3()
if typeof(cell) == TYPE_VECTOR3:
cell_coords = cell
else:
cell_coords = cell.coords
return cell_coords
func get_cell_at( p_position ):
var position_local = p_position - self.origin
var coords = (position_local / self.cell_size)
var cell = SquareCell.new( coords )
return cell
func get_cell_position( p_cell ):
var position = (p_cell.coords * self.cell_size) + self.origin
return position
func get_cell_direction( p_direction ):
if p_direction is SquareCell.DIR_ALL:
return p_direction
var coords = self.get_cell_at( p_direction ).coords
if coords is SquareCell.DIR_ALL:
return coords
return null
func add_obstacle( cell, cost=0 ):
self.obstacles.push_back( self.get_cell_coords( cell ) )
func remove_obstacle( cell ):
self.obstacles.erase( self.get_cell_coords( cell ) )
func is_obstacle( cell ):
return ( self.get_cell_coords( cell ) in self.obstacles )
func add_barriere( cell, dir ):
var coords = self.get_cell_coords( cell )
if not coords in self.barrieres:
self.barrieres[ coords ] = []
if not dir in self.barrieres[ coords ]:
self.barrieres[ coords ].push_back( dir )
func remove_barriere( cell, dir ):
var coords = self.get_cell_coords( cell )
if coords in self.barrieres and dir in self.barrieres[ coords ]:
self.barrieres[ coords ].remove( dir )
func update_barrieres( p_cell, p_barrieres ):
var coords = self.get_cell_coords( p_cell )
self.barrieres[ coords ] = p_barrieres
func is_barriere( cell, dir ):
var coords = self.get_cell_coords( cell )
if not coords in self.barrieres:
return false
if not dir in self.barrieres[ coords ]:
return false
return true
func get_move_cost(p_cell, p_direction):
var cell_coords = self.get_cell_coords( p_cell )
var next_cell = SquareCell.new( cell_coords + p_direction )
var cost = abs(p_direction.x) + abs(p_direction.y) + abs(p_direction.z)*self.get_cell_cost( next_cell )
if self.is_obstacle( cell_coords ):
return 0
if cell_coords in self.barrieres and p_direction in self.barrieres[ cell_coords ]:
return 0
if next_cell.coords in self.barrieres and -p_direction in self.barrieres[ next_cell.coords ]:
return 0
return cost
func find_path(start, goal, exceptions=[]):
# Light a starry path from the start to the goal, inclusive
start = start.coords
goal = goal.coords
# Make sure all the exceptions are coords
var exc = []
for exception in exceptions:
if exception is SquareCell:
exc.append(exception.coords)
exceptions = exc
# Now we begin the A* search
var frontier = [self.make_priority_item(start, 0)]
var came_from = {start: null}
var cost_so_far = {start: 0}
while not frontier.empty():
var current = frontier.pop_front().v
if current == goal:
break
for next_cell in SquareCell.new(current).get_cells_adjacent():
var next = next_cell.coords
var next_cost = self.get_move_cost(current, next - current)
if next == goal and (next in exceptions or get_cell_cost(next) == 0):
# Our goal is an obstacle, but we're next to it
# so our work here is done
came_from[next] = current
frontier.clear()
break
if not next_cost or next in exceptions:
# We shall not pass
continue
next_cost += cost_so_far[current]
if not next in cost_so_far or next_cost < cost_so_far[next]:
# New shortest path to that node
cost_so_far[next] = next_cost
var priority = next_cost + next_cell.cell_distance_to(goal)
# Insert into the frontier
var item = make_priority_item(next, priority)
var idx = frontier.bsearch_custom(item, self, "comp_priority_item")
frontier.insert(idx, item)
came_from[next] = current
if not goal in came_from:
# Not found
print( "Path not found." )
return []
# Follow the path back where we came_from
var path = []
if not (self.get_cell_cost(goal) == 0 or goal in exceptions):
# We only include the goal if it's traversable
path.append(SquareCell.new(goal))
var current = goal
while current != start:
current = came_from[current]
path.push_front(SquareCell.new(current))
return path
# Used to make a priority queue out of an array
func make_priority_item(val, priority):
return {"v": val, "p": priority}
func comp_priority_item(a, b):
return a.p < b.p
func get_cell_cost( cell ):
var cell_coords = self.get_cell_coords( cell )
if self.is_obstacle( cell_coords ):
return 0
if cell_coords in self.cells_cost:
return self.cells_cost[ cell_coords ]
return self.path_cost_default

View file

@ -1,77 +1,9 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://assets/creatures/ra/basemesh_humanoid.glb" type="PackedScene" id=1] [ext_resource path="res://assets/creatures/ra/basemesh_humanoid.glb" type="PackedScene" id=1]
[ext_resource path="res://assets/creatures/ra/textures/basemesh_humanoid.png" type="Texture" id=2] [ext_resource path="res://assets/creatures/ra/basemesh_humanoid.material" type="Material" id=2]
[ext_resource path="res://assets/creatures/ra/textures/Wood035_2K_Roughness.jpg" type="Texture" id=3]
[ext_resource path="res://assets/creatures/ra/textures/Wood035_2K_Normal.jpg" type="Texture" id=4]
[ext_resource path="res://assets/creatures/ra/tatoos/tatoo_001.png" type="Texture" id=5]
[sub_resource type="Shader" id=1]
code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
uniform vec4 albedo : hint_color;
uniform sampler2D texture_albedo : hint_albedo;
uniform float specular;
uniform float metallic;
uniform float roughness : hint_range(0,1);
uniform float point_size : hint_range(0,128);
uniform sampler2D texture_roughness : hint_white;
uniform vec4 roughness_texture_channel;
uniform sampler2D texture_normal : hint_normal;
uniform float normal_scale : hint_range(-16,16);
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;
uniform sampler2D tatoo_albedo : hint_black;
void vertex() {
UV=UV*uv1_scale.xy+uv1_offset.xy;
}
void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo,base_uv);
vec4 tatoo_tex = texture(tatoo_albedo,base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb;
METALLIC = metallic;
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
ROUGHNESS = roughness_tex * roughness;
SPECULAR = specular;
NORMALMAP = texture(texture_normal,base_uv).rgb;
NORMALMAP_DEPTH = normal_scale;
if ( tatoo_tex.a > 0.2 )
{
ALBEDO += tatoo_tex.rgb;
}
}
"
[sub_resource type="ShaderMaterial" id=2]
shader = SubResource( 1 )
shader_param/albedo = Color( 1, 1, 1, 1 )
shader_param/specular = 0.0
shader_param/metallic = 0.0
shader_param/roughness = 1.0
shader_param/point_size = 1.0
shader_param/roughness_texture_channel = Plane( 1, 0, 0, 0 )
shader_param/normal_scale = 1.0
shader_param/uv1_scale = Vector3( 1, 1, 1 )
shader_param/uv1_offset = Vector3( 0, 0, 0 )
shader_param/uv2_scale = Vector3( 1, 1, 1 )
shader_param/uv2_offset = Vector3( 0, 0, 0 )
shader_param/texture_albedo = ExtResource( 2 )
shader_param/texture_roughness = ExtResource( 3 )
shader_param/texture_normal = ExtResource( 4 )
shader_param/tatoo_albedo = ExtResource( 5 )
[node name="basemesh_humanoid" instance=ExtResource( 1 )] [node name="basemesh_humanoid" instance=ExtResource( 1 )]
[node name="body" parent="." index="0"] [node name="body" parent="." index="0"]
material/0 = SubResource( 2 ) material/0 = ExtResource( 2 )

View file

@ -0,0 +1,12 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://assets/creatures/ra/basemesh_humanoid_animated.glb" type="PackedScene" id=1]
[ext_resource path="res://assets/creatures/ra/basemesh_humanoid.material" type="Material" id=2]
[node name="basemesh_humanoid_animated" instance=ExtResource( 1 )]
[node name="body" parent="metarig/Skeleton" index="0"]
material/0 = ExtResource( 2 )
[node name="AnimationPlayer" parent="." index="1"]
autoplay = "idle"

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://scenes/creatures/ra/basemesh_humanoid.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/creatures/ra/basemesh_humanoid.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/creatures/ra/basemesh_humanoid_animated.tscn" type="PackedScene" id=2]
[sub_resource type="CapsuleShape" id=1] [sub_resource type="CapsuleShape" id=1]
margin = 0.1 margin = 0.1
@ -15,7 +16,10 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.73134, -1.7404 )
[node name="camera" type="Camera" parent="spring_arm"] [node name="camera" type="Camera" parent="spring_arm"]
transform = Transform( -0.999408, 0.0139118, -0.0314544, 0.00553681, 0.967693, 0.252072, 0.033945, 0.251749, -0.967197, 0, -1.19209e-07, 1.19209e-07 ) transform = Transform( -0.999408, 0.0139118, -0.0314544, 0.00553681, 0.967693, 0.252072, 0.033945, 0.251749, -0.967197, 0, -1.19209e-07, 1.19209e-07 )
[node name="model" parent="." instance=ExtResource( 1 )] [node name="model_static" parent="." instance=ExtResource( 1 )]
visible = false
[node name="model" parent="." instance=ExtResource( 2 )]
[node name="collision" type="CollisionShape" parent="."] [node name="collision" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.808348, 0 ) transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.808348, 0 )

View file

@ -0,0 +1,69 @@
[gd_scene load_steps=18 format=2]
[ext_resource path="res://scenes/decors/terrains/demo/ground_0_0.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/decors/terrains/demo/ground_1_-1.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/decors/terrains/demo/ground_1_1.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/decors/terrains/demo/ground_-1_-1.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/decors/terrains/demo/ground_-1_0.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/decors/terrains/demo/ground_0_1.tscn" type="PackedScene" id=6]
[ext_resource path="res://scenes/decors/terrains/demo/ground_-1_1.tscn" type="PackedScene" id=7]
[ext_resource path="res://scenes/decors/terrains/demo/ground_0_-1.tscn" type="PackedScene" id=8]
[ext_resource path="res://scenes/decors/terrains/demo/ground_1_0.tscn" type="PackedScene" id=9]
[ext_resource path="res://assets/decors/terrains/demo/water/textures/Caustic.png" type="Texture" id=10]
[ext_resource path="res://assets/decors/terrains/demo/water/textures/Water_N_A.png" type="Texture" id=11]
[ext_resource path="res://assets/decors/terrains/demo/water/textures/Water_UV.png" type="Texture" id=12]
[ext_resource path="res://assets/decors/terrains/demo/water/textures/Water_N_B.png" type="Texture" id=13]
[ext_resource path="res://assets/decors/terrains/demo/water/textures/Foam.png" type="Texture" id=14]
[ext_resource path="res://assets/decors/terrains/demo/water/water.shader" type="Shader" id=15]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 15 )
shader_param/wave_speed = 0.12
shader_param/wave_a = Plane( 1, 1, 0.35, 3 )
shader_param/wave_b = Plane( 1, 0.6, 0.3, 1.55 )
shader_param/wave_c = Plane( 1, 1.3, 0.25, 0.9 )
shader_param/sampler_scale = Vector2( 1.2, 1.2 )
shader_param/sampler_direction = Vector2( 0.05, 0.04 )
shader_param/uv_sampler_scale = Vector2( 0.25, 0.25 )
shader_param/uv_sampler_strength = 0.04
shader_param/foam_level = 0.5
shader_param/refraction = 0.075
shader_param/color_deep = Color( 0.466667, 0.666667, 0.901961, 1 )
shader_param/color_shallow = Color( 0.666667, 0.752941, 0.768627, 1 )
shader_param/beers_law = 1.3
shader_param/depth_offset = -0.75
shader_param/projector = null
shader_param/uv_sampler = ExtResource( 12 )
shader_param/normalmap_a_sampler = ExtResource( 11 )
shader_param/normalmap_b_sampler = ExtResource( 13 )
shader_param/foam_sampler = ExtResource( 14 )
shader_param/caustic_sampler = ExtResource( 10 )
[sub_resource type="PlaneMesh" id=2]
material = SubResource( 1 )
size = Vector2( 6, 6 )
[node name="demo" type="Spatial"]
[node name="ground_0_0" parent="." instance=ExtResource( 1 )]
[node name="ground_0_1" parent="." instance=ExtResource( 6 )]
[node name="ground_0_-1" parent="." instance=ExtResource( 8 )]
[node name="ground_1_0" parent="." instance=ExtResource( 9 )]
[node name="ground_1_1" parent="." instance=ExtResource( 3 )]
[node name="ground_1_-1" parent="." instance=ExtResource( 2 )]
[node name="ground_-1_0" parent="." instance=ExtResource( 5 )]
[node name="ground_-1_1" parent="." instance=ExtResource( 7 )]
[node name="ground_-1_-1" parent="." instance=ExtResource( 4 )]
[node name="water" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.074535, 0 )
mesh = SubResource( 2 )
material/0 = null

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,36 @@
extends Spatial
var square_grid = preload( "res://ressources/scripts/square_grid.gd" ).new()
export( Vector2 ) var size = Vector2( 512, 512 )
export( float ) var cell_size = 1.0
export( String ) var heightmap_filename = "dunes_heightmap.png"
var heightmap_image = null
func _ready():
self.heightmap_image = Image.new()
self.heightmap_image.load( "res://assets/decors/terrains/heightmaps/" + self.heightmap_filename )
square_grid.set_size( self.heightmap_image.get_size() )
square_grid.cell_size = self.cell_size
$terrain.mesh.size = self.size
func get_height( p_position ):
var cell = self.square_grid.get_cell_at( p_position )
var ratio = Vector2( self.heightmap_image.get_size().x/ self.size.x, self.heightmap_image.get_size().y/self.size.y )
var offset = ( Vector2(self.heightmap_image.get_size().x/2, self.heightmap_image.get_size().y/2 ) )
# var coords = (Vector2( cell.coords.x, cell.coords.z ) + offset) * ratio
var coords = (Vector2( cell.coords.x, cell.coords.z )* ratio) +offset
var pixel_coords = (Vector2( p_position.x, p_position.z ) + offset)
heightmap_image.lock()
# var pixel = heightmap_image.get_pixel( pixel_coords.x, pixel_coords.y )
var pixel = heightmap_image.get_pixel( coords.x, coords.y )
heightmap_image.unlock()
return pixel.r * 100.0

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=19 format=2] [gd_scene load_steps=19 format=2]
[ext_resource path="res://scenes/player/player.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/player/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/decors/terrains/demo/demo.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/game/game.gd" type="Script" id=3] [ext_resource path="res://scenes/game/game.gd" type="Script" id=3]
[ext_resource path="res://assets/sky/sky.shader" type="Shader" id=5] [ext_resource path="res://assets/sky/sky.shader" type="Shader" id=5]
[ext_resource path="res://scenes/game/sky.gd" type="Script" id=6] [ext_resource path="res://scenes/game/sky.gd" type="Script" id=6]
@ -8,7 +9,6 @@
[ext_resource path="res://assets/interfaces/debug_window/debug_window.tscn" type="PackedScene" id=8] [ext_resource path="res://assets/interfaces/debug_window/debug_window.tscn" type="PackedScene" id=8]
[ext_resource path="res://assets/interfaces/themes/khanat_theme.theme" type="Theme" id=9] [ext_resource path="res://assets/interfaces/themes/khanat_theme.theme" type="Theme" id=9]
[ext_resource path="res://scenes/interfaces/game_menu/game_ui.tscn" type="PackedScene" id=11] [ext_resource path="res://scenes/interfaces/game_menu/game_ui.tscn" type="PackedScene" id=11]
[ext_resource path="res://scenes/decors/terrains/test/test_level.tscn" type="PackedScene" id=12]
[sub_resource type="OpenSimplexNoise" id=1] [sub_resource type="OpenSimplexNoise" id=1]
period = 8.0 period = 8.0
@ -23,8 +23,8 @@ noise = SubResource( 1 )
[sub_resource type="ShaderMaterial" id=3] [sub_resource type="ShaderMaterial" id=3]
resource_local_to_scene = true resource_local_to_scene = true
shader = ExtResource( 5 ) shader = ExtResource( 5 )
shader_param/iTime = 233.623 shader_param/iTime = 6560.62
shader_param/iFrame = 16024 shader_param/iFrame = 391307
shader_param/COVERAGE = 0.5 shader_param/COVERAGE = 0.5
shader_param/THICKNESS = 25.0 shader_param/THICKNESS = 25.0
shader_param/ABSORPTION = 1.031 shader_param/ABSORPTION = 1.031
@ -89,7 +89,6 @@ texture = SubResource( 4 )
offset = Vector2( 640, 360 ) offset = Vector2( 640, 360 )
script = ExtResource( 6 ) script = ExtResource( 6 )
editor_clouds_playing = true editor_clouds_playing = true
day_time_hours = 12.0
directional_light_node_path = NodePath("../../sun") directional_light_node_path = NodePath("../../sun")
sun_position = Vector3( -1.15706e-06, 100, 8.66537e-06 ) sun_position = Vector3( -1.15706e-06, 100, 8.66537e-06 )
@ -102,12 +101,12 @@ environment = SubResource( 7 )
[node name="level" type="Spatial" parent="."] [node name="level" type="Spatial" parent="."]
[node name="test_level" parent="level" instance=ExtResource( 12 )] [node name="demo" parent="level" instance=ExtResource( 2 )]
transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 )
[node name="creatures" type="Spatial" parent="."] [node name="creatures" type="Spatial" parent="."]
[node name="player" parent="creatures" instance=ExtResource( 1 )] [node name="player" parent="creatures" instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 14.7098, 0 )
[node name="mist_fx" type="MeshInstance" parent="."] [node name="mist_fx" type="MeshInstance" parent="."]
cast_shadow = 0 cast_shadow = 0

View file

@ -1,29 +1,35 @@
extends "res://ressources/scripts/entity.gd" extends "res://ressources/scripts/entity.gd"
func _ready(): func _ready():
$model/ra/spring_arm/camera.make_current() $model/ra/spring_arm/camera.make_current()
func load_creature( filename ): func load_creature( filename ):
var file = File.new()
if file.file_exists( "user://creatures/" + filename ):
file.open( "user://creatures/" + filename, File.READ )
var lines = ""
while not file.eof_reached():
var current_line = file.get_line()
lines += current_line
var json = JSON.parse( lines ).result
$model/ra/model/body.set( "blend_shapes/Boobs", str2var(json[ "female_boobs" ] ) ) self.creature = Creatures.Ra.new()
$model/ra/model/body.set( "blend_shapes/Female_hip", str2var(json[ "female_hip" ] ) ) self.creature.from_file( filename )
$model/ra/model/body.set( "blend_shapes/Male_Pack", str2var(json[ "male_pack" ] ) )
$model/ra/model/body.set( "blend_shapes/Male_Throat", str2var(json[ "male_throat" ] ) ) # # version statique.
$model/ra/model/body.set( "blend_shapes/Pregnant", str2var(json[ "female_pregnant" ] ) ) # $model/ra/model/body.set( "blend_shapes/Boobs", self.creature.female_boobs )
$model/ra/model/body.set( "blend_shapes/Pregnant", str2var(json[ "female_pregnant" ] ) ) # $model/ra/model/body.set( "blend_shapes/Female_hip", self.creature.female_hip )
$model/ra/model/body.get_surface_material( 0 ).set_shader_param( "albedo", str2var( json[ "color" ] ) ) # $model/ra/model/body.set( "blend_shapes/Male_Pack", self.creature.male_pack )
print( str2var( json[ "color" ] ) ) # $model/ra/model/body.set( "blend_shapes/Male_Throat", self.creature.male_throat )
file.close() # $model/ra/model/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
# $model/ra/model/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
# $model/ra/model/body.get_surface_material( 0 ).set_shader_param( "albedo", self.creature.color )
#
# Version animée.
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Boobs", self.creature.female_boobs )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Female_hip", self.creature.female_hip )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Male_Pack", self.creature.male_pack )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Male_Throat", self.creature.male_throat )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
$model/ra/model/metarig/Skeleton/body.get_surface_material( 0 ).set_shader_param( "albedo", self.creature.color )
func rotate_camera_arm( p_axis, p_angle_degree ): func rotate_camera_arm( p_axis, p_angle_degree ):