first examples

This commit is contained in:
Luca 2024-12-19 14:04:09 +01:00
parent a01a7a7acc
commit 2219e943da
33 changed files with 785 additions and 6 deletions

View file

@ -0,0 +1,16 @@
@tool
extends Node3D
@export var my_variable: float = 1.0:
set(value):
my_variable = value
shader_material.set_shader_parameter("my_variable", value)
@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

View file

@ -0,0 +1,13 @@
shader_type spatial;
uniform float my_variable = 0.0;
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.
}

View file

@ -0,0 +1,18 @@
[gd_scene load_steps=5 format=3 uid="uid://c0c1k04qmog56"]
[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"]
render_priority = 0
shader = ExtResource("1_0fhw0")
shader_parameter/my_variable = 1.0
[sub_resource type="SphereMesh" id="SphereMesh_6preo"]
material = SubResource("ShaderMaterial_h8cto")
[node name="Playground" type="Node3D"]
script = ExtResource("1_08keh")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("SphereMesh_6preo")