GodotComponentTest/scenes/HexGrid3DTest.tscn

62 lines
1.9 KiB
Plaintext

[gd_scene load_steps=7 format=2]
[ext_resource path="res://scenes/HexTile3D.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/HexGrid3DTest.gd" type="Script" id=2]
[ext_resource path="res://scenes/DebugCamera.gd" type="Script" id=3]
[sub_resource type="PlaneMesh" id=1]
size = Vector2( 50, 50 )
[sub_resource type="Shader" id=2]
code = "shader_type spatial;
uniform float beer_factor = 5.0;
void fragment() {
// sample our depth buffer
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
// grab to values
//depth = depth * 50.0 - 49.0;
// unproject depth
depth = depth * 2.0 - 1.0;
float z = -PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]);
// float x = (SCREEN_UV.x * 2.0 - 1.0) * z / PROJECTION_MATRIX[0][0];
// float y = (SCREEN_UV.y * 2.0 - 1.0) * z / PROJECTION_MATRIX[1][1];
float delta = -(z - VERTEX.z); // z is negative.
// delta *= 0.1;
// beers law
float att = exp(-delta * beer_factor);
ALPHA = clamp(1.0 - att, 0.0, 1.0);
ALBEDO = vec3(0.0, 0.0, 0.05);
}"
[sub_resource type="ShaderMaterial" id=3]
shader = SubResource( 2 )
shader_param/beer_factor = 5.0
[node name="HexGrid3DTest" type="Spatial"]
script = ExtResource( 2 )
[node name="HexTile3D" parent="." instance=ExtResource( 1 )]
visible = false
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.511698, 0.859165, 0, -0.859165, 0.511698, -1.05655, 3.66248, 10.3074 )
fov = 60.0
script = ExtResource( 3 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.83729, 0.174005, 0.518332, -0.54676, 0.266466, 0.793757, 0, -0.948008, 0.318248, 0, 8.03448, 0 )
shadow_enabled = true
shadow_contact = 1.565
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.568377, 0.0356998 )
mesh = SubResource( 1 )
material/0 = SubResource( 3 )