Island Update
This commit is contained in:
parent
ab688ccbbc
commit
271412d932
|
@ -0,0 +1,3 @@
|
|||
[*.{cs,vb}]
|
||||
|
||||
dotnet_naming_rule.*.severity = none
|
|
@ -3,33 +3,33 @@
|
|||
[ext_resource type="PackedScene" uid="uid://dxopbum6c606y" path="res://Packed/Setup/Application.tscn" id="1_3xlgt"]
|
||||
[ext_resource type="PackedScene" uid="uid://cldwxu6bbswx7" path="res://Packed/Dark World/Dark World.tscn" id="2_kftla"]
|
||||
[ext_resource type="Resource" uid="uid://ch5nsa6yafs5l" path="res://addons/rokojori_action_library/Runtime/Time/TimeLines/GameTime.tres" id="3_bdt4g"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/Shake/Shake.cs" id="10_rtx5p"]
|
||||
[ext_resource type="Script" uid="uid://bkefj5g5km2ao" path="res://addons/rokojori_action_library/Runtime/Animation/Shake/Shake.cs" id="10_rtx5p"]
|
||||
[ext_resource type="Resource" uid="uid://c2wbn25rxynk8" path="res://addons/rokojori_action_library/Runtime/Animation/Shake/Presets/Small Impact Low FPS - Shake.tres" id="11_a32tl"]
|
||||
[ext_resource type="Resource" uid="uid://begmg64jiaoq0" path="res://addons/rokojori_action_library/Runtime/Animation/Shake/Presets/Mini Poke - Shake.tres" id="11_kv57l"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Interactions/Grabbable.cs" id="12_tevia"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Procedural/Parametric/Cuboid/Cuboid.cs" id="18_6u4rt"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Actions/Sequence/Parallel.cs" id="24_vsk86"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Actions/Time/Delay.cs" id="26_imrh7"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleLabel3D.cs" id="28_tlgxg"]
|
||||
[ext_resource type="Script" uid="uid://dsfymubxsimx2" path="res://addons/rokojori_action_library/Runtime/Interactions/Grabbable.cs" id="12_tevia"]
|
||||
[ext_resource type="Script" uid="uid://b1lw6t0yp13lq" path="res://addons/rokojori_action_library/Runtime/Procedural/Parametric/Cuboid/Cuboid.cs" id="18_6u4rt"]
|
||||
[ext_resource type="Script" uid="uid://drx2l2e81di4h" path="res://addons/rokojori_action_library/Runtime/Actions/Sequence/Parallel.cs" id="24_vsk86"]
|
||||
[ext_resource type="Script" uid="uid://dox0mfbihokfo" path="res://addons/rokojori_action_library/Runtime/Actions/Time/Delay.cs" id="26_imrh7"]
|
||||
[ext_resource type="Script" uid="uid://b5rxovdepmpnu" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleLabel3D.cs" id="28_tlgxg"]
|
||||
[ext_resource type="Resource" uid="uid://cptsuefrom6wu" path="res://Research/Hello World.tres" id="29_e5hcu"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Godot/Scenes/SceneFileReader.cs" id="30_gswu4"]
|
||||
[ext_resource type="Script" uid="uid://ny4r8f87b8po" path="res://addons/rokojori_action_library/Runtime/Godot/Scenes/SceneFileReader.cs" id="30_gswu4"]
|
||||
[ext_resource type="PackedScene" uid="uid://igjwcq828c3x" path="res://Packed/Character/character.glb" id="34_iqgaf"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Actions/ActionList.cs" id="36_48c1t"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/Flash/Flash.cs" id="37_jrcib"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Interactions/Pointable.cs" id="38_iknbl"]
|
||||
[ext_resource type="Script" uid="uid://d2kukvsokpevq" path="res://addons/rokojori_action_library/Runtime/Actions/ActionList.cs" id="36_48c1t"]
|
||||
[ext_resource type="Script" uid="uid://c8xk2x8xgkpce" path="res://addons/rokojori_action_library/Runtime/Animation/Flash/Flash.cs" id="37_jrcib"]
|
||||
[ext_resource type="Script" uid="uid://bip7ficujepw8" path="res://addons/rokojori_action_library/Runtime/Interactions/Pointable.cs" id="38_iknbl"]
|
||||
[ext_resource type="Resource" uid="uid://bfxwx0fiejnk3" path="res://addons/rokojori_action_library/Runtime/Animation/Flash/Presets/Blue Shield - Flash.tres" id="39_1edeu"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Interactions/Interactable.cs" id="44_4apug"]
|
||||
[ext_resource type="Script" uid="uid://qfenwgjjavbr" path="res://addons/rokojori_action_library/Runtime/Interactions/Interactable.cs" id="44_4apug"]
|
||||
[ext_resource type="Resource" uid="uid://drjdsp2qnceql" path="res://addons/rokojori_action_library/Runtime/Animation/Flash/Presets/Green Charge - Flash.tres" id="49_td0wp"]
|
||||
[ext_resource type="Resource" uid="uid://d06w8jorebto2" path="res://addons/rokojori_action_library/Runtime/Animation/Flash/Presets/Orange Boost - Flash.tres" id="50_uj384"]
|
||||
[ext_resource type="Resource" uid="uid://pok7bfoksfmr" path="res://addons/rokojori_action_library/Runtime/Animation/Flash/Presets/White Blinking - Flash.tres" id="51_iktfu"]
|
||||
[ext_resource type="Resource" uid="uid://cwdnm658q3jta" path="res://addons/rokojori_action_library/Runtime/Animation/Flash/Presets/Red Hit - Flash.tres" id="52_pmlj5"]
|
||||
[ext_resource type="Material" uid="uid://crki78c10w11u" path="res://Research/RainbowMaterial.material" id="54_tihw8"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/Rotate.cs" id="55_67hvr"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Actions/ActionSequence.cs" id="56_nd25v"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/VirtualCameras/Effects/PlayCameraEffect.cs" id="57_2ytre"]
|
||||
[ext_resource type="Script" uid="uid://8mbha1fcs3ty" path="res://addons/rokojori_action_library/Runtime/Animation/Rotate.cs" id="55_67hvr"]
|
||||
[ext_resource type="Script" uid="uid://bbrxyifjx4fit" path="res://addons/rokojori_action_library/Runtime/Actions/ActionSequence.cs" id="56_nd25v"]
|
||||
[ext_resource type="Script" uid="uid://butjmu7ygyupl" path="res://addons/rokojori_action_library/Runtime/VirtualCameras/Effects/PlayCameraEffect.cs" id="57_2ytre"]
|
||||
[ext_resource type="Resource" uid="uid://uyuplc6hm25j" path="res://addons/rokojori_action_library/Runtime/VirtualCameras/Effects/Presets/ScreenShake.tres" id="58_gwjbe"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Time/ModulateTimeLineSpeed.cs" id="59_nluph"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Animation/AnimationCurve.cs" id="60_u7bgt"]
|
||||
[ext_resource type="Script" uid="uid://bna0cq2rqt1v7" path="res://addons/rokojori_action_library/Runtime/Time/ModulateTimeLineSpeed.cs" id="59_nluph"]
|
||||
[ext_resource type="Script" uid="uid://c1o3bxnc8dwuh" path="res://addons/rokojori_action_library/Runtime/Animation/AnimationCurve.cs" id="60_u7bgt"]
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_2m7yo"]
|
||||
_surfaces = [{
|
||||
|
@ -181,7 +181,7 @@ _surfaces = [{
|
|||
[sub_resource type="BoxShape3D" id="BoxShape3D_hs17q"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_wlnjp"]
|
||||
max_value = 2.0
|
||||
_limits = [0.0, 2.0, 0.0, 1.0]
|
||||
_data = [Vector2(0, 1), 0.0, -21.7817, 0, 1, Vector2(0.0441176, 0.0390418), 0.0, 0.0, 0, 0, Vector2(0.504902, 0.085182), 0.0, 0.0, 0, 0, Vector2(1, 1), 1.84775, 0.0, 1, 0]
|
||||
point_count = 4
|
||||
|
||||
|
@ -485,7 +485,7 @@ output = NodePath("Node3D/MeshInstance3D")
|
|||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Node3D" type="Node3D" parent="Flash Examples/Special Cube"]
|
||||
transform = Transform3D(0.963173, 0, -0.268877, 0, 1, 0, 0.268877, 0, 0.963173, 0, 0, 0)
|
||||
transform = Transform3D(0.0254748, 0, -0.999674, 0, 1, 0, 0.999674, 0, 0.0254748, 0, 0, 0)
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Flash Examples/Special Cube/Node3D"]
|
||||
transform = Transform3D(-0.707107, 0.707107, 0, -0.566941, -0.566941, -0.597625, -0.422585, -0.422585, 0.801776, 0, 0.5, 0)
|
||||
|
@ -635,7 +635,7 @@ text = "Lasfkasl"
|
|||
|
||||
[node name="LocaleLabel3D" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.549893, 0)
|
||||
text = "Hello World!"
|
||||
text = "Hallo Welt!"
|
||||
script = ExtResource("28_tlgxg")
|
||||
locale = ExtResource("29_e5hcu")
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ nodes/root_name=""
|
|||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,30 @@
|
|||
|
||||
// NOTE: Shader automatically converted from Godot Engine 4.4.stable.mono's PanoramaSkyMaterial.
|
||||
|
||||
shader_type sky;
|
||||
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Noise.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Light.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc"
|
||||
|
||||
uniform sampler2D source_panorama : filter_linear, source_color, hint_default_black;
|
||||
uniform float exposure : hint_range(0, 128) = 1.0;
|
||||
uniform float yScale = 1;
|
||||
uniform float yOffset = 1;
|
||||
uniform vec3 hslOffset;
|
||||
uniform sampler2D hslOffsetAmount;
|
||||
|
||||
uniform vec3 skyTint: source_color;
|
||||
|
||||
void sky()
|
||||
{
|
||||
vec2 skyUV = SKY_COORDS * vec2( 1 , yScale ) + vec2( 0, yOffset );
|
||||
vec3 color = texture(source_panorama, skyUV ).rgb * exposure;
|
||||
vec3 hsl = RGBtoHSL( color ) + hslOffset;
|
||||
hsl.r = mod( hsl.r, 1 );
|
||||
float hslAmount = texture( hslOffsetAmount, SKY_COORDS ).r;
|
||||
color = mix( color, HSLtoRGB( hsl ), hslAmount );
|
||||
COLOR = color * skyTint;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
uid://cvj3yhhpc8ivs
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,182 @@
|
|||
// NOTE: Shader automatically converted from Godot Engine 4.4.stable.mono's StandardMaterial3D.
|
||||
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;
|
||||
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Noise.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Light.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Textures.gdshaderinc"
|
||||
|
||||
uniform vec4 albedo : source_color;
|
||||
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
|
||||
uniform ivec2 albedo_texture_size;
|
||||
uniform float point_size : hint_range(0.1, 128.0, 0.1);
|
||||
|
||||
uniform sampler2D terrain : filter_linear_mipmap, repeat_enable;
|
||||
uniform sampler2D terrainNormal : filter_linear_mipmap, repeat_enable;
|
||||
uniform float terrainNormalScaling: hint_range(0.5,10);
|
||||
uniform vec3 terrainSize;
|
||||
uniform vec3 terrainOffset;
|
||||
uniform float terrainMaxHeight = 500;
|
||||
varying vec2 terrainUV;
|
||||
uniform float texel = 1;
|
||||
uniform float texelSpread = 2;
|
||||
uniform float texelVertexSpread = 2;
|
||||
uniform float texelVertexSpreadCamDistance = 2000;
|
||||
uniform float texelVertexSpreadCamPower = 1;
|
||||
uniform float texelVertexSpreadCamAmount = 1;
|
||||
uniform float texelVertexSpreadWeight = 1;
|
||||
uniform float texelNormalScale = 100;
|
||||
|
||||
uniform float roughness : hint_range(0.0, 1.0);
|
||||
uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable;
|
||||
uniform vec4 metallic_texture_channel;
|
||||
uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable;
|
||||
|
||||
uniform float specular : hint_range(0.0, 1.0, 0.01);
|
||||
uniform float metallic : hint_range(0.0, 1.0, 0.01);
|
||||
|
||||
uniform sampler2D texture_normal : hint_roughness_normal, filter_linear_mipmap, repeat_enable;
|
||||
uniform float normal_scale : hint_range(-16.0, 16.0);
|
||||
uniform float normalMinDistance = 5;
|
||||
uniform float normalMaxDistance = 100;
|
||||
uniform float normalMinValue = 0.5;
|
||||
uniform float normalMaxValue = 1;
|
||||
|
||||
uniform float rim : hint_range(0.0, 1.0, 0.01);
|
||||
uniform float rim_tint : hint_range(0.0, 1.0, 0.01);
|
||||
uniform sampler2D texture_rim : hint_default_white, filter_linear_mipmap, repeat_enable;
|
||||
|
||||
uniform sampler2D texture_detail_albedo : source_color, filter_linear_mipmap, repeat_enable;
|
||||
uniform sampler2D texture_detail_normal : hint_normal, filter_linear_mipmap, repeat_enable;
|
||||
uniform sampler2D texture_detail_mask : hint_default_white, filter_linear_mipmap, repeat_enable;
|
||||
|
||||
uniform sampler2D texture_heightmap : hint_default_black, filter_linear_mipmap, repeat_enable;
|
||||
uniform float heightmap_scale : hint_range(-16.0, 16.0, 0.001);
|
||||
uniform int heightmap_min_layers : hint_range(1, 64);
|
||||
uniform int heightmap_max_layers : hint_range(1, 64);
|
||||
uniform vec2 heightmap_flip;
|
||||
varying vec3 uv1_triplanar_pos;
|
||||
varying vec3 uv2_triplanar_pos;
|
||||
|
||||
uniform float uv1_blend_sharpness : hint_range(0.0, 150.0, 0.001);
|
||||
varying vec3 uv1_power_normal;
|
||||
uniform float uv2_blend_sharpness : hint_range(0.0, 150.0, 0.001);
|
||||
varying vec3 uv2_power_normal;
|
||||
|
||||
uniform vec3 uv1_scale;
|
||||
uniform vec3 uv1_offset;
|
||||
uniform vec3 uv2_scale;
|
||||
uniform vec3 uv2_offset;
|
||||
varying float cameraDistanceFactor;
|
||||
|
||||
uniform float terrainUVScale = 1;
|
||||
|
||||
void vertex()
|
||||
{
|
||||
vec3 normal = NORMAL;
|
||||
|
||||
TANGENT = vec3(0.0, 0.0, -1.0) * abs(normal.x);
|
||||
TANGENT += vec3(1.0, 0.0, 0.0) * abs(normal.y);
|
||||
TANGENT += vec3(1.0, 0.0, 0.0) * abs(normal.z);
|
||||
TANGENT = normalize(TANGENT);
|
||||
|
||||
BINORMAL = vec3(0.0, 1.0, 0.0) * abs(normal.x);
|
||||
BINORMAL += vec3(0.0, 0.0, -1.0) * abs(normal.y);
|
||||
BINORMAL += vec3(0.0, 1.0, 0.0) * abs(normal.z);
|
||||
BINORMAL = normalize(BINORMAL);
|
||||
|
||||
// UV1 Triplanar: Enabled
|
||||
uv1_power_normal = pow(abs(NORMAL), vec3(uv1_blend_sharpness));
|
||||
uv1_triplanar_pos = VERTEX * uv1_scale + uv1_offset;
|
||||
uv1_power_normal /= dot(uv1_power_normal, vec3(1.0));
|
||||
uv1_triplanar_pos *= vec3(1.0, -1.0, 1.0);
|
||||
|
||||
// UV2 Triplanar: Enabled (with World Triplanar)
|
||||
uv2_power_normal = pow(abs(mat3(MODEL_MATRIX) * NORMAL), vec3(uv2_blend_sharpness));
|
||||
uv2_triplanar_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz * uv2_scale + uv2_offset;
|
||||
uv2_power_normal /= dot(uv2_power_normal, vec3(1.0));
|
||||
uv2_triplanar_pos *= vec3(1.0, -1.0, 1.0);
|
||||
|
||||
vec3 worldPosition = localToWorld( VERTEX, MODEL_MATRIX );
|
||||
terrainUV = heightMapUV( worldPosition, terrainSize, terrainOffset );
|
||||
//vec4 heightMapData = texture( terrain, terrainUV );
|
||||
float tx = texelVertexSpread / 2048.0;
|
||||
|
||||
vec3 camPosWorld = ( vec4( 0, 0, 0, 1 ) * INV_VIEW_MATRIX ).xyz;
|
||||
float cameraDistance = length( worldPosition - CAMERA_POSITION_WORLD );
|
||||
float txCam = texelVertexSpreadCamAmount * pow( cameraDistance / texelVertexSpreadCamDistance, texelVertexSpreadCamPower );
|
||||
txCam /= 2048.0;
|
||||
txCam = min( txCam, 1.0/100.0 );
|
||||
vec4 heightMapData = fromHeightMapSmoothed( terrain, terrainUV, vec2( tx + txCam ), texelVertexSpreadWeight );
|
||||
UV = terrainUV * terrainUVScale;
|
||||
|
||||
worldPosition.y += heightMapData.r * terrainMaxHeight;
|
||||
|
||||
|
||||
cameraDistanceFactor = mapClamped( cameraDistance, normalMinDistance, normalMaxDistance, normalMinValue, normalMaxValue );
|
||||
// (dx, dy, dz)
|
||||
|
||||
VERTEX.y += heightMapData.r * terrainMaxHeight;
|
||||
}
|
||||
|
||||
vec4 triplanar_texture(sampler2D p_sampler, vec3 p_weights, vec3 p_triplanar_pos) {
|
||||
vec4 samp = vec4(0.0);
|
||||
samp += texture(p_sampler, p_triplanar_pos.xy) * p_weights.z;
|
||||
samp += texture(p_sampler, p_triplanar_pos.xz) * p_weights.y;
|
||||
samp += texture(p_sampler, p_triplanar_pos.zy * vec2(-1.0, 1.0)) * p_weights.x;
|
||||
return samp;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 base_uv2 = UV2;
|
||||
|
||||
vec4 albedo_tex = triplanar_texture(texture_albedo, uv1_power_normal, uv1_triplanar_pos);
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb;
|
||||
|
||||
float metallic_tex = dot(triplanar_texture(texture_metallic, uv1_power_normal, uv1_triplanar_pos), metallic_texture_channel);
|
||||
METALLIC = metallic_tex * metallic;
|
||||
SPECULAR = specular;
|
||||
|
||||
vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
float roughness_tex = dot(triplanar_texture(texture_roughness, uv1_power_normal, uv1_triplanar_pos), roughness_texture_channel);
|
||||
ROUGHNESS = roughness_tex * roughness;
|
||||
|
||||
float tx = texel / 2048.0;
|
||||
|
||||
// Sample heights at neighboring pixels
|
||||
float hL = texture(terrain, terrainUV - vec2(tx, 0)).r * texelNormalScale;
|
||||
float hR = texture(terrain, terrainUV + vec2(tx, 0)).r * texelNormalScale;
|
||||
float hD = texture(terrain, terrainUV - vec2(0, tx)).r * texelNormalScale;
|
||||
float hU = texture(terrain, terrainUV + vec2(0, tx)).r * texelNormalScale;
|
||||
|
||||
// Compute gradient
|
||||
//NORMAL = normalize( texture( terrainNormal, terrainUV ).rgb - vec3( 0.5, 0.5, 0.5 ) );
|
||||
//NORMAL = normalize(vec3(hL - hR, hD - hU, 2.0));
|
||||
vec3 worldNormal = heightMapNormalSmoothed( terrain, terrainUV, vec2(tx,tx), texelNormalScale, texelSpread );
|
||||
NORMAL = worldToViewDirection( worldNormal, VIEW_MATRIX );
|
||||
NORMAL_MAP = texture( texture_normal, UV ).rgb;
|
||||
// Normal Map: Enabled
|
||||
//NORMAL_MAP = normalize( texture( terrainNormal, terrainUV ).rgb * vec3( 1, terrainNormalScaling, 1 ) );
|
||||
NORMAL_MAP_DEPTH = normal_scale * cameraDistanceFactor;
|
||||
|
||||
// Rim: Enabled
|
||||
/*
|
||||
vec2 rim_tex = triplanar_texture(texture_rim, uv1_power_normal, uv1_triplanar_pos).xy;
|
||||
RIM = rim * rim_tex.x;
|
||||
RIM_TINT = rim_tint * rim_tex.y;
|
||||
*/
|
||||
|
||||
// Detail: Enabled
|
||||
vec4 detail_tex = triplanar_texture(texture_detail_albedo, uv2_power_normal, uv2_triplanar_pos);
|
||||
vec4 detail_norm_tex = triplanar_texture(texture_detail_normal, uv2_power_normal, uv2_triplanar_pos);
|
||||
vec4 detail_mask_tex = triplanar_texture(texture_detail_mask, uv1_power_normal, uv1_triplanar_pos);
|
||||
|
||||
// Detail Blend Mode: Mix
|
||||
vec3 detail = mix(ALBEDO.rgb, detail_tex.rgb, detail_tex.a);
|
||||
vec3 detail_norm = mix(NORMAL_MAP, detail_norm_tex.rgb, detail_tex.a);
|
||||
//NORMAL_MAP = mix(NORMAL_MAP, detail_norm, detail_mask_tex.r);
|
||||
ALBEDO.rgb = mix(ALBEDO.rgb, detail, detail_mask_tex.r);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
uid://duxfvnrr6uh6d
|
|
@ -0,0 +1,100 @@
|
|||
// NOTE: Shader automatically converted from Godot Engine 4.4.stable.mono's StandardMaterial3D.
|
||||
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;
|
||||
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Noise.gdshaderinc"
|
||||
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Light.gdshaderinc"
|
||||
|
||||
|
||||
uniform vec4 albedo : source_color;
|
||||
uniform sampler2D depthTexture:hint_depth_texture;
|
||||
uniform sampler2D screenTexture:hint_screen_texture;
|
||||
|
||||
uniform float roughness : hint_range(0.0, 1.0);
|
||||
uniform float specular : hint_range(0.0, 1.0, 0.01);
|
||||
uniform float metallic : hint_range(0.0, 1.0, 0.01);
|
||||
|
||||
uniform float normal_scale : hint_range(-16.0, 16.0);
|
||||
|
||||
uniform sampler2D waterNoiseOffset : source_color, filter_linear_mipmap, repeat_enable;
|
||||
uniform sampler2D waterNoiseNormal : hint_roughness_normal, filter_linear_mipmap, repeat_enable;
|
||||
uniform float waterNoiseScale;
|
||||
uniform float waterNoiseWaveHeight;
|
||||
uniform vec2 waterNoiseScroll;
|
||||
varying vec2 waterUV;
|
||||
uniform float sinkStart;
|
||||
uniform float sinkEnd;
|
||||
uniform float sinkOffset;
|
||||
uniform float sinkBend: hint_range(0.0, 1.0) = 0.5;
|
||||
uniform vec4 deepWater:source_color;
|
||||
varying float deepWaterAmount;
|
||||
uniform vec4 centerWater:source_color;
|
||||
varying float centerWaterAmount;
|
||||
uniform vec4 fromTopColor:source_color;
|
||||
varying vec3 world_position;
|
||||
uniform float alphaFadeDistance = 10;
|
||||
uniform float albedoFadeDistance = 10;
|
||||
|
||||
void vertex()
|
||||
{
|
||||
|
||||
vec3 worldPosition = ( vec4( VERTEX, 1 ) * MODEL_MATRIX ).xyz;
|
||||
UV = worldPosition.xz * waterNoiseScale + waterNoiseScroll * TIME;
|
||||
float heightAmount = texture( waterNoiseOffset, UV ).r;
|
||||
VERTEX.y += heightAmount * waterNoiseWaveHeight;
|
||||
|
||||
deepWaterAmount = 1.0 - heightAmount;
|
||||
|
||||
|
||||
|
||||
float d = length( worldPosition );
|
||||
float m = mapClamped( d, sinkStart, sinkEnd, 0, 1 );
|
||||
centerWaterAmount = 1.0 - m;
|
||||
m = mix( m, m*m*m, sinkBend );
|
||||
float offset = mix( 0, sinkOffset, m );
|
||||
VERTEX.y += offset;
|
||||
|
||||
world_position = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||
|
||||
}
|
||||
|
||||
void fragment()
|
||||
{
|
||||
float depth = texture(depthTexture, SCREEN_UV).x;
|
||||
vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
|
||||
vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
|
||||
view.xyz /= view.w;
|
||||
float linear_depth = -view.z;
|
||||
|
||||
vec4 world = INV_VIEW_MATRIX * INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
|
||||
vec3 worldPosition = world.xyz / world.w;
|
||||
|
||||
float depthDistance = length( worldPosition - world_position );
|
||||
float alphaFade = 1.0 - clamp( depthDistance / alphaFadeDistance, 0, 1 );
|
||||
float albedoFade = 1.0 - clamp( depthDistance * 5.0 / albedoFadeDistance , 0, 1 );
|
||||
vec2 base_uv = UV;
|
||||
float fresnelAmount = 1.0 - fresnel( NORMAL, VIEW, 3 );
|
||||
ALBEDO = mix( albedo.rgb, deepWater.rgb, deepWaterAmount * deepWater.a );
|
||||
ALBEDO = mix( ALBEDO, centerWater.rgb, centerWaterAmount * centerWater.a );
|
||||
//ALBEDO = mix( ALBEDO, texture( screenTexture, SCREEN_U
|
||||
vec3 screenRGB = mix( texture( screenTexture, SCREEN_UV ).rgb*2.0, vec3( 1,1,1 ), 0.5) ;
|
||||
ALBEDO = mix( ALBEDO, screenRGB, albedoFade );
|
||||
//ALBEDO = vec3( 1, 1, 1 ) * worldDistance;
|
||||
|
||||
METALLIC = mix( metallic, 0, albedoFade );;
|
||||
SPECULAR = mix( specular, 0, albedoFade );
|
||||
|
||||
ROUGHNESS = mix( roughness, 1, albedoFade );
|
||||
|
||||
|
||||
vec3 waterNormal = texture( waterNoiseNormal, UV ).rgb;
|
||||
|
||||
NORMAL_MAP = waterNormal;
|
||||
NORMAL_MAP_DEPTH = normal_scale;
|
||||
|
||||
ALPHA = 1.0 - alphaFade;
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
uid://cqnyck1plqvsi
|
|
@ -1,9 +1,9 @@
|
|||
[gd_resource type="Resource" script_class="CombineSensor" load_steps=6 format=3 uid="uid://b6omv5bjjp2us"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_ttsj5"]
|
||||
[ext_resource type="Script" uid="uid://eid0qnlvq4n1" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_ttsj5"]
|
||||
[ext_resource type="Resource" uid="uid://ci42d04kv03yx" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Keyboard & Mouse/Mouse/Mouse-Button Left.tres" id="2_h072s"]
|
||||
[ext_resource type="Resource" uid="uid://dffkdky8iowro" path="res://addons/rokojori_action_library/Runtime/Sensors/Default-Sensors/Gamepad/Buttons/Button A, PS Cross, Nin B.tres" id="3_5my10"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="4_js0nn"]
|
||||
[ext_resource type="Script" uid="uid://bjo1usdu525m" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="4_js0nn"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_kitj7"]
|
||||
script = ExtResource("4_js0nn")
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[gd_resource type="Resource" script_class="CombineSensor" load_steps=10 format=3 uid="uid://o55y4n73ivh5"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_ikub8"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_dx1wq"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadAxisSensor.cs" id="3_1wc0w"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="4_wj7li"]
|
||||
[ext_resource type="Script" uid="uid://eid0qnlvq4n1" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_ikub8"]
|
||||
[ext_resource type="Script" uid="uid://bjo1usdu525m" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_dx1wq"]
|
||||
[ext_resource type="Script" uid="uid://cb81s7ud1de7h" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadAxisSensor.cs" id="3_1wc0w"]
|
||||
[ext_resource type="Script" uid="uid://0ji11kv86cpk" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="4_wj7li"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jlvht"]
|
||||
script = ExtResource("2_dx1wq")
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[gd_resource type="Resource" script_class="CombineSensor" load_steps=8 format=3 uid="uid://t5no1o63fjr5"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_e8w3r"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_elgr4"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="3_pyik4"]
|
||||
[ext_resource type="Script" uid="uid://eid0qnlvq4n1" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_e8w3r"]
|
||||
[ext_resource type="Script" uid="uid://bjo1usdu525m" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_elgr4"]
|
||||
[ext_resource type="Script" uid="uid://0ji11kv86cpk" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="3_pyik4"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1iwsh"]
|
||||
script = ExtResource("2_elgr4")
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[gd_resource type="Resource" script_class="CombineSensor" load_steps=10 format=3 uid="uid://df6lrugctcuel"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_r4ul7"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_rofew"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="3_dyhbp"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadAxisSensor.cs" id="3_nh2m3"]
|
||||
[ext_resource type="Script" uid="uid://eid0qnlvq4n1" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_r4ul7"]
|
||||
[ext_resource type="Script" uid="uid://bjo1usdu525m" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_rofew"]
|
||||
[ext_resource type="Script" uid="uid://0ji11kv86cpk" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="3_dyhbp"]
|
||||
[ext_resource type="Script" uid="uid://cb81s7ud1de7h" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadAxisSensor.cs" id="3_nh2m3"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8h6fq"]
|
||||
script = ExtResource("2_rofew")
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[gd_resource type="Resource" script_class="CombineSensor" load_steps=10 format=3 uid="uid://csuggvbd1w2a4"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_w0cyl"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_umtky"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadAxisSensor.cs" id="3_ushvr"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="4_53tr6"]
|
||||
[ext_resource type="Script" uid="uid://eid0qnlvq4n1" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_w0cyl"]
|
||||
[ext_resource type="Script" uid="uid://bjo1usdu525m" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_umtky"]
|
||||
[ext_resource type="Script" uid="uid://cb81s7ud1de7h" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadAxisSensor.cs" id="3_ushvr"]
|
||||
[ext_resource type="Script" uid="uid://0ji11kv86cpk" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="4_53tr6"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jlvht"]
|
||||
script = ExtResource("2_umtky")
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[gd_resource type="Resource" script_class="CombineSensor" load_steps=10 format=3 uid="uid://da2q51p05qdyy"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_vdwin"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_prxyq"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadAxisSensor.cs" id="3_4antj"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="4_ucs5r"]
|
||||
[ext_resource type="Script" uid="uid://eid0qnlvq4n1" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_vdwin"]
|
||||
[ext_resource type="Script" uid="uid://bjo1usdu525m" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_prxyq"]
|
||||
[ext_resource type="Script" uid="uid://cb81s7ud1de7h" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadAxisSensor.cs" id="3_4antj"]
|
||||
[ext_resource type="Script" uid="uid://0ji11kv86cpk" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="4_ucs5r"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jlvht"]
|
||||
script = ExtResource("2_prxyq")
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[gd_resource type="Resource" script_class="CombineSensor" load_steps=8 format=3 uid="uid://4mbw74ka5aln"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_5263n"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_g8pg7"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="3_ejsq1"]
|
||||
[ext_resource type="Script" uid="uid://eid0qnlvq4n1" path="res://addons/rokojori_action_library/Runtime/Sensors/CombineSensor.cs" id="1_5263n"]
|
||||
[ext_resource type="Script" uid="uid://bjo1usdu525m" path="res://addons/rokojori_action_library/Runtime/Sensors/KeySensor.cs" id="2_g8pg7"]
|
||||
[ext_resource type="Script" uid="uid://0ji11kv86cpk" path="res://addons/rokojori_action_library/Runtime/Sensors/GamePadButtonSensor.cs" id="3_ejsq1"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jt01w"]
|
||||
script = ExtResource("2_g8pg7")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="LocaleText" load_steps=4 format=3 uid="uid://lr7gcd6yg8i4"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_4c4fl"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_lbvlr"]
|
||||
[ext_resource type="Script" uid="uid://b584767duemqk" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_4c4fl"]
|
||||
[ext_resource type="Script" uid="uid://bvj322mokkq63" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_lbvlr"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_07s3v"]
|
||||
script = ExtResource("1_4c4fl")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="LocaleText" load_steps=4 format=3 uid="uid://ciqjgtj8ajsm0"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_lbyqk"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="1_qp53m"]
|
||||
[ext_resource type="Script" uid="uid://b584767duemqk" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_lbyqk"]
|
||||
[ext_resource type="Script" uid="uid://bvj322mokkq63" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="1_qp53m"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_07s3v"]
|
||||
script = ExtResource("1_lbyqk")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="LocaleText" load_steps=4 format=3 uid="uid://dgxv8o8qhd5wl"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_i45a2"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_6bmky"]
|
||||
[ext_resource type="Script" uid="uid://b584767duemqk" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_i45a2"]
|
||||
[ext_resource type="Script" uid="uid://bvj322mokkq63" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_6bmky"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_07s3v"]
|
||||
script = ExtResource("1_i45a2")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="LocaleText" load_steps=4 format=3 uid="uid://bmhsl7uoaa67v"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_4dw48"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_mro0w"]
|
||||
[ext_resource type="Script" uid="uid://b584767duemqk" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_4dw48"]
|
||||
[ext_resource type="Script" uid="uid://bvj322mokkq63" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_mro0w"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_07s3v"]
|
||||
script = ExtResource("1_4dw48")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="LocaleText" load_steps=4 format=3 uid="uid://dn21j6dga66mp"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_ued7x"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_ifor6"]
|
||||
[ext_resource type="Script" uid="uid://b584767duemqk" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_ued7x"]
|
||||
[ext_resource type="Script" uid="uid://bvj322mokkq63" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_ifor6"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_07s3v"]
|
||||
script = ExtResource("1_ued7x")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="LocaleText" load_steps=4 format=3 uid="uid://dp0u2gty1bqms"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_l855s"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_gsuqi"]
|
||||
[ext_resource type="Script" uid="uid://b584767duemqk" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_l855s"]
|
||||
[ext_resource type="Script" uid="uid://bvj322mokkq63" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="2_gsuqi"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_07s3v"]
|
||||
script = ExtResource("1_l855s")
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
uid://sxnbdxbxycnl
|
|
@ -18,6 +18,7 @@ nodes/root_name=""
|
|||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
|
|
|
@ -18,6 +18,7 @@ nodes/root_name=""
|
|||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
|
@ -41,6 +42,7 @@ blender/nodes/modifiers=1
|
|||
blender/meshes/colors=false
|
||||
blender/meshes/uvs=true
|
||||
blender/meshes/normals=true
|
||||
blender/meshes/export_geometry_nodes_instances=false
|
||||
blender/meshes/tangents=true
|
||||
blender/meshes/skins=2
|
||||
blender/meshes/export_bones_deforming_mesh_only=false
|
||||
|
|
|
@ -18,6 +18,7 @@ nodes/root_name=""
|
|||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="LocaleText" load_steps=4 format=3 uid="uid://cptsuefrom6wu"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_nq55j"]
|
||||
[ext_resource type="Script" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="1_umpj1"]
|
||||
[ext_resource type="Script" uid="uid://b584767duemqk" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleTextEntry.cs" id="1_nq55j"]
|
||||
[ext_resource type="Script" uid="uid://bvj322mokkq63" path="res://addons/rokojori_action_library/Runtime/Localization/LocaleText.cs" id="1_umpj1"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6l7m4"]
|
||||
script = ExtResource("1_nq55j")
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
uid://db02a5v6ff2b6
|
|
@ -1,8 +1,6 @@
|
|||
<Project Sdk="Godot.NET.Sdk/4.3.0">
|
||||
<Project Sdk="Godot.NET.Sdk/4.4.0">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
|
||||
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'ios' ">net8.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
<RootNamespace>RokojoriActionLibraryExamples</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Godot.NET.Sdk/4.3.0">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
|
||||
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'ios' ">net8.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
<RootNamespace>RokojoriActionLibraryExamples</RootNamespace>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,45 @@
|
|||
// NOTE: Shader automatically converted from Godot Engine 4.4.stable.mono's StandardMaterial3D.
|
||||
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;
|
||||
|
||||
uniform vec4 albedo : source_color;
|
||||
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
|
||||
uniform ivec2 albedo_texture_size;
|
||||
uniform float point_size : hint_range(0.1, 128.0, 0.1);
|
||||
|
||||
uniform float roughness : hint_range(0.0, 1.0);
|
||||
uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable;
|
||||
uniform vec4 metallic_texture_channel;
|
||||
uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable;
|
||||
|
||||
uniform float specular : hint_range(0.0, 1.0, 0.01);
|
||||
uniform float metallic : hint_range(0.0, 1.0, 0.01);
|
||||
|
||||
uniform vec3 uv1_scale;
|
||||
uniform vec3 uv1_offset;
|
||||
uniform vec3 uv2_scale;
|
||||
uniform vec3 uv2_offset;
|
||||
uniform vec2 uvScrolling;
|
||||
uniform float uvScrollFPS = 10;
|
||||
|
||||
void vertex()
|
||||
{
|
||||
float fpsTime = round( TIME * uvScrollFPS ) / uvScrollFPS;
|
||||
UV = UV * uv1_scale.xy + uv1_offset.xy + uvScrolling * fpsTime;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 base_uv = UV;
|
||||
|
||||
vec4 albedo_tex = texture(texture_albedo, base_uv);
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb;
|
||||
|
||||
float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel);
|
||||
METALLIC = metallic_tex * metallic;
|
||||
SPECULAR = specular;
|
||||
|
||||
vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel);
|
||||
ROUGHNESS = roughness_tex * roughness;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
uid://0gguxb7uc3ih
|
|
@ -1,227 +0,0 @@
|
|||
extends CompositorEffect
|
||||
|
||||
var rd: RenderingDevice
|
||||
|
||||
var linear_sampler: RID
|
||||
|
||||
var nearest_sampler : RID
|
||||
|
||||
var context: StringName = "PostProcess"
|
||||
|
||||
var all_shader_stages : Dictionary
|
||||
|
||||
@export var debug : bool = false:
|
||||
set(value):
|
||||
if(debug == value):
|
||||
return
|
||||
|
||||
debug = value
|
||||
free_shaders.call_deferred()
|
||||
generate_shaders.call_deferred()
|
||||
|
||||
var debug_1 : String = "debug_1"
|
||||
var debug_2 : String = "debug_2"
|
||||
var debug_3 : String = "debug_3"
|
||||
var debug_4 : String = "debug_4"
|
||||
var debug_5 : String = "debug_5"
|
||||
var debug_6 : String = "debug_6"
|
||||
var debug_7 : String = "debug_7"
|
||||
var debug_8 : String = "debug_8"
|
||||
|
||||
var all_debug_images : Array[RID]
|
||||
|
||||
func _init():
|
||||
RenderingServer.call_on_render_thread(_initialize_compute)
|
||||
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_PREDELETE:
|
||||
if !rd:
|
||||
return
|
||||
if linear_sampler.is_valid():
|
||||
rd.free_rid(linear_sampler)
|
||||
if nearest_sampler.is_valid():
|
||||
rd.free_rid(nearest_sampler)
|
||||
for shader_stage in all_shader_stages.keys():
|
||||
if shader_stage.pipeline.is_valid():
|
||||
rd.free_rid(shader_stage.pipeline)
|
||||
if shader_stage.shader.is_valid():
|
||||
rd.free_rid(shader_stage.shader)
|
||||
|
||||
func free_shaders():
|
||||
for shader_stage in all_shader_stages.keys():
|
||||
if shader_stage.pipeline.is_valid():
|
||||
rd.free_rid(shader_stage.pipeline)
|
||||
if shader_stage.shader.is_valid():
|
||||
rd.free_rid(shader_stage.shader)
|
||||
|
||||
func generate_shaders():
|
||||
for shader_stage in all_shader_stages.keys():
|
||||
generate_shader_stage(shader_stage)
|
||||
|
||||
|
||||
func subscirbe_shader_stage(shader_stage : ShaderStageResource):
|
||||
if all_shader_stages.has(shader_stage):
|
||||
return
|
||||
|
||||
all_shader_stages[shader_stage] = 1
|
||||
|
||||
if rd:
|
||||
generate_shader_stage(shader_stage)
|
||||
|
||||
func unsubscribe_shader_stage(shader_stage : ShaderStageResource):
|
||||
if all_shader_stages.has(shader_stage):
|
||||
all_shader_stages.erase(shader_stage)
|
||||
if !rd:
|
||||
return
|
||||
|
||||
if shader_stage.shader.is_valid():
|
||||
rd.free_rid(shader_stage.shader)
|
||||
if shader_stage.pipeline.is_valid():
|
||||
rd.free_rid(shader_stage.pipeline)
|
||||
|
||||
func _initialize_compute():
|
||||
rd = RenderingServer.get_rendering_device()
|
||||
|
||||
if !rd:
|
||||
return
|
||||
|
||||
var sampler_state := RDSamplerState.new()
|
||||
|
||||
sampler_state.min_filter = RenderingDevice.SAMPLER_FILTER_LINEAR
|
||||
sampler_state.mag_filter = RenderingDevice.SAMPLER_FILTER_LINEAR
|
||||
sampler_state.repeat_u = RenderingDevice.SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE
|
||||
sampler_state.repeat_v = RenderingDevice.SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE
|
||||
|
||||
linear_sampler = rd.sampler_create(sampler_state)
|
||||
|
||||
sampler_state.min_filter = RenderingDevice.SAMPLER_FILTER_NEAREST
|
||||
sampler_state.mag_filter = RenderingDevice.SAMPLER_FILTER_NEAREST
|
||||
sampler_state.repeat_u = RenderingDevice.SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE
|
||||
sampler_state.repeat_v = RenderingDevice.SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE
|
||||
|
||||
nearest_sampler = rd.sampler_create(sampler_state)
|
||||
|
||||
generate_shaders()
|
||||
|
||||
|
||||
func generate_shader_stage(shader_stage : ShaderStageResource):
|
||||
var shader_spirv : RDShaderSPIRV
|
||||
if debug:
|
||||
var file = FileAccess.open(shader_stage.shader_file.resource_path, FileAccess.READ)
|
||||
var split_shader : PackedStringArray = file.get_as_text().split("#[compute]", true, 1)
|
||||
var content : String = split_shader[min(1, split_shader.size() - 1)]
|
||||
var all_split_parts : PackedStringArray = content.split("#version 450", true, 1)
|
||||
content = str(all_split_parts[0],
|
||||
"#version 450
|
||||
#define DEBUG
|
||||
layout(rgba16f, set = 0, binding = 10) uniform image2D debug_1_image;
|
||||
layout(rgba16f, set = 0, binding = 11) uniform image2D debug_2_image;
|
||||
layout(rgba16f, set = 0, binding = 12) uniform image2D debug_3_image;
|
||||
layout(rgba16f, set = 0, binding = 13) uniform image2D debug_4_image;
|
||||
layout(rgba16f, set = 0, binding = 14) uniform image2D debug_5_image;
|
||||
layout(rgba16f, set = 0, binding = 15) uniform image2D debug_6_image;
|
||||
layout(rgba16f, set = 0, binding = 16) uniform image2D debug_7_image;
|
||||
layout(rgba16f, set = 0, binding = 17) uniform image2D debug_8_image;",
|
||||
all_split_parts[1])
|
||||
var shader_source : RDShaderSource = RDShaderSource.new()
|
||||
shader_source.set_stage_source(RenderingDevice.SHADER_STAGE_COMPUTE, content)
|
||||
shader_spirv = rd.shader_compile_spirv_from_source(shader_source, false)
|
||||
print(content)
|
||||
else:
|
||||
shader_spirv = shader_stage.shader_file.get_spirv()
|
||||
|
||||
shader_stage.shader = rd.shader_create_from_spirv(shader_spirv)
|
||||
shader_stage.pipeline = rd.compute_pipeline_create(shader_stage.shader)
|
||||
|
||||
func _render_callback(p_effect_callback_type, p_render_data):
|
||||
if !rd:
|
||||
return
|
||||
|
||||
var render_scene_buffers: RenderSceneBuffersRD = p_render_data.get_render_scene_buffers()
|
||||
var render_scene_data: RenderSceneDataRD = p_render_data.get_render_scene_data()
|
||||
if !render_scene_buffers or !render_scene_data:
|
||||
return
|
||||
|
||||
var render_size: Vector2i = render_scene_buffers.get_internal_size()
|
||||
|
||||
if render_size.x == 0 or render_size.y == 0:
|
||||
return
|
||||
|
||||
if debug:
|
||||
ensure_texture(debug_1, render_scene_buffers)
|
||||
ensure_texture(debug_2, render_scene_buffers)
|
||||
ensure_texture(debug_3, render_scene_buffers)
|
||||
ensure_texture(debug_4, render_scene_buffers)
|
||||
ensure_texture(debug_5, render_scene_buffers)
|
||||
ensure_texture(debug_6, render_scene_buffers)
|
||||
ensure_texture(debug_7, render_scene_buffers)
|
||||
ensure_texture(debug_8, render_scene_buffers)
|
||||
|
||||
var view_count = render_scene_buffers.get_view_count()
|
||||
|
||||
for view in range(view_count):
|
||||
all_debug_images.append(render_scene_buffers.get_texture_slice(context, debug_1, view, 0, 1, 1))
|
||||
all_debug_images.append(render_scene_buffers.get_texture_slice(context, debug_2, view, 0, 1, 1))
|
||||
all_debug_images.append(render_scene_buffers.get_texture_slice(context, debug_3, view, 0, 1, 1))
|
||||
all_debug_images.append(render_scene_buffers.get_texture_slice(context, debug_4, view, 0, 1, 1))
|
||||
all_debug_images.append(render_scene_buffers.get_texture_slice(context, debug_5, view, 0, 1, 1))
|
||||
all_debug_images.append(render_scene_buffers.get_texture_slice(context, debug_6, view, 0, 1, 1))
|
||||
all_debug_images.append(render_scene_buffers.get_texture_slice(context, debug_7, view, 0, 1, 1))
|
||||
all_debug_images.append(render_scene_buffers.get_texture_slice(context, debug_8, view, 0, 1, 1))
|
||||
|
||||
_render_callback_2(render_size, render_scene_buffers, render_scene_data)
|
||||
|
||||
all_debug_images.clear()
|
||||
|
||||
func _render_callback_2(render_size : Vector2i, render_scene_buffers : RenderSceneBuffersRD, render_scene_data : RenderSceneDataRD):
|
||||
pass
|
||||
|
||||
func ensure_texture(texture_name : StringName, render_scene_buffers : RenderSceneBuffersRD, texture_format : RenderingDevice.DataFormat = RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, render_size_multiplier : Vector2 = Vector2(1, 1)):
|
||||
var render_size : Vector2i = Vector2(render_scene_buffers.get_internal_size()) * render_size_multiplier
|
||||
|
||||
if render_scene_buffers.has_texture(context, texture_name):
|
||||
var tf: RDTextureFormat = render_scene_buffers.get_texture_format(context, texture_name)
|
||||
if tf.width != render_size.x or tf.height != render_size.y:
|
||||
render_scene_buffers.clear_context(context)
|
||||
|
||||
if !render_scene_buffers.has_texture(context, texture_name):
|
||||
var usage_bits: int = RenderingDevice.TEXTURE_USAGE_SAMPLING_BIT | RenderingDevice.TEXTURE_USAGE_STORAGE_BIT
|
||||
render_scene_buffers.create_texture(context, texture_name, texture_format, usage_bits, RenderingDevice.TEXTURE_SAMPLES_1, render_size, 1, 1, true)
|
||||
|
||||
func get_image_uniform(image: RID, binding: int) -> RDUniform:
|
||||
var uniform: RDUniform = RDUniform.new()
|
||||
uniform.uniform_type = RenderingDevice.UNIFORM_TYPE_IMAGE
|
||||
uniform.binding = binding
|
||||
uniform.add_id(image)
|
||||
return uniform
|
||||
|
||||
func get_sampler_uniform(image: RID, binding: int, linear : bool = true) -> RDUniform:
|
||||
var uniform: RDUniform = RDUniform.new()
|
||||
uniform.uniform_type = RenderingDevice.UNIFORM_TYPE_SAMPLER_WITH_TEXTURE
|
||||
uniform.binding = binding
|
||||
uniform.add_id(linear_sampler if linear else nearest_sampler)
|
||||
uniform.add_id(image)
|
||||
return uniform
|
||||
|
||||
func dispatch_stage(stage : ShaderStageResource, uniforms : Array[RDUniform], push_constants : PackedByteArray, dispatch_size : Vector3i, label : String = "DefaultLabel", view : int = 0, color : Color = Color(1, 1, 1, 1)):
|
||||
rd.draw_command_begin_label(label + " " + str(view), color)
|
||||
|
||||
if debug:
|
||||
for i in 8:
|
||||
var debug_image_index = i + view * 8;
|
||||
uniforms.append(get_image_uniform(all_debug_images[debug_image_index], 10 + i))
|
||||
|
||||
var tex_uniform_set = UniformSetCacheRD.get_cache(stage.shader, 0, uniforms)
|
||||
|
||||
var compute_list = rd.compute_list_begin()
|
||||
rd.compute_list_bind_compute_pipeline(compute_list, stage.pipeline)
|
||||
rd.compute_list_bind_uniform_set(compute_list, tex_uniform_set, 0)
|
||||
|
||||
if !push_constants.is_empty():
|
||||
rd.compute_list_set_push_constant(compute_list, push_constants, push_constants.size())
|
||||
|
||||
rd.compute_list_dispatch(compute_list, dispatch_size.x, dispatch_size.y, dispatch_size.z)
|
||||
|
||||
rd.compute_list_end()
|
||||
|
||||
rd.draw_command_end_label()
|
|
@ -1,49 +0,0 @@
|
|||
extends Compositor
|
||||
class_name MotionBlurCompositor
|
||||
|
||||
@export_group("Motion Blur")
|
||||
# diminishing returns over 16
|
||||
@export_range(4, 64) var samples: int = 16 :
|
||||
set(value):
|
||||
for effect in compositor_effects:
|
||||
effect.set("samples", value)
|
||||
samples = value
|
||||
# you really don't want this over 0.5, but you can if you want to try
|
||||
@export_range(0, 0.5, 0.001, "or_greater") var intensity: float = 1 :
|
||||
set(value):
|
||||
for effect in compositor_effects:
|
||||
effect.set("intensity", value)
|
||||
intensity = value
|
||||
@export_range(0, 1) var center_fade: float = 0.0 :
|
||||
set(value):
|
||||
for effect in compositor_effects:
|
||||
effect.set("center_fade", value)
|
||||
center_fade = value
|
||||
|
||||
## wether this motion blur stays the same intensity below
|
||||
## target_constant_framerate
|
||||
@export var framerate_independent : bool = true :
|
||||
set(value):
|
||||
for effect in compositor_effects:
|
||||
effect.set("framerate_independent", value)
|
||||
framerate_independent = value
|
||||
|
||||
## Description: Removes clamping on motion blur scale to allow framerate independent motion
|
||||
## blur to scale longer than realistically possible when render framerate is higher
|
||||
## than target framerate.[br][br]
|
||||
## [color=yellow]Warning:[/color] Turning this on would allow over-blurring of pixels, which
|
||||
## produces inaccurate results, and would likely cause nausea in players over
|
||||
## long exposure durations, use with caution and out of artistic intent
|
||||
@export var uncapped_independence : bool = false :
|
||||
set(value):
|
||||
for effect in compositor_effects:
|
||||
effect.set("uncapped_independence", value)
|
||||
uncapped_independence = value
|
||||
|
||||
## if framerate_independent is enabled, the blur would simulate
|
||||
## sutter speeds at that framerate, and up.
|
||||
@export var target_constant_framerate : float = 30 :
|
||||
set(value):
|
||||
for effect in compositor_effects:
|
||||
effect.set("target_constant_framerate", value)
|
||||
target_constant_framerate = value
|
|
@ -1,28 +0,0 @@
|
|||
extends "res://addons/SphynxMotionBlurToolkit/BaseClasses/enhanced_compositor_effect.gd"
|
||||
|
||||
# diminishing returns over 16
|
||||
var samples: int = 16
|
||||
# you really don't want this over 0.5, but you can if you want to try
|
||||
var intensity: float = 1
|
||||
var center_fade: float = 0.0
|
||||
|
||||
## wether this motion blur stays the same intensity below
|
||||
## target_constant_framerate
|
||||
var framerate_independent : bool = true
|
||||
|
||||
## Description: Removes clamping on motion blur scale to allow framerate independent motion
|
||||
## blur to scale longer than realistically possible when render framerate is higher
|
||||
## than target framerate.[br][br]
|
||||
## [color=yellow]Warning:[/color] Turning this on would allow over-blurring of pixels, which
|
||||
## produces inaccurate results, and would likely cause nausea in players over
|
||||
## long exposure durations, use with caution and out of artistic intent
|
||||
var uncapped_independence : bool = false
|
||||
|
||||
## if framerate_independent is enabled, the blur would simulate
|
||||
## sutter speeds at that framerate, and up.
|
||||
var target_constant_framerate : float = 30
|
||||
|
||||
func _init():
|
||||
needs_motion_vectors = true
|
||||
set_deferred("context", "MotionBlur")
|
||||
super()
|
|
@ -1,7 +0,0 @@
|
|||
extends Resource
|
||||
class_name ShaderStageResource
|
||||
|
||||
@export var shader_file : RDShaderFile
|
||||
|
||||
var shader : RID
|
||||
var pipeline : RID
|
|
@ -1,87 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
#define DBL_MAX 1.7976931348623158e+308
|
||||
#define DBL_MIN 2.2250738585072014e-308
|
||||
|
||||
layout(rgba16f, set = 0, binding = 0) uniform image2D past_color_image;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform image2D output_color_image;
|
||||
layout(set = 0, binding = 2) uniform sampler2D color_sampler;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan_fl_1;
|
||||
float nan_fl_2;
|
||||
float nan_fl_3;
|
||||
float nan_fl_4;
|
||||
int freeze;
|
||||
int draw_debug;
|
||||
int debug_page;
|
||||
int nan3;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// show past image for freeze frame
|
||||
if(params.freeze > 0)
|
||||
{
|
||||
imageStore(output_color_image, uvi, imageLoad(past_color_image, uvi));
|
||||
return;
|
||||
}
|
||||
// must be on pixel center for whole values (tested)
|
||||
vec2 uvn = vec2(uvi + vec2(0.5)) / render_size;
|
||||
|
||||
vec4 source = textureLod(color_sampler, uvn, 0.0);
|
||||
|
||||
if (params.draw_debug == 0)
|
||||
{
|
||||
imageStore(output_color_image, uvi, source);
|
||||
imageStore(past_color_image, uvi, source);
|
||||
return;
|
||||
}
|
||||
|
||||
vec4 tl_col;
|
||||
|
||||
vec4 tr_col;
|
||||
|
||||
vec4 bl_col;
|
||||
|
||||
vec4 br_col;
|
||||
|
||||
#ifdef DEBUG
|
||||
if(params.debug_page == 0)
|
||||
{
|
||||
tl_col = imageLoad(debug_1_image, uvi);
|
||||
tr_col = imageLoad(debug_2_image, uvi);
|
||||
bl_col = imageLoad(debug_3_image, uvi);
|
||||
br_col = imageLoad(debug_4_image, uvi);
|
||||
}
|
||||
if(params.debug_page == 1)
|
||||
{
|
||||
tl_col = imageLoad(debug_5_image, uvi);
|
||||
tr_col = imageLoad(debug_6_image, uvi);
|
||||
bl_col = imageLoad(debug_7_image, uvi);
|
||||
br_col = imageLoad(debug_8_image, uvi);
|
||||
}
|
||||
#endif
|
||||
|
||||
imageStore(output_color_image, uvi / 2, tl_col);
|
||||
imageStore(output_color_image, uvi / 2 + ivec2(vec2(0.5, 0.5) * render_size), br_col);
|
||||
imageStore(output_color_image, uvi / 2 + ivec2(vec2(0.0, 0.5) * render_size), bl_col);
|
||||
imageStore(output_color_image, uvi / 2 + ivec2(vec2(0.5, 0.0) * render_size), tr_col);
|
||||
imageStore(past_color_image, uvi / 2, tl_col);
|
||||
imageStore(past_color_image, uvi / 2 + ivec2(vec2(0.5, 0.5) * render_size), br_col);
|
||||
imageStore(past_color_image, uvi / 2 + ivec2(vec2(0.0, 0.5) * render_size), bl_col);
|
||||
imageStore(past_color_image, uvi / 2 + ivec2(vec2(0.5, 0.0) * render_size), tr_col);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://dyxn6g5gvoge7"
|
||||
path="res://.godot/imported/debug_overlay.glsl-5ad15477a64c7f484bc494103ad163b6.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Debug/ShaderFiles/debug_overlay.glsl"
|
||||
dest_files=["res://.godot/imported/debug_overlay.glsl-5ad15477a64c7f484bc494103ad163b6.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="ShaderStageResource" load_steps=3 format=3 uid="uid://o2bivm33b0v4"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SphynxMotionBlurToolkit/BaseClasses/shader_pass_resource.gd" id="1_rqnmr"]
|
||||
[ext_resource type="RDShaderFile" uid="uid://dyxn6g5gvoge7" path="res://addons/SphynxMotionBlurToolkit/Debug/ShaderFiles/debug_overlay.glsl" id="2_qgd1y"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_rqnmr")
|
||||
shader_file = ExtResource("2_qgd1y")
|
|
@ -1,99 +0,0 @@
|
|||
extends "res://addons/SphynxMotionBlurToolkit/BaseClasses/enhanced_compositor_effect.gd"
|
||||
class_name DebugCompositorEffect
|
||||
|
||||
@export var overlay_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Debug/debug_overlay_shader_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(overlay_stage)
|
||||
overlay_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
## wether to display debug views for velocity and depth
|
||||
## buffers
|
||||
@export var draw_debug : bool = false
|
||||
|
||||
## currently 0 - 1, flip between velocity buffers
|
||||
## and depth buffers debug views
|
||||
@export var debug_page : int = 0
|
||||
|
||||
var past_color : StringName = "past_color"
|
||||
|
||||
var freeze : bool = false
|
||||
|
||||
func _init():
|
||||
set_deferred("context", "MotionBlur")
|
||||
set_deferred("debug", true)
|
||||
super()
|
||||
|
||||
func _render_callback_2(render_size : Vector2i, render_scene_buffers : RenderSceneBuffersRD, render_scene_data : RenderSceneDataRD):
|
||||
ensure_texture(past_color, render_scene_buffers)
|
||||
ensure_texture(debug_1, render_scene_buffers)
|
||||
ensure_texture(debug_2, render_scene_buffers)
|
||||
ensure_texture(debug_3, render_scene_buffers)
|
||||
ensure_texture(debug_4, render_scene_buffers)
|
||||
ensure_texture(debug_5, render_scene_buffers)
|
||||
ensure_texture(debug_6, render_scene_buffers)
|
||||
ensure_texture(debug_7, render_scene_buffers)
|
||||
ensure_texture(debug_8, render_scene_buffers)
|
||||
|
||||
rd.draw_command_begin_label("Debug", Color(1.0, 1.0, 1.0, 1.0))
|
||||
|
||||
if Input.is_action_just_pressed("freeze"):
|
||||
freeze = !freeze
|
||||
|
||||
if Input.is_action_just_pressed("Z"):
|
||||
draw_debug = !draw_debug
|
||||
|
||||
if Input.is_action_just_pressed("C"):
|
||||
debug_page = 1 if debug_page == 0 else 0
|
||||
|
||||
var push_constant: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
]
|
||||
var int_push_constant : PackedInt32Array = [
|
||||
freeze,
|
||||
draw_debug,
|
||||
debug_page,
|
||||
0
|
||||
]
|
||||
var byte_array = push_constant.to_byte_array()
|
||||
byte_array.append_array(int_push_constant.to_byte_array())
|
||||
|
||||
var view_count = render_scene_buffers.get_view_count()
|
||||
for view in range(view_count):
|
||||
var color_image := render_scene_buffers.get_color_layer(view)
|
||||
var past_color_image := render_scene_buffers.get_texture_slice(context, past_color, view, 0, 1, 1)
|
||||
var debug_1_image := render_scene_buffers.get_texture_slice(context, debug_1, view, 0, 1, 1)
|
||||
var debug_2_image := render_scene_buffers.get_texture_slice(context, debug_2, view, 0, 1, 1)
|
||||
var debug_3_image := render_scene_buffers.get_texture_slice(context, debug_3, view, 0, 1, 1)
|
||||
var debug_4_image := render_scene_buffers.get_texture_slice(context, debug_4, view, 0, 1, 1)
|
||||
var debug_5_image := render_scene_buffers.get_texture_slice(context, debug_5, view, 0, 1, 1)
|
||||
var debug_6_image := render_scene_buffers.get_texture_slice(context, debug_6, view, 0, 1, 1)
|
||||
var debug_7_image := render_scene_buffers.get_texture_slice(context, debug_7, view, 0, 1, 1)
|
||||
var debug_8_image := render_scene_buffers.get_texture_slice(context, debug_8, view, 0, 1, 1)
|
||||
|
||||
var x_groups := floori((render_size.x - 1) / 16 + 1)
|
||||
var y_groups := floori((render_size.y - 1) / 16 + 1)
|
||||
|
||||
dispatch_stage(overlay_stage,
|
||||
[
|
||||
get_image_uniform(past_color_image, 0),
|
||||
get_image_uniform(color_image, 1),
|
||||
get_sampler_uniform(color_image, 2),
|
||||
get_sampler_uniform(debug_1_image, 3),
|
||||
get_sampler_uniform(debug_2_image, 4),
|
||||
get_sampler_uniform(debug_3_image, 5),
|
||||
get_sampler_uniform(debug_4_image, 6),
|
||||
get_sampler_uniform(debug_5_image, 7),
|
||||
get_sampler_uniform(debug_6_image, 8),
|
||||
get_sampler_uniform(debug_7_image, 9),
|
||||
get_sampler_uniform(debug_8_image, 10),
|
||||
],
|
||||
byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"Debug Overlay",
|
||||
view)
|
||||
|
||||
rd.draw_command_end_label()
|
|
@ -1,156 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D color_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D depth_sampler;
|
||||
layout(set = 0, binding = 2) uniform sampler2D velocity_sampler;
|
||||
layout(set = 0, binding = 3) uniform sampler2D neighbor_max;
|
||||
layout(set = 0, binding = 4) uniform sampler2D tile_variance;
|
||||
layout(rgba16f, set = 0, binding = 5) uniform writeonly image2D output_color;
|
||||
layout(rgba16f, set = 0, binding = 6) uniform image2D debug_1_image;
|
||||
layout(rgba16f, set = 0, binding = 7) uniform image2D debug_2_image;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float minimum_user_threshold;
|
||||
float importance_bias;
|
||||
float maximum_jitter_value;
|
||||
float nan8;
|
||||
int tile_size;
|
||||
int sample_count;
|
||||
int frame;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
// McGuire's functions https://docs.google.com/document/d/1IIlAKTj-O01hcXEdGxTErQbCHO9iBmRx6oFUy_Jm0fI/edit
|
||||
// ----------------------------------------------------------
|
||||
float soft_depth_compare(float depth_X, float depth_Y, float sze)
|
||||
{
|
||||
return clamp(1 - (depth_X - depth_Y) / sze, 0, 1);
|
||||
}
|
||||
|
||||
float cone(float T, float v)
|
||||
{
|
||||
return clamp(1 - abs(T) / v, 0, 1);
|
||||
}
|
||||
|
||||
float cylinder(float T, float v)
|
||||
{
|
||||
return 1.0 - smoothstep(0.95 * v, 1.05 * v, abs(T));
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// Guertin's functions https://research.nvidia.com/sites/default/files/pubs/2013-11_A-Fast-and/Guertin2013MotionBlur-small.pdf
|
||||
// ----------------------------------------------------------
|
||||
float z_compare(float a, float b)
|
||||
{
|
||||
return clamp(1. - (a - b) / min(a, b), 0, 1);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://www.shadertoy.com/view/ftKfzc
|
||||
// ----------------------------------------------------------
|
||||
float interleaved_gradient_noise(vec2 uv, int FrameId){
|
||||
uv += float(FrameId) * (vec2(47, 17) * 0.695);
|
||||
|
||||
vec3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
|
||||
return fract(magic.z * fract(dot(uv, magic.xy)));
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
vec2 sample_random_offset(vec2 uv, float j)
|
||||
{
|
||||
return vec2(0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
ivec2 tile_render_size = ivec2(textureSize(neighbor_max, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 x = (vec2(uvi) + vec2(0.5)) / vec2(render_size);
|
||||
|
||||
float j = interleaved_gradient_noise(uvi, params.frame) * 2. - 1.;
|
||||
|
||||
vec2 vn = textureLod(neighbor_max, x, 0.0).xy * render_size / 2;
|
||||
|
||||
float vn_length = max(0.5, length(vn));
|
||||
|
||||
vec4 base_color = textureLod(color_sampler, x, 0.0);
|
||||
|
||||
if(vn_length <= 0.5)
|
||||
{
|
||||
imageStore(output_color, uvi, base_color);
|
||||
imageStore(debug_1_image, uvi, base_color);
|
||||
imageStore(debug_2_image, uvi, vec4(vn / render_size * 2, 0, 1));
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 wn = normalize(vn);
|
||||
|
||||
vec2 vx = textureLod(velocity_sampler, x, 0.0).xy * render_size / 2;
|
||||
|
||||
float vx_length = max(0.5, length(vx));
|
||||
|
||||
vec2 wp = vec2(-wn.y, wn.x);
|
||||
|
||||
if(dot(wp, vx) < 0)
|
||||
{
|
||||
wp = -wp;
|
||||
}
|
||||
|
||||
vec2 wc = normalize(mix(wp, normalize(vx), (vx_length - 0.5) / params.minimum_user_threshold));
|
||||
|
||||
float zx = -0.05 / textureLod(depth_sampler, x, 0.0).x;
|
||||
|
||||
float weight = params.sample_count / (params.importance_bias * vx_length);
|
||||
|
||||
vec4 sum = base_color * weight;
|
||||
|
||||
for(int i = 0; i < params.sample_count; i++)
|
||||
{
|
||||
float t = mix(-1.0, 1.0, (i + j * params.maximum_jitter_value + 1.0) / (params.sample_count + 1.0));
|
||||
|
||||
vec2 d = ((i % 2) > 0) ? vx : vn;
|
||||
|
||||
float T = t * vn_length;
|
||||
|
||||
vec2 y = x + t * d / render_size;
|
||||
|
||||
vec2 vy = textureLod(velocity_sampler, y, 0.0).xy * render_size / 2;
|
||||
|
||||
float vy_length = max(0.5, length(vy));
|
||||
|
||||
float zy = -0.05 / textureLod(depth_sampler, y, 0.0).x;
|
||||
|
||||
float f = z_compare(zx, zy);
|
||||
float b = z_compare(zy, zx);
|
||||
|
||||
float wa = dot(wc, d);
|
||||
float wb = dot(normalize(vy), d);
|
||||
|
||||
float ay = f * cone(T, 1. / vy_length) * max(FLT_MIN, abs(wb))
|
||||
+ b * cone(T, 1. / vx_length) * max(FLT_MIN, abs(wa))
|
||||
+ cylinder(T, min(vx_length, vy_length)) * 2 * max(FLT_MIN, max(abs(wa), abs(wb)));
|
||||
|
||||
weight += abs(ay);
|
||||
sum += ay * textureLod(color_sampler, y, 0.0);
|
||||
}
|
||||
|
||||
sum /= weight;
|
||||
|
||||
imageStore(output_color, uvi, sum);
|
||||
imageStore(debug_1_image, uvi, sum);
|
||||
imageStore(debug_2_image, uvi, vec4(vn / render_size * 2, 0, 1));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://cbdyfuhewqag8"
|
||||
path="res://.godot/imported/guertin_blur.glsl-bc647b2d965e982b702f0e036903e801.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_blur.glsl"
|
||||
dest_files=["res://.godot/imported/guertin_blur.glsl-bc647b2d965e982b702f0e036903e801.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D color_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D velocity_sampler;
|
||||
layout(set = 0, binding = 2) uniform sampler2D neighbor_max;
|
||||
layout(set = 0, binding = 3) uniform sampler2D tile_variance;
|
||||
layout(rgba16f, set = 0, binding = 4) uniform writeonly image2D output_color;
|
||||
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float minimum_user_threshold;
|
||||
float importance_bias;
|
||||
float maximum_jitter_value;
|
||||
float motion_blur_intensity;
|
||||
int tile_size;
|
||||
int sample_count;
|
||||
int frame;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
// McGuire's functions https://docs.google.com/document/d/1IIlAKTj-O01hcXEdGxTErQbCHO9iBmRx6oFUy_Jm0fI/edit
|
||||
// ----------------------------------------------------------
|
||||
float soft_depth_compare(float depth_X, float depth_Y, float sze)
|
||||
{
|
||||
return clamp(1 - (depth_X - depth_Y) / sze, 0, 1);
|
||||
}
|
||||
|
||||
float cone(float T, float v)
|
||||
{
|
||||
return clamp(1 - T / v, 0, 1);
|
||||
}
|
||||
|
||||
float cylinder(float T, float v)
|
||||
{
|
||||
return 1.0 - smoothstep(0.95 * v, 1.05 * v, T);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// Guertin's functions https://research.nvidia.com/sites/default/files/pubs/2013-11_A-Fast-and/Guertin2013MotionBlur-small.pdf
|
||||
// ----------------------------------------------------------
|
||||
float z_compare(float a, float b, float sze)
|
||||
{
|
||||
return clamp(1. - sze * (a - b), 0, 1);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://www.shadertoy.com/view/ftKfzc
|
||||
// ----------------------------------------------------------
|
||||
float interleaved_gradient_noise(vec2 uv){
|
||||
uv += float(params.frame) * (vec2(47, 17) * 0.695);
|
||||
|
||||
vec3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
|
||||
return fract(magic.z * fract(dot(uv, magic.xy)));
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://github.com/bradparks/KinoMotion__unity_motion_blur/tree/master
|
||||
// ----------------------------------------------------------
|
||||
vec2 safenorm(vec2 v)
|
||||
{
|
||||
float l = max(length(v), 1e-6);
|
||||
return v / l * int(l >= 0.5);
|
||||
}
|
||||
|
||||
vec2 jitter_tile(vec2 uvi)
|
||||
{
|
||||
float rx, ry;
|
||||
float angle = interleaved_gradient_noise(uvi + vec2(2, 0)) * M_PI * 2;
|
||||
rx = cos(angle);
|
||||
ry = sin(angle);
|
||||
return vec2(rx, ry) / textureSize(neighbor_max, 0) / 4;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
ivec2 tile_render_size = ivec2(textureSize(neighbor_max, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 x = (vec2(uvi) + vec2(0.5)) / vec2(render_size);
|
||||
|
||||
vec4 vnzw = textureLod(neighbor_max, x + vec2(params.tile_size / 2) / vec2(render_size) + jitter_tile(uvi), 0.0) * vec4(render_size / 2., 1, 1) * params.motion_blur_intensity;
|
||||
|
||||
vec2 vn = vnzw.xy;
|
||||
|
||||
float vn_length = length(vn);
|
||||
|
||||
vec4 base_color = textureLod(color_sampler, x, 0.0);
|
||||
|
||||
vec4 vxzw = textureLod(velocity_sampler, x, 0.0) * vec4(render_size / 2., 1, 1) * params.motion_blur_intensity;
|
||||
|
||||
if(vn_length < 0.5)
|
||||
{
|
||||
imageStore(output_color, uvi, base_color);
|
||||
#ifdef DEBUG
|
||||
imageStore(debug_1_image, uvi, base_color);
|
||||
imageStore(debug_2_image, uvi, vec4(vn / render_size * 2, 0, 1));
|
||||
imageStore(debug_3_image, uvi, vec4(vxzw.xy / render_size * 2, 0, 1));
|
||||
imageStore(debug_4_image, uvi, vec4(0));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 wn = safenorm(vn);
|
||||
|
||||
vec2 vx = vxzw.xy;
|
||||
|
||||
float vx_length = max(0.5, length(vx));
|
||||
|
||||
vec2 wx = safenorm(vx);
|
||||
|
||||
float j = interleaved_gradient_noise(uvi) * 2. - 1.;
|
||||
|
||||
float zx = vxzw.w;
|
||||
|
||||
float weight = 1e-6;
|
||||
|
||||
vec4 sum = base_color * weight;
|
||||
|
||||
float nai_weight = 1e-6;
|
||||
|
||||
vec4 nai_sum = base_color * nai_weight;
|
||||
|
||||
for(int i = 0; i < params.sample_count; i++)
|
||||
{
|
||||
float t = mix(-1.0, 1.0, (i + j * params.maximum_jitter_value + 1.0) / (params.sample_count + 1.0));
|
||||
|
||||
bool use_vn = ((i % 2) == 0);
|
||||
|
||||
vec2 d = use_vn ? vn : vx;
|
||||
|
||||
float dz = use_vn ? vnzw.z : vxzw.z;
|
||||
|
||||
vec2 wd = use_vn ? wn : wx;
|
||||
|
||||
float T = abs(t * vn_length);
|
||||
|
||||
vec2 y = x + t * d / render_size;
|
||||
|
||||
float wa = abs(dot(wx, wd));
|
||||
|
||||
vec4 vyzw = textureLod(velocity_sampler, y, 0.0) * vec4(render_size / 2, 1, 1) * params.motion_blur_intensity;
|
||||
|
||||
vec2 vy = vyzw.xy - dz * t;
|
||||
|
||||
float vy_length = max(0.5, length(vy));
|
||||
|
||||
float zy = vyzw.w;
|
||||
|
||||
float f = z_compare(-zy, -zx, 20000);
|
||||
float b = z_compare(-zx, -zy, 20000);
|
||||
|
||||
float wb = abs(dot(vy / vy_length, wd));
|
||||
|
||||
if(use_vn)
|
||||
{
|
||||
float ay = f * step(T, vy_length * wb);
|
||||
|
||||
weight += ay;
|
||||
|
||||
sum += textureLod(color_sampler, y, 0.0) * ay;
|
||||
}
|
||||
|
||||
float nai_ay = b * step(T, vx_length * wa) * 2;
|
||||
|
||||
nai_weight += nai_ay;
|
||||
|
||||
nai_sum += textureLod(color_sampler, y, 0.0) * nai_ay;
|
||||
}
|
||||
|
||||
sum /= weight;
|
||||
|
||||
weight /= params.sample_count / 2;
|
||||
|
||||
nai_sum /= nai_weight;
|
||||
|
||||
sum = mix(nai_sum, sum, weight);
|
||||
|
||||
imageStore(output_color, uvi, sum);
|
||||
#ifdef DEBUG
|
||||
imageStore(debug_1_image, uvi, base_color);
|
||||
imageStore(debug_2_image, uvi, vec4(vn / render_size * 2, 0, 1));
|
||||
imageStore(debug_3_image, uvi, vec4(vx / render_size * 2, 0, 1));
|
||||
imageStore(debug_4_image, uvi, vxzw);
|
||||
#endif
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://br71y0l0rxt8h"
|
||||
path="res://.godot/imported/guertin_experimental_blur.glsl-196a1037ea9a4eb1095033202fe161a7.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_experimental_blur.glsl"
|
||||
dest_files=["res://.godot/imported/guertin_experimental_blur.glsl-196a1037ea9a4eb1095033202fe161a7.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D color_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D velocity_sampler;
|
||||
layout(set = 0, binding = 2) uniform sampler2D neighbor_max;
|
||||
layout(set = 0, binding = 3) uniform sampler2D tile_variance;
|
||||
layout(rgba16f, set = 0, binding = 4) uniform writeonly image2D output_color;
|
||||
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float minimum_user_threshold;
|
||||
float importance_bias;
|
||||
float maximum_jitter_value;
|
||||
float motion_blur_intensity;
|
||||
int tile_size;
|
||||
int sample_count;
|
||||
int frame;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
// McGuire's functions https://docs.google.com/document/d/1IIlAKTj-O01hcXEdGxTErQbCHO9iBmRx6oFUy_Jm0fI/edit
|
||||
// ----------------------------------------------------------
|
||||
float soft_depth_compare(float depth_X, float depth_Y, float sze)
|
||||
{
|
||||
return clamp(1 - (depth_X - depth_Y) / sze, 0, 1);
|
||||
}
|
||||
|
||||
float cone(float T, float v)
|
||||
{
|
||||
return clamp(1 - T / v, 0, 1);
|
||||
}
|
||||
|
||||
float cylinder(float T, float v)
|
||||
{
|
||||
return 1.0 - smoothstep(0.95 * v, 1.05 * v, T);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// Guertin's functions https://research.nvidia.com/sites/default/files/pubs/2013-11_A-Fast-and/Guertin2013MotionBlur-small.pdf
|
||||
// ----------------------------------------------------------
|
||||
float z_compare(float a, float b, float sze)
|
||||
{
|
||||
return clamp(1. - sze * (a - b), 0, 1);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://www.shadertoy.com/view/ftKfzc
|
||||
// ----------------------------------------------------------
|
||||
float interleaved_gradient_noise(vec2 uv){
|
||||
uv += float(params.frame) * (vec2(47, 17) * 0.695);
|
||||
|
||||
vec3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
|
||||
return fract(magic.z * fract(dot(uv, magic.xy)));
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://github.com/bradparks/KinoMotion__unity_motion_blur/tree/master
|
||||
// ----------------------------------------------------------
|
||||
vec2 safenorm(vec2 v)
|
||||
{
|
||||
float l = max(length(v), 1e-6);
|
||||
return v / l * int(l >= 0.5);
|
||||
}
|
||||
|
||||
vec2 jitter_tile(vec2 uvi)
|
||||
{
|
||||
float rx, ry;
|
||||
float angle = interleaved_gradient_noise(uvi + vec2(2, 0)) * M_PI * 2;
|
||||
rx = cos(angle);
|
||||
ry = sin(angle);
|
||||
return vec2(rx, ry) / textureSize(neighbor_max, 0) / 4;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
ivec2 tile_render_size = ivec2(textureSize(neighbor_max, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 x = (vec2(uvi) + vec2(0.5)) / vec2(render_size);
|
||||
|
||||
float j = interleaved_gradient_noise(uvi) * 2. - 1.;
|
||||
|
||||
vec4 vnzw = textureLod(neighbor_max, x + vec2(params.tile_size / 2) / vec2(render_size) + jitter_tile(uvi), 0.0) * vec4(render_size / 2., 1, 1) * params.motion_blur_intensity;
|
||||
|
||||
vec2 vn = vnzw.xy;
|
||||
|
||||
float vn_length = length(vn);
|
||||
|
||||
vec4 base_color = textureLod(color_sampler, x, 0.0);
|
||||
|
||||
if(vn_length < 0.5)
|
||||
{
|
||||
imageStore(output_color, uvi, base_color);
|
||||
#ifdef DEBUG
|
||||
imageStore(debug_1_image, uvi, base_color);
|
||||
imageStore(debug_2_image, uvi, vec4(vn / render_size * 2, 0, 1));
|
||||
imageStore(debug_3_image, uvi, vec4(0));
|
||||
imageStore(debug_4_image, uvi, vec4(0));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 wn = safenorm(vn);
|
||||
|
||||
vec4 vxzw = textureLod(velocity_sampler, x, 0.0) * vec4(render_size / 2., 1, 1) * params.motion_blur_intensity;
|
||||
|
||||
vec2 vx = vxzw.xy;
|
||||
|
||||
float vx_length = max(0.5, length(vx));
|
||||
|
||||
vec2 wx = safenorm(vx);
|
||||
|
||||
vec2 wp = vec2(-wn.y, wn.x);
|
||||
|
||||
if(dot(wp, vx) < 0)
|
||||
{
|
||||
wp = -wp;
|
||||
}
|
||||
|
||||
vec2 wc = safenorm(mix(wp, wx, clamp((vx_length - 0.5) / params.minimum_user_threshold, 0, 1)));
|
||||
|
||||
float zx = vxzw.w;
|
||||
|
||||
float total_weight = params.sample_count / (params.importance_bias * vx_length);
|
||||
|
||||
vec4 sum = base_color * total_weight;
|
||||
|
||||
for(int i = 0; i < params.sample_count; i++)
|
||||
{
|
||||
float t = mix(-1.0, 1.0, (i + j * params.maximum_jitter_value + 1.0) / (params.sample_count + 1.0));
|
||||
|
||||
vec2 d = ((i % 2) > 0) ? vx : vn;
|
||||
|
||||
float dz = ((i % 2) > 0) ? vxzw.z : vnzw.z;
|
||||
|
||||
vec2 wd = safenorm(d);
|
||||
|
||||
float T = abs(t * vn_length);
|
||||
|
||||
vec2 y = x + t * d / render_size;
|
||||
|
||||
float wa = dot(wc, wd);
|
||||
|
||||
vec4 vyzw = textureLod(velocity_sampler, y, 0.0) * vec4(render_size / 2, 1, 1) * params.motion_blur_intensity;
|
||||
|
||||
vec2 vy = vyzw.xy - dz * t;
|
||||
|
||||
float vy_length = max(0.5, length(vy));
|
||||
|
||||
float zy = vyzw.w;
|
||||
|
||||
float f = z_compare(-zy, -zx, 20000);
|
||||
float b = z_compare(-zx, -zy, 20000);
|
||||
|
||||
float wb = abs(dot(vy / vy_length, wd));
|
||||
|
||||
float weight = 0.0;
|
||||
weight += f * cone(T, vy_length) * wb;
|
||||
weight += b * cone(T, vx_length) * wa;
|
||||
weight += cylinder(T, min(vy_length, vx_length)) * 2. * max(wa, wb);
|
||||
|
||||
total_weight += weight;
|
||||
|
||||
sum += weight * textureLod(color_sampler, y, 0.0);
|
||||
}
|
||||
|
||||
sum /= total_weight;
|
||||
|
||||
imageStore(output_color, uvi, sum);
|
||||
#ifdef DEBUG
|
||||
imageStore(debug_1_image, uvi, sum);
|
||||
imageStore(debug_2_image, uvi, vec4(vn / render_size * 2, 0, 1));
|
||||
imageStore(debug_3_image, uvi, vnzw);
|
||||
imageStore(debug_4_image, uvi, vxzw);
|
||||
#endif
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://m6rlgfu6i0b3"
|
||||
path="res://.godot/imported/guertin_kino_blur.glsl-71e9932045a7522115793d60f179d67e.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_kino_blur.glsl"
|
||||
dest_files=["res://.godot/imported/guertin_kino_blur.glsl-71e9932045a7522115793d60f179d67e.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform writeonly image2D neighbor_max;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan5;
|
||||
float nan6;
|
||||
float nan7;
|
||||
float nan8;
|
||||
int nan1;
|
||||
int nan2;
|
||||
int nan3;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec2 max_neighbor_velocity = vec2(0);
|
||||
|
||||
float max_neighbor_velocity_length = 0;
|
||||
|
||||
for(int i = -1; i < 2; i++)
|
||||
{
|
||||
for(int j = -1; j < 2; j++)
|
||||
{
|
||||
vec2 current_offset = vec2(1) / vec2(render_size) * vec2(i, j);
|
||||
vec2 current_uv = uvn + current_offset;
|
||||
if(current_uv.x < 0 || current_uv.x > 1 || current_uv.y < 0 || current_uv.y > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool is_diagonal = (abs(i) + abs(j) == 2);
|
||||
|
||||
vec2 current_neighbor_velocity = textureLod(tile_max, current_uv, 0.0).xy;
|
||||
|
||||
bool facing_center = dot(current_neighbor_velocity, current_offset) > 0;
|
||||
|
||||
if(is_diagonal && !facing_center)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float current_neighbor_velocity_length = dot(current_neighbor_velocity, current_neighbor_velocity);
|
||||
if(current_neighbor_velocity_length > max_neighbor_velocity_length)
|
||||
{
|
||||
max_neighbor_velocity_length = current_neighbor_velocity_length;
|
||||
max_neighbor_velocity = current_neighbor_velocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imageStore(neighbor_max, uvi, vec4(max_neighbor_velocity, 0, 1));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://bn88jkvr17x4j"
|
||||
path="res://.godot/imported/guertin_neighbor_max.glsl-91e836516679e0c51b67df5b480ef0af.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_neighbor_max.glsl"
|
||||
dest_files=["res://.godot/imported/guertin_neighbor_max.glsl-91e836516679e0c51b67df5b480ef0af.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D blur_sampler;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform image2D color_image;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(blur_sampler, 0));
|
||||
ivec2 output_size = imageSize(color_image);
|
||||
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uv.x >= output_size.x) || (uv.y >= output_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
imageStore(color_image, uv, textureLod(blur_sampler, (vec2(uv) + 0.5) / output_size, 0.0));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://i6rnwhmss334"
|
||||
path="res://.godot/imported/guertin_overlay.glsl-506c18362b63cb0a2477b4a4fbfea046.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_overlay.glsl"
|
||||
dest_files=["res://.godot/imported/guertin_overlay.glsl-506c18362b63cb0a2477b4a4fbfea046.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D velocity_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D depth_sampler;
|
||||
layout(rgba16f, set = 0, binding = 2) uniform writeonly image2D tile_max_x;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan5;
|
||||
float nan6;
|
||||
float nan7;
|
||||
float nan8;
|
||||
int tile_size;
|
||||
int nan2;
|
||||
int nan3;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(velocity_sampler, 0));
|
||||
ivec2 output_size = imageSize(tile_max_x);
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
ivec2 global_uvi = uvi * ivec2(params.tile_size, 1);
|
||||
if ((uvi.x >= output_size.x) || (uvi.y >= output_size.y) || (global_uvi.x >= render_size.x) || (global_uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(global_uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec4 max_velocity = vec4(0);
|
||||
|
||||
float max_velocity_length = -1;
|
||||
|
||||
for(int i = 0; i < params.tile_size; i++)
|
||||
{
|
||||
vec2 current_uv = uvn + vec2(float(i) / render_size.x, 0);
|
||||
vec3 velocity_sample = textureLod(velocity_sampler, current_uv, 0.0).xyz;
|
||||
float current_velocity_length = dot(velocity_sample.xy, velocity_sample.xy);
|
||||
if(current_velocity_length > max_velocity_length)
|
||||
{
|
||||
max_velocity_length = current_velocity_length;
|
||||
max_velocity = vec4(velocity_sample, textureLod(depth_sampler, current_uv, 0.0).x);
|
||||
}
|
||||
}
|
||||
imageStore(tile_max_x, uvi, max_velocity);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://d0s5upcgm7r6l"
|
||||
path="res://.godot/imported/guertin_tile_max_x.glsl-7ca561425618287b0f2821fd8c232f09.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_tile_max_x.glsl"
|
||||
dest_files=["res://.godot/imported/guertin_tile_max_x.glsl-7ca561425618287b0f2821fd8c232f09.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max_x;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform writeonly image2D tile_max;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan5;
|
||||
float nan6;
|
||||
float nan7;
|
||||
float nan8;
|
||||
int tile_size;
|
||||
int nan2;
|
||||
int nan3;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max_x, 0));
|
||||
ivec2 output_size = imageSize(tile_max);
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
ivec2 global_uvi = uvi * ivec2(1, params.tile_size);
|
||||
if ((uvi.x >= output_size.x) || (uvi.y >= output_size.y) || (global_uvi.x >= render_size.x) || (global_uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(global_uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec4 max_velocity = vec4(0);
|
||||
|
||||
float max_velocity_length = -1;
|
||||
|
||||
for(int i = 0; i < params.tile_size; i++)
|
||||
{
|
||||
vec2 current_uv = uvn + vec2(0, float(i) / render_size.y);
|
||||
vec4 velocity_sample = textureLod(tile_max_x, current_uv, 0.0);
|
||||
float current_velocity_length = dot(velocity_sample.xy, velocity_sample.xy);
|
||||
if(current_velocity_length > max_velocity_length)
|
||||
{
|
||||
max_velocity_length = current_velocity_length;
|
||||
max_velocity = velocity_sample;
|
||||
}
|
||||
}
|
||||
imageStore(tile_max, uvi, max_velocity);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://ceetvitdbio4l"
|
||||
path="res://.godot/imported/guertin_tile_max_y.glsl-60f045725ff6917c4bd911cf3710a444.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_tile_max_y.glsl"
|
||||
dest_files=["res://.godot/imported/guertin_tile_max_y.glsl-60f045725ff6917c4bd911cf3710a444.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform writeonly image2D tile_variance;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan5;
|
||||
float nan6;
|
||||
float nan7;
|
||||
float nan8;
|
||||
int nan1;
|
||||
int nan2;
|
||||
int nan3;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
float variance = 0;
|
||||
|
||||
vec2 current_velocity = abs(normalize(textureLod(tile_max, uvn, 0.0).xy));
|
||||
|
||||
float tile_count = 0;
|
||||
|
||||
for(int i = -1; i < 2; i++)
|
||||
{
|
||||
for(int j = -1; j < 2; j++)
|
||||
{
|
||||
vec2 current_offset = vec2(1) / vec2(render_size) * vec2(i, j);
|
||||
vec2 current_uv = uvn + current_offset;
|
||||
if(current_uv.x < 0 || current_uv.x > 1 || current_uv.y < 0 || current_uv.y > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(i == j && i == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
tile_count += 1;
|
||||
|
||||
vec2 current_neighbor_velocity = abs(normalize(textureLod(tile_max, current_uv, 0.0).xy));
|
||||
|
||||
variance += dot(current_velocity, current_neighbor_velocity);
|
||||
}
|
||||
}
|
||||
|
||||
variance /= tile_count;
|
||||
|
||||
imageStore(tile_variance, uvi, vec4(1 - variance));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://by6mslkv0palh"
|
||||
path="res://.godot/imported/guertin_tile_variance.glsl-2fb44423dc25efae19822b8cfbe32a55.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_tile_variance.glsl"
|
||||
dest_files=["res://.godot/imported/guertin_tile_variance.glsl-2fb44423dc25efae19822b8cfbe32a55.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
extends "res://addons/SphynxMotionBlurToolkit/BaseClasses/mb_compositor_effect.gd"
|
||||
|
||||
@export_group("Shader Parameters")
|
||||
@export var tile_size : int = 40
|
||||
|
||||
@export var linear_falloff_slope : float = 1
|
||||
|
||||
@export var importance_bias : float = 40
|
||||
|
||||
@export var maximum_jitter_value : float = 0.95
|
||||
|
||||
@export var minimum_user_threshold : float = 1.5
|
|
@ -1,8 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="ShaderStageResource" load_steps=3 format=3 uid="uid://dre56ajymywpr"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SphynxMotionBlurToolkit/BaseClasses/shader_pass_resource.gd" id="1_loemu"]
|
||||
[ext_resource type="RDShaderFile" uid="uid://m6rlgfu6i0b3" path="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_kino_blur.glsl" id="2_uo41r"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_loemu")
|
||||
shader_file = ExtResource("2_uo41r")
|
|
@ -1,8 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="ShaderStageResource" load_steps=3 format=3 uid="uid://ca45noqewsyvp"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SphynxMotionBlurToolkit/BaseClasses/shader_pass_resource.gd" id="1_kvtxq"]
|
||||
[ext_resource type="RDShaderFile" uid="uid://br71y0l0rxt8h" path="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_experimental_blur.glsl" id="2_ykr12"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_kvtxq")
|
||||
shader_file = ExtResource("2_ykr12")
|
|
@ -1,245 +0,0 @@
|
|||
extends "res://addons/SphynxMotionBlurToolkit/Guertin/base_guertin_motion_blur.gd"
|
||||
class_name OldGuertinMotionBlur
|
||||
|
||||
@export_group("Shader Stages")
|
||||
@export var blur_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_blur_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(blur_stage)
|
||||
blur_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var overlay_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_overlay_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(overlay_stage)
|
||||
overlay_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var tile_max_x_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_tile_max_x_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(tile_max_x_stage)
|
||||
tile_max_x_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var tile_max_y_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_tile_max_y_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(tile_max_y_stage)
|
||||
tile_max_y_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var neighbor_max_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_neighbor_max_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(neighbor_max_stage)
|
||||
neighbor_max_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var tile_variance_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_tile_variance_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(tile_variance_stage)
|
||||
tile_variance_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
var output_color: StringName = "output_color"
|
||||
|
||||
var tile_max_x : StringName = "tile_max_x"
|
||||
|
||||
var tile_max : StringName = "tile_max"
|
||||
|
||||
var neighbor_max : StringName = "neighbor_max"
|
||||
|
||||
var tile_variance : StringName = "tile_variance"
|
||||
|
||||
var custom_velocity : StringName = "custom_velocity"
|
||||
|
||||
var freeze : bool = false
|
||||
|
||||
var temp_intensity : float
|
||||
|
||||
var previous_time : float = 0
|
||||
|
||||
func _render_callback_2(render_size : Vector2i, render_scene_buffers : RenderSceneBuffersRD, render_scene_data : RenderSceneDataRD):
|
||||
var time : float = float(Time.get_ticks_msec()) / 1000
|
||||
|
||||
var delta_time : float = time - previous_time
|
||||
|
||||
previous_time = time
|
||||
|
||||
temp_intensity = intensity
|
||||
|
||||
if framerate_independent:
|
||||
var capped_frame_time : float = 1 / target_constant_framerate
|
||||
|
||||
if !uncapped_independence:
|
||||
capped_frame_time = min(capped_frame_time, delta_time)
|
||||
|
||||
temp_intensity = intensity * capped_frame_time / delta_time
|
||||
|
||||
ensure_texture(tile_max_x, render_scene_buffers, RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, Vector2(1. / tile_size, 1.))
|
||||
ensure_texture(tile_max, render_scene_buffers, RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, Vector2(1. / tile_size, 1. / tile_size))
|
||||
ensure_texture(neighbor_max, render_scene_buffers, RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, Vector2(1. / tile_size, 1. / tile_size))
|
||||
ensure_texture(tile_variance, render_scene_buffers, RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, Vector2(1. / tile_size, 1. / tile_size))
|
||||
ensure_texture(custom_velocity, render_scene_buffers)
|
||||
ensure_texture(output_color, render_scene_buffers)
|
||||
|
||||
rd.draw_command_begin_label("Motion Blur", Color(1.0, 1.0, 1.0, 1.0))
|
||||
|
||||
var tile_max_x_push_constants: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var int_tile_max_x_push_constants : PackedInt32Array = [
|
||||
tile_size,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var tile_max_x_push_constants_byte_array = tile_max_x_push_constants.to_byte_array()
|
||||
tile_max_x_push_constants_byte_array.append_array(int_tile_max_x_push_constants.to_byte_array())
|
||||
|
||||
var tile_max_y_push_constants: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var int_tile_max_y_push_constants : PackedInt32Array = [
|
||||
tile_size,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var tile_max_y_push_constants_byte_array = tile_max_y_push_constants.to_byte_array()
|
||||
tile_max_y_push_constants_byte_array.append_array(int_tile_max_y_push_constants.to_byte_array())
|
||||
|
||||
var neighbor_max_push_constants: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var int_neighbor_max_push_constants : PackedInt32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var neighbor_max_push_constants_byte_array = neighbor_max_push_constants.to_byte_array()
|
||||
neighbor_max_push_constants_byte_array.append_array(int_neighbor_max_push_constants.to_byte_array())
|
||||
|
||||
var tile_variance_push_constants: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var int_tile_variance_push_constants : PackedInt32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var tile_variance_push_constants_byte_array = tile_variance_push_constants.to_byte_array()
|
||||
tile_variance_push_constants_byte_array.append_array(int_tile_variance_push_constants.to_byte_array())
|
||||
|
||||
var blur_push_constants: PackedFloat32Array = [
|
||||
minimum_user_threshold,
|
||||
importance_bias,
|
||||
maximum_jitter_value,
|
||||
temp_intensity,
|
||||
]
|
||||
var int_blur_push_constants : PackedInt32Array = [
|
||||
tile_size,
|
||||
samples,
|
||||
Engine.get_frames_drawn() % 8,
|
||||
0
|
||||
]
|
||||
var blur_push_constants_byte_array = blur_push_constants.to_byte_array()
|
||||
blur_push_constants_byte_array.append_array(int_blur_push_constants.to_byte_array())
|
||||
|
||||
var view_count = render_scene_buffers.get_view_count()
|
||||
|
||||
for view in range(view_count):
|
||||
var color_image := render_scene_buffers.get_color_layer(view)
|
||||
var depth_image := render_scene_buffers.get_depth_layer(view)
|
||||
var output_color_image := render_scene_buffers.get_texture_slice(context, output_color, view, 0, 1, 1)
|
||||
var tile_max_x_image := render_scene_buffers.get_texture_slice(context, tile_max_x, view, 0, 1, 1)
|
||||
var tile_max_image := render_scene_buffers.get_texture_slice(context, tile_max, view, 0, 1, 1)
|
||||
var neighbor_max_image := render_scene_buffers.get_texture_slice(context, neighbor_max, view, 0, 1, 1)
|
||||
var tile_variance_image := render_scene_buffers.get_texture_slice(context, tile_variance, view, 0, 1, 1)
|
||||
var custom_velocity_image := render_scene_buffers.get_texture_slice(context, custom_velocity, view, 0, 1, 1)
|
||||
|
||||
var x_groups := floori((render_size.x / tile_size - 1) / 16 + 1)
|
||||
var y_groups := floori((render_size.y - 1) / 16 + 1)
|
||||
|
||||
dispatch_stage(tile_max_x_stage,
|
||||
[
|
||||
get_sampler_uniform(custom_velocity_image, 0, false),
|
||||
get_sampler_uniform(depth_image, 1, false),
|
||||
get_image_uniform(tile_max_x_image, 2)
|
||||
],
|
||||
tile_max_x_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"TileMaxX",
|
||||
view)
|
||||
|
||||
x_groups = floori((render_size.x / tile_size - 1) / 16 + 1)
|
||||
y_groups = floori((render_size.y / tile_size - 1) / 16 + 1)
|
||||
|
||||
dispatch_stage(tile_max_y_stage,
|
||||
[
|
||||
get_sampler_uniform(tile_max_x_image, 0, false),
|
||||
get_image_uniform(tile_max_image, 1)
|
||||
],
|
||||
tile_max_y_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"TileMaxY",
|
||||
view)
|
||||
|
||||
dispatch_stage(neighbor_max_stage,
|
||||
[
|
||||
get_sampler_uniform(tile_max_image, 0, false),
|
||||
get_image_uniform(neighbor_max_image, 1)
|
||||
],
|
||||
neighbor_max_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"NeighborMax",
|
||||
view)
|
||||
|
||||
dispatch_stage(tile_variance_stage,
|
||||
[
|
||||
get_sampler_uniform(tile_max_image, 0, false),
|
||||
get_image_uniform(tile_variance_image, 1)
|
||||
],
|
||||
tile_variance_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"TileVariance",
|
||||
view)
|
||||
|
||||
x_groups = floori((render_size.x - 1) / 16 + 1)
|
||||
y_groups = floori((render_size.y - 1) / 16 + 1)
|
||||
|
||||
dispatch_stage(blur_stage,
|
||||
[
|
||||
get_sampler_uniform(color_image, 0, false),
|
||||
get_sampler_uniform(custom_velocity_image, 1, false),
|
||||
get_sampler_uniform(neighbor_max_image, 2, false),
|
||||
get_sampler_uniform(tile_variance_image, 3, true),
|
||||
get_image_uniform(output_color_image, 4),
|
||||
],
|
||||
blur_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"Blur",
|
||||
view)
|
||||
|
||||
dispatch_stage(overlay_stage,
|
||||
[
|
||||
get_sampler_uniform(output_color_image, 0, false),
|
||||
get_image_uniform(color_image, 1)
|
||||
],
|
||||
[],
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"Overlay result",
|
||||
view)
|
||||
|
||||
rd.draw_command_end_label()
|
|
@ -1,8 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="ShaderStageResource" load_steps=3 format=3 uid="uid://cvb65hfs2lrxo"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SphynxMotionBlurToolkit/BaseClasses/shader_pass_resource.gd" id="1_i1bu0"]
|
||||
[ext_resource type="RDShaderFile" uid="uid://bn88jkvr17x4j" path="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_neighbor_max.glsl" id="2_jp4do"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_i1bu0")
|
||||
shader_file = ExtResource("2_jp4do")
|
|
@ -1,8 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="ShaderStageResource" load_steps=3 format=3 uid="uid://bidsfymvdyhek"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SphynxMotionBlurToolkit/BaseClasses/shader_pass_resource.gd" id="1_2uett"]
|
||||
[ext_resource type="RDShaderFile" uid="uid://i6rnwhmss334" path="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_overlay.glsl" id="2_evkw4"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_2uett")
|
||||
shader_file = ExtResource("2_evkw4")
|
|
@ -1,8 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="ShaderStageResource" load_steps=3 format=3 uid="uid://dipvwksvqb3dm"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SphynxMotionBlurToolkit/BaseClasses/shader_pass_resource.gd" id="1_bxcqf"]
|
||||
[ext_resource type="RDShaderFile" uid="uid://d0s5upcgm7r6l" path="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_tile_max_x.glsl" id="2_q6kae"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_bxcqf")
|
||||
shader_file = ExtResource("2_q6kae")
|
|
@ -1,8 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="ShaderStageResource" load_steps=3 format=3 uid="uid://bxfg45ubc2pv7"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SphynxMotionBlurToolkit/BaseClasses/shader_pass_resource.gd" id="1_gy5dj"]
|
||||
[ext_resource type="RDShaderFile" uid="uid://ceetvitdbio4l" path="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_tile_max_y.glsl" id="2_grpec"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_gy5dj")
|
||||
shader_file = ExtResource("2_grpec")
|
|
@ -1,8 +0,0 @@
|
|||
[gd_resource type="Resource" script_class="ShaderStageResource" load_steps=3 format=3 uid="uid://bqehecsdgt70s"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SphynxMotionBlurToolkit/BaseClasses/shader_pass_resource.gd" id="1_kkpwt"]
|
||||
[ext_resource type="RDShaderFile" uid="uid://by6mslkv0palh" path="res://addons/SphynxMotionBlurToolkit/Guertin/ShaderFiles/guertin_tile_variance.glsl" id="2_r5u5d"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_kkpwt")
|
||||
shader_file = ExtResource("2_r5u5d")
|
|
@ -1,245 +0,0 @@
|
|||
extends "res://addons/SphynxMotionBlurToolkit/Guertin/base_guertin_motion_blur.gd"
|
||||
class_name GuertinMotionBlur
|
||||
|
||||
@export_group("Shader Stages")
|
||||
@export var blur_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_experimental_blur_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(blur_stage)
|
||||
blur_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var overlay_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_overlay_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(overlay_stage)
|
||||
overlay_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var tile_max_x_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_tile_max_x_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(tile_max_x_stage)
|
||||
tile_max_x_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var tile_max_y_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_tile_max_y_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(tile_max_y_stage)
|
||||
tile_max_y_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var neighbor_max_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_neighbor_max_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(neighbor_max_stage)
|
||||
neighbor_max_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
@export var tile_variance_stage : ShaderStageResource = preload("res://addons/SphynxMotionBlurToolkit/Guertin/guertin_tile_variance_stage.tres"):
|
||||
set(value):
|
||||
unsubscribe_shader_stage(tile_variance_stage)
|
||||
tile_variance_stage = value
|
||||
subscirbe_shader_stage(value)
|
||||
|
||||
var output_color: StringName = "output_color"
|
||||
|
||||
var tile_max_x : StringName = "tile_max_x"
|
||||
|
||||
var tile_max : StringName = "tile_max"
|
||||
|
||||
var neighbor_max : StringName = "neighbor_max"
|
||||
|
||||
var tile_variance : StringName = "tile_variance"
|
||||
|
||||
var custom_velocity : StringName = "custom_velocity"
|
||||
|
||||
var freeze : bool = false
|
||||
|
||||
var temp_intensity : float
|
||||
|
||||
var previous_time : float = 0
|
||||
|
||||
func _render_callback_2(render_size : Vector2i, render_scene_buffers : RenderSceneBuffersRD, render_scene_data : RenderSceneDataRD):
|
||||
var time : float = float(Time.get_ticks_msec()) / 1000
|
||||
|
||||
var delta_time : float = time - previous_time
|
||||
|
||||
previous_time = time
|
||||
|
||||
temp_intensity = intensity
|
||||
|
||||
if framerate_independent:
|
||||
var capped_frame_time : float = 1 / target_constant_framerate
|
||||
|
||||
if !uncapped_independence:
|
||||
capped_frame_time = min(capped_frame_time, delta_time)
|
||||
|
||||
temp_intensity = intensity * capped_frame_time / delta_time
|
||||
|
||||
ensure_texture(tile_max_x, render_scene_buffers, RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, Vector2(1. / tile_size, 1.))
|
||||
ensure_texture(tile_max, render_scene_buffers, RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, Vector2(1. / tile_size, 1. / tile_size))
|
||||
ensure_texture(neighbor_max, render_scene_buffers, RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, Vector2(1. / tile_size, 1. / tile_size))
|
||||
ensure_texture(tile_variance, render_scene_buffers, RenderingDevice.DATA_FORMAT_R16G16B16A16_SFLOAT, Vector2(1. / tile_size, 1. / tile_size))
|
||||
ensure_texture(custom_velocity, render_scene_buffers)
|
||||
ensure_texture(output_color, render_scene_buffers)
|
||||
|
||||
rd.draw_command_begin_label("Motion Blur", Color(1.0, 1.0, 1.0, 1.0))
|
||||
|
||||
var tile_max_x_push_constants: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var int_tile_max_x_push_constants : PackedInt32Array = [
|
||||
tile_size,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var tile_max_x_push_constants_byte_array = tile_max_x_push_constants.to_byte_array()
|
||||
tile_max_x_push_constants_byte_array.append_array(int_tile_max_x_push_constants.to_byte_array())
|
||||
|
||||
var tile_max_y_push_constants: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var int_tile_max_y_push_constants : PackedInt32Array = [
|
||||
tile_size,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var tile_max_y_push_constants_byte_array = tile_max_y_push_constants.to_byte_array()
|
||||
tile_max_y_push_constants_byte_array.append_array(int_tile_max_y_push_constants.to_byte_array())
|
||||
|
||||
var neighbor_max_push_constants: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var int_neighbor_max_push_constants : PackedInt32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var neighbor_max_push_constants_byte_array = neighbor_max_push_constants.to_byte_array()
|
||||
neighbor_max_push_constants_byte_array.append_array(int_neighbor_max_push_constants.to_byte_array())
|
||||
|
||||
var tile_variance_push_constants: PackedFloat32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var int_tile_variance_push_constants : PackedInt32Array = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
var tile_variance_push_constants_byte_array = tile_variance_push_constants.to_byte_array()
|
||||
tile_variance_push_constants_byte_array.append_array(int_tile_variance_push_constants.to_byte_array())
|
||||
|
||||
var blur_push_constants: PackedFloat32Array = [
|
||||
minimum_user_threshold,
|
||||
importance_bias,
|
||||
maximum_jitter_value,
|
||||
temp_intensity,
|
||||
]
|
||||
var int_blur_push_constants : PackedInt32Array = [
|
||||
tile_size,
|
||||
samples,
|
||||
Engine.get_frames_drawn() % 8,
|
||||
0
|
||||
]
|
||||
var blur_push_constants_byte_array = blur_push_constants.to_byte_array()
|
||||
blur_push_constants_byte_array.append_array(int_blur_push_constants.to_byte_array())
|
||||
|
||||
var view_count = render_scene_buffers.get_view_count()
|
||||
|
||||
for view in range(view_count):
|
||||
var color_image := render_scene_buffers.get_color_layer(view)
|
||||
var depth_image := render_scene_buffers.get_depth_layer(view)
|
||||
var output_color_image := render_scene_buffers.get_texture_slice(context, output_color, view, 0, 1, 1)
|
||||
var tile_max_x_image := render_scene_buffers.get_texture_slice(context, tile_max_x, view, 0, 1, 1)
|
||||
var tile_max_image := render_scene_buffers.get_texture_slice(context, tile_max, view, 0, 1, 1)
|
||||
var neighbor_max_image := render_scene_buffers.get_texture_slice(context, neighbor_max, view, 0, 1, 1)
|
||||
var tile_variance_image := render_scene_buffers.get_texture_slice(context, tile_variance, view, 0, 1, 1)
|
||||
var custom_velocity_image := render_scene_buffers.get_texture_slice(context, custom_velocity, view, 0, 1, 1)
|
||||
|
||||
var x_groups := floori((render_size.x / tile_size - 1) / 16 + 1)
|
||||
var y_groups := floori((render_size.y - 1) / 16 + 1)
|
||||
|
||||
dispatch_stage(tile_max_x_stage,
|
||||
[
|
||||
get_sampler_uniform(custom_velocity_image, 0, false),
|
||||
get_sampler_uniform(depth_image, 1, false),
|
||||
get_image_uniform(tile_max_x_image, 2)
|
||||
],
|
||||
tile_max_x_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"TileMaxX",
|
||||
view)
|
||||
|
||||
x_groups = floori((render_size.x / tile_size - 1) / 16 + 1)
|
||||
y_groups = floori((render_size.y / tile_size - 1) / 16 + 1)
|
||||
|
||||
dispatch_stage(tile_max_y_stage,
|
||||
[
|
||||
get_sampler_uniform(tile_max_x_image, 0, false),
|
||||
get_image_uniform(tile_max_image, 1)
|
||||
],
|
||||
tile_max_y_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"TileMaxY",
|
||||
view)
|
||||
|
||||
dispatch_stage(neighbor_max_stage,
|
||||
[
|
||||
get_sampler_uniform(tile_max_image, 0, false),
|
||||
get_image_uniform(neighbor_max_image, 1)
|
||||
],
|
||||
neighbor_max_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"NeighborMax",
|
||||
view)
|
||||
|
||||
dispatch_stage(tile_variance_stage,
|
||||
[
|
||||
get_sampler_uniform(tile_max_image, 0, false),
|
||||
get_image_uniform(tile_variance_image, 1)
|
||||
],
|
||||
tile_variance_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"TileVariance",
|
||||
view)
|
||||
|
||||
x_groups = floori((render_size.x - 1) / 16 + 1)
|
||||
y_groups = floori((render_size.y - 1) / 16 + 1)
|
||||
|
||||
dispatch_stage(blur_stage,
|
||||
[
|
||||
get_sampler_uniform(color_image, 0, false),
|
||||
get_sampler_uniform(custom_velocity_image, 1, false),
|
||||
get_sampler_uniform(neighbor_max_image, 2, false),
|
||||
get_sampler_uniform(tile_variance_image, 3, true),
|
||||
get_image_uniform(output_color_image, 4),
|
||||
],
|
||||
blur_push_constants_byte_array,
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"Blur",
|
||||
view)
|
||||
|
||||
dispatch_stage(overlay_stage,
|
||||
[
|
||||
get_sampler_uniform(output_color_image, 0, false),
|
||||
get_image_uniform(color_image, 1)
|
||||
],
|
||||
[],
|
||||
Vector3i(x_groups, y_groups, 1),
|
||||
"Overlay result",
|
||||
view)
|
||||
|
||||
rd.draw_command_end_label()
|
|
@ -1,63 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max;
|
||||
layout(set = 0, binding = 1) uniform sampler2D tile_max_map;
|
||||
layout(rgba16f, set = 0, binding = 2) uniform writeonly image2D neighbor_max;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan5;
|
||||
float nan6;
|
||||
float nan7;
|
||||
float nan8;
|
||||
int nan1;
|
||||
int nan2;
|
||||
int nan3;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec2 max_neighbor_velocity = vec2(0);
|
||||
|
||||
float max_neighbor_depth = -1;
|
||||
|
||||
for(int i = -1; i < 2; i++)
|
||||
{
|
||||
for(int j = -1; j < 2; j++)
|
||||
{
|
||||
vec2 current_offset = vec2(1) / vec2(render_size) * vec2(i, j);
|
||||
vec2 current_uv = uvn + current_offset;
|
||||
if(current_uv.x < 0 || current_uv.x > 1 || current_uv.y < 0 || current_uv.y > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vec3 current_neighbor_sample = textureLod(tile_max_map, current_uv, 0.0).xyz;
|
||||
|
||||
if(current_neighbor_sample.z > max_neighbor_depth)
|
||||
{
|
||||
max_neighbor_depth = current_neighbor_sample.z;
|
||||
max_neighbor_velocity = current_neighbor_sample.xy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imageStore(neighbor_max, uvi, vec4(max_neighbor_velocity, 0, 1));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://bcivntgn7ipwo"
|
||||
path="res://.godot/imported/jf_neighbor_depth_max.glsl-d20bc4da7a00b27ca7e046fc2a191610.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/Archive/jf_neighbor_depth_max.glsl"
|
||||
dest_files=["res://.godot/imported/jf_neighbor_depth_max.glsl-d20bc4da7a00b27ca7e046fc2a191610.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max_sampler;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform writeonly image2D buffer_a;
|
||||
layout(rgba16f, set = 0, binding = 2) uniform writeonly image2D buffer_b;
|
||||
layout(set = 0, binding = 3) uniform sampler2D buffer_a_sampler;
|
||||
layout(set = 0, binding = 4) uniform sampler2D buffer_b_sampler;
|
||||
|
||||
layout(set = 0, binding = 5, std430) restrict buffer MyDataBuffer {
|
||||
int iteration_index;
|
||||
}
|
||||
iteration_data;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
int nan0;//iteration_index;
|
||||
int last_iteration_index;
|
||||
int nan1;
|
||||
int nan2;
|
||||
float perpen_error_thresh;
|
||||
float sample_step_multiplier;
|
||||
float motion_blur_intensity;
|
||||
float nan_fl_5;
|
||||
float nan_fl_4;
|
||||
float nan_fl_3;
|
||||
float nan_fl_6;
|
||||
float step_exponent_modifier;
|
||||
float nan_fl_0;//step_size;
|
||||
float max_dilation_radius;
|
||||
float nan_fl_1;
|
||||
float nan_fl_2;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
const int kernel_size = 8;
|
||||
|
||||
const vec2 check_step_kernel[kernel_size] = {
|
||||
vec2(-1, 0),
|
||||
vec2(1, 0),
|
||||
vec2(0, -1),
|
||||
vec2(0, 1),
|
||||
vec2(-1, 1),
|
||||
vec2(1, -1),
|
||||
vec2(1, 1),
|
||||
vec2(-1, -1),
|
||||
};
|
||||
|
||||
vec2 get_value(bool a, vec2 uv)
|
||||
{
|
||||
if(a)
|
||||
{
|
||||
return textureLod(buffer_a_sampler, uv, 0.0).xy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return textureLod(buffer_b_sampler, uv, 0.0).xy;
|
||||
}
|
||||
}
|
||||
|
||||
void set_value(bool a, ivec2 uvi, vec4 value)
|
||||
{
|
||||
if(a)
|
||||
{
|
||||
imageStore(buffer_a, uvi, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageStore(buffer_b, uvi, value);
|
||||
}
|
||||
}
|
||||
|
||||
void sample_fitness(vec2 uv_offset, vec4 uv_sample, vec2 render_size, inout vec4 current_sample_fitness)
|
||||
{
|
||||
vec2 sample_velocity = -uv_sample.xy;
|
||||
|
||||
// if (dot(sample_velocity, sample_velocity) <= FLT_MIN || uv_sample.w == 0)
|
||||
// {
|
||||
// current_sample_fitness = vec4(10, 10, 0, 0);
|
||||
// return;
|
||||
// }
|
||||
|
||||
float velocity_space_distance = dot(sample_velocity, uv_offset) / dot(sample_velocity, sample_velocity);
|
||||
|
||||
float mid_point = params.motion_blur_intensity / 2 + 1e-5;
|
||||
|
||||
float absolute_velocity_space_distance = abs(velocity_space_distance - mid_point);
|
||||
|
||||
float within_velocity_range = step(absolute_velocity_space_distance, mid_point);
|
||||
|
||||
float side_offset = abs(dot(vec2(uv_offset.y, -uv_offset.x), sample_velocity)) / dot(sample_velocity, sample_velocity);
|
||||
|
||||
float within_perpen_error_range = step(side_offset, params.perpen_error_thresh * params.motion_blur_intensity);
|
||||
|
||||
current_sample_fitness = vec4(/*max(absolute_velocity_space_distance, side_offset)*/absolute_velocity_space_distance, velocity_space_distance, uv_sample.w + uv_sample.z * velocity_space_distance, within_velocity_range * within_perpen_error_range);
|
||||
}
|
||||
|
||||
//float is_sample_better(vec4 a, vec4 b)
|
||||
//{
|
||||
// return 1. - step(b.x * a.w, a.x * b.w);//mix(1. - step(b.x * a.w, a.x * b.w), step(b.z, a.z), step(0.5, b.w) * step(0.5, a.w));
|
||||
//}
|
||||
|
||||
//vec4 backtrack_sample(vec2 chosen_uv, vec4 best_sample_fitness)
|
||||
//{
|
||||
// vec4 velocity = textureLod(tile_max_sampler, chosen_uv, 0.0);
|
||||
//
|
||||
// vec2 uv_candidate = chosen_uv + velocity.xy;
|
||||
//
|
||||
// vec4 velocity_candidate = textureLod(tile_max_sampler, uv_candidate, 0.0);
|
||||
//
|
||||
// if((dot(velocity, velocity_candidate) / dot(velocity, velocity)) > 0.5 && velocity_candidate.w > 0)
|
||||
// {
|
||||
// return vec4(uv_candidate, 0, 0);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return vec4(chosen_uv, 0, 0);
|
||||
// }
|
||||
//}
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec2 step_size = vec2(round(pow(2 + params.step_exponent_modifier, params.last_iteration_index - iteration_data.iteration_index)));
|
||||
|
||||
vec2 uv_step = vec2(round(step_size)) / render_size;
|
||||
|
||||
vec4 best_sample_fitness = vec4(10, 10, 0, 0);
|
||||
|
||||
vec2 chosen_uv = uvn;
|
||||
|
||||
bool set_a = !bool(step(0.5, float(iteration_data.iteration_index % 2)));
|
||||
|
||||
iteration_data.iteration_index += 1;
|
||||
|
||||
vec2 step_offset;
|
||||
|
||||
vec2 check_uv;
|
||||
|
||||
vec4 uv_sample;
|
||||
|
||||
vec4 current_sample_fitness;
|
||||
|
||||
for(int i = 0; i < kernel_size; i++)
|
||||
{
|
||||
step_offset = check_step_kernel[i] * uv_step;
|
||||
check_uv = uvn + step_offset;
|
||||
|
||||
if(any(notEqual(check_uv, clamp(check_uv, vec2(0.0), vec2(1.0)))))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// if(iteration_data.iteration_index > 0)
|
||||
// {
|
||||
check_uv = get_value(!set_a, check_uv).xy;
|
||||
|
||||
step_offset = check_uv - uvn;
|
||||
// }
|
||||
|
||||
uv_sample = textureLod(tile_max_sampler, check_uv, 0.0);
|
||||
|
||||
sample_fitness(step_offset, uv_sample, render_size, current_sample_fitness);
|
||||
|
||||
float sample_better = 1. - step(current_sample_fitness.z * current_sample_fitness.w, best_sample_fitness.z * best_sample_fitness.w);
|
||||
best_sample_fitness = mix(best_sample_fitness, current_sample_fitness, sample_better);
|
||||
chosen_uv = mix(chosen_uv, check_uv, sample_better);
|
||||
}
|
||||
|
||||
// if(params.iteration_index < params.last_iteration_index)
|
||||
// {
|
||||
// set_value(set_a, uvi, vec4(chosen_uv, 0, 0));
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// float depth = textureLod(tile_max_sampler, uvn, 0.0).w;
|
||||
//
|
||||
// if(params.iteration_index == params.last_iteration_index && (best_sample_fitness.w < 0.5 || depth > best_sample_fitness.z))
|
||||
// {
|
||||
// set_value(set_a, uvi, vec4(uvn, 0, 0));
|
||||
// return;
|
||||
// }
|
||||
|
||||
set_value(set_a, uvi, vec4(chosen_uv, 0, 0));
|
||||
|
||||
// vec4 backtracked_sample = backtrack_sample(chosen_uv, best_sample_fitness);
|
||||
//
|
||||
// set_value(set_a, uvi, backtracked_sample);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://brlr85tfh5tv2"
|
||||
path="res://.godot/imported/jf_simple_archive_17_8_24.glsl-e91ee2bf9d7e74579e89e443fc0e02d3.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/Archive/jf_simple_archive_17_8_24.glsl"
|
||||
dest_files=["res://.godot/imported/jf_simple_archive_17_8_24.glsl-e91ee2bf9d7e74579e89e443fc0e02d3.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,192 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max_sampler;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform writeonly image2D buffer_a;
|
||||
layout(rgba16f, set = 0, binding = 2) uniform writeonly image2D buffer_b;
|
||||
layout(set = 0, binding = 3) uniform sampler2D buffer_a_sampler;
|
||||
layout(set = 0, binding = 4) uniform sampler2D buffer_b_sampler;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
int iteration_index;
|
||||
int last_iteration_index;
|
||||
int nan1;
|
||||
int nan2;
|
||||
float perpen_error_thresh;
|
||||
float sample_step_multiplier;
|
||||
float motion_blur_intensity;
|
||||
float nan_fl_5;
|
||||
float nan_fl_4;
|
||||
float nan_fl_3;
|
||||
float nan_fl_6;
|
||||
float step_exponent_modifier;
|
||||
float step_size;
|
||||
float max_dilation_radius;
|
||||
float nan_fl_1;
|
||||
float nan_fl_2;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
const int kernel_size = 8;
|
||||
|
||||
const vec2 check_step_kernel[kernel_size] = {
|
||||
vec2(-1, 0),
|
||||
vec2(1, 0),
|
||||
vec2(0, -1),
|
||||
vec2(0, 1),
|
||||
vec2(-1, 1),
|
||||
vec2(1, -1),
|
||||
vec2(1, 1),
|
||||
vec2(-1, -1),
|
||||
};
|
||||
|
||||
vec2 get_value(bool a, vec2 uv)
|
||||
{
|
||||
if(a)
|
||||
{
|
||||
return textureLod(buffer_a_sampler, uv, 0.0).xy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return textureLod(buffer_b_sampler, uv, 0.0).xy;
|
||||
}
|
||||
}
|
||||
|
||||
void set_value(bool a, ivec2 uvi, vec4 value)
|
||||
{
|
||||
if(a)
|
||||
{
|
||||
imageStore(buffer_a, uvi, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageStore(buffer_b, uvi, value);
|
||||
}
|
||||
}
|
||||
|
||||
void sample_fitness(vec2 uv_offset, vec4 uv_sample, vec2 render_size, inout vec4 current_sample_fitness)
|
||||
{
|
||||
vec2 sample_velocity = -uv_sample.xy;
|
||||
|
||||
// if (dot(sample_velocity, sample_velocity) <= FLT_MIN || uv_sample.w == 0)
|
||||
// {
|
||||
// current_sample_fitness = vec4(10, 10, 0, 0);
|
||||
// return;
|
||||
// }
|
||||
|
||||
float velocity_space_distance = dot(sample_velocity, uv_offset) / dot(sample_velocity, sample_velocity);
|
||||
|
||||
float mid_point = params.motion_blur_intensity / 2 + 1e-5;
|
||||
|
||||
float absolute_velocity_space_distance = abs(velocity_space_distance - mid_point);
|
||||
|
||||
float within_velocity_range = step(absolute_velocity_space_distance, mid_point);
|
||||
|
||||
float side_offset = abs(dot(vec2(uv_offset.y, -uv_offset.x), sample_velocity)) / dot(sample_velocity, sample_velocity);
|
||||
|
||||
float within_perpen_error_range = step(side_offset, params.perpen_error_thresh * params.motion_blur_intensity);
|
||||
|
||||
current_sample_fitness = vec4(/*max(absolute_velocity_space_distance, side_offset)*/absolute_velocity_space_distance, velocity_space_distance, uv_sample.w + uv_sample.z * velocity_space_distance, within_velocity_range * within_perpen_error_range);
|
||||
}
|
||||
|
||||
//float is_sample_better(vec4 a, vec4 b)
|
||||
//{
|
||||
// return 1. - step(b.x * a.w, a.x * b.w);//mix(1. - step(b.x * a.w, a.x * b.w), step(b.z, a.z), step(0.5, b.w) * step(0.5, a.w));
|
||||
//}
|
||||
|
||||
//vec4 backtrack_sample(vec2 chosen_uv, vec4 best_sample_fitness)
|
||||
//{
|
||||
// vec4 velocity = textureLod(tile_max_sampler, chosen_uv, 0.0);
|
||||
//
|
||||
// vec2 uv_candidate = chosen_uv + velocity.xy;
|
||||
//
|
||||
// vec4 velocity_candidate = textureLod(tile_max_sampler, uv_candidate, 0.0);
|
||||
//
|
||||
// if((dot(velocity, velocity_candidate) / dot(velocity, velocity)) > 0.5 && velocity_candidate.w > 0)
|
||||
// {
|
||||
// return vec4(uv_candidate, 0, 0);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return vec4(chosen_uv, 0, 0);
|
||||
// }
|
||||
//}
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec2 uv_step = vec2(round(params.step_size)) / render_size;
|
||||
|
||||
vec4 best_sample_fitness = vec4(10, 10, 0, 0);
|
||||
|
||||
vec2 chosen_uv = uvn;
|
||||
|
||||
bool set_a = !bool(step(0.5, float(params.iteration_index % 2)));
|
||||
|
||||
vec2 step_offset;
|
||||
|
||||
vec2 check_uv;
|
||||
|
||||
vec4 uv_sample;
|
||||
|
||||
vec4 current_sample_fitness;
|
||||
|
||||
for(int i = 0; i < kernel_size; i++)
|
||||
{
|
||||
step_offset = check_step_kernel[i] * uv_step;
|
||||
check_uv = uvn + step_offset;
|
||||
|
||||
if(any(notEqual(check_uv, clamp(check_uv, vec2(0.0), vec2(1.0)))))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(params.iteration_index > 0)
|
||||
{
|
||||
check_uv = get_value(!set_a, check_uv).xy;
|
||||
|
||||
step_offset = check_uv - uvn;
|
||||
}
|
||||
|
||||
uv_sample = textureLod(tile_max_sampler, check_uv, 0.0);
|
||||
|
||||
sample_fitness(step_offset, uv_sample, render_size, current_sample_fitness);
|
||||
|
||||
float sample_better = 1. - step(current_sample_fitness.z * current_sample_fitness.w, best_sample_fitness.z * best_sample_fitness.w);
|
||||
best_sample_fitness = mix(best_sample_fitness, current_sample_fitness, sample_better);
|
||||
chosen_uv = mix(chosen_uv, check_uv, sample_better);
|
||||
}
|
||||
|
||||
// if(params.iteration_index < params.last_iteration_index)
|
||||
// {
|
||||
// set_value(set_a, uvi, vec4(chosen_uv, 0, 0));
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// float depth = textureLod(tile_max_sampler, uvn, 0.0).w;
|
||||
//
|
||||
// if(params.iteration_index == params.last_iteration_index && (best_sample_fitness.w < 0.5 || depth > best_sample_fitness.z))
|
||||
// {
|
||||
// set_value(set_a, uvi, vec4(uvn, 0, 0));
|
||||
// return;
|
||||
// }
|
||||
|
||||
set_value(set_a, uvi, vec4(chosen_uv, 0, 0));
|
||||
|
||||
// vec4 backtracked_sample = backtrack_sample(chosen_uv, best_sample_fitness);
|
||||
//
|
||||
// set_value(set_a, uvi, backtracked_sample);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://c7q41dxu78i8o"
|
||||
path="res://.godot/imported/jfp_simple_push_based_archive.glsl-a99001e07de7540b5869f83d2e3643a4.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/Archive/jfp_simple_push_based_archive.glsl"
|
||||
dest_files=["res://.godot/imported/jfp_simple_push_based_archive.glsl-a99001e07de7540b5869f83d2e3643a4.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D color_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D depth_sampler;
|
||||
layout(set = 0, binding = 2) uniform sampler2D vector_sampler;
|
||||
layout(set = 0, binding = 3) uniform sampler2D velocity_map;
|
||||
layout(rgba16f, set = 0, binding = 4) uniform writeonly image2D output_image;
|
||||
layout(rgba16f, set = 0, binding = 5) uniform writeonly image2D debug_1_image;
|
||||
layout(rgba16f, set = 0, binding = 6) uniform writeonly image2D debug_2_image;
|
||||
layout(rgba16f, set = 0, binding = 7) uniform writeonly image2D debug_3_image;
|
||||
layout(rgba16f, set = 0, binding = 8) uniform writeonly image2D debug_4_image;
|
||||
layout(rgba16f, set = 0, binding = 9) uniform writeonly image2D debug_5_image;
|
||||
layout(rgba16f, set = 0, binding = 10) uniform writeonly image2D debug_6_image;
|
||||
layout(rgba16f, set = 0, binding = 11) uniform writeonly image2D debug_7_image;
|
||||
layout(rgba16f, set = 0, binding = 12) uniform writeonly image2D debug_8_image;
|
||||
layout(set = 0, binding = 13) uniform sampler2D tile_max;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float motion_blur_samples;
|
||||
float motion_blur_intensity;
|
||||
float motion_blur_center_fade;
|
||||
float frame;
|
||||
float last_iteration_index;
|
||||
float sample_step_multiplier;
|
||||
float step_exponent_modifier;
|
||||
float max_dilation_radius;
|
||||
int nan0;
|
||||
int nan1;
|
||||
int nan2;
|
||||
int nan3;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
// McGuire's functions https://docs.google.com/document/d/1IIlAKTj-O01hcXEdGxTErQbCHO9iBmRx6oFUy_Jm0fI/edit
|
||||
// ----------------------------------------------------------
|
||||
float soft_depth_compare(float depth_X, float depth_Y, float sze)
|
||||
{
|
||||
return clamp(1 - (depth_X - depth_Y) / sze, 0, 1);
|
||||
}
|
||||
|
||||
float cone(float T, float v)
|
||||
{
|
||||
return clamp(1 - T / v, 0, 1);
|
||||
}
|
||||
|
||||
float cylinder(float T, float v)
|
||||
{
|
||||
return 1.0 - smoothstep(0.95 * v, 1.05 * v, T);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// Guertin's functions https://research.nvidia.com/sites/default/files/pubs/2013-11_A-Fast-and/Guertin2013MotionBlur-small.pdf
|
||||
// ----------------------------------------------------------
|
||||
float z_compare(float a, float b, float sze)
|
||||
{
|
||||
return clamp(1. - sze * (a - b) / min(a, b), 0, 1);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://www.shadertoy.com/view/ftKfzc
|
||||
// ----------------------------------------------------------
|
||||
float interleaved_gradient_noise(vec2 uv){
|
||||
uv += float(params.frame) * (vec2(47, 17) * 0.695);
|
||||
|
||||
vec3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
|
||||
return fract(magic.z * fract(dot(uv, magic.xy)));
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://github.com/bradparks/KinoMotion__unity_motion_blur/tree/master
|
||||
// ----------------------------------------------------------
|
||||
vec2 safenorm(vec2 v)
|
||||
{
|
||||
float l = max(length(v), 1e-6);
|
||||
return v / l * int(1 >= 0.5);
|
||||
}
|
||||
|
||||
vec2 jitter_tile(vec2 uvi)
|
||||
{
|
||||
float rx, ry;
|
||||
float angle = interleaved_gradient_noise(uvi + vec2(2, 0)) * M_PI * 2;
|
||||
rx = cos(angle);
|
||||
ry = sin(angle);
|
||||
return vec2(rx, ry) / textureSize(tile_max, 0) / 4;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
float get_motion_difference(vec2 V, vec2 V2, float power)
|
||||
{
|
||||
vec2 VO = V - V2;
|
||||
float difference = dot(VO, V) / max(FLT_MIN, dot(V, V));
|
||||
return pow(clamp(difference, 0, 1), power);
|
||||
}
|
||||
|
||||
vec2 sample_random_offset(vec2 uv, float j)
|
||||
{
|
||||
return vec2(0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 x = (vec2(uvi) + vec2(0.5)) / vec2(render_size);
|
||||
|
||||
vec2 velocity_map_sample = textureLod(velocity_map, x + jitter_tile(uvi), 0.0).xy;
|
||||
|
||||
vec3 vnz = textureLod(tile_max, velocity_map_sample, 0.0).xyz * vec3(render_size, 1);// * 2;
|
||||
|
||||
vec2 vn = vnz.xy;
|
||||
|
||||
float vn_length = max(0.5, length(vn));
|
||||
|
||||
vec2 wn = safenorm(vn);
|
||||
|
||||
vec4 col_x = textureLod(color_sampler, x, 0.0);
|
||||
|
||||
vec3 vxz = textureLod(vector_sampler, x, 0.0).xyz * vec3(render_size, 1);// * 2;
|
||||
|
||||
vec2 vx = vxz.xy;
|
||||
|
||||
if(vn_length <= 0.5)
|
||||
{
|
||||
imageStore(output_image, uvi, col_x);
|
||||
imageStore(debug_1_image, uvi, col_x);
|
||||
imageStore(debug_2_image, uvi, abs(vec4(vn / render_size * 10, vnz.z * 100, 1)));
|
||||
imageStore(debug_3_image, uvi, abs(vec4(velocity_map_sample - x, 0, 1)));
|
||||
imageStore(debug_4_image, uvi, abs(vec4(vx / render_size * 10, vxz.z * 100, 1)));
|
||||
imageStore(debug_5_image, uvi, 10 * abs(textureLod(tile_max, x, 0.0)));
|
||||
imageStore(debug_6_image, uvi, 10 * abs(textureLod(tile_max, textureLod(velocity_map, x, 0.0).xy, 0.0)));
|
||||
imageStore(debug_7_image, uvi, 10 * abs(textureLod(velocity_map, x, 0.0)));
|
||||
imageStore(debug_8_image, uvi, abs(textureLod(velocity_map, x, 0.0) / 10));
|
||||
return;
|
||||
}
|
||||
|
||||
float zx = -0.05 / max(FLT_MIN, textureLod(depth_sampler, x, 0.0).x);
|
||||
|
||||
float vx_length = max(0.5, length(vx));
|
||||
|
||||
vec2 wx = safenorm(vx);
|
||||
|
||||
vec2 wp = vec2(-wn.y, wn.x);
|
||||
|
||||
if(dot(wp, vx) < 0)
|
||||
{
|
||||
wp = -wp;
|
||||
}
|
||||
|
||||
vec2 wc = safenorm(mix(wp, wx, clamp((vx_length - 0.5) / 1.5, 0, 1)));
|
||||
|
||||
float weight = 1;//params.motion_blur_samples / (100 * vx_length);
|
||||
|
||||
vec4 sum = col_x * weight;
|
||||
|
||||
float j = interleaved_gradient_noise(uvi) - 0.5;
|
||||
|
||||
int vnvx = 2;//int(vn_length / (10 + vx_length)) + 2;
|
||||
|
||||
for(int i = 0; i < params.motion_blur_samples; i++)
|
||||
{
|
||||
if(i == (params.motion_blur_samples - 1) / 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float t = mix(-1., 0.0, (i + j + 1.0) / (params.motion_blur_samples + 1.0));
|
||||
|
||||
float T = abs(t * vn_length);
|
||||
|
||||
float Tx = abs((t + 0.5) * vn_length);
|
||||
|
||||
bool sample_main_v = !(((i - 1) % vnvx) == 0);
|
||||
|
||||
vec2 d = vn;//sample_main_v ? vn : vx;
|
||||
|
||||
float dz = vnz.z;//sample_main_v ? vnz.z : vxz.z;
|
||||
|
||||
vec2 wd = safenorm(d);
|
||||
|
||||
vec2 y = x + (d / render_size) * t;
|
||||
|
||||
vec2 vy = textureLod(vector_sampler, y, 0.0).xy * render_size;// * 2;
|
||||
|
||||
float vy_length = max(0.5, length(vy));
|
||||
|
||||
float zy = -0.05 / max(FLT_MIN, textureLod(depth_sampler, y, 0.0).x - dz * t);
|
||||
|
||||
float f = z_compare(zy, zx, 15);
|
||||
float b = z_compare(zx, zy, 15);
|
||||
|
||||
float wa = abs(max(0, dot(vy / vy_length, wd)));
|
||||
|
||||
float wb = abs((dot(wc, wd)));
|
||||
|
||||
float cone_x = cone(T, vx_length); // how much of the velocity reaches the current position
|
||||
|
||||
float cone_y = cone(T, vy_length); // how much of the velocity reaches the current position
|
||||
|
||||
float ay = clamp(max(step(FLT_MIN, f * wa * cone_y), step(FLT_MIN, b * wb * cone_x)), 0, 1);// * wb;// + cylinder(T, vy_length) * cylinder(T, vx_length) * 2;//cylinder(T, min(vy_length, vx_length)) * 2. * max(wa, wb);//
|
||||
|
||||
vec4 col_y = textureLod(color_sampler, y, 0.0);
|
||||
|
||||
vec4 final_color = mix(col_x, col_y, ay);
|
||||
|
||||
float final_weight = mix(1, 1, ay);
|
||||
|
||||
weight += final_weight;//ay;
|
||||
sum += final_color * final_weight;// * ay;
|
||||
}
|
||||
|
||||
sum /= weight;
|
||||
|
||||
imageStore(output_image, uvi, sum);
|
||||
|
||||
imageStore(debug_1_image, uvi, sum);
|
||||
imageStore(debug_2_image, uvi, abs(vec4(vn / render_size * 10, vnz.z * 100, 1)));
|
||||
imageStore(debug_3_image, uvi, abs(vec4(velocity_map_sample - x, 0, 1)));
|
||||
imageStore(debug_4_image, uvi, abs(vec4(vx / render_size * 10, vxz.z * 100, 1)));
|
||||
imageStore(debug_5_image, uvi, 10 * abs(textureLod(tile_max, x, 0.0)));
|
||||
imageStore(debug_6_image, uvi, 10 * abs(textureLod(tile_max, textureLod(velocity_map, x, 0.0).xy, 0.0)));
|
||||
imageStore(debug_7_image, uvi, 10 * abs(textureLod(velocity_map, x, 0.0)));
|
||||
imageStore(debug_8_image, uvi, abs(textureLod(velocity_map, x, 0.0) / 10));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://dc6r26wwdjceq"
|
||||
path="res://.godot/imported/jump_flood_mcguire_blur.glsl-db182d03471f2a14ff66b8fcdafe8dc6.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/Archive/jump_flood_mcguire_blur.glsl"
|
||||
dest_files=["res://.godot/imported/jump_flood_mcguire_blur.glsl-db182d03471f2a14ff66b8fcdafe8dc6.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,452 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D color_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D depth_sampler;
|
||||
layout(set = 0, binding = 2) uniform sampler2D velocity_sampler;
|
||||
layout(set = 0, binding = 3) uniform sampler2D velocity_map;
|
||||
layout(rgba16f, set = 0, binding = 4) uniform writeonly image2D output_image;
|
||||
layout(set = 0, binding = 5) uniform sampler2D tile_max;
|
||||
layout(set = 0, binding = 6) uniform sampler2D past_color_sampler;
|
||||
layout(set = 0, binding = 7) uniform sampler2D past_velocity_sampler;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float motion_blur_samples;
|
||||
float motion_blur_intensity;
|
||||
float motion_blur_center_fade;
|
||||
float frame;
|
||||
float last_iteration_index;
|
||||
float sample_step_multiplier;
|
||||
float step_exponent_modifier;
|
||||
float max_dilation_radius;
|
||||
int nan0;
|
||||
int nan1;
|
||||
int nan2;
|
||||
int nan3;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
// McGuire's functions https://docs.google.com/document/d/1IIlAKTj-O01hcXEdGxTErQbCHO9iBmRx6oFUy_Jm0fI/edit
|
||||
// ----------------------------------------------------------
|
||||
float soft_depth_compare(float depth_X, float depth_Y, float sze)
|
||||
{
|
||||
return clamp(1 - (depth_X - depth_Y) / sze, 0, 1);
|
||||
}
|
||||
|
||||
float cone(float T, float v)
|
||||
{
|
||||
return clamp(1 - T / v, 0, 1);
|
||||
}
|
||||
|
||||
float cylinder(float T, float v)
|
||||
{
|
||||
return 1.0 - smoothstep(0.95 * v, 1.05 * v, T);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// Guertin's functions https://research.nvidia.com/sites/default/files/pubs/2013-11_A-Fast-and/Guertin2013MotionBlur-small.pdf
|
||||
// ----------------------------------------------------------
|
||||
float z_compare(float a, float b, float sze)
|
||||
{
|
||||
return clamp(1. - sze * (a - b), 0, 1);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://www.shadertoy.com/view/ftKfzc
|
||||
// ----------------------------------------------------------
|
||||
float interleaved_gradient_noise(vec2 uv){
|
||||
uv += float(params.frame) * (vec2(47, 17) * 0.695);
|
||||
|
||||
vec3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
|
||||
return fract(magic.z * fract(dot(uv, magic.xy)));
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://github.com/bradparks/KinoMotion__unity_motion_blur/tree/master
|
||||
// ----------------------------------------------------------
|
||||
vec2 safenorm(vec2 v)
|
||||
{
|
||||
float l = max(length(v), 1e-6);
|
||||
return v / l * int(l >= 0.5);
|
||||
}
|
||||
|
||||
vec2 jitter_tile(vec2 uvi)
|
||||
{
|
||||
float rx, ry;
|
||||
float angle = interleaved_gradient_noise(uvi + vec2(2, 0)) * M_PI * 2;
|
||||
rx = cos(angle);
|
||||
ry = sin(angle);
|
||||
return vec2(rx, ry) / textureSize(tile_max, 0) / 4;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 x = (vec2(uvi) + vec2(0.5)) / vec2(render_size);
|
||||
|
||||
vec2 velocity_map_sample = textureLod(velocity_map, x + jitter_tile(uvi), 0.0).xy;
|
||||
|
||||
vec3 vnz = textureLod(tile_max, velocity_map_sample, 0.0).xyz * vec3(render_size, 1);
|
||||
|
||||
float vn_length = max(0.5, length(vnz.xy));
|
||||
|
||||
float multiplier = clamp(vn_length, 0, min(params.max_dilation_radius, vn_length * params.motion_blur_intensity)) / max(FLT_MIN, vn_length);
|
||||
|
||||
vnz.xyz *= multiplier;
|
||||
|
||||
vn_length *= multiplier;
|
||||
|
||||
vec2 vn = vnz.xy;
|
||||
|
||||
vec4 col_x = textureLod(color_sampler, x, 0.0);
|
||||
|
||||
vec2 wn = safenorm(vn);
|
||||
|
||||
vec4 vxz = textureLod(velocity_sampler, x, 0.0) * vec4(render_size, 1, 1);
|
||||
|
||||
float vx_length = max(0.5, length(vxz.xy));
|
||||
|
||||
multiplier = clamp(vx_length, 0, min(params.max_dilation_radius, vn_length * params.motion_blur_intensity)) / max(FLT_MIN, vx_length);
|
||||
|
||||
vxz.xyz *= multiplier;
|
||||
|
||||
vx_length *= multiplier;
|
||||
|
||||
vec2 vx = vxz.xy;
|
||||
|
||||
if(vn_length <= 0.5)
|
||||
{
|
||||
imageStore(output_image, uvi, col_x);
|
||||
|
||||
#ifdef DEBUG
|
||||
imageStore(debug_1_image, uvi, col_x);
|
||||
imageStore(debug_2_image, uvi, abs(vec4(vn / render_size * 10, vnz.z * 100, 1)));
|
||||
imageStore(debug_3_image, uvi, abs(vec4(velocity_map_sample - x, 0, 1)));
|
||||
imageStore(debug_4_image, uvi, abs(vec4(vx / render_size * 10, vxz.z * 100, 1)));
|
||||
imageStore(debug_5_image, uvi, col_x);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
float velocity_match = pow(clamp(dot(vx, vn) / dot(vn, vn), 0, 1), 0.25);
|
||||
|
||||
vn = mix(vn, vx, velocity_match);
|
||||
|
||||
vnz = mix(vnz, vxz.xyz, velocity_match);
|
||||
|
||||
float zx = vxz.w;
|
||||
|
||||
vec2 wx = safenorm(vx);
|
||||
|
||||
float weight = 0;
|
||||
|
||||
vec4 sum = col_x * weight;
|
||||
|
||||
float total_back_weight = 1e-10;
|
||||
|
||||
vec4 back_sum = col_x * total_back_weight;
|
||||
|
||||
float j = interleaved_gradient_noise(uvi) - 0.5;
|
||||
|
||||
vec4 past_vxz = textureLod(past_velocity_sampler, x, 0.0) * vec4(render_size, 1, 1);
|
||||
|
||||
vec2 past_vx = past_vxz.xy;
|
||||
|
||||
vec4 past_col_x = textureLod(past_color_sampler, x, 0.0);
|
||||
|
||||
for(int i = 0; i < params.motion_blur_samples; i++)
|
||||
{
|
||||
float nai_t = mix(0., -1., (i + j + 1.0) / (params.motion_blur_samples + 1.0));
|
||||
|
||||
float nai_T = abs(nai_t * vx_length);
|
||||
|
||||
vec2 nai_y = x + (vx / render_size) * nai_t;
|
||||
|
||||
if(nai_y.x < 0 || nai_y.x > 1 || nai_y.y < 0 || nai_y.y > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vec4 nai_vy = textureLod(velocity_sampler, nai_y, 0.0) * vec4(render_size, 1, 1);
|
||||
|
||||
float nai_zy = nai_vy.w - vxz.z * nai_t;
|
||||
|
||||
float nai_b = z_compare(-zx, -nai_zy, 20000);
|
||||
|
||||
float nai_f = z_compare(-nai_zy, -zx, 20000);
|
||||
|
||||
float nai_ay = nai_b + (1 - nai_f);
|
||||
|
||||
float past_t = mix(0., -1., (i + j + 1.0) / (params.motion_blur_samples + 1.0));
|
||||
|
||||
vec2 past_y = x + (past_vx / render_size) * past_t;
|
||||
|
||||
float alpha = z_compare(-past_vxz.w, -vxz.w, 20000); // may need to be a step
|
||||
|
||||
vec4 past_vy = mix(textureLod(past_velocity_sampler, past_y, 0.0) * vec4(render_size, 1, 1), textureLod(velocity_sampler, past_y, 0.0) * vec4(render_size, 1, 1), alpha);
|
||||
|
||||
float past_zy = past_vy.w - past_vxz.z * past_t;
|
||||
|
||||
float past_b = z_compare(-past_vxz.w, -past_zy, 20000);
|
||||
|
||||
vec4 nai_col_y = mix(textureLod(color_sampler, nai_y, 0.0), mix(textureLod(past_color_sampler, x, 0.0), mix(textureLod(past_color_sampler, past_y, 0.0), textureLod(color_sampler, past_y, 0.0), alpha), past_b), (1 - nai_f));
|
||||
|
||||
total_back_weight += nai_ay;
|
||||
|
||||
back_sum += nai_col_y * nai_ay;
|
||||
|
||||
float t = mix(0., -1., (i + j + 1.0) / (params.motion_blur_samples + 1.0));
|
||||
|
||||
float T = abs(t * vn_length);
|
||||
|
||||
vec2 y = x + (vn / render_size) * t;
|
||||
|
||||
if(y.x < 0 || y.x > 1 || y.y < 0 || y.y > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vec4 vy = textureLod(velocity_sampler, y, 0.0) * vec4(render_size, 1, 1);
|
||||
|
||||
float vy_length = max(0.5, length(vy.xy));
|
||||
|
||||
float zy = vy.w - vnz.z * t;
|
||||
|
||||
float f = z_compare(-zy, -zx, 20000);
|
||||
|
||||
float wa = abs(max(0, dot(vy.xy / vy_length, wn)));
|
||||
|
||||
float ay_trail = f * step(T, vy_length * wa);
|
||||
|
||||
vec4 col_y = textureLod(color_sampler, y, 0.0);
|
||||
|
||||
weight += ay_trail;
|
||||
|
||||
sum += col_y * ay_trail;
|
||||
}
|
||||
|
||||
back_sum *= (params.motion_blur_samples - weight) / total_back_weight;
|
||||
|
||||
sum /= params.motion_blur_samples;
|
||||
|
||||
back_sum /= params.motion_blur_samples;
|
||||
|
||||
imageStore(output_image, uvi, sum + back_sum);
|
||||
|
||||
#ifdef DEBUG
|
||||
imageStore(debug_1_image, uvi, sum + back_sum);
|
||||
imageStore(debug_2_image, uvi, abs(vec4(vn / render_size * 10, vnz.z * 100, 1)));
|
||||
imageStore(debug_3_image, uvi, abs(vec4(velocity_map_sample - x, 0, 1)));
|
||||
imageStore(debug_4_image, uvi, abs(vec4(vx / render_size * 10, vxz.z * 100, 1)));
|
||||
imageStore(debug_5_image, uvi, col_x);
|
||||
imageStore(debug_6_image, uvi, past_col_x);
|
||||
imageStore(debug_7_image, uvi, past_col_x);
|
||||
imageStore(debug_8_image, uvi, back_sum);
|
||||
#endif
|
||||
}
|
||||
|
||||
//void main()
|
||||
//{
|
||||
// ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
// ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
// if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// vec2 x = (vec2(uvi) + vec2(0.5)) / vec2(render_size);
|
||||
//
|
||||
// vec2 velocity_map_sample = textureLod(velocity_map, x + jitter_tile(uvi), 0.0).xy;
|
||||
//
|
||||
// vec3 vnz = textureLod(tile_max, velocity_map_sample, 0.0).xyz * vec3(render_size, 1);// * 2;
|
||||
//
|
||||
// vec2 vn = vnz.xy;
|
||||
//
|
||||
// float vn_length = max(0.5, length(vn));
|
||||
//
|
||||
// vec2 wn = safenorm(vn);
|
||||
//
|
||||
// vec4 col_x = textureLod(color_sampler, x, 0.0);
|
||||
//
|
||||
// vec3 vxz = textureLod(vector_sampler, x, 0.0).xyz * vec3(render_size, 1);// * 2;
|
||||
//
|
||||
// vec2 vx = vxz.xy;
|
||||
//
|
||||
// vec3 past_vxz = textureLod(past_velocity_sampler, x, 0.0).xyz * vec3(render_size, 1);
|
||||
//
|
||||
// vec2 past_vx = past_vxz.xy;
|
||||
//
|
||||
// vec4 past_col_x = textureLod(past_color_sampler, x, 0.0);
|
||||
//
|
||||
// float velocity_match = pow(clamp(dot(vx, vn) / dot(vn, vn), 0, 1), 0.5);
|
||||
//
|
||||
// vn = mix(vn, vx, velocity_match);
|
||||
//
|
||||
// vnz = mix(vnz, vxz, velocity_match);
|
||||
//
|
||||
// if(vn_length <= 0.5)
|
||||
// {
|
||||
// imageStore(output_image, uvi, col_x);
|
||||
//
|
||||
//#ifdef DEBUG
|
||||
// imageStore(debug_1_image, uvi, col_x);
|
||||
// imageStore(debug_2_image, uvi, abs(vec4(vn / render_size * 10, vnz.z * 100, 1)));
|
||||
// imageStore(debug_3_image, uvi, abs(vec4(velocity_map_sample - x, 0, 1)));
|
||||
// imageStore(debug_4_image, uvi, abs(vec4(vx / render_size * 10, vxz.z * 100, 1)));
|
||||
// imageStore(debug_5_image, uvi, col_x);
|
||||
// imageStore(debug_6_image, uvi, past_col_x);
|
||||
// imageStore(debug_7_image, uvi, past_col_x);
|
||||
// imageStore(debug_8_image, uvi, abs(vec4(past_vx / render_size * 10, past_vxz.z * 100, 1)));
|
||||
//#endif
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// float zx = -0.05 / max(FLT_MIN, textureLod(depth_sampler, x, 0.0).x);
|
||||
//
|
||||
// float vx_length = max(0.5, length(vx));
|
||||
//
|
||||
// vec2 wx = safenorm(vx);
|
||||
//
|
||||
// vec2 wp = vec2(-wn.y, wn.x);
|
||||
//
|
||||
// if(dot(wp, vx) < 0)
|
||||
// {
|
||||
// wp = -wp;
|
||||
// }
|
||||
//
|
||||
// vec2 wc = safenorm(mix(wp, wx, clamp((vx_length - 0.5) / 1.5, 0, 1)));
|
||||
//
|
||||
// float weight = 0;// params.motion_blur_samples / (40 * vx_length);
|
||||
//
|
||||
// vec4 sum = col_x * weight;
|
||||
//
|
||||
// float j = interleaved_gradient_noise(uvi) - 0.5;
|
||||
//
|
||||
// int vnvx = 2;//int(vn_length / (10 + vx_length)) + 2;
|
||||
//
|
||||
// float total_back_weight = 1e-10;
|
||||
//
|
||||
// vec4 back_sum = col_x * total_back_weight;
|
||||
//
|
||||
// for(int i = 0; i < params.motion_blur_samples; i++)
|
||||
// {
|
||||
// float t = mix(-1., 0.0, (i + j + 1.0) / (params.motion_blur_samples + 1.0));
|
||||
//
|
||||
// float T = abs(t * vn_length);
|
||||
//
|
||||
// float Tx = abs((t + 0.5) * vn_length);
|
||||
//
|
||||
// bool sample_main_v = !(((i - 1) % vnvx) == 0);
|
||||
//
|
||||
// vec2 d = vn;//sample_main_v ? vn : vx;
|
||||
//
|
||||
// vec2 nai_d = vx;
|
||||
//
|
||||
// vec2 nai_wd = safenorm(nai_d);
|
||||
//
|
||||
// float nai_dz = vxz.z;
|
||||
//
|
||||
// vec2 past_nai_d = past_vx;
|
||||
//
|
||||
// float dz = vnz.z;//sample_main_v ? vnz.z : vxz.z;
|
||||
//
|
||||
// vec2 wd = safenorm(d);
|
||||
//
|
||||
// vec2 y = x + (d / render_size) * t;
|
||||
//
|
||||
// vec2 nai_y = x + (nai_d / render_size) * t;
|
||||
//
|
||||
// vec2 past_nai_y = x + (past_nai_d / render_size) * t;
|
||||
//
|
||||
// float nai_y_length = max(0.5, length(nai_y));
|
||||
//
|
||||
// vec2 vy = textureLod(vector_sampler, y, 0.0).xy * render_size;// * 2;
|
||||
//
|
||||
// float vy_length = max(0.5, length(vy));
|
||||
//
|
||||
// vec2 nai_vy = textureLod(vector_sampler, nai_y, 0.0).xy * render_size;
|
||||
//
|
||||
// float nai_vy_length = max(0.5, length(nai_vy));
|
||||
//
|
||||
// float zy = -0.05 / max(FLT_MIN, textureLod(depth_sampler, y, 0.0).x - dz * t);
|
||||
//
|
||||
// float nai_zy = -0.05 / max(FLT_MIN, textureLod(depth_sampler, nai_y, 0.0).x - nai_dz * t);
|
||||
//
|
||||
// float f = z_compare(zy, zx, 15);
|
||||
// float b = z_compare(zx, zy, 15);
|
||||
//
|
||||
// float wa = abs(max(0, dot(vy / vy_length, wd)));
|
||||
//
|
||||
// float wb = abs((dot(wc, wd)));
|
||||
//
|
||||
// float cone_x = cone(T, vx_length);
|
||||
//
|
||||
// float cone_y = cone(T, vy_length);
|
||||
//
|
||||
// float nai_f = z_compare(nai_zy, zx, 15);
|
||||
//
|
||||
// float nai_b = z_compare(zx, nai_zy, 15);
|
||||
//
|
||||
// float nai_wa = abs(max(0, dot(nai_vy / nai_vy_length, nai_wd)));
|
||||
//
|
||||
// float nai_wb = abs((dot(wc, nai_wd)));
|
||||
//
|
||||
// float nai_cone_y = cone(T, nai_vy_length);
|
||||
//
|
||||
// float ay_trail = f * wa * step(FLT_MIN, cone_y);
|
||||
//
|
||||
// float ay_lead = (1 - f) * wb * step(FLT_MIN, cone_x);
|
||||
//
|
||||
// float nai_ay = nai_b;//max(nai_b, nai_f * nai_wa * step(FLT_MIN, nai_cone_y));
|
||||
//
|
||||
// vec4 col_y = textureLod(color_sampler, y, 0.0);
|
||||
//
|
||||
// vec4 past_col_y = textureLod(past_color_sampler, past_nai_y, 0.0);
|
||||
//
|
||||
// vec4 nai_col_y = textureLod(color_sampler, nai_y, 0.0);
|
||||
//
|
||||
// vec4 col_back = nai_col_y;
|
||||
//
|
||||
// total_back_weight += nai_ay;
|
||||
//
|
||||
// back_sum += col_back * nai_ay;
|
||||
//
|
||||
// weight += ay_trail + ay_lead;
|
||||
//
|
||||
// sum += col_y * ay_trail + past_col_y * ay_lead;
|
||||
// }
|
||||
//
|
||||
// back_sum *= (params.motion_blur_samples - weight) / total_back_weight;
|
||||
//
|
||||
// sum /= params.motion_blur_samples;
|
||||
//
|
||||
// back_sum /= params.motion_blur_samples;
|
||||
//
|
||||
// imageStore(output_image, uvi, sum + back_sum);
|
||||
//
|
||||
//#ifdef DEBUG
|
||||
// imageStore(debug_1_image, uvi, sum + back_sum);
|
||||
// imageStore(debug_2_image, uvi, abs(vec4(vn / render_size * 10, vnz.z * 100, 1)));
|
||||
// imageStore(debug_3_image, uvi, abs(vec4(velocity_map_sample - x, 0, 1)));
|
||||
// imageStore(debug_4_image, uvi, abs(vec4(vx / render_size * 10, vxz.z * 100, 1)));
|
||||
// imageStore(debug_5_image, uvi, col_x);//sum + back_sum);
|
||||
// imageStore(debug_6_image, uvi, past_col_x);
|
||||
// imageStore(debug_7_image, uvi, past_col_x);
|
||||
// imageStore(debug_8_image, uvi, abs(vec4(past_vx / render_size * 10, past_vxz.z * 100, 1)));
|
||||
//#endif
|
||||
//}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://4vnw7nqk2lmb"
|
||||
path="res://.godot/imported/jump_flood_past_experimental_blur.glsl-75b0138dd1cf1e624e753e1e20d4e672.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/Archive/jump_flood_past_experimental_blur.glsl"
|
||||
dest_files=["res://.godot/imported/jump_flood_past_experimental_blur.glsl-75b0138dd1cf1e624e753e1e20d4e672.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D velocity_sampler;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform writeonly image2D tile_max_x;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan5;
|
||||
float nan6;
|
||||
float nan7;
|
||||
float nan8;
|
||||
int tile_size;
|
||||
int nan2;
|
||||
int nan3;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(velocity_sampler, 0));
|
||||
ivec2 output_size = imageSize(tile_max_x);
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
int tile_size = render_size.x / output_size.x;
|
||||
ivec2 global_uvi = uvi * ivec2(tile_size, 1);
|
||||
if ((uvi.x >= output_size.x) || (uvi.y >= output_size.y) || (global_uvi.x >= render_size.x) || (global_uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(global_uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec4 max_velocity = vec4(0);
|
||||
|
||||
float max_velocity_length = -1;
|
||||
|
||||
//bool foreground = false;
|
||||
|
||||
for(int i = 0; i < tile_size; i++)
|
||||
{
|
||||
vec2 current_uv = uvn + vec2(float(i) / render_size.x, 0);
|
||||
vec4 velocity_sample = textureLod(velocity_sampler, current_uv, 0.0);
|
||||
float current_velocity_length = dot(velocity_sample.xy, velocity_sample.xy);
|
||||
if(current_velocity_length > max_velocity_length)// || (velocity_sample.w > 0 && !foreground))
|
||||
{
|
||||
max_velocity_length = current_velocity_length;
|
||||
max_velocity = vec4(velocity_sample);
|
||||
// if(velocity_sample.w > 0)
|
||||
// {
|
||||
// foreground = true;
|
||||
// }
|
||||
}
|
||||
}
|
||||
imageStore(tile_max_x, uvi, max_velocity);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://djp3da364fk2l"
|
||||
path="res://.godot/imported/jf_guertin_tile_max_x.glsl-acb187dfb7304d498ecdfb75a54c725d.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jf_guertin_tile_max_x.glsl"
|
||||
dest_files=["res://.godot/imported/jf_guertin_tile_max_x.glsl-acb187dfb7304d498ecdfb75a54c725d.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max_x;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform writeonly image2D tile_max;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan5;
|
||||
float nan6;
|
||||
float nan7;
|
||||
float nan8;
|
||||
int tile_size;
|
||||
int nan2;
|
||||
int nan3;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max_x, 0));
|
||||
ivec2 output_size = imageSize(tile_max);
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
int tile_size = render_size.y / output_size.y;
|
||||
ivec2 global_uvi = uvi * ivec2(1, tile_size);
|
||||
if ((uvi.x >= output_size.x) || (uvi.y >= output_size.y) || (global_uvi.x >= render_size.x) || (global_uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(global_uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec4 max_velocity = vec4(0);
|
||||
|
||||
float max_velocity_length = -1;
|
||||
|
||||
//bool foreground = false;
|
||||
|
||||
for(int i = 0; i < tile_size; i++)
|
||||
{
|
||||
vec2 current_uv = uvn + vec2(0, float(i) / render_size.y);
|
||||
vec4 velocity_sample = textureLod(tile_max_x, current_uv, 0.0);
|
||||
float current_velocity_length = dot(velocity_sample.xy, velocity_sample.xy);
|
||||
if(current_velocity_length > max_velocity_length)// || (velocity_sample.w > 0 && !foreground))
|
||||
{
|
||||
max_velocity_length = current_velocity_length;
|
||||
max_velocity = vec4(velocity_sample);
|
||||
// if(velocity_sample.w > 0)
|
||||
// {
|
||||
// foreground = true;
|
||||
// }
|
||||
}
|
||||
}
|
||||
imageStore(tile_max, uvi, max_velocity);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://cqlltc8f21wre"
|
||||
path="res://.godot/imported/jf_guertin_tile_max_y.glsl-8b893536de27f9161f4a8be7b8c5058f.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jf_guertin_tile_max_y.glsl"
|
||||
dest_files=["res://.godot/imported/jf_guertin_tile_max_y.glsl-8b893536de27f9161f4a8be7b8c5058f.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max;
|
||||
layout(set = 0, binding = 1) uniform sampler2D tile_max_map;
|
||||
layout(rgba16f, set = 0, binding = 2) uniform writeonly image2D neighbor_max;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float nan5;
|
||||
float nan6;
|
||||
float nan7;
|
||||
float nan8;
|
||||
int nan1;
|
||||
int nan2;
|
||||
int nan3;
|
||||
int nan4;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec2 best_sample_uv = vec2(uvn);
|
||||
|
||||
float max_neighbor_velocity_length = -1;
|
||||
|
||||
for(int i = -1; i < 2; i++)
|
||||
{
|
||||
for(int j = -1; j < 2; j++)
|
||||
{
|
||||
vec2 current_offset = vec2(1) / vec2(render_size) * vec2(i, j);
|
||||
vec2 current_uv = uvn + current_offset;
|
||||
if(current_uv.x < 0 || current_uv.x > 1 || current_uv.y < 0 || current_uv.y > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vec2 velocity_map_sample = textureLod(tile_max_map, current_uv, 0.0).xy;
|
||||
|
||||
vec4 velocity_sample = textureLod(tile_max, velocity_map_sample, 0.0);
|
||||
|
||||
float current_velocity_length = dot(velocity_sample.xy, velocity_sample.xy);
|
||||
|
||||
if(current_velocity_length > max_neighbor_velocity_length)
|
||||
{
|
||||
max_neighbor_velocity_length = current_velocity_length;
|
||||
best_sample_uv = velocity_map_sample;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imageStore(neighbor_max, uvi, vec4(best_sample_uv, 0, 1));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://cfk5chwlcyay4"
|
||||
path="res://.godot/imported/jf_neighbor_max.glsl-d9e677fd383d0688a8ad642473870160.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jf_neighbor_max.glsl"
|
||||
dest_files=["res://.godot/imported/jf_neighbor_max.glsl-d9e677fd383d0688a8ad642473870160.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,283 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D depth_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D velocity_sampler;
|
||||
layout(rgba16f, set = 0, binding = 2) uniform writeonly image2D buffer_a;
|
||||
layout(rgba16f, set = 0, binding = 3) uniform writeonly image2D buffer_b;
|
||||
layout(set = 0, binding = 4) uniform sampler2D buffer_a_sampler;
|
||||
layout(set = 0, binding = 5) uniform sampler2D buffer_b_sampler;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
int iteration_index;
|
||||
int last_iteration_index;
|
||||
int backtracking_sample_count;
|
||||
int nan2;
|
||||
float perpen_error_thresh;
|
||||
float sample_step_multiplier;
|
||||
float motion_blur_intensity;
|
||||
float velocity_match_threshold;
|
||||
float parallel_sensitivity;
|
||||
float perpendicular_sensitivity;
|
||||
float depth_match_threshold;
|
||||
float step_exponent_modifier;
|
||||
float step_size;
|
||||
float max_dilation_radius;
|
||||
float nan_fl_1;
|
||||
float nan_fl_2;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
const int kernel_size = 8;
|
||||
|
||||
const vec2 check_step_kernel[kernel_size] = {
|
||||
vec2(-1, 0),
|
||||
vec2(1, 0),
|
||||
vec2(0, -1),
|
||||
vec2(0, 1),
|
||||
vec2(-1, 1),
|
||||
vec2(1, -1),
|
||||
vec2(1, 1),
|
||||
vec2(-1, -1),
|
||||
};
|
||||
|
||||
void get_value(bool a,inout vec2 uv)
|
||||
{
|
||||
if(a)
|
||||
{
|
||||
uv = textureLod(buffer_a_sampler, uv, 0.0).xy;
|
||||
}
|
||||
else
|
||||
{
|
||||
uv = textureLod(buffer_b_sampler, uv, 0.0).xy;
|
||||
}
|
||||
}
|
||||
|
||||
void set_value(bool a, ivec2 uvi, vec4 value)
|
||||
{
|
||||
if(a)
|
||||
{
|
||||
imageStore(buffer_a, uvi, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageStore(buffer_b, uvi, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Motion similarity
|
||||
// ----------------------------------------------------------
|
||||
float get_motion_difference(vec2 V, vec2 V2)
|
||||
{
|
||||
return clamp(dot(V - V2, V) / dot(V, V), 0, 1);
|
||||
// vec2 VO = V - V2;
|
||||
// float parallel = dot(VO, V) / dot(V, V);
|
||||
// return clamp(parallel, 0, 1);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
void sample_fitness(vec2 uv_offset, vec4 uv_sample, vec2 render_size, inout vec4 curren_sample_fitness)
|
||||
{
|
||||
vec2 sample_velocity = -uv_sample.xy;
|
||||
|
||||
// if velocity is 0, we never reach it (steps never smaller than 1)
|
||||
if (dot(sample_velocity, sample_velocity) <= FLT_MIN || uv_sample.w == 0)
|
||||
{
|
||||
curren_sample_fitness = vec4(FLT_MAX, FLT_MAX, FLT_MAX, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// velocity space distance (projected pixel offset onto velocity vector)
|
||||
float velocity_space_distance = dot(sample_velocity, uv_offset) / dot(sample_velocity, sample_velocity);
|
||||
// the velcity space distance to gravitate the JFA to (found more relieable than doing a 0 - 1 range)
|
||||
float mid_point = params.motion_blur_intensity / 2;
|
||||
// centralize the velocity space distance around that mid point
|
||||
float absolute_velocity_space_distance = abs(velocity_space_distance - mid_point);
|
||||
// if that distance is half the original, its within range (we centered around a mid point)
|
||||
float within_velocity_range = step(absolute_velocity_space_distance, mid_point);
|
||||
// perpendicular offset
|
||||
float side_offset = abs(dot(vec2(uv_offset.y, -uv_offset.x), sample_velocity)) / dot(sample_velocity, sample_velocity);
|
||||
// arbitrary perpendicular limit (lower means tighter dilation, but less reliable)
|
||||
float within_perpen_error_range = step(side_offset, params.perpen_error_thresh * params.motion_blur_intensity);
|
||||
// store relevant data for use in conditions
|
||||
curren_sample_fitness = vec4(absolute_velocity_space_distance, velocity_space_distance, uv_sample.w + uv_sample.z * velocity_space_distance, within_velocity_range * within_perpen_error_range);
|
||||
}
|
||||
|
||||
float is_sample_better(vec4 a, vec4 b)
|
||||
{
|
||||
// see explanation at end of code
|
||||
return mix(1. - step(b.x * a.w, a.x * b.w), step(b.z, a.z), step(0.5, b.w) * step(0.5, a.w));
|
||||
}
|
||||
|
||||
// dilation validation and better sample selection
|
||||
vec4 get_backtracked_sample(vec2 uvn, vec2 chosen_uv, vec3 chosen_velocity, vec4 best_sample_fitness, vec2 render_size)
|
||||
{
|
||||
//return vec4(chosen_uv, best_sample_fitness.z, best_sample_fitness.w);// comment this to enable backtracking
|
||||
|
||||
float smallest_step = 1 / max(render_size.x, render_size.y);
|
||||
// choose maximum range to check along (matches with implementation in blur stage)
|
||||
float general_velocity_multiplier = min(best_sample_fitness.y, params.max_dilation_radius * smallest_step / (length(chosen_velocity) * params.motion_blur_intensity));
|
||||
|
||||
vec2 best_uv = chosen_uv;
|
||||
|
||||
float best_multiplier = best_sample_fitness.y;
|
||||
|
||||
float best_depth = best_sample_fitness.z;
|
||||
|
||||
// set temp variable to keet track of better matches
|
||||
float smallest_velocity_difference = 0.99;//params.velocity_match_threshold;
|
||||
// minimum amount of valid velocities to compare before decision
|
||||
int initial_steps_to_compare = 2;
|
||||
|
||||
int steps_to_compare = initial_steps_to_compare;
|
||||
|
||||
float velocity_multiplier;
|
||||
|
||||
vec2 check_uv;
|
||||
|
||||
vec3 velocity_test;
|
||||
|
||||
float depth_test;
|
||||
|
||||
float velocity_difference;
|
||||
|
||||
float current_depth;
|
||||
|
||||
for(int i = -params.backtracking_sample_count; i < params.backtracking_sample_count + 1; i++)
|
||||
{
|
||||
velocity_multiplier = general_velocity_multiplier * (1 + float(i) / float(params.backtracking_sample_count));
|
||||
|
||||
if(velocity_multiplier > params.motion_blur_intensity || velocity_multiplier < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
check_uv = uvn - chosen_velocity.xy * velocity_multiplier;
|
||||
|
||||
if(any(notEqual(check_uv, clamp(check_uv, vec2(0.0), vec2(1.0)))))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// get potential velocity and depth matches
|
||||
velocity_test = textureLod(velocity_sampler, check_uv, 0.0).xyz;
|
||||
|
||||
depth_test = textureLod(depth_sampler, check_uv, 0.0).x;
|
||||
|
||||
velocity_difference = get_motion_difference(chosen_velocity.xy, velocity_test.xy);
|
||||
|
||||
current_depth = depth_test + chosen_velocity.z * velocity_multiplier;
|
||||
|
||||
// if checked sample matches depth and velocity, it is valid for backtracking
|
||||
if((abs(current_depth - best_sample_fitness.z) < 0.002) && (velocity_difference <= smallest_velocity_difference))
|
||||
{
|
||||
best_uv = check_uv;
|
||||
best_multiplier = velocity_multiplier;
|
||||
best_depth = current_depth;
|
||||
if(steps_to_compare == 0)
|
||||
{
|
||||
return vec4(best_uv, best_depth, 0);
|
||||
}
|
||||
steps_to_compare--;
|
||||
}
|
||||
// if a sample was found and we lost footing after, go with that found sample right away
|
||||
else if(initial_steps_to_compare > steps_to_compare)
|
||||
{
|
||||
return vec4(best_uv, best_depth, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return vec4(uvn, best_sample_fitness.z, 1);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(velocity_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// must be on pixel center for whole values
|
||||
vec2 uvn = (vec2(uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec2 uv_step = vec2(round(params.step_size)) / render_size;
|
||||
|
||||
vec4 best_sample_fitness = vec4(FLT_MAX, FLT_MAX, FLT_MAX, 0.);
|
||||
|
||||
vec2 chosen_uv = uvn;
|
||||
|
||||
vec3 chosen_velocity = vec3(0.);
|
||||
|
||||
bool set_a = !bool(step(0.5, float(params.iteration_index % 2)));
|
||||
|
||||
vec2 step_offset;
|
||||
|
||||
vec2 check_uv;
|
||||
|
||||
vec4 uv_sample;
|
||||
|
||||
vec4 current_sample_fitness;
|
||||
|
||||
for(int i = 0; i < kernel_size; i++)
|
||||
{
|
||||
step_offset = check_step_kernel[i] * uv_step;
|
||||
check_uv = uvn + step_offset;
|
||||
|
||||
if(any(notEqual(check_uv, clamp(check_uv, vec2(0.0), vec2(1.0)))))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(params.iteration_index > 0.)
|
||||
{
|
||||
get_value(!set_a, check_uv);
|
||||
|
||||
step_offset = check_uv - uvn;
|
||||
}
|
||||
|
||||
uv_sample = vec4(textureLod(velocity_sampler, check_uv, 0.0).xyz, textureLod(depth_sampler, check_uv, 0.0).x);
|
||||
|
||||
sample_fitness(step_offset, uv_sample, render_size, current_sample_fitness);
|
||||
|
||||
if (mix(1. - step(best_sample_fitness.x * current_sample_fitness.w, current_sample_fitness.x * best_sample_fitness.w), step(best_sample_fitness.z, current_sample_fitness.z), step(0.5, best_sample_fitness.w) * step(0.5, current_sample_fitness.w)) > 0.5)//is_sample_better(current_sample_fitness, best_sample_fitness) > 0.5)
|
||||
{
|
||||
best_sample_fitness = current_sample_fitness;
|
||||
chosen_uv = check_uv;
|
||||
chosen_velocity = uv_sample.xyz;
|
||||
}
|
||||
}
|
||||
|
||||
if(params.iteration_index < params.last_iteration_index)
|
||||
{
|
||||
set_value(set_a, uvi, vec4(chosen_uv, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
float depth = textureLod(depth_sampler, uvn, 0.0).x;
|
||||
|
||||
// best_sample_fitness.z contains the depth of the texture + offset of velocity z
|
||||
vec4 backtracked_sample = get_backtracked_sample(uvn, chosen_uv, chosen_velocity, best_sample_fitness, render_size);
|
||||
|
||||
if(best_sample_fitness.w == 0 || depth > backtracked_sample.z)
|
||||
{
|
||||
set_value(set_a, uvi, vec4(uvn, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
set_value(set_a, uvi, backtracked_sample);
|
||||
|
||||
return;
|
||||
}
|
||||
//
|
||||
// if((a.w == b.w) && (a.w == 1))
|
||||
// {
|
||||
// return a.z < b.z ? 0. : 1.;
|
||||
// }
|
||||
//
|
||||
// return a.x * b.w < b.x * a.w ? 1. : 0.;
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://rkkajixdjosk"
|
||||
path="res://.godot/imported/jfp_backtracking_experimental.glsl-a7a47621c3999d6edb8c655271f824d5.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jfp_backtracking_experimental.glsl"
|
||||
dest_files=["res://.godot/imported/jfp_backtracking_experimental.glsl-a7a47621c3999d6edb8c655271f824d5.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D tile_max_sampler;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform writeonly image2D buffer_a;
|
||||
layout(rgba16f, set = 0, binding = 2) uniform writeonly image2D buffer_b;
|
||||
layout(set = 0, binding = 3) uniform sampler2D buffer_a_sampler;
|
||||
layout(set = 0, binding = 4) uniform sampler2D buffer_b_sampler;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
int iteration_index;
|
||||
int last_iteration_index;
|
||||
int nan1;
|
||||
int nan2;
|
||||
float perpen_error_thresh;
|
||||
float sample_step_multiplier;
|
||||
float motion_blur_intensity;
|
||||
float nan_fl_5;
|
||||
float nan_fl_4;
|
||||
float nan_fl_3;
|
||||
float nan_fl_6;
|
||||
float step_exponent_modifier;
|
||||
float nan_fl_0;
|
||||
float max_dilation_radius;
|
||||
float nan_fl_1;
|
||||
float nan_fl_2;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
const int kernel_size = 8;
|
||||
|
||||
const vec2 check_step_kernel[kernel_size] = {
|
||||
vec2(-1, 0),
|
||||
vec2(1, 0),
|
||||
vec2(0, -1),
|
||||
vec2(0, 1),
|
||||
vec2(-1, 1),
|
||||
vec2(1, -1),
|
||||
vec2(1, 1),
|
||||
vec2(-1, -1),
|
||||
};
|
||||
|
||||
vec2 get_value(bool a, vec2 uv)
|
||||
{
|
||||
if(a)
|
||||
{
|
||||
return textureLod(buffer_a_sampler, uv, 0.0).xy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return textureLod(buffer_b_sampler, uv, 0.0).xy;
|
||||
}
|
||||
}
|
||||
|
||||
void set_value(bool a, ivec2 uvi, vec4 value)
|
||||
{
|
||||
if(a)
|
||||
{
|
||||
imageStore(buffer_a, uvi, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageStore(buffer_b, uvi, value);
|
||||
}
|
||||
}
|
||||
|
||||
void sample_fitness(vec2 uv_offset, vec4 uv_sample, vec2 render_size, inout vec4 current_sample_fitness)
|
||||
{
|
||||
vec2 sample_velocity = -uv_sample.xy;
|
||||
|
||||
if (dot(sample_velocity, sample_velocity) <= FLT_MIN || uv_sample.w == 0)
|
||||
{
|
||||
current_sample_fitness = vec4(10, 10, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
float velocity_space_distance = dot(sample_velocity, uv_offset) / dot(sample_velocity, sample_velocity);
|
||||
|
||||
float mid_point = params.motion_blur_intensity / 2;
|
||||
|
||||
float absolute_velocity_space_distance = abs(velocity_space_distance - mid_point);
|
||||
|
||||
float within_velocity_range = step(absolute_velocity_space_distance, mid_point);
|
||||
|
||||
float side_offset = abs(dot(vec2(uv_offset.y, -uv_offset.x), sample_velocity)) / dot(sample_velocity, sample_velocity);
|
||||
|
||||
float within_perpen_error_range = step(side_offset, params.perpen_error_thresh * params.motion_blur_intensity);
|
||||
|
||||
current_sample_fitness = vec4(absolute_velocity_space_distance, velocity_space_distance, uv_sample.w + uv_sample.z * velocity_space_distance, within_velocity_range * within_perpen_error_range);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(tile_max_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uvn = (vec2(uvi) + vec2(0.5)) / render_size;
|
||||
|
||||
vec2 step_size = vec2(round(pow(2 + params.step_exponent_modifier, params.last_iteration_index - params.iteration_index)));
|
||||
|
||||
vec2 uv_step = vec2(round(step_size)) / render_size;
|
||||
|
||||
vec4 best_sample_fitness = vec4(10, 10, 0, 0);
|
||||
|
||||
vec2 chosen_uv = uvn;
|
||||
|
||||
bool set_a = !bool(step(0.5, float(params.iteration_index % 2)));
|
||||
|
||||
vec2 step_offset;
|
||||
|
||||
vec2 check_uv;
|
||||
|
||||
vec4 uv_sample;
|
||||
|
||||
vec4 current_sample_fitness;
|
||||
|
||||
for(int i = 0; i < kernel_size; i++)
|
||||
{
|
||||
step_offset = check_step_kernel[i] * uv_step;
|
||||
check_uv = uvn + step_offset;
|
||||
|
||||
if(any(notEqual(check_uv, clamp(check_uv, vec2(0.0), vec2(1.0)))))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
check_uv = get_value(!set_a, check_uv).xy;
|
||||
|
||||
step_offset = check_uv - uvn;
|
||||
|
||||
uv_sample = textureLod(tile_max_sampler, check_uv, 0.0);
|
||||
|
||||
sample_fitness(step_offset, uv_sample, render_size, current_sample_fitness);
|
||||
|
||||
float sample_better = 1. - step(current_sample_fitness.z * current_sample_fitness.w, best_sample_fitness.z * best_sample_fitness.w);
|
||||
best_sample_fitness = mix(best_sample_fitness, current_sample_fitness, sample_better);
|
||||
chosen_uv = mix(chosen_uv, check_uv, sample_better);
|
||||
}
|
||||
|
||||
set_value(set_a, uvi, vec4(chosen_uv, 0, 0));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://c4dywnp7k8rph"
|
||||
path="res://.godot/imported/jfp_simple.glsl-96987ba8c42947c7e648d28f42a73f7a.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jfp_simple.glsl"
|
||||
dest_files=["res://.godot/imported/jfp_simple.glsl-96987ba8c42947c7e648d28f42a73f7a.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,192 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
#define DBL_MAX 1.7976931348623158e+308
|
||||
#define DBL_MIN 2.2250738585072014e-308
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D color_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D depth_sampler;
|
||||
layout(set = 0, binding = 2) uniform sampler2D vector_sampler;
|
||||
layout(set = 0, binding = 3) uniform sampler2D velocity_map;
|
||||
layout(rgba16f, set = 0, binding = 4) uniform writeonly image2D output_image;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float motion_blur_samples;
|
||||
float motion_blur_intensity;
|
||||
float motion_blur_center_fade;
|
||||
float frame;
|
||||
float last_iteration_index;
|
||||
float sample_step_multiplier;
|
||||
float step_exponent_modifier;
|
||||
float max_dilation_radius;
|
||||
int nan0;
|
||||
int nan1;
|
||||
int nan2;
|
||||
int nan3;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
// near plane distance
|
||||
float npd = 0.05;
|
||||
|
||||
// SOFT_Z_EXTENT
|
||||
float sze = 0.1;
|
||||
|
||||
// Helper functions
|
||||
// --------------------------------------------
|
||||
// from https://www.shadertoy.com/view/ftKfzc
|
||||
float interleaved_gradient_noise(vec2 uv, int FrameId){
|
||||
uv += float(FrameId) * (vec2(47, 17) * 0.695);
|
||||
|
||||
vec3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
|
||||
return fract(magic.z * fract(dot(uv, magic.xy)));
|
||||
}
|
||||
float get_motion_difference(vec2 V, vec2 V2, float power)
|
||||
{
|
||||
vec2 VO = V - V2;
|
||||
float difference = dot(VO, V) / max(FLT_MIN, dot(V, V));
|
||||
return pow(clamp(difference, 0, 1), power);
|
||||
}
|
||||
// McGuire's function https://docs.google.com/document/d/1IIlAKTj-O01hcXEdGxTErQbCHO9iBmRx6oFUy_Jm0fI/edit
|
||||
float soft_depth_compare(float depth_X, float depth_Y)
|
||||
{
|
||||
return clamp(1 - (depth_X - depth_Y) / sze, 0, 1);
|
||||
}
|
||||
// -------------------------------------------------------
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// must be on pixel center for whole values (tested)
|
||||
vec2 uvn = vec2(uvi + vec2(0.5)) / render_size;
|
||||
|
||||
vec4 base_color = textureLod(color_sampler, uvn, 0.0);
|
||||
// get dominant velocity data
|
||||
vec4 velocity_map_sample = textureLod(velocity_map, uvn, 0.0);
|
||||
|
||||
vec3 dominant_velocity = -textureLod(vector_sampler, velocity_map_sample.xy, 0.0).xyz;
|
||||
|
||||
vec3 naive_velocity = -textureLod(vector_sampler, uvn, 0.0).xyz;
|
||||
// if velocity is 0 and we dont show debug, return right away.
|
||||
if ((dot(dominant_velocity, dominant_velocity) == 0 || params.motion_blur_intensity == 0))
|
||||
{
|
||||
imageStore(output_image, uvi, base_color);
|
||||
return;
|
||||
}
|
||||
// offset along velocity to blend between sample steps
|
||||
float noise_offset = interleaved_gradient_noise(uvi, int(params.frame)) - 1;
|
||||
// scale of step
|
||||
float velocity_step_coef = min(params.motion_blur_intensity, params.max_dilation_radius / max(render_size.x, render_size.y) / (length(dominant_velocity) * params.motion_blur_intensity)) / max(1.0, params.motion_blur_samples - 1.0);
|
||||
|
||||
vec3 step_sample = dominant_velocity * velocity_step_coef;
|
||||
|
||||
vec3 naive_step_sample = naive_velocity * velocity_step_coef;
|
||||
|
||||
vec4 velocity_map_step_sample = vec4(0);
|
||||
|
||||
//float d = 1.0 - min(1.0, 2.0 * distance(uvn, vec2(0.5)));
|
||||
//sample_step *= 1.0 - d * params.fade_padding.x;
|
||||
|
||||
float total_weight = 1;
|
||||
|
||||
vec3 dominant_offset = step_sample * noise_offset;
|
||||
|
||||
vec3 naive_offset = naive_step_sample * noise_offset;
|
||||
|
||||
vec3 dominant_back_offset = -step_sample * (1. - noise_offset);
|
||||
|
||||
vec4 col = base_color * total_weight;
|
||||
|
||||
float naive_depth = textureLod(depth_sampler, uvn, 0.0).x;
|
||||
|
||||
float backstepping_coef = clamp(length(dominant_velocity) / 0.05, 0, 1);
|
||||
|
||||
vec2 dominant_uvo;
|
||||
|
||||
vec2 naive_uvo;
|
||||
|
||||
vec3 current_dominant_offset;
|
||||
|
||||
float current_naive_depth;
|
||||
|
||||
float foreground;
|
||||
|
||||
vec3 current_dominant_velocity;
|
||||
|
||||
float motion_difference;
|
||||
|
||||
float sample_weight;
|
||||
|
||||
float dominant_naive_mix;
|
||||
|
||||
vec2 sample_uv;
|
||||
|
||||
for (int i = 1; i < params.motion_blur_samples; i++)
|
||||
{
|
||||
dominant_offset += step_sample;
|
||||
|
||||
naive_offset += naive_step_sample;
|
||||
|
||||
dominant_uvo = uvn + dominant_offset.xy;
|
||||
|
||||
naive_uvo = uvn + naive_offset.xy;
|
||||
|
||||
current_dominant_offset = dominant_offset;
|
||||
|
||||
current_naive_depth = textureLod(depth_sampler, dominant_uvo, 0.0).x;
|
||||
// is current depth closer than origin of dilation (stepped into a foreground object)
|
||||
foreground = step(naive_depth + current_dominant_offset.z, current_naive_depth - 0.0001);
|
||||
|
||||
velocity_map_step_sample = textureLod(velocity_map, dominant_uvo, 0.0);
|
||||
|
||||
current_dominant_velocity = -textureLod(vector_sampler, velocity_map_step_sample.xy, 0.0).xyz;
|
||||
|
||||
motion_difference = get_motion_difference(dominant_velocity.xy, current_dominant_velocity.xy, 0.1);
|
||||
|
||||
sample_weight = 1;
|
||||
|
||||
if (any(notEqual(dominant_uvo, clamp(dominant_uvo, vec2(0.0), vec2(1.0)))) || foreground * motion_difference > 0.5)
|
||||
{
|
||||
dominant_uvo = uvn + dominant_back_offset.xy;
|
||||
current_dominant_offset = dominant_back_offset;
|
||||
dominant_back_offset -= step_sample;
|
||||
sample_weight = 0.5;//backstepping_coef;
|
||||
}
|
||||
|
||||
velocity_map_step_sample = textureLod(velocity_map, dominant_uvo, 0.0);
|
||||
|
||||
current_dominant_velocity = -textureLod(vector_sampler, velocity_map_step_sample.xy, 0.0).xyz;
|
||||
// is current velocity different than dilated velocity
|
||||
|
||||
current_naive_depth = textureLod(depth_sampler, dominant_uvo, 0.0).x;
|
||||
// is current depth closer than origin of dilation (stepped into a foreground object)
|
||||
foreground = step(naive_depth + current_dominant_offset.z, current_naive_depth - 0.002);
|
||||
|
||||
motion_difference = get_motion_difference(dominant_velocity.xy, current_dominant_velocity.xy, 0.1);
|
||||
// if we are sampling a foreground object and its velocity is different, discard this sample (prevent ghosting)
|
||||
sample_weight *= 1 - (foreground * motion_difference);
|
||||
|
||||
dominant_naive_mix = 1. - step(0.9, motion_difference);
|
||||
|
||||
sample_uv = mix(naive_uvo, dominant_uvo, dominant_naive_mix);
|
||||
|
||||
total_weight += sample_weight;
|
||||
|
||||
col += textureLod(color_sampler, sample_uv, 0.0) * sample_weight;
|
||||
}
|
||||
|
||||
col /= total_weight;
|
||||
|
||||
imageStore(output_image, uvi, col);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://c57nhlyxb4m1t"
|
||||
path="res://.godot/imported/jump_flood_blur.glsl-11f088c8cddfb4c62f32dfa84c694ded.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jump_flood_blur.glsl"
|
||||
dest_files=["res://.godot/imported/jump_flood_blur.glsl-11f088c8cddfb4c62f32dfa84c694ded.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D velocity_sampler;
|
||||
layout(set = 0, binding = 1) uniform sampler2D color_sampler;
|
||||
layout(rgba16f, set = 0, binding = 2) uniform image2D past_velocity;
|
||||
layout(rgba16f, set = 0, binding = 3) uniform image2D past_color;
|
||||
|
||||
// Guertin's functions https://research.nvidia.com/sites/default/files/pubs/2013-11_A-Fast-and/Guertin2013MotionBlur-small.pdf
|
||||
// ----------------------------------------------------------
|
||||
float z_compare(float a, float b, float sze)
|
||||
{
|
||||
return clamp(1. - sze * (a - b), 0, 1);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(velocity_sampler, 0));
|
||||
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uv.x >= render_size.x) || (uv.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 x = (vec2(uv) + 0.5) / render_size;
|
||||
|
||||
vec4 past_vx = textureLod(velocity_sampler, x, 0.0);
|
||||
|
||||
vec4 past_vx_vx = textureLod(velocity_sampler, x + past_vx.xy, 0.0);
|
||||
|
||||
vec4 past_col_vx = textureLod(color_sampler, x + past_vx.xy, 0.0);
|
||||
|
||||
vec4 past_col_x = textureLod(color_sampler, x, 0.0);
|
||||
|
||||
float alpha = 1 - z_compare(-past_vx.w, -past_vx_vx.w, 20000);
|
||||
|
||||
vec4 final_past_col = mix(past_col_vx, past_col_x, alpha);
|
||||
|
||||
vec4 final_past_vx = mix(vec4(past_vx_vx.xyz, past_vx.w), past_vx, alpha);
|
||||
|
||||
imageStore(past_color, uv, final_past_col);
|
||||
imageStore(past_velocity, uv, final_past_vx);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://quuyr2q5w5kx"
|
||||
path="res://.godot/imported/jump_flood_cache.glsl-f4eae7ab471d126e0587a3e727d847f6.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jump_flood_cache.glsl"
|
||||
dest_files=["res://.godot/imported/jump_flood_cache.glsl-f4eae7ab471d126e0587a3e727d847f6.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,316 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
#define FLT_MAX 3.402823466e+38
|
||||
#define FLT_MIN 1.175494351e-38
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D color_sampler;
|
||||
layout(set = 0, binding = 2) uniform sampler2D velocity_sampler;
|
||||
layout(set = 0, binding = 3) uniform sampler2D velocity_map;
|
||||
layout(rgba16f, set = 0, binding = 4) uniform writeonly image2D output_image;
|
||||
layout(set = 0, binding = 5) uniform sampler2D tile_max;
|
||||
layout(set = 0, binding = 6) uniform sampler2D past_color_sampler;
|
||||
layout(set = 0, binding = 7) uniform sampler2D past_velocity_sampler;
|
||||
|
||||
layout(push_constant, std430) uniform Params
|
||||
{
|
||||
float motion_blur_samples;
|
||||
float motion_blur_intensity;
|
||||
float motion_blur_center_fade;
|
||||
float frame;
|
||||
float last_iteration_index;
|
||||
float sample_step_multiplier;
|
||||
float step_exponent_modifier;
|
||||
float max_dilation_radius;
|
||||
int nan0;
|
||||
int nan1;
|
||||
int nan2;
|
||||
int nan3;
|
||||
} params;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
|
||||
// McGuire's functions https://docs.google.com/document/d/1IIlAKTj-O01hcXEdGxTErQbCHO9iBmRx6oFUy_Jm0fI/edit
|
||||
// ----------------------------------------------------------
|
||||
float soft_depth_compare(float depth_X, float depth_Y, float sze)
|
||||
{
|
||||
return clamp(1 - (depth_X - depth_Y) / sze, 0, 1);
|
||||
}
|
||||
|
||||
float cone(float T, float v)
|
||||
{
|
||||
return clamp(1 - T / v, 0, 1);
|
||||
}
|
||||
|
||||
float cylinder(float T, float v)
|
||||
{
|
||||
return 1.0 - smoothstep(0.95 * v, 1.05 * v, T);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// Guertin's functions https://research.nvidia.com/sites/default/files/pubs/2013-11_A-Fast-and/Guertin2013MotionBlur-small.pdf
|
||||
// ----------------------------------------------------------
|
||||
float z_compare(float a, float b, float sze)
|
||||
{
|
||||
return clamp(1. - sze * (a - b), 0, 1);
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://www.shadertoy.com/view/ftKfzc
|
||||
// ----------------------------------------------------------
|
||||
float interleaved_gradient_noise(vec2 uv){
|
||||
uv += float(params.frame) * (vec2(47, 17) * 0.695);
|
||||
|
||||
vec3 magic = vec3( 0.06711056, 0.00583715, 52.9829189 );
|
||||
|
||||
return fract(magic.z * fract(dot(uv, magic.xy)));
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
// from https://github.com/bradparks/KinoMotion__unity_motion_blur/tree/master
|
||||
// ----------------------------------------------------------
|
||||
vec2 safenorm(vec2 v)
|
||||
{
|
||||
float l = max(length(v), 1e-6);
|
||||
return v / l * int(l >= 0.5);
|
||||
}
|
||||
|
||||
vec2 jitter_tile(vec2 uvi)
|
||||
{
|
||||
float rx, ry;
|
||||
float angle = interleaved_gradient_noise(uvi + vec2(2, 0)) * M_PI * 2;
|
||||
rx = cos(angle);
|
||||
ry = sin(angle);
|
||||
return vec2(rx, ry) / textureSize(tile_max, 0) / 4;
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(color_sampler, 0));
|
||||
ivec2 uvi = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uvi.x >= render_size.x) || (uvi.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 x = (vec2(uvi) + vec2(0.5)) / vec2(render_size);
|
||||
|
||||
vec2 velocity_map_sample = textureLod(velocity_map, x + jitter_tile(uvi), 0.0).xy;
|
||||
|
||||
vec3 vnz = textureLod(tile_max, velocity_map_sample, 0.0).xyz * vec3(render_size, 1);
|
||||
|
||||
float vn_length = max(0.5, length(vnz.xy));
|
||||
|
||||
float multiplier = clamp(vn_length, 0, min(params.max_dilation_radius, vn_length * params.motion_blur_intensity)) / max(FLT_MIN, vn_length);
|
||||
|
||||
vnz.xyz *= multiplier;
|
||||
|
||||
vn_length *= multiplier;
|
||||
|
||||
vec2 vn = vnz.xy;
|
||||
|
||||
vec4 col_x = textureLod(color_sampler, x, 0.0);
|
||||
|
||||
vec4 vxz = textureLod(velocity_sampler, x, 0.0) * vec4(render_size, 1, 1);
|
||||
|
||||
float vx_length = max(0.5, length(vxz.xy));
|
||||
|
||||
//multiplier = clamp(vx_length, 0, min(params.max_dilation_radius, vn_length * params.motion_blur_intensity)) / max(FLT_MIN, vx_length);
|
||||
|
||||
vxz.xyz *= multiplier;
|
||||
|
||||
vx_length *= multiplier;
|
||||
|
||||
vec2 vx = vxz.xy;
|
||||
|
||||
vec2 wx = safenorm(vx);
|
||||
|
||||
if(vn_length <= 0.5)
|
||||
{
|
||||
imageStore(output_image, uvi, col_x);
|
||||
|
||||
#ifdef DEBUG
|
||||
imageStore(debug_1_image, uvi, col_x);
|
||||
imageStore(debug_2_image, uvi, abs(vec4(vn / render_size * 10, vnz.z * 100, 1)));
|
||||
imageStore(debug_3_image, uvi, abs(vec4(velocity_map_sample - x, 0, 1)));
|
||||
imageStore(debug_4_image, uvi, abs(vec4(vx / render_size * 10, vxz.z * 100, 1)));
|
||||
imageStore(debug_5_image, uvi, col_x);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 wvnz = normalize(vnz.xyz);
|
||||
|
||||
float velocity_match = pow(clamp(dot(vx, vn) / dot(vn, vn), 0, 1), 1 / (10000 * pow(abs(vnz.z), 2)));
|
||||
|
||||
vn = mix(vn, vx, velocity_match);
|
||||
|
||||
vnz = mix(vnz, vxz.xyz, velocity_match);
|
||||
|
||||
vec2 wn = safenorm(vn);
|
||||
|
||||
float zx = vxz.w;
|
||||
|
||||
float j = interleaved_gradient_noise(uvi) - 0.5;
|
||||
|
||||
vec4 past_vxz = textureLod(past_velocity_sampler, x, 0.0) * vec4(render_size * multiplier, 1 * multiplier, 1);
|
||||
|
||||
vec2 past_vx = past_vxz.xy;
|
||||
|
||||
vec4 past_col_x = textureLod(past_color_sampler, x, 0.0);
|
||||
|
||||
float t;
|
||||
float back_t;
|
||||
float T;
|
||||
vec2 y;
|
||||
float y_inside;
|
||||
vec4 nai_vy;
|
||||
vec2 nai_y;
|
||||
vec2 nai_back_y;
|
||||
float nai_zy;
|
||||
float nai_b;
|
||||
float nai_ay;
|
||||
float nai_y_inside;
|
||||
vec4 vy;
|
||||
float vy_length;
|
||||
float zy;
|
||||
float f;
|
||||
float wa;
|
||||
float ay_trail;
|
||||
float past_t;
|
||||
vec2 past_y;
|
||||
vec2 past_back_y;
|
||||
float past_ay;
|
||||
float alpha;
|
||||
vec4 past_vy;
|
||||
float past_zy;
|
||||
float past_b;
|
||||
float past_y_inside;
|
||||
float nai_T;
|
||||
float nai_vy_length;
|
||||
float nai_wa;
|
||||
|
||||
float weight = 1e-5;
|
||||
|
||||
vec4 sum = col_x * weight;
|
||||
|
||||
float nai_weight = 1e-5;
|
||||
|
||||
float nai_sub_weight = 1e-5;
|
||||
|
||||
vec4 nai_sum = col_x * nai_sub_weight;
|
||||
|
||||
float past_weight = 1e-5;
|
||||
|
||||
float past_sub_weight = 1e-5;
|
||||
|
||||
vec4 past_sum = past_col_x * past_sub_weight;
|
||||
|
||||
float final_sample_count = params.motion_blur_samples + 1e-5;
|
||||
|
||||
for(int i = 0; i < params.motion_blur_samples; i++)
|
||||
{
|
||||
t = mix(0., -1., (i + j + 1.0) / (params.motion_blur_samples + 1.0));
|
||||
|
||||
back_t = mix(1, 0, (i + j + 1.0) / (params.motion_blur_samples + 1.0));
|
||||
|
||||
T = abs(t * vn_length);
|
||||
|
||||
y = x + (vn / render_size) * t;
|
||||
|
||||
nai_T = abs(t * vx_length);
|
||||
|
||||
nai_y = x + (vx / render_size) * t;
|
||||
|
||||
nai_back_y = x + (vx / render_size) * back_t;
|
||||
|
||||
nai_vy = textureLod(velocity_sampler, nai_y, 0.0) * vec4(render_size * multiplier, 1 * multiplier, 1);
|
||||
|
||||
nai_vy_length = max(0.5, length(nai_vy.xy));
|
||||
|
||||
nai_zy = nai_vy.w - vxz.z * t;
|
||||
|
||||
nai_b = z_compare(-zx, -nai_zy, 20000);
|
||||
|
||||
float nai_f = z_compare(-nai_zy, -zx, 20000);
|
||||
|
||||
nai_wa = abs(max(0, dot(nai_vy.xy / vy_length, wx)));
|
||||
|
||||
nai_ay = max(nai_b, 0);//step(nai_T, nai_vy_length * nai_wa));
|
||||
|
||||
nai_weight += 1;
|
||||
|
||||
nai_sub_weight += 1;
|
||||
|
||||
nai_y_inside = step(0, nai_y.x) * step(nai_y.x, 1) * step(0, nai_y.y) * step(nai_y.y, 1);
|
||||
|
||||
nai_sum += mix(textureLod(color_sampler, nai_back_y, 0.0), textureLod(color_sampler, nai_y, 0.0), nai_ay * nai_y_inside);
|
||||
|
||||
past_y = x + (past_vx / render_size) * t;
|
||||
|
||||
past_back_y = x + (past_vx / render_size) * back_t;
|
||||
|
||||
alpha = z_compare(-past_vxz.w, -vxz.w, 20000);
|
||||
|
||||
past_vy = textureLod(past_velocity_sampler, past_y, 0.0) * vec4(render_size * multiplier, 1 * multiplier, 1);
|
||||
|
||||
past_zy = past_vy.w - past_vxz.z * t;
|
||||
|
||||
past_b = z_compare(-past_vxz.w, -past_zy, 20000);
|
||||
|
||||
past_ay = (1 - step(nai_T, nai_vy_length * nai_wa)) * (1 - alpha);
|
||||
|
||||
past_weight += past_ay;
|
||||
|
||||
past_sub_weight += 1;
|
||||
|
||||
past_y_inside = step(0, past_y.x) * step(past_y.x, 1) * step(0, past_y.y) * step(past_y.y, 1);
|
||||
|
||||
past_sum += mix(textureLod(past_color_sampler, past_back_y, 0.0), textureLod(past_color_sampler, past_y, 0.0), past_b * past_y_inside);
|
||||
|
||||
vy = textureLod(velocity_sampler, y, 0.0) * vec4(render_size * multiplier, 1 * multiplier, 1);
|
||||
|
||||
vy_length = max(0.5, length(vy.xy));
|
||||
|
||||
zy = vy.w - vnz.z * t;
|
||||
|
||||
f = z_compare(-zy, -zx, 20000);
|
||||
|
||||
wa = abs(max(0, dot(vy.xy / vy_length, wn)));
|
||||
|
||||
ay_trail = f * step(T, vy_length * wa);
|
||||
|
||||
y_inside = step(0, y.x) * step(y.x, 1) * step(0, y.y) * step(y.y, 1);
|
||||
|
||||
weight += ay_trail * y_inside;
|
||||
|
||||
sum += textureLod(color_sampler, y, 0.0) * ay_trail * y_inside;
|
||||
}
|
||||
|
||||
sum /= weight;
|
||||
|
||||
weight /= final_sample_count;
|
||||
|
||||
nai_sum /= nai_sub_weight;
|
||||
|
||||
nai_weight /= final_sample_count;
|
||||
|
||||
past_sum /= past_sub_weight;
|
||||
|
||||
past_weight /= final_sample_count;
|
||||
|
||||
sum = mix(mix(nai_sum, past_sum, past_weight), sum, weight);
|
||||
|
||||
imageStore(output_image, uvi, sum);
|
||||
|
||||
#ifdef DEBUG
|
||||
imageStore(debug_1_image, uvi, sum);
|
||||
imageStore(debug_2_image, uvi, abs(vec4(vn / render_size * 10, vnz.z * 100, 1)));
|
||||
imageStore(debug_3_image, uvi, abs(vec4(velocity_map_sample - x, 0, 1)));
|
||||
imageStore(debug_4_image, uvi, abs(vec4(vx / render_size * 10, vxz.z * 100, 1)));
|
||||
imageStore(debug_5_image, uvi, col_x);
|
||||
#endif
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://bud4a7eh5sqr8"
|
||||
path="res://.godot/imported/jump_flood_experimental_blur.glsl-27880bed814a937f2189c48828ca161e.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jump_flood_experimental_blur.glsl"
|
||||
dest_files=["res://.godot/imported/jump_flood_experimental_blur.glsl-27880bed814a937f2189c48828ca161e.res"]
|
||||
|
||||
[params]
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#[compute]
|
||||
#version 450
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D blur_sampler;
|
||||
layout(rgba16f, set = 0, binding = 1) uniform image2D color_image;
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
||||
void main()
|
||||
{
|
||||
ivec2 render_size = ivec2(textureSize(blur_sampler, 0));
|
||||
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
||||
if ((uv.x >= render_size.x) || (uv.y >= render_size.y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
imageStore(color_image, uv, textureLod(blur_sampler, (vec2(uv) + 0.5) / render_size, 0.0));
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://dig08kpnfakuf"
|
||||
path="res://.godot/imported/jump_flood_overlay.glsl-fc28b3ae9a688e5da04536a5cdb7b76e.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/SphynxMotionBlurToolkit/JumpFlood/ShaderFiles/jump_flood_overlay.glsl"
|
||||
dest_files=["res://.godot/imported/jump_flood_overlay.glsl-fc28b3ae9a688e5da04536a5cdb7b76e.res"]
|
||||
|
||||
[params]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue