ADD debut de test sur un shader de terrain.
114
assets/decors/terrains/demo/terrain.shader
Normal file
|
@ -0,0 +1,114 @@
|
|||
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 sampler2D texture_grass_2 : hint_albedo;
|
||||
uniform sampler2D texture_albedo_2 : hint_albedo;
|
||||
uniform sampler2D texture_albedo_hsv : hint_white;
|
||||
uniform sampler2D texture_albedo_mix : hint_black;
|
||||
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 sampler2D texture_ambient_occlusion : hint_white;
|
||||
uniform vec4 ao_texture_channel;
|
||||
uniform float ao_light_affect;
|
||||
uniform vec3 uv1_scale;
|
||||
uniform vec3 uv1_offset;
|
||||
uniform vec3 uv2_scale;
|
||||
uniform vec3 uv2_offset;
|
||||
|
||||
uniform vec3 hsv;
|
||||
uniform float grass_level = 1.0;
|
||||
|
||||
varying vec2 base_uv;
|
||||
varying vec2 rotated_uv;
|
||||
varying vec2 rotated_uv_mask;
|
||||
|
||||
|
||||
|
||||
vec2 rotateUVmatrinx(vec2 uv, vec2 pivot, float rotation)
|
||||
{
|
||||
mat2 rotation_matrix=mat2( vec2(sin(rotation),-cos(rotation)),
|
||||
vec2(cos(rotation),sin(rotation))
|
||||
);
|
||||
uv -= pivot;
|
||||
uv= uv*rotation_matrix;
|
||||
uv += pivot;
|
||||
return uv;
|
||||
}
|
||||
vec2 rotateUV(vec2 uv, vec2 pivot, float rotation) {
|
||||
float sine = sin(rotation);
|
||||
float cosine = cos(rotation);
|
||||
|
||||
uv -= pivot;
|
||||
uv.x = uv.x * cosine - uv.y * sine;
|
||||
uv.y = uv.x * sine + uv.y * cosine;
|
||||
uv += pivot;
|
||||
|
||||
return uv;
|
||||
}
|
||||
|
||||
vec3 rgb2hsv(vec3 c)
|
||||
{
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
vec3 hsv2rgb(vec3 c)
|
||||
{
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
base_uv=UV*uv1_scale.xy+uv1_offset.xy;
|
||||
rotated_uv = rotateUVmatrinx(base_uv, vec2(0.5), (VERTEX.x));
|
||||
rotated_uv = base_uv;
|
||||
rotated_uv_mask = rotateUVmatrinx(UV, vec2(0.5), (VERTEX.x));
|
||||
rotated_uv_mask = UV;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void fragment() {
|
||||
// vec2 base_uv = UV;
|
||||
vec4 albedo_tex = texture(texture_albedo,rotated_uv);
|
||||
vec4 grass_2_tex = texture(texture_grass_2,rotated_uv);
|
||||
vec4 albedo_2_tex = texture(texture_albedo_2,rotated_uv);
|
||||
vec4 albedo_hsv_tex = texture(texture_albedo_hsv,rotated_uv_mask);
|
||||
vec4 albedo_mix_tex = texture(texture_albedo_mix,rotated_uv_mask);
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb;
|
||||
|
||||
// ALBEDO = mix( ALBEDO, grass_2_tex.rgb, 0.5 );
|
||||
|
||||
vec3 hsv_albedo = rgb2hsv(ALBEDO);
|
||||
vec3 hsv_mask = rgb2hsv( albedo_hsv_tex.rgb );
|
||||
hsv_albedo.x = hsv_mask.x;
|
||||
hsv_albedo.y = hsv_mask.y;
|
||||
hsv_albedo.z *= hsv_mask.z;
|
||||
ALBEDO = hsv2rgb( hsv_albedo );
|
||||
|
||||
ALBEDO = mix( ALBEDO, albedo_2_tex.rgb, min( 1.0, max(-1.0, albedo_mix_tex.r-grass_level)) );
|
||||
|
||||
METALLIC = metallic;
|
||||
float roughness_tex = dot(texture(texture_roughness,rotated_uv),roughness_texture_channel);
|
||||
ROUGHNESS = roughness_tex * roughness;
|
||||
SPECULAR = specular;
|
||||
NORMALMAP = texture(texture_normal,rotated_uv).rgb;
|
||||
NORMALMAP_DEPTH = normal_scale;
|
||||
AO = dot(texture(texture_ambient_occlusion,rotated_uv),ao_texture_channel);
|
||||
AO_LIGHT_AFFECT = ao_light_affect;
|
||||
}
|
BIN
assets/decors/terrains/demo/textures/Grass_001_COLOR.jpg
Normal file
After Width: | Height: | Size: 432 KiB |
BIN
assets/decors/terrains/demo/textures/Grass_001_DISP.png
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
assets/decors/terrains/demo/textures/Grass_001_NORM.jpg
Normal file
After Width: | Height: | Size: 850 KiB |
BIN
assets/decors/terrains/demo/textures/Grass_001_OCC.jpg
Normal file
After Width: | Height: | Size: 157 KiB |
BIN
assets/decors/terrains/demo/textures/Grass_001_ROUGH.jpg
Normal file
After Width: | Height: | Size: 378 KiB |
BIN
assets/decors/terrains/demo/textures/Ground003_2K_Color.jpg
Normal file
After Width: | Height: | Size: 3.9 MiB |
After Width: | Height: | Size: 1.5 MiB |
BIN
assets/decors/terrains/demo/textures/Ground003_2K_Normal.jpg
Normal file
After Width: | Height: | Size: 8.1 MiB |
BIN
assets/decors/terrains/demo/textures/Ground003_2K_Roughness.jpg
Normal file
After Width: | Height: | Size: 2 MiB |
After Width: | Height: | Size: 1.8 MiB |
BIN
assets/decors/terrains/demo/textures/Ground013_2K_Color.jpg
Normal file
After Width: | Height: | Size: 6.2 MiB |
After Width: | Height: | Size: 1.1 MiB |
BIN
assets/decors/terrains/demo/textures/Ground013_2K_Normal.jpg
Normal file
After Width: | Height: | Size: 9.1 MiB |
BIN
assets/decors/terrains/demo/textures/Ground013_2K_Roughness.jpg
Normal file
After Width: | Height: | Size: 3.4 MiB |
After Width: | Height: | Size: 2.2 MiB |
BIN
assets/decors/terrains/demo/textures/Ground037_2K_Color.jpg
Normal file
After Width: | Height: | Size: 8.3 MiB |
After Width: | Height: | Size: 1.6 MiB |
BIN
assets/decors/terrains/demo/textures/Ground037_2K_Normal.jpg
Normal file
After Width: | Height: | Size: 9.3 MiB |
BIN
assets/decors/terrains/demo/textures/Ground037_2K_Roughness.jpg
Normal file
After Width: | Height: | Size: 3.1 MiB |
BIN
assets/decors/terrains/demo/textures/border_smooth_mask.png
Normal file
After Width: | Height: | Size: 515 KiB |
BIN
assets/decors/terrains/demo/textures/cloud_noise.png
Normal file
After Width: | Height: | Size: 298 KiB |
BIN
assets/decors/terrains/demo/textures/dry-dirt1-albedo.png
Normal file
After Width: | Height: | Size: 7.2 MiB |
BIN
assets/decors/terrains/demo/textures/dry-dirt1-ao.png
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
assets/decors/terrains/demo/textures/dry-dirt1-height2.png
Normal file
After Width: | Height: | Size: 981 KiB |
BIN
assets/decors/terrains/demo/textures/dry-dirt1-metalness.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
assets/decors/terrains/demo/textures/dry-dirt1-normal2.png
Normal file
After Width: | Height: | Size: 10 MiB |
BIN
assets/decors/terrains/demo/textures/dry-dirt1-roughness.png
Normal file
After Width: | Height: | Size: 3.6 MiB |
BIN
assets/decors/terrains/demo/textures/grass1-albedo3.png
Normal file
After Width: | Height: | Size: 9.7 MiB |
BIN
assets/decors/terrains/demo/textures/grass1-albedo3_BW.jpg
Normal file
After Width: | Height: | Size: 3.2 MiB |
BIN
assets/decors/terrains/demo/textures/grass1-ao.png
Normal file
After Width: | Height: | Size: 2.8 MiB |
BIN
assets/decors/terrains/demo/textures/grass1-height.png
Normal file
After Width: | Height: | Size: 3.9 MiB |
BIN
assets/decors/terrains/demo/textures/grass1-normal1-ogl.png
Normal file
After Width: | Height: | Size: 11 MiB |
BIN
assets/decors/terrains/demo/textures/grass1-rough.png
Normal file
After Width: | Height: | Size: 2.2 MiB |
BIN
assets/decors/terrains/demo/textures/grass_hsv.jpg
Normal file
After Width: | Height: | Size: 528 KiB |
BIN
assets/decors/terrains/demo/textures/grass_hsv.jpg-autosave.kra
Normal file
BIN
assets/decors/terrains/demo/textures/grass_hsv_2.png
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
assets/decors/terrains/demo/textures/grass_mask.jpg
Normal file
After Width: | Height: | Size: 472 KiB |
BIN
assets/items/equippable/pendo_teddy/pendo_teddy.glb
Normal file
BIN
assets/items/equippable/pendo_teddy/pendo_teddy.material
Normal file
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 418 KiB |
After Width: | Height: | Size: 2 MiB |
After Width: | Height: | Size: 503 KiB |
|
@ -9,13 +9,37 @@
|
|||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "Node",
|
||||
"class": "Creature",
|
||||
"language": "GDScript",
|
||||
"path": "res://ressources/scripts/creatures/creature.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "Equippable",
|
||||
"language": "GDScript",
|
||||
"path": "res://ressources/scripts/items/equippable.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "Item",
|
||||
"language": "GDScript",
|
||||
"path": "res://ressources/scripts/items/item.gd"
|
||||
}, {
|
||||
"base": "Spatial",
|
||||
"class": "Mannequiny",
|
||||
"language": "GDScript",
|
||||
"path": "res://scenes/creatures/ra/ra_model.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "Ra",
|
||||
"language": "GDScript",
|
||||
"path": "res://ressources/scripts/creatures/ra.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Mannequiny": ""
|
||||
"Creature": "",
|
||||
"Equippable": "",
|
||||
"Item": "",
|
||||
"Mannequiny": "",
|
||||
"Ra": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
|
3
ressources/files/creatures/test.creature
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"inventory": [ "pendo_teddy.equippable" ]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"label": "Pendo Teddy",
|
||||
"scene": "pendo_teddy/pendo_teddy.tscn",
|
||||
"attachment": "hand_r_attachment"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
extends Node
|
||||
|
||||
class Creature:
|
||||
class Creature_old:
|
||||
|
||||
enum Sex { F, M, H, A, U }
|
||||
|
||||
|
@ -13,10 +13,10 @@ class Creature:
|
|||
self.pseudonym = p_pseudonym
|
||||
|
||||
|
||||
class Ra extends Creature:
|
||||
class Ra_old extends Creature_old:
|
||||
|
||||
|
||||
var sex = Creature.Sex.F
|
||||
var sex = Creature_old.Sex.F
|
||||
|
||||
var female_boobs = 0.0
|
||||
var female_hip = 0.0
|
||||
|
|
9
ressources/scripts/creatures/creature.gd
Normal file
|
@ -0,0 +1,9 @@
|
|||
extends Node
|
||||
class_name Creature
|
||||
|
||||
|
||||
|
||||
|
||||
func from_dict( datas ):
|
||||
pass
|
||||
|
11
ressources/scripts/creatures/ra.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends "res://ressources/scripts/creatures/creature.gd"
|
||||
class_name Ra
|
||||
|
||||
var inventory = []
|
||||
|
||||
|
||||
|
||||
func from_dict( datas ):
|
||||
.creature( datas )
|
||||
|
||||
self.inventory = datas.get( "inventory", self.inventory )
|
12
ressources/scripts/items/equippable.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends "res://ressources/scripts/items/item.gd"
|
||||
class_name Equippable
|
||||
|
||||
var scene = ""
|
||||
var attachment = ""
|
||||
|
||||
|
||||
func from_dict( datas ):
|
||||
.item( datas )
|
||||
|
||||
self.scene = datas.get( "scene", self.scene )
|
||||
self.attachment = datas.get( "attachment", self.attachment )
|
9
ressources/scripts/items/item.gd
Normal file
|
@ -0,0 +1,9 @@
|
|||
extends Node
|
||||
class_name Item
|
||||
|
||||
var label = ""
|
||||
|
||||
|
||||
func from_dict( datas ):
|
||||
|
||||
self.label = datas.get( "label", self.label )
|
|
@ -8,5 +8,9 @@
|
|||
[node name="body" parent="metarig/Skeleton" index="0"]
|
||||
material/0 = ExtResource( 2 )
|
||||
|
||||
[node name="hand_r_attachment" type="BoneAttachment" parent="metarig/Skeleton" index="1"]
|
||||
transform = Transform( -0.999354, -0.0308115, 0.0184786, 0.032408, -0.995098, 0.0934347, 0.0155092, 0.0939735, 0.995454, -0.270437, 1.0472, -0.0492001 )
|
||||
bone_name = "hand_r"
|
||||
|
||||
[node name="AnimationPlayer" parent="." index="1"]
|
||||
autoplay = "idle"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
[sub_resource type="CapsuleShape" id=1]
|
||||
margin = 0.1
|
||||
radius = 0.404418
|
||||
radius = 0.416012
|
||||
height = 0.827082
|
||||
|
||||
[node name="ra" type="KinematicBody"]
|
||||
|
|
10
scenes/decors/terrains/demo/demo.gd
Normal file
|
@ -0,0 +1,10 @@
|
|||
extends Spatial
|
||||
|
||||
|
||||
|
||||
#func _ready():
|
||||
#
|
||||
# for child in self.get_children():
|
||||
# if child is MeshInstance and not child.name == "water":
|
||||
# child.get_surface_material(0).set_shader_param( "texture_albedo_noise/seed", child.translation.x+child.translation.y )
|
||||
#
|
|
@ -63,6 +63,33 @@ size = Vector2( 6, 6 )
|
|||
|
||||
[node name="ground_-1_-1" parent="." instance=ExtResource( 4 )]
|
||||
|
||||
[node name="ground_0_3" parent="." instance=ExtResource( 1 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="ground_0_2" parent="." instance=ExtResource( 6 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="ground_0_-1_2" parent="." instance=ExtResource( 8 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="ground_1_3" parent="." instance=ExtResource( 9 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="ground_1_2" parent="." instance=ExtResource( 3 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="ground_1_-1_2" parent="." instance=ExtResource( 2 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="ground_-1_3" parent="." instance=ExtResource( 5 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="ground_-1_2" parent="." instance=ExtResource( 7 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="ground_-1_-1_2" parent="." instance=ExtResource( 4 )]
|
||||
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -6 )
|
||||
|
||||
[node name="water" type="MeshInstance" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.074535, 0 )
|
||||
mesh = SubResource( 2 )
|
||||
|
|
|
@ -13,6 +13,14 @@ var camera_zoom = 0.0
|
|||
var heightmap = null
|
||||
|
||||
|
||||
func _ready():
|
||||
|
||||
var player_ra = Ra.new()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func _input( event ):
|
||||
var movment = Vector3( 0.0, 0.0, 0.0 )
|
||||
var rotation = Vector3( 0.0, 0.0, 0.0 )
|
||||
|
|
|
@ -25,8 +25,8 @@ noise = SubResource( 1 )
|
|||
[sub_resource type="ShaderMaterial" id=3]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource( 5 )
|
||||
shader_param/iTime = 330.89
|
||||
shader_param/iFrame = 20619
|
||||
shader_param/iTime = 92.0443
|
||||
shader_param/iFrame = 3942
|
||||
shader_param/COVERAGE = 0.5
|
||||
shader_param/THICKNESS = 25.0
|
||||
shader_param/ABSORPTION = 1.031
|
||||
|
|
|
@ -33,7 +33,7 @@ func _ready():
|
|||
self.slots[ self.slots_number ] = creature_box
|
||||
self.slots_number += 1
|
||||
|
||||
var creature = Creatures.Ra.new()
|
||||
var creature = Creatures.Ra_old.new()
|
||||
creature.from_file( file )
|
||||
creature_box.get_node( "label" ).text = creature.pseudonym
|
||||
|
||||
|
|
5
scenes/items/equippable/pendo_teddy/pendo_teddy.tscn
Normal file
|
@ -0,0 +1,5 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://assets/items/equippable/pendo_teddy/pendo_teddy.glb" type="PackedScene" id=1]
|
||||
|
||||
[node name="pendo_teddy" instance=ExtResource( 1 )]
|
|
@ -89,7 +89,7 @@ func calculate_velocity(
|
|||
|
||||
func load_creature( filename ):
|
||||
|
||||
self.creature = Creatures.Ra.new()
|
||||
self.creature = Creatures.Ra_old.new()
|
||||
self.creature.from_file( filename )
|
||||
|
||||
# # version statique.
|
||||
|
|
|
@ -15,4 +15,7 @@ enabled = true
|
|||
|
||||
[node name="ra" parent="model" instance=ExtResource( 2 )]
|
||||
|
||||
[node name="collision" parent="model/ra" index="3"]
|
||||
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.831027, 0 )
|
||||
|
||||
[editable path="model/ra"]
|
||||
|
|