diff --git a/BlurNoise.tres b/BlurNoise.tres new file mode 100644 index 0000000..873454d --- /dev/null +++ b/BlurNoise.tres @@ -0,0 +1,131 @@ +[gd_resource type="VisualShader" load_steps=12 format=3 uid="uid://ulljr4hxdmvr"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_w3o50"] +seed = 666 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_5i62n"] +noise = SubResource("FastNoiseLite_w3o50") + +[sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_p0ff0"] +output_port_for_preview = 0 +texture = SubResource("NoiseTexture2D_5i62n") + +[sub_resource type="VisualShaderNodeVec3Constant" id="VisualShaderNodeVec3Constant_3q5bf"] +constant = Vector3(1, 1, 1) + +[sub_resource type="VisualShaderNodeVec3Constant" id="VisualShaderNodeVec3Constant_t0a48"] + +[sub_resource type="VisualShaderNodeTexture2DParameter" id="VisualShaderNodeTexture2DParameter_ii6y5"] +parameter_name = "Texture2DParameter" + +[sub_resource type="VisualShaderNodeExpression" id="VisualShaderNodeExpression_by0vp"] +size = Vector2(916.9, 484.033) +expression = "vec3 pixel0 = step(step_comparator, texture(sampler, uv.xy + vec2(-step, -step)).xyz); +vec3 pixel1 = step(step_comparator, texture(sampler, uv.xy + vec2(-step, 0)).xyz); +vec3 pixel2 = step(step_comparator, texture(sampler, uv.xy + vec2(-step, step)).xyz); +vec3 pixel3 = step(step_comparator, texture(sampler, uv.xy + vec2(0, -step)).xyz); +vec3 pixel4 = step(step_comparator, texture(sampler, uv.xy + vec2(0, 0)).xyz); +vec3 pixel5 = step(step_comparator, texture(sampler, uv.xy + vec2(0, +step)).xyz); +vec3 pixel6 = step(step_comparator, texture(sampler, uv.xy + vec2(step, -step)).xyz); +vec3 pixel7 = step(step_comparator, texture(sampler, uv.xy + vec2(step, 0)).xyz); +vec3 pixel8 = step(step_comparator, texture(sampler, uv.xy + vec2(step, step)).xyz); + +albedo = (pixel0 + pixel1 + pixel2 + pixel3 + pixel4 + pixel5 + pixel6 + pixel7 + pixel8) / vec3(9, 9, 9); +" + +[sub_resource type="VisualShaderNodeInput" id="VisualShaderNodeInput_j8b80"] +input_name = "uv" + +[sub_resource type="VisualShaderNodeFloatConstant" id="VisualShaderNodeFloatConstant_rnhgr"] +constant = 0.007 + +[sub_resource type="VisualShaderNodeVec3Constant" id="VisualShaderNodeVec3Constant_v76ww"] +constant = Vector3(0.8, 0.8, 0.8) + +[sub_resource type="VisualShaderNodeExpression" id="VisualShaderNodeExpression_ddc37"] +output_port_for_preview = 0 +size = Vector2(844.92, 505.52) +expression = "// Scale, and clamp x to 0..1 range +vec3 x = clamp((input0 - minimum) / (maximum - minimum), 0.0, 1.0); +// Evaluate polynomial +output0 = x * x * x * (x * (x * vec3(6) - vec3(15)) + vec3(10));" + +[resource] +code = "shader_type spatial; +uniform sampler2D tex_frg_10; + + + +void fragment() { +// Texture2D:10 + vec4 n_out10p0 = texture(tex_frg_10, UV); + + +// Vector3Constant:11 + vec3 n_out11p0 = vec3(1.000000, 1.000000, 1.000000); + + +// Vector3Constant:12 + vec3 n_out12p0 = vec3(0.000000, 0.000000, 0.000000); + + + vec3 n_out9p0; +// Expression:9 + n_out9p0 = vec3(0.0, 0.0, 0.0); + { + // Scale, and clamp x to 0..1 range + vec3 x = clamp((vec3(n_out10p0.xyz) - n_out12p0) / (n_out11p0 - n_out12p0), 0.0, 1.0); + // Evaluate polynomial + n_out9p0 = x * x * x * (x * (x * vec3(6) - vec3(15)) + vec3(10)); + } + + +// Output:0 + ALBEDO = n_out9p0; + + +} +" +graph_offset = Vector2(-957.583, 126.888) +nodes/fragment/0/position = Vector2(880, 120) +nodes/fragment/2/node = SubResource("VisualShaderNodeTexture2DParameter_ii6y5") +nodes/fragment/2/position = Vector2(-540, 120) +nodes/fragment/3/node = SubResource("VisualShaderNodeExpression_by0vp") +nodes/fragment/3/position = Vector2(-140, 120) +nodes/fragment/3/size = Vector2(916.9, 484.033) +nodes/fragment/3/input_ports = "0,7,sampler;1,3,uv;2,0,step;3,3,step_comparator;" +nodes/fragment/3/output_ports = "0,3,albedo;" +nodes/fragment/3/expression = "vec3 pixel0 = step(step_comparator, texture(sampler, uv.xy + vec2(-step, -step)).xyz); +vec3 pixel1 = step(step_comparator, texture(sampler, uv.xy + vec2(-step, 0)).xyz); +vec3 pixel2 = step(step_comparator, texture(sampler, uv.xy + vec2(-step, step)).xyz); +vec3 pixel3 = step(step_comparator, texture(sampler, uv.xy + vec2(0, -step)).xyz); +vec3 pixel4 = step(step_comparator, texture(sampler, uv.xy + vec2(0, 0)).xyz); +vec3 pixel5 = step(step_comparator, texture(sampler, uv.xy + vec2(0, +step)).xyz); +vec3 pixel6 = step(step_comparator, texture(sampler, uv.xy + vec2(step, -step)).xyz); +vec3 pixel7 = step(step_comparator, texture(sampler, uv.xy + vec2(step, 0)).xyz); +vec3 pixel8 = step(step_comparator, texture(sampler, uv.xy + vec2(step, step)).xyz); + +albedo = (pixel0 + pixel1 + pixel2 + pixel3 + pixel4 + pixel5 + pixel6 + pixel7 + pixel8) / vec3(9, 9, 9); +" +nodes/fragment/6/node = SubResource("VisualShaderNodeInput_j8b80") +nodes/fragment/6/position = Vector2(-540, 400) +nodes/fragment/7/node = SubResource("VisualShaderNodeFloatConstant_rnhgr") +nodes/fragment/7/position = Vector2(-400, 500) +nodes/fragment/8/node = SubResource("VisualShaderNodeVec3Constant_v76ww") +nodes/fragment/8/position = Vector2(-560, 580) +nodes/fragment/9/node = SubResource("VisualShaderNodeExpression_ddc37") +nodes/fragment/9/position = Vector2(-100, 720) +nodes/fragment/9/size = Vector2(844.92, 505.52) +nodes/fragment/9/input_ports = "0,3,input0;1,3,maximum;2,3,minimum;" +nodes/fragment/9/output_ports = "0,3,output0;" +nodes/fragment/9/expression = "// Scale, and clamp x to 0..1 range +vec3 x = clamp((input0 - minimum) / (maximum - minimum), 0.0, 1.0); +// Evaluate polynomial +output0 = x * x * x * (x * (x * vec3(6) - vec3(15)) + vec3(10));" +nodes/fragment/10/node = SubResource("VisualShaderNodeTexture_p0ff0") +nodes/fragment/10/position = Vector2(-760, 720) +nodes/fragment/11/node = SubResource("VisualShaderNodeVec3Constant_3q5bf") +nodes/fragment/11/position = Vector2(-520, 1000) +nodes/fragment/12/node = SubResource("VisualShaderNodeVec3Constant_t0a48") +nodes/fragment/12/position = Vector2(-520, 1100) +nodes/fragment/connections = PackedInt32Array(2, 0, 3, 0, 6, 0, 3, 1, 7, 0, 3, 2, 8, 0, 3, 3, 10, 0, 9, 0, 9, 0, 0, 0, 11, 0, 9, 1, 12, 0, 9, 2) diff --git a/BlurNoise.tscn b/BlurNoise.tscn new file mode 100644 index 0000000..10400a7 --- /dev/null +++ b/BlurNoise.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=4 format=3 uid="uid://dh012o0lwgja0"] + +[ext_resource type="Shader" uid="uid://ulljr4hxdmvr" path="res://BlurNoise.tres" id="1_u072e"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_kldin"] +render_priority = 0 +shader = ExtResource("1_u072e") + +[sub_resource type="PlaneMesh" id="PlaneMesh_8idyw"] +material = SubResource("ShaderMaterial_kldin") + +[node name="BlurNoise" type="Node3D"] + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +mesh = SubResource("PlaneMesh_8idyw") diff --git a/FreeLookCamera.gd b/FreeLookCamera.gd new file mode 100644 index 0000000..bdf07b3 --- /dev/null +++ b/FreeLookCamera.gd @@ -0,0 +1,113 @@ +extends Camera3D + +# Modifier keys' speed multiplier +const SHIFT_MULTIPLIER = 2.5 +const ALT_MULTIPLIER = 1.0 / SHIFT_MULTIPLIER + +@export var sensitivity : float = 0.25 + +# Mouse state +var _mouse_position = Vector2(0.0, 0.0) +var _total_pitch = 0.0 + +# Movement state +var _direction = Vector3(0.0, 0.0, 0.0) +var _velocity = Vector3(0.0, 0.0, 0.0) +var _acceleration = 30 +var _deceleration = -10 +var _vel_multiplier = 4 + +# Keyboard state +var _w = false +var _s = false +var _a = false +var _d = false +var _q = false +var _e = false +var _shift = false +var _alt = false + +func _input(event): + # Receives mouse motion + if event is InputEventMouseMotion: + _mouse_position = event.relative + + # Receives mouse button input + if event is InputEventMouseButton: + match event.button_index: + MOUSE_BUTTON_RIGHT: # Only allows rotation if right click down + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED if event.pressed else Input.MOUSE_MODE_VISIBLE) + MOUSE_BUTTON_WHEEL_UP: # Increases max velocity + _vel_multiplier = clamp(_vel_multiplier * 1.1, 0.2, 20) + MOUSE_BUTTON_WHEEL_DOWN: # Decereases max velocity + _vel_multiplier = clamp(_vel_multiplier / 1.1, 0.2, 20) + + # Receives key input + if event is InputEventKey: + match event.keycode: + KEY_W: + _w = event.pressed + KEY_S: + _s = event.pressed + KEY_A: + _a = event.pressed + KEY_D: + _d = event.pressed + KEY_Q: + _q = event.pressed + KEY_E: + _e = event.pressed + KEY_SHIFT: + _shift = event.pressed + KEY_ALT: + _alt = event.pressed + +# Updates mouselook and movement every frame +func _physics_process(delta): + _update_mouselook() + _update_movement(delta) + +# Updates camera movement +func _update_movement(delta): + # Computes desired direction from key states + _direction = Vector3(float(_d) - float(_a), + float(_e) - float(_q), + float(_s) - float(_w)) + + # Computes the change in velocity due to desired direction and "drag" + # The "drag" is a constant acceleration on the camera to bring it's velocity to 0 + var offset = _direction.normalized() * _acceleration * _vel_multiplier * delta \ + + _velocity.normalized() * _deceleration * _vel_multiplier * delta + + # Compute modifiers' speed multiplier + var speed_multi = 1 + if _shift: speed_multi *= SHIFT_MULTIPLIER + if _alt: speed_multi *= ALT_MULTIPLIER + + # Checks if we should bother translating the camera + if _direction == Vector3.ZERO and offset.length_squared() > _velocity.length_squared(): + # Sets the velocity to 0 to prevent jittering due to imperfect deceleration + _velocity = Vector3.ZERO + else: + # Clamps speed to stay within maximum value (_vel_multiplier) + _velocity.x = clamp(_velocity.x + offset.x, -_vel_multiplier, _vel_multiplier) + _velocity.y = clamp(_velocity.y + offset.y, -_vel_multiplier, _vel_multiplier) + _velocity.z = clamp(_velocity.z + offset.z, -_vel_multiplier, _vel_multiplier) + + translate(_velocity * delta * speed_multi) + +# Updates mouse look +func _update_mouselook(): + # Only rotates mouse if the mouse is captured + if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: + _mouse_position *= sensitivity + var yaw = _mouse_position.x + var pitch = _mouse_position.y + _mouse_position = Vector2(0, 0) + + # Prevents looking up/down too far + pitch = clamp(pitch, -90 - _total_pitch, 90 - _total_pitch) + _total_pitch += pitch + + rotate_y(deg_to_rad(-yaw)) + rotate_object_local(Vector3(1,0,0), deg_to_rad(-pitch)) diff --git a/Points.gd b/Points.gd new file mode 100644 index 0000000..9fa3f68 --- /dev/null +++ b/Points.gd @@ -0,0 +1,12 @@ +@tool +extends Node3D + +@export var sphere : NodePath +@export var cube : NodePath +@export var material : ShaderMaterial + +func _process(delta): + material.set_shader_parameter("sphere_pos", -(get_node(sphere) as Node3D).position) + material.set_shader_parameter("cube_pos", -(get_node(cube) as Node3D).position) + + material.set_shader_parameter("plane_dir", (get_node(cube) as Node3D).rotation) diff --git a/RayMarching.gdshader b/RayMarching.gdshader new file mode 100644 index 0000000..24bd3be --- /dev/null +++ b/RayMarching.gdshader @@ -0,0 +1,139 @@ +shader_type spatial; + +uniform bool disable_threshold = false; + +uniform float threshold = 0.001f; +uniform int max_iterations = 300; +uniform vec4 colour : source_color; +uniform float epsilon = 0.1f; + +uniform vec3 sphere_pos = vec3(0.2f, -0.2f, -0.1f); +uniform vec3 cube_pos = vec3(0.3f, 0, 0); +uniform vec3 plane_dir = vec3(0, 1.0f, 0); + +// polynomial smooth min +float sminCubic( float a, float b, float k ) +{ + float h = max( k-abs(a-b), 0.0 )/k; + return min( a, b ) - h*h*h*k*(1.0/6.0); +} + +float intersectSDF(float distA, float distB) { + return max(distA, distB); +} + +float unionSDF(float distA, float distB) { + return min(distA, distB); +} + +float differenceSDF(float distA, float distB) { + return max(distA, -distB); +} + +void vertex() { + //POSITION = vec4(VERTEX, 1.0); +} + +float sdEllipsoid( vec3 p, vec3 r ) { + float k0 = length(p/r); + float k1 = length(p/(r*r)); + return (k0<1.0) ? (k0-1.0)*min(min(r.x,r.y),r.z) : k0*(k0-1.0)/k1; +} + +float sdPlane(vec3 p, vec3 n, float h) { + return dot(n, p) + h; +} + +float sdBox( vec3 b, vec3 p ) { + vec3 q = abs(p) - b; + return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); +} + +float dstFromSphere(vec3 target, vec3 pos, float r) { + return distance(target, pos) - r; +} + +float sdVerticalCapsule( vec3 p, float h, float r ) { + p.y -= clamp( p.y, 0.0, h ); + return length( p ) - r; +} + +float get_distance(vec3 p) { + //return sdEllipsoid(p + sphere_pos, vec3(0.01f, 0.01f, 0.015f)); + //return sdVerticalCapsule(p + sphere_pos, 0.015f, 0.01f); + return sminCubic( + sdVerticalCapsule(p + sphere_pos, 0.015f, 0.01f), + sdVerticalCapsule(p + cube_pos, 0.015f, 0.01f), + epsilon + ); + /*return sminCubic( + sdBox(vec3(0.2f), p + cube_pos), + //sdPlane(p + cube_pos, plane_dir, 0), + //dstFromSphere(p + sphere_pos, vec3(0), 0.199f), + sdEllipsoid(p + sphere_pos, vec3(0.01f, 0.01f, 0.015f)), + epsilon + );*/ + /*return sminCubic( + sdEllipsoid(p + cube_pos, vec3(0.01f, 0.01f, 0.015f)), + sdEllipsoid(p + sphere_pos, vec3(0.01f, 0.01f, 0.015f)), + 0.1 + );*/ +} + +vec3 get_normal(vec3 p) { + vec2 e = vec2(1e-5, 0); + + vec3 n = get_distance(p) - vec3( + get_distance(p - e.xyy), + get_distance(p - e.yxy), + get_distance(p - e.yyx) + ); + + return normalize(n); +} + +vec4 rayMarch(vec3 orig, vec3 dir) { + vec3 sphere_orig = vec3(0, 0, 0); + float dst = get_distance(orig); + int inc = 0; + for (int i = 0; i < max_iterations; i++) { + if (dst <= threshold && !disable_threshold) { + break; + } + orig += dst * dir; + dst = get_distance(orig); + } + + if (dst <= threshold) { + // We touched a shape + return vec4(orig, 1.0f); + } + else { + // Render some white transparent background so we can still see the quad + return vec4(vec3(1), 0); + } +} + +void fragment() { + vec2 uv = SCREEN_UV * 2.0 - 1.0; + vec4 camera = INV_VIEW_MATRIX * INV_PROJECTION_MATRIX * vec4(uv, 1, 1); + + vec3 orig = INV_VIEW_MATRIX[3].xyz; + vec3 dir = normalize(camera.xyz); + + vec4 point = rayMarch(orig, dir); + + // Render white transparent background by default + vec4 col = vec4(1, 1, 1, 0.1f); + + // The w member of the vec4 is used to convey that we hit something. + // Let put a colour on that and compute the normal + if (point.w > 0.0f) { + col = colour; + col.a = point.w; + NORMAL = (vec4(get_normal(point.xyz), 1) * INV_VIEW_MATRIX).xyz; + } + + ALPHA = col.a; + ALBEDO = col.rgb; +} \ No newline at end of file diff --git a/RayMarching.tres b/RayMarching.tres new file mode 100644 index 0000000..2c87122 --- /dev/null +++ b/RayMarching.tres @@ -0,0 +1,15 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://bjaju04p8dibc"] + +[ext_resource type="Shader" path="res://RayMarching.gdshader" id="1_lgue0"] + +[resource] +render_priority = 0 +shader = ExtResource("1_lgue0") +shader_parameter/disable_threshold = true +shader_parameter/threshold = 0.001 +shader_parameter/max_iterations = 300 +shader_parameter/colour = Color(0.988235, 0.529412, 0.988235, 1) +shader_parameter/epsilon = 0.05 +shader_parameter/sphere_pos = Vector3(0, -0.0428429, -0.00133324) +shader_parameter/cube_pos = Vector3(0, 0, 0) +shader_parameter/plane_dir = Vector3(0, 0, 0) diff --git a/RayMarching.tscn b/RayMarching.tscn new file mode 100644 index 0000000..dbeec5e --- /dev/null +++ b/RayMarching.tscn @@ -0,0 +1,51 @@ +[gd_scene load_steps=8 format=3 uid="uid://3ulakdj5yski"] + +[ext_resource type="Material" uid="uid://bjaju04p8dibc" path="res://RayMarching.tres" id="2_mld7j"] +[ext_resource type="Script" path="res://FreeLookCamera.gd" id="2_vgmbw"] +[ext_resource type="Script" path="res://Points.gd" id="3_uwkra"] + +[sub_resource type="QuadMesh" id="QuadMesh_k5f3w"] +material = ExtResource("2_mld7j") +size = Vector2(2, 2) + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_uqjfj"] + +[sub_resource type="Sky" id="Sky_ovm7d"] +sky_material = SubResource("ProceduralSkyMaterial_uqjfj") + +[sub_resource type="Environment" id="Environment_ujk77"] +background_mode = 2 +sky = SubResource("Sky_ovm7d") + +[node name="RayMarching" type="Node3D"] + +[node name="CSGSphere3D" type="CSGSphere3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.26359, 0, 0) +radial_segments = 64 +rings = 64 + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.34284) +script = ExtResource("2_vgmbw") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Camera3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.34284) +mesh = SubResource("QuadMesh_k5f3w") +skeleton = NodePath("../..") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.563065, 0.604085, -0.56395, 1.89847e-08, 0.682407, 0.730973, 0.826413, -0.411585, 0.384239, 0, 2.90305, 0) + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_ujk77") + +[node name="Points" type="Node3D" parent="."] +script = ExtResource("3_uwkra") +sphere = NodePath("Sphere") +cube = NodePath("Cube") +material = ExtResource("2_mld7j") + +[node name="Sphere" type="Node3D" parent="Points"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0428429, 0.00133324) + +[node name="Cube" type="Node3D" parent="Points"] diff --git a/SoapBubble.tscn b/SoapBubble.tscn new file mode 100644 index 0000000..e579f97 --- /dev/null +++ b/SoapBubble.tscn @@ -0,0 +1,69 @@ +[gd_scene load_steps=11 format=3 uid="uid://dfuaaaimxo810"] + +[ext_resource type="PackedScene" uid="uid://sft6mp442uxe" path="res://models/icosphere.glb" id="1_dqpwr"] +[ext_resource type="Material" uid="uid://ccjdj6yfj5gfg" path="res://materials/soap.tres" id="2_em4sg"] +[ext_resource type="Texture2D" uid="uid://s3urfbs8wl8d" path="res://textures/AllSkyFree_Sky_EpicBlueSunset_Equirect.png" id="3_jmgiy"] +[ext_resource type="Script" path="res://FreeLookCamera.gd" id="4_at5xm"] +[ext_resource type="PackedScene" uid="uid://b0ht1ye2dpq51" path="res://models/weird_bubble.blend" id="5_u12t1"] + +[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_su7nb"] +panorama = ExtResource("3_jmgiy") + +[sub_resource type="Sky" id="Sky_gjovo"] +sky_material = SubResource("PanoramaSkyMaterial_su7nb") +radiance_size = 6 + +[sub_resource type="Environment" id="Environment_mjq32"] +background_mode = 2 +sky = SubResource("Sky_gjovo") +ambient_light_source = 3 +reflected_light_source = 2 +tonemap_mode = 3 +tonemap_exposure = 0.5 +sdfgi_enabled = true +sdfgi_use_occlusion = true +glow_enabled = true + +[sub_resource type="SphereShape3D" id="SphereShape3D_f3t7v"] +radius = 0.2 + +[sub_resource type="SphereMesh" id="SphereMesh_wf6pm"] + +[node name="SoapBubble" type="Node3D"] + +[node name="icosphere2" parent="." instance=ExtResource("1_dqpwr")] + +[node name="Icosphere" parent="icosphere2" index="0"] +material_override = ExtResource("2_em4sg") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 10, 0) + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_mjq32") + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(-0.777113, 0, -0.629361, 0, 1, 0, 0.629361, 0, -0.777113, 0, -0.556943, 1.45498) +script = ExtResource("4_at5xm") + +[node name="RigidBody3D" type="RigidBody3D" parent="Camera3D"] +freeze = true +freeze_mode = 1 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Camera3D/RigidBody3D"] +shape = SubResource("SphereShape3D_f3t7v") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.89841) +visible = false +material_override = ExtResource("2_em4sg") +mesh = SubResource("SphereMesh_wf6pm") + +[node name="weird_bubble" parent="." instance=ExtResource("5_u12t1")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -6.19148) + +[node name="Mball004" parent="weird_bubble" index="0"] +material_override = ExtResource("2_em4sg") + +[editable path="icosphere2"] +[editable path="weird_bubble"] diff --git a/Test.tres b/Test.tres index 6129c76..44eefff 100644 --- a/Test.tres +++ b/Test.tres @@ -1,4 +1,4 @@ -[gd_resource type="VisualShader" load_steps=19 format=3 uid="uid://dotlcmfer5kxw"] +[gd_resource type="VisualShader" load_steps=20 format=3 uid="uid://dotlcmfer5kxw"] [ext_resource type="Texture2D" uid="uid://dxcmick7pytlf" path="res://noise.tres" id="1_xedsf"] @@ -51,6 +51,8 @@ op_type = 3 [sub_resource type="VisualShaderNodeVectorOp" id="VisualShaderNodeVectorOp_gb7li"] operator = 2 +[sub_resource type="VisualShaderNodeExpression" id="VisualShaderNodeExpression_1868y"] + [sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_b0p1s"] output_port_for_preview = 0 expanded_output_ports = [0] @@ -92,7 +94,6 @@ void vertex() { // Texture2D:5 vec4 n_out5p0 = texture(tex_vtx_5, UV); - float n_out5p1 = n_out5p0.r; // VectorOp:11 @@ -134,7 +135,7 @@ void vertex() { } " -graph_offset = Vector2(-1143.06, -151.487) +graph_offset = Vector2(-401.502, 311.459) nodes/vertex/0/position = Vector2(1580, 120) nodes/vertex/3/node = SubResource("VisualShaderNodeInput_7j14n") nodes/vertex/3/position = Vector2(-1340, 260) @@ -166,4 +167,10 @@ nodes/vertex/30/node = SubResource("VisualShaderNodeMix_vyit1") nodes/vertex/30/position = Vector2(-500, -260) nodes/vertex/31/node = SubResource("VisualShaderNodeVectorOp_gb7li") nodes/vertex/31/position = Vector2(780, -80) +nodes/vertex/39/node = SubResource("VisualShaderNodeExpression_1868y") +nodes/vertex/39/position = Vector2(3260, 2960) +nodes/vertex/39/size = Vector2(0, 0) +nodes/vertex/39/input_ports = "" +nodes/vertex/39/output_ports = "" +nodes/vertex/39/expression = "" nodes/vertex/connections = PackedInt32Array(3, 0, 14, 0, 3, 0, 15, 1, 11, 0, 16, 0, 16, 0, 12, 1, 15, 0, 21, 0, 5, 0, 11, 1, 21, 0, 11, 0, 23, 0, 22, 2, 22, 0, 15, 0, 22, 0, 12, 0, 14, 0, 22, 1, 3, 0, 22, 0, 27, 0, 16, 1, 29, 0, 30, 0, 23, 0, 30, 2, 12, 0, 0, 0, 21, 0, 30, 1, 30, 0, 31, 0, 31, 0, 0, 1, 19, 0, 31, 1) diff --git a/materials/basic.tres b/materials/basic.tres new file mode 100644 index 0000000..6a5443d --- /dev/null +++ b/materials/basic.tres @@ -0,0 +1,3 @@ +[gd_resource type="StandardMaterial3D" format=3 uid="uid://csj153xgrrjd1"] + +[resource] diff --git a/materials/plane.tres b/materials/plane.tres new file mode 100644 index 0000000..fb01c27 --- /dev/null +++ b/materials/plane.tres @@ -0,0 +1,4 @@ +[gd_resource type="StandardMaterial3D" format=3 uid="uid://cxfvkn1l35sna"] + +[resource] +cull_mode = 2 diff --git a/materials/soap.tres b/materials/soap.tres new file mode 100644 index 0000000..3610885 --- /dev/null +++ b/materials/soap.tres @@ -0,0 +1,16 @@ +[gd_resource type="ShaderMaterial" load_steps=4 format=3 uid="uid://ccjdj6yfj5gfg"] + +[ext_resource type="Shader" path="res://shaders/soap.gdshader" id="1_4akdf"] +[ext_resource type="Texture2D" uid="uid://2i2g7306xmrh" path="res://textures/Soap.png" id="2_aijul"] +[ext_resource type="Texture2D" uid="uid://dxcmick7pytlf" path="res://noise.tres" id="3_ru46l"] + +[resource] +render_priority = 0 +shader = ExtResource("1_4akdf") +shader_parameter/thickness = 500.0 +shader_parameter/alpha = 0.35 +shader_parameter/metallic = 1.0 +shader_parameter/roughness = 0.6 +shader_parameter/gravity_strength = 350.0 +shader_parameter/gradient = ExtResource("2_aijul") +shader_parameter/noise = ExtResource("3_ru46l") diff --git a/models/icosphere.glb b/models/icosphere.glb new file mode 100644 index 0000000..fea7405 Binary files /dev/null and b/models/icosphere.glb differ diff --git a/models/icosphere.glb.import b/models/icosphere.glb.import new file mode 100644 index 0000000..d5acf74 --- /dev/null +++ b/models/icosphere.glb.import @@ -0,0 +1,30 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://sft6mp442uxe" +path="res://.godot/imported/icosphere.glb-fe561c341942b5de3c68acb46c901bbd.scn" + +[deps] + +source_file="res://models/icosphere.glb" +dest_files=["res://.godot/imported/icosphere.glb-fe561c341942b5de3c68acb46c901bbd.scn"] + +[params] + +nodes/root_type="Node3D" +nodes/root_name="Scene Root" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +import_script/path="" +_subresources={} diff --git a/models/plane.blend b/models/plane.blend new file mode 100644 index 0000000..24bdaa0 Binary files /dev/null and b/models/plane.blend differ diff --git a/models/plane.blend.import b/models/plane.blend.import new file mode 100644 index 0000000..3f04d2b --- /dev/null +++ b/models/plane.blend.import @@ -0,0 +1,46 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://blp2ftypsofyd" +path="res://.godot/imported/plane.blend-42f3e2f3465244747390ade5d653d64d.scn" + +[deps] + +source_file="res://models/plane.blend" +dest_files=["res://.godot/imported/plane.blend-42f3e2f3465244747390ade5d653d64d.scn"] + +[params] + +nodes/root_type="Node3D" +nodes/root_name="Scene Root" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +import_script/path="" +_subresources={} +blender/nodes/visible=0 +blender/nodes/punctual_lights=true +blender/nodes/cameras=true +blender/nodes/custom_properties=true +blender/nodes/modifiers=1 +blender/meshes/colors=false +blender/meshes/uvs=true +blender/meshes/normals=true +blender/meshes/tangents=true +blender/meshes/skins=2 +blender/meshes/export_bones_deforming_mesh_only=false +blender/materials/unpack_enabled=true +blender/materials/export_materials=1 +blender/animation/limit_playback=true +blender/animation/always_sample=true +blender/animation/group_tracks=true diff --git a/models/weird_bubble.blend b/models/weird_bubble.blend new file mode 100644 index 0000000..a88f848 Binary files /dev/null and b/models/weird_bubble.blend differ diff --git a/models/weird_bubble.blend.import b/models/weird_bubble.blend.import new file mode 100644 index 0000000..fca9040 --- /dev/null +++ b/models/weird_bubble.blend.import @@ -0,0 +1,53 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://b0ht1ye2dpq51" +path="res://.godot/imported/weird_bubble.blend-63d9183565e6083cf72d44e55c587755.scn" + +[deps] + +source_file="res://models/weird_bubble.blend" +dest_files=["res://.godot/imported/weird_bubble.blend-63d9183565e6083cf72d44e55c587755.scn"] + +[params] + +nodes/root_type="Node3D" +nodes/root_name="Scene Root" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +import_script/path="" +_subresources={ +"materials": { +"@MATERIAL:0": { +"use_external/enabled": true, +"use_external/path": "res://materials/soap.tres" +} +} +} +blender/nodes/visible=0 +blender/nodes/punctual_lights=true +blender/nodes/cameras=true +blender/nodes/custom_properties=true +blender/nodes/modifiers=1 +blender/meshes/colors=false +blender/meshes/uvs=true +blender/meshes/normals=true +blender/meshes/tangents=true +blender/meshes/skins=2 +blender/meshes/export_bones_deforming_mesh_only=false +blender/materials/unpack_enabled=true +blender/materials/export_materials=1 +blender/animation/limit_playback=true +blender/animation/always_sample=true +blender/animation/group_tracks=true diff --git a/models/weird_bubble.blend1 b/models/weird_bubble.blend1 new file mode 100644 index 0000000..73b0b24 Binary files /dev/null and b/models/weird_bubble.blend1 differ diff --git a/noise.tres b/noise.tres index d12734e..2743f37 100644 --- a/noise.tres +++ b/noise.tres @@ -3,4 +3,5 @@ [sub_resource type="FastNoiseLite" id="FastNoiseLite_66eei"] [resource] +seamless = true noise = SubResource("FastNoiseLite_66eei") diff --git a/project.godot b/project.godot index c50e4c3..f108943 100644 --- a/project.godot +++ b/project.godot @@ -11,5 +11,6 @@ config_version=5 [application] config/name="Shaders" +run/main_scene="res://RayMarching.tscn" config/features=PackedStringArray("4.0", "Forward Plus") config/icon="res://icon.svg" diff --git a/textures/AllSkyFree_Sky_EpicBlueSunset_Equirect.png b/textures/AllSkyFree_Sky_EpicBlueSunset_Equirect.png new file mode 100644 index 0000000..f804408 Binary files /dev/null and b/textures/AllSkyFree_Sky_EpicBlueSunset_Equirect.png differ diff --git a/textures/AllSkyFree_Sky_EpicBlueSunset_Equirect.png.import b/textures/AllSkyFree_Sky_EpicBlueSunset_Equirect.png.import new file mode 100644 index 0000000..3356787 --- /dev/null +++ b/textures/AllSkyFree_Sky_EpicBlueSunset_Equirect.png.import @@ -0,0 +1,36 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://s3urfbs8wl8d" +path.s3tc="res://.godot/imported/AllSkyFree_Sky_EpicBlueSunset_Equirect.png-153896cd68204db74e699536a5e343fb.s3tc.ctex" +path.etc2="res://.godot/imported/AllSkyFree_Sky_EpicBlueSunset_Equirect.png-153896cd68204db74e699536a5e343fb.etc2.ctex" +metadata={ +"imported_formats": ["s3tc", "etc2"], +"vram_texture": true +} + +[deps] + +source_file="res://textures/AllSkyFree_Sky_EpicBlueSunset_Equirect.png" +dest_files=["res://.godot/imported/AllSkyFree_Sky_EpicBlueSunset_Equirect.png-153896cd68204db74e699536a5e343fb.s3tc.ctex", "res://.godot/imported/AllSkyFree_Sky_EpicBlueSunset_Equirect.png-153896cd68204db74e699536a5e343fb.etc2.ctex"] + +[params] + +compress/mode=2 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/textures/Soap.png b/textures/Soap.png new file mode 100644 index 0000000..7b25947 Binary files /dev/null and b/textures/Soap.png differ diff --git a/textures/Soap.png.import b/textures/Soap.png.import new file mode 100644 index 0000000..e4530a4 --- /dev/null +++ b/textures/Soap.png.import @@ -0,0 +1,36 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://2i2g7306xmrh" +path.s3tc="res://.godot/imported/Soap.png-8dda8f6b63aa540ff2eba1a5c7eefb96.s3tc.ctex" +path.etc2="res://.godot/imported/Soap.png-8dda8f6b63aa540ff2eba1a5c7eefb96.etc2.ctex" +metadata={ +"imported_formats": ["s3tc", "etc2"], +"vram_texture": true +} + +[deps] + +source_file="res://textures/Soap.png" +dest_files=["res://.godot/imported/Soap.png-8dda8f6b63aa540ff2eba1a5c7eefb96.s3tc.ctex", "res://.godot/imported/Soap.png-8dda8f6b63aa540ff2eba1a5c7eefb96.etc2.ctex"] + +[params] + +compress/mode=2 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/vertical_noise.tres b/vertical_noise.tres new file mode 100644 index 0000000..33f4e7b --- /dev/null +++ b/vertical_noise.tres @@ -0,0 +1,5 @@ +[gd_resource type="FastNoiseLite" format=3 uid="uid://ciqwjntd6xw48"] + +[resource] +domain_warp_enabled = true +domain_warp_amplitude = 100.0