ADD debut de test sur un shader de terrain.

This commit is contained in:
osquallo 2020-03-29 13:29:57 +02:00
parent 9ea371191f
commit 71bbdf4c0c
63 changed files with 253 additions and 9 deletions

View 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 850 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 KiB

View file

@ -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]

View file

@ -0,0 +1,3 @@
{
"inventory": [ "pendo_teddy.equippable" ]
}

View file

@ -0,0 +1,5 @@
{
"label": "Pendo Teddy",
"scene": "pendo_teddy/pendo_teddy.tscn",
"attachment": "hand_r_attachment"
}

View file

@ -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

View file

@ -0,0 +1,9 @@
extends Node
class_name Creature
func from_dict( datas ):
pass

View 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 )

View 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 )

View file

@ -0,0 +1,9 @@
extends Node
class_name Item
var label = ""
func from_dict( datas ):
self.label = datas.get( "label", self.label )

View file

@ -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"

View file

@ -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"]

View 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 )
#

View file

@ -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 )

View file

@ -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 )

View file

@ -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

View file

@ -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

View 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 )]

View file

@ -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.

View file

@ -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"]