Browse Source

shader stuff

max
Pixdigit 3 months ago
parent
commit
10b897306f
4 changed files with 24 additions and 122 deletions
  1. BIN
     
  2. +2
    -117
      scenes/sub_scenes/ship.tscn
  3. +5
    -1
      scenes/sub_scenes/water_logo.tscn
  4. +17
    -4
      src/shader/sail.shader

BIN
View File


+ 2
- 117
scenes/sub_scenes/ship.tscn View File

@@ -1,6 +1,7 @@
[gd_scene load_steps=10 format=2]

[ext_resource path="res://assets/models/ship/prototype ship.escn" type="PackedScene" id=1]
[ext_resource path="res://src/shader/sail.shader" type="Shader" id=2]

[sub_resource type="GDScript" id=1]
script/source = "extends Spatial
@@ -17,122 +18,6 @@ func _ready():
child2.play()
"

[sub_resource type="Shader" id=2]
resource_name = "Shader Nodetree"
code = "shader_type spatial;
render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx;


uniform sampler2D noise1;
uniform sampler2D noise2;


void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
float metallic, float specular, float roughness, float clearcoat,
float clearcoat_roughness, float anisotropy, float transmission,
float IOR, out vec3 albedo, out float sss_strength_out,
out float metallic_out, out float specular_out,
out float roughness_out, out float clearcoat_out,
out float clearcoat_gloss_out, out float anisotropy_out,
out float transmission_out, out float ior) {
metallic = clamp(metallic, 0.0, 1.0);
transmission = clamp(transmission, 0.0, 1.0);

subsurface = subsurface * (1.0 - metallic);

albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
sss_strength_out = subsurface;
metallic_out = metallic;
specular_out = pow((IOR - 1.0)/(IOR + 1.0), 2)/0.08;
roughness_out = roughness;
clearcoat_out = clearcoat * (1.0 - transmission);
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
transmission_out = (1.0 - transmission) * (1.0 - metallic);
ior = IOR;
}

void vertex () {
}

void fragment () {
// node: 'Principled BSDF'
// type: 'ShaderNodeBsdfPrincipled'
// input sockets handling
vec4 node0_in0_basecolor = vec4(0.09167075157165527, 0.46101850271224976, 1.0,
1.0);
float node0_in1_subsurface = float(0.0);
vec3 node0_in2_subsurfaceradius = vec3(1.0, 0.20000000298023224,
0.10000000149011612);
vec4 node0_in3_subsurfacecolor = vec4(0.8000000715255737, 0.7206057906150818,
0.7986864447593689, 1.0);
float node0_in4_metallic = float(0.0);
float node0_in5_specular = float(0.5681818127632141);
float node0_in6_speculartint = float(0.4636363685131073);
float node0_in7_roughness = float(0.25);
float node0_in8_anisotropic = float(0.0);
float node0_in9_anisotropicrotation = float(0.17272727191448212);
float node0_in10_sheen = float(0.16363635659217834);
float node0_in11_sheentint = float(0.5);
float node0_in12_clearcoat = float(0.0);
float node0_in13_clearcoatroughness = float(0.029999999329447746);
float node0_in14_ior = float(1.100000023841858);
float node0_in15_transmission = float(1.0);
float node0_in16_transmissionroughness = float(0.0);
vec4 node0_in17_emission = vec4(0.0, 0.0, 0.0, 1.0);
float node0_in18_alpha = float(1.0);
vec3 node0_in19_normal = NORMAL;
vec3 node0_in20_clearcoatnormal = vec3(0.0, 0.0, 0.0);
vec3 node0_in21_tangent = TANGENT;
// output sockets definitions
vec3 node0_bsdf_out0_albedo;
float node0_bsdf_out1_sss_strength;
float node0_bsdf_out3_specular;
float node0_bsdf_out2_metallic;
float node0_bsdf_out4_roughness;
float node0_bsdf_out5_clearcoat;
float node0_bsdf_out6_clearcoat_gloss;
float node0_bsdf_out7_anisotropy;
float node0_bsdf_out8_transmission;
float node0_bsdf_out9_ior;
node_bsdf_principled(node0_in0_basecolor, node0_in1_subsurface,
node0_in3_subsurfacecolor, node0_in4_metallic, node0_in5_specular,
node0_in7_roughness, node0_in12_clearcoat, node0_in13_clearcoatroughness,
node0_in8_anisotropic, node0_in15_transmission, node0_in14_ior,
node0_bsdf_out0_albedo, node0_bsdf_out1_sss_strength, node0_bsdf_out2_metallic,
node0_bsdf_out3_specular, node0_bsdf_out4_roughness, node0_bsdf_out5_clearcoat,
node0_bsdf_out6_clearcoat_gloss, node0_bsdf_out7_anisotropy,
node0_bsdf_out8_transmission, node0_bsdf_out9_ior);
float t = TIME * 0.3;

ALPHA = mix(
smoothstep(0.3, 0.7, texture(noise1, UV + vec2(0.5, 1) * TIME * 0.16).r),
smoothstep(0.3, 0.7, texture(noise2, UV + vec2(0., 1.3) * TIME * 0.1).r),
mix(fract(t), 1. - fract(t), step(fract(t), 0.5))
) * 0.5;

ALBEDO = node0_bsdf_out0_albedo;
EMISSION = node0_bsdf_out0_albedo * 1.4;
SSS_STRENGTH = node0_bsdf_out1_sss_strength;
SPECULAR = node0_bsdf_out3_specular;
METALLIC = node0_bsdf_out2_metallic;
ROUGHNESS = node0_bsdf_out4_roughness;
CLEARCOAT = node0_bsdf_out5_clearcoat;
CLEARCOAT_GLOSS = node0_bsdf_out6_clearcoat_gloss;
NORMAL = node0_in19_normal;
// uncomment it when you need it
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * node0_bsdf_out8_transmission;
// uncomment it when you are modifing TANGENT
// TANGENT = normalize(cross(cross(node0_in21_tangent, NORMAL), NORMAL));
// BINORMAL = cross(TANGENT, NORMAL);
// uncomment it when you have tangent(UV) set
// ANISOTROPY = node0_bsdf_out7_anisotropy;
}
"

[sub_resource type="OpenSimplexNoise" id=3]
seed = 2
period = 72.4
@@ -152,7 +37,7 @@ noise = SubResource( 5 )

[sub_resource type="ShaderMaterial" id=7]
resource_name = "sicherheitssegel"
shader = SubResource( 2 )
shader = ExtResource( 2 )
shader_param/noise1 = SubResource( 4 )
shader_param/noise2 = SubResource( 6 )



+ 5
- 1
scenes/sub_scenes/water_logo.tscn View File

@@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]

[ext_resource path="res://assets/models/ui/Wasser Logo.escn" type="PackedScene" id=1]
[ext_resource path="res://assets/models/ui/water.material" type="Material" id=2]

[node name="Wasser Logo" instance=ExtResource( 1 )]

@@ -9,3 +10,6 @@ visible = false

[node name="Camera" parent="." index="1"]
visible = false

[node name="Sphere" parent="." index="2"]
material_override = ExtResource( 2 )

+ 17
- 4
src/shader/sail.shader View File

@@ -34,6 +34,10 @@ void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
void vertex () {
}

float triag(float a) {
return min(fract(a), 1. - fract(a)) * 2.;
}

void fragment () {
// node: 'Principled BSDF'
@@ -87,13 +91,22 @@ void fragment () {
float t = TIME * 0.3;

ALPHA = mix(
float noiseAlpha = mix(
smoothstep(0.3, 0.7, texture(noise1, UV + vec2(0.5, 1) * TIME * 0.16).r),
smoothstep(0.3, 0.7, texture(noise2, UV + vec2(0., 1.3) * TIME * 0.1).r),
mix(fract(t), 1. - fract(t), step(fract(t), 0.5))
) * 0.5;
triag(t) * 0.5
);

noiseAlpha = mix(noiseAlpha, 1., smoothstep(.2, 0., min(triag(UV.x), triag(UV.y))));

vec3 albedo = mix(
node0_bsdf_out0_albedo,
vec3(1.),
smoothstep(.2, 0., min(triag(UV.x), triag(UV.y)))
);

ALBEDO = node0_bsdf_out0_albedo;
ALPHA = noiseAlpha;
ALBEDO = albedo;
EMISSION = node0_bsdf_out0_albedo * 1.4;
SSS_STRENGTH = node0_bsdf_out1_sss_strength;
SPECULAR = node0_bsdf_out3_specular;


Loading…
Cancel
Save