update
This commit is contained in:
parent
2219e943da
commit
c4115b3569
40 changed files with 2035 additions and 19 deletions
|
|
@ -8,9 +8,6 @@ extends Node3D
|
|||
|
||||
@onready var shader_material = $MeshInstance3D.mesh.material
|
||||
|
||||
func _ready() -> void:
|
||||
print(shader_material)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
shader_type spatial;
|
||||
|
||||
uniform float my_variable = 0.0;
|
||||
render_mode cull_disabled;
|
||||
|
||||
void vertex() {
|
||||
VERTEX.y += my_variable;
|
||||
// Called for every vertex the material is visible on.
|
||||
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = NORMAL;
|
||||
// Called for every pixel the material is visible on.
|
||||
|
||||
}
|
||||
|
|
@ -3,16 +3,15 @@
|
|||
[ext_resource type="Shader" path="res://shaders/000_playground/playground.gdshader" id="1_0fhw0"]
|
||||
[ext_resource type="Script" path="res://shaders/000_playground/playground.gd" id="1_08keh"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_h8cto"]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fofry"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_0fhw0")
|
||||
shader_parameter/my_variable = 1.0
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_6preo"]
|
||||
material = SubResource("ShaderMaterial_h8cto")
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_v7gb1"]
|
||||
material = SubResource("ShaderMaterial_fofry")
|
||||
|
||||
[node name="Playground" type="Node3D"]
|
||||
script = ExtResource("1_08keh")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("SphereMesh_6preo")
|
||||
mesh = SubResource("SphereMesh_v7gb1")
|
||||
|
|
|
|||
22
shaders/009_fresnel/fresnel.gdshader
Normal file
22
shaders/009_fresnel/fresnel.gdshader
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
shader_type spatial;
|
||||
|
||||
uniform vec3 base_color : source_color = vec3(0.173, 0.731, 0.541);
|
||||
uniform vec3 fresnel_color : source_color = vec3(0.887, 0, 1.0);
|
||||
uniform float fresnel_strength = 2.0;
|
||||
uniform float fresnel_amount = 1.0;
|
||||
|
||||
float fresnel(vec3 normal, vec3 view) {
|
||||
return pow((1.0 - clamp(dot(normal, view), 0.0, 1.0)), fresnel_amount);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
//VERTEX.y += 0.5 + sin(VERTEX.x * 10.0 + TIME * 20.0) * 0.3;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
float fresnel_value = fresnel(NORMAL, VIEW) * fresnel_strength;
|
||||
vec3 fresnel = fresnel_value * fresnel_color;
|
||||
|
||||
ALBEDO = base_color + fresnel;
|
||||
ROUGHNESS = 0.05;
|
||||
}
|
||||
19
shaders/009_fresnel/fresnel.tscn
Normal file
19
shaders/009_fresnel/fresnel.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bcsb32y37da3f"]
|
||||
|
||||
[ext_resource type="Shader" path="res://shaders/009_fresnel/fresnel.gdshader" id="1_dvfmg"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_t4a8f"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_dvfmg")
|
||||
shader_parameter/base_color = Color(0.173, 0.731, 0.541, 1)
|
||||
shader_parameter/fresnel_color = Color(0.887, 0, 1, 1)
|
||||
shader_parameter/fresnel_strength = 3.0
|
||||
shader_parameter/fresnel_amount = 3.6
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_pr1ms"]
|
||||
material = SubResource("ShaderMaterial_t4a8f")
|
||||
|
||||
[node name="Fresnel" type="Node3D"]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("SphereMesh_pr1ms")
|
||||
14
shaders/010_outline/outline.gdshader
Normal file
14
shaders/010_outline/outline.gdshader
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
shader_type spatial;
|
||||
|
||||
void vertex() {
|
||||
// Called for every vertex the material is visible on.
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// Called for every pixel the material is visible on.
|
||||
}
|
||||
|
||||
//void light() {
|
||||
// Called for every pixel for every light affecting the material.
|
||||
// Uncomment to replace the default light processing function with this one.
|
||||
//}
|
||||
15
shaders/010_outline/outline.tscn
Normal file
15
shaders/010_outline/outline.tscn
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://drgqrnj1otb25"]
|
||||
|
||||
[ext_resource type="Shader" path="res://shaders/010_outline/outline.gdshader" id="1_34hnr"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vbj21"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_34hnr")
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_wnbfj"]
|
||||
material = SubResource("ShaderMaterial_vbj21")
|
||||
|
||||
[node name="Outline" type="Node3D"]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("SphereMesh_wnbfj")
|
||||
17
shaders/011_circle/circle.gdshader
Normal file
17
shaders/011_circle/circle.gdshader
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
shader_type spatial;
|
||||
render_mode cull_disabled;
|
||||
|
||||
/*
|
||||
We define the center position of our circle and then ask each pixel how far from that
|
||||
center position it is. This will give the pixel a value between 0 – 1.
|
||||
We can then ask the pixel if its value is lower or higher than a predefined value.
|
||||
If it is higher we will set the pixel to white
|
||||
and if it is lower we will set it to black.
|
||||
*/
|
||||
float circle(vec2 position, float radius, float feather) {
|
||||
return smoothstep(radius, radius + feather, length(position - vec2(0.5)));
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO.rgb = vec3( circle(UV, 0.3, 0.0) );
|
||||
}
|
||||
15
shaders/011_circle/circle.tscn
Normal file
15
shaders/011_circle/circle.tscn
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cjcfr8tqdhbro"]
|
||||
|
||||
[ext_resource type="Shader" path="res://shaders/011_circle/circle.gdshader" id="1_omahb"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_iu8hm"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_omahb")
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_md0p6"]
|
||||
material = SubResource("ShaderMaterial_iu8hm")
|
||||
|
||||
[node name="Circle" type="Node3D"]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("QuadMesh_md0p6")
|
||||
30
shaders/012_polygon/polygon.gdshader
Normal file
30
shaders/012_polygon/polygon.gdshader
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
shader_type spatial;
|
||||
render_mode cull_disabled;
|
||||
|
||||
vec4 polygon(vec2 uv, float width, int sides)
|
||||
{
|
||||
// UV goes from [0 , 1], we multiply by two ( [0, 2] ) and subtract one [ -1, 1]
|
||||
// So the range is centered
|
||||
uv = uv * 2.0 - 1.0;
|
||||
|
||||
// Get the angle from the point to the center, starting with 0 at the middle left side
|
||||
float angle = atan(uv.x, uv.y);
|
||||
|
||||
float radius = TAU / float(sides);
|
||||
|
||||
float dist = cos(floor(0.5 + angle / radius) * radius - angle) * length(uv);
|
||||
|
||||
float poly = step(width, dist);
|
||||
|
||||
return vec4(vec3(poly), 1.0);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// Multiply [0, 1] range of sine to [0, 7]
|
||||
float side_value = 7.0 * sin(TIME);
|
||||
|
||||
// shift the value to half = [3, 10]
|
||||
side_value = side_value + 3.0;
|
||||
|
||||
ALBEDO = vec3(polygon(UV, 0.3, clamp(int(side_value), 3, 9)).rgb);
|
||||
}
|
||||
15
shaders/012_polygon/polygon.tscn
Normal file
15
shaders/012_polygon/polygon.tscn
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://2o8nbxn0x7of"]
|
||||
|
||||
[ext_resource type="Shader" path="res://shaders/012_polygon/polygon.gdshader" id="1_cwvsg"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_4pm8x"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_cwvsg")
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_87u1q"]
|
||||
material = SubResource("ShaderMaterial_4pm8x")
|
||||
|
||||
[node name="Polygon" type="Node3D"]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("QuadMesh_87u1q")
|
||||
Loading…
Add table
Add a link
Reference in a new issue