yes
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"version" : 1,
|
||||
"replacementkey" : "cursorripple",
|
||||
"name" : "ui_editor_effect_cursor_ripple_title",
|
||||
"description" : "ui_editor_effect_cursor_ripple_description",
|
||||
"group" : "interactive",
|
||||
"preview" : "preview/project.json",
|
||||
"passes" :
|
||||
[
|
||||
{
|
||||
"material" : "materials/effects/cursorripple_apply_force.json",
|
||||
"target" : "_rt_QuarterForceRG1",
|
||||
"bind" :
|
||||
[
|
||||
{
|
||||
"name" : "_rt_QuarterForceRG2",
|
||||
"index" : 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"material" : "materials/effects/cursorripple_simulate_force.json",
|
||||
"target" : "_rt_QuarterForceRG2",
|
||||
"bind" :
|
||||
[
|
||||
{
|
||||
"name" : "_rt_QuarterForceRG1",
|
||||
"index" : 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"material" : "materials/effects/cursorripple_combine.json",
|
||||
"bind" :
|
||||
[
|
||||
{
|
||||
"name" : "_rt_QuarterForceRG2",
|
||||
"index" : 0
|
||||
},
|
||||
{
|
||||
"name" : "previous",
|
||||
"index" : 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"fbos" :
|
||||
[
|
||||
{
|
||||
"name" : "_rt_QuarterForceRG1",
|
||||
"scale" : 4,
|
||||
"format" : "rgba8888"
|
||||
},
|
||||
{
|
||||
"name" : "_rt_QuarterForceRG2",
|
||||
"scale" : 4,
|
||||
"format" : "rgba8888"
|
||||
}
|
||||
],
|
||||
"dependencies" :
|
||||
[
|
||||
"materials/effects/cursorripple_apply_force.json",
|
||||
"materials/effects/cursorripple_simulate_force.json",
|
||||
"materials/effects/cursorripple_combine.json",
|
||||
"shaders/effects/cursorripple_apply_force.frag",
|
||||
"shaders/effects/cursorripple_apply_force.vert",
|
||||
"shaders/effects/cursorripple_simulate_force.frag",
|
||||
"shaders/effects/cursorripple_simulate_force.vert",
|
||||
"shaders/effects/cursorripple_combine.frag",
|
||||
"shaders/effects/cursorripple_combine.vert"
|
||||
],
|
||||
"gizmos" :
|
||||
[
|
||||
{
|
||||
"type" : "EffectPerspectiveUV",
|
||||
"condition" :
|
||||
{
|
||||
"PERSPECTIVE" : 1
|
||||
},
|
||||
"vars" :
|
||||
{
|
||||
"p0" : "point0",
|
||||
"p1" : "point1",
|
||||
"p2" : "point2",
|
||||
"p3" : "point3"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"passes" :
|
||||
[
|
||||
{
|
||||
"blending" : "translucent",
|
||||
"cullmode" : "nocull",
|
||||
"depthtest" : "disabled",
|
||||
"depthwrite" : "disabled",
|
||||
"shader" : "genericimage2",
|
||||
"textures" : [ "effectpreview" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"clampuvs" : true,
|
||||
"format" : "rgba8888",
|
||||
"nomip" : true,
|
||||
"nonpoweroftwo" : true
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"passes": [{
|
||||
"shader": "effects/cursorripple_apply_force",
|
||||
"blending": "normal",
|
||||
"depthtest": "disabled",
|
||||
"depthwrite": "disabled",
|
||||
"cullmode": "nocull",
|
||||
"alphawriting": "enabled"
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"passes": [{
|
||||
"shader": "effects/cursorripple_combine",
|
||||
"blending": "normal",
|
||||
"depthtest": "disabled",
|
||||
"depthwrite": "disabled",
|
||||
"cullmode": "nocull"
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"passes": [{
|
||||
"shader": "effects/cursorripple_simulate_force",
|
||||
"blending": "normal",
|
||||
"depthtest": "disabled",
|
||||
"depthwrite": "disabled",
|
||||
"cullmode": "nocull",
|
||||
"alphawriting": "enabled"
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"autosize" : true,
|
||||
"material" : "materials/effectpreview.json"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"file" : "scene.json",
|
||||
"general" :
|
||||
{
|
||||
"properties" :
|
||||
{
|
||||
"schemecolor" :
|
||||
{
|
||||
"order" : 0,
|
||||
"text" : "ui_browse_properties_scheme_color",
|
||||
"type" : "color",
|
||||
"value" : "0 0 0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"title" : "preview",
|
||||
"type" : "scene",
|
||||
"version" : 0
|
||||
}
|
||||
108
modules/wallpaper-engine/effects/cursorripple/preview/scene.json
Normal file
108
modules/wallpaper-engine/effects/cursorripple/preview/scene.json
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"camera" :
|
||||
{
|
||||
"center" : "0.00000 0.00000 -1.00000",
|
||||
"eye" : "0.00000 0.00000 0.00000",
|
||||
"up" : "0.00000 1.00000 0.00000"
|
||||
},
|
||||
"general" :
|
||||
{
|
||||
"ambientcolor" : "0.30000 0.30000 0.30000",
|
||||
"bloom" : false,
|
||||
"bloomhdrfeather" : 0.1,
|
||||
"bloomhdriterations" : 8,
|
||||
"bloomhdrscatter" : 1.619,
|
||||
"bloomhdrstrength" : 2.0,
|
||||
"bloomhdrthreshold" : 1.0,
|
||||
"bloomstrength" : 2.0,
|
||||
"bloomthreshold" : 0.64999998,
|
||||
"camerafade" : true,
|
||||
"cameraparallax" : false,
|
||||
"cameraparallaxamount" : 0.5,
|
||||
"cameraparallaxdelay" : 0.1,
|
||||
"cameraparallaxmouseinfluence" : 0.0,
|
||||
"camerapreview" : true,
|
||||
"camerashake" : false,
|
||||
"camerashakeamplitude" : 0.5,
|
||||
"camerashakeroughness" : 1.0,
|
||||
"camerashakespeed" : 3.0,
|
||||
"clearcolor" : "0.70000 0.70000 0.70000",
|
||||
"clearenabled" : true,
|
||||
"farz" : 10000.0,
|
||||
"fov" : 50.0,
|
||||
"hdr" : false,
|
||||
"nearz" : 0.0099999998,
|
||||
"orthogonalprojection" :
|
||||
{
|
||||
"height" : 256,
|
||||
"width" : 256
|
||||
},
|
||||
"skylightcolor" : "0.30000 0.30000 0.30000",
|
||||
"zoom" : 1.0
|
||||
},
|
||||
"objects" :
|
||||
[
|
||||
{
|
||||
"alignment" : "center",
|
||||
"alpha" : 1.0,
|
||||
"angles" : "0.00000 0.00000 0.00000",
|
||||
"brightness" : 1.0,
|
||||
"color" : "1.00000 1.00000 1.00000",
|
||||
"colorBlendMode" : 0,
|
||||
"copybackground" : true,
|
||||
"depth" : 1,
|
||||
"effects" :
|
||||
[
|
||||
{
|
||||
"file" : "effects/cursorripple/effect.json",
|
||||
"id" : 18,
|
||||
"name" : "",
|
||||
"passes" :
|
||||
[
|
||||
{
|
||||
"constantshadervalues" :
|
||||
{
|
||||
"ripplescale" : 1.0
|
||||
},
|
||||
"id" : 19
|
||||
},
|
||||
{
|
||||
"combos" :
|
||||
{
|
||||
"REFLECTION" : 1
|
||||
},
|
||||
"constantshadervalues" :
|
||||
{
|
||||
"rippledecay" : 1.0,
|
||||
"ripplespeed" : 1.0
|
||||
},
|
||||
"id" : 21
|
||||
},
|
||||
{
|
||||
"constantshadervalues" :
|
||||
{
|
||||
"ripplestrength" : 1.0
|
||||
},
|
||||
"id" : 22,
|
||||
"textures" : [ null, "_rt_imageLayerComposite_38_a" ]
|
||||
}
|
||||
],
|
||||
"visible" : true
|
||||
}
|
||||
],
|
||||
"id" : 38,
|
||||
"image" : "models/effectpreview.json",
|
||||
"ledsource" : false,
|
||||
"locktransforms" : false,
|
||||
"name" : "",
|
||||
"origin" : "128.00000 128.00000 0.00000",
|
||||
"parallaxDepth" : "1.00000 1.00000",
|
||||
"perspective" : false,
|
||||
"scale" : "1.00000 1.00000 1.00000",
|
||||
"size" : "256.00000 256.00000",
|
||||
"solid" : true,
|
||||
"visible" : true
|
||||
}
|
||||
],
|
||||
"version" : 0
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
|
||||
varying vec4 v_TexCoord;
|
||||
|
||||
uniform float g_Frametime;
|
||||
uniform vec4 g_PointerState;
|
||||
uniform sampler2D g_Texture0; // {"hidden":true}
|
||||
|
||||
varying vec4 v_PointerUV;
|
||||
varying vec4 v_PointerUVLast;
|
||||
varying vec2 v_PointDelta;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
varying mat3 v_XForm;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 texSource = v_TexCoord.xy;
|
||||
|
||||
vec4 albedo = texSample2D(g_Texture0, texSource);
|
||||
|
||||
// Complete unproject per pixel
|
||||
vec2 unprojectedUVs = v_PointerUV.xy / v_PointerUV.z;
|
||||
vec2 unprojectedUVsLast = v_PointerUVLast.xy / v_PointerUVLast.z;
|
||||
|
||||
//vec2 pointerDebug;
|
||||
//pointerDebug = unprojectedUVs;
|
||||
unprojectedUVs += 0.5;
|
||||
unprojectedUVs.y = 1.0 - unprojectedUVs.y;
|
||||
unprojectedUVsLast += 0.5;
|
||||
unprojectedUVsLast.y = 1.0 - unprojectedUVsLast.y;
|
||||
|
||||
float rippleMask = 1.0;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
// This perspective transform will take the cursor within the gizmo boundaries and
|
||||
// map it to the entire simulation canvas
|
||||
vec3 tmp = vec3(unprojectedUVs.xy, 1.0);
|
||||
tmp.xyz = mul(tmp.xyz, v_XForm);
|
||||
unprojectedUVs = tmp.xy / tmp.z;
|
||||
|
||||
tmp = vec3(unprojectedUVsLast.xy, 1.0);
|
||||
tmp.xyz = mul(tmp.xyz, v_XForm);
|
||||
unprojectedUVsLast = tmp.xy / tmp.z;
|
||||
|
||||
// Block impulse when cursor moves across perspective horizon
|
||||
rippleMask *= step(abs(unprojectedUVs.x - 0.5), 0.5);
|
||||
rippleMask *= step(abs(unprojectedUVs.y - 0.5), 0.5);
|
||||
rippleMask *= step(abs(unprojectedUVsLast.x - 0.5), 0.5);
|
||||
rippleMask *= step(abs(unprojectedUVsLast.y - 0.5), 0.5);
|
||||
#endif
|
||||
|
||||
//unprojectedUVs = (texSource - unprojectedUVs); // * vec2(v_PointDelta.y, v_PointerUV.w);
|
||||
//unprojectedUVsLast = (texSource - unprojectedUVsLast); // * vec2(v_PointDelta.y, v_PointerUVLast.w);
|
||||
|
||||
vec2 lDelta = unprojectedUVs - unprojectedUVsLast;
|
||||
vec2 texDelta = texSource - unprojectedUVsLast;
|
||||
|
||||
float distLDelta = length(lDelta);
|
||||
distLDelta = max(0.0001, distLDelta);
|
||||
lDelta /= distLDelta; // DIV ZERO
|
||||
float distOnLine = dot(lDelta, texDelta);
|
||||
//distOnLine = distOnLine * distLDelta;
|
||||
|
||||
float rayMask = max(step(0.0, distOnLine) * step(distOnLine, distLDelta), step(distLDelta, 0.1));
|
||||
|
||||
distOnLine = saturate(distOnLine / distLDelta) * distLDelta;
|
||||
vec2 posOnLine = unprojectedUVsLast + lDelta * distOnLine;
|
||||
|
||||
|
||||
unprojectedUVs = (texSource - posOnLine) * vec2(v_PointDelta.y, v_PointerUV.w);
|
||||
|
||||
float pointerDist = length(unprojectedUVs);
|
||||
pointerDist = saturate(1.0 - pointerDist);
|
||||
|
||||
//pointerDist *= step(0.05 * distLDelta, distOnLine);
|
||||
//pointerDist = 1.0;
|
||||
pointerDist *= rayMask * rippleMask;
|
||||
|
||||
|
||||
float timeAmt = g_Frametime / 0.02;
|
||||
float pointerMoveAmt = v_PointDelta.x;
|
||||
float inputStrength = pointerDist * timeAmt * (pointerMoveAmt + g_PointerState.z); // * g_PointerState.z;
|
||||
//albedo.a = inputStrength
|
||||
//vec2 impulseDir = saturate(unprojectedUVs * 0.5 + CAST2(0.5));
|
||||
vec2 impulseDir = max(CAST2(-1.0), min(CAST2(1.0), unprojectedUVs));
|
||||
//albedo.b = 1.0;
|
||||
|
||||
vec4 colorAdd = vec4(
|
||||
step(0.0, impulseDir.x) * impulseDir.x * inputStrength,
|
||||
step(0.0, impulseDir.y) * impulseDir.y * inputStrength,
|
||||
step(impulseDir.x, 0.0) * -impulseDir.x * inputStrength,
|
||||
step(impulseDir.y, 0.0) * -impulseDir.y * inputStrength
|
||||
);
|
||||
|
||||
gl_FragColor = albedo + colorAdd;
|
||||
|
||||
//colorAdd = vec4(pointerDebug * 0.5 + 0.5, 0, 0);
|
||||
//gl_FragColor = colorAdd;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
|
||||
|
||||
#include "common_perspective.h"
|
||||
|
||||
uniform mat4 g_ModelViewProjectionMatrix;
|
||||
uniform mat4 g_EffectTextureProjectionMatrixInverse;
|
||||
uniform vec2 g_PointerPosition;
|
||||
uniform vec2 g_PointerPositionLast;
|
||||
uniform vec4 g_Texture0Resolution;
|
||||
|
||||
uniform float g_RippleScale; // {"material":"ripplescale","label":"ui_editor_properties_ripple_scale","default":1.0,"range":[0,2]}
|
||||
|
||||
|
||||
attribute vec3 a_Position;
|
||||
attribute vec2 a_TexCoord;
|
||||
|
||||
varying vec2 v_TexCoord;
|
||||
varying vec4 v_PointerUV;
|
||||
varying vec4 v_PointerUVLast;
|
||||
varying vec2 v_PointDelta;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
uniform vec2 g_Point0; // {"material":"point0","label":"p0","default":"0 0"}
|
||||
uniform vec2 g_Point1; // {"material":"point1","label":"p1","default":"1 0"}
|
||||
uniform vec2 g_Point2; // {"material":"point2","label":"p2","default":"1 1"}
|
||||
uniform vec2 g_Point3; // {"material":"point3","label":"p3","default":"0 1"}
|
||||
varying mat3 v_XForm;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(a_Position, 1.0);
|
||||
|
||||
v_TexCoord.xy = a_TexCoord.xy;
|
||||
|
||||
vec2 pointer = g_PointerPosition;
|
||||
pointer.y = 1.0 - pointer.y; // Flip pointer screen space Y to match texture space Y
|
||||
vec2 pointerLast = g_PointerPositionLast;
|
||||
pointerLast.y = 1.0 - pointerLast.y;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
mat3 xform = inverse(squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3));
|
||||
v_XForm = xform;
|
||||
#endif
|
||||
|
||||
vec4 preTransformPoint = vec4(pointer * 2 - 1, 0.0, 1.0);
|
||||
vec4 preTransformPointLast = vec4(pointerLast * 2 - 1, 0.0, 1.0);
|
||||
|
||||
|
||||
v_PointerUV.xyz = mul(preTransformPoint, g_EffectTextureProjectionMatrixInverse).xyw;
|
||||
v_PointerUV.xy *= 0.5;
|
||||
|
||||
v_PointerUVLast.xyz = mul(preTransformPointLast, g_EffectTextureProjectionMatrixInverse).xyw;
|
||||
v_PointerUVLast.xy *= 0.5;
|
||||
|
||||
|
||||
v_PointerUV.w = g_Texture0Resolution.y / -g_Texture0Resolution.x;
|
||||
//v_PointerUV.y *= v_PointerUV.w;
|
||||
|
||||
v_PointDelta.x = length(g_PointerPosition - g_PointerPositionLast);
|
||||
//v_PointDelta *= v_PointDelta;
|
||||
v_PointDelta.x *= 100;
|
||||
//v_PointDelta = 1;
|
||||
|
||||
v_PointDelta.y = 60.0 / max(0.0001, g_RippleScale);
|
||||
v_PointerUV.w *= -v_PointDelta.y;
|
||||
v_PointerUVLast.w = v_PointerUV.w;
|
||||
|
||||
//vec2 pointerLast = g_PointerPositionLast;
|
||||
//pointerLast.y = 1.0 - pointerLast.y; // Flip pointer screen space Y to match texture space Y
|
||||
//v_PointerUVLast.xyz = mul(vec4(pointerLast * 2 - 1, 0.0, 1.0), g_EffectTextureProjectionMatrixInverse).xyw;
|
||||
//v_PointerUVLast.xy *= 0.5;
|
||||
//v_PointerUVLast.w = g_Texture0Resolution.y / -g_Texture0Resolution.x;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
// [COMBO] {"material":"ui_editor_properties_shading","combo":"SHADING","type":"options","default":0}
|
||||
|
||||
#include "common.h"
|
||||
|
||||
uniform sampler2D g_Texture0; // {"hidden":true}
|
||||
uniform sampler2D g_Texture1; // {"hidden":true}
|
||||
//uniform sampler2D g_Texture2; // {"label":"ui_editor_properties_opacity_mask","mode":"opacitymask","combo":"MASK","paintdefaultcolor":"0 0 0 1"}
|
||||
|
||||
//uniform vec4 g_Texture0Resolution;
|
||||
|
||||
uniform float g_RippleStrength; // {"material":"ripplestrength","label":"ui_editor_properties_ripple_strength","default":1.0,"range":[0,2]}
|
||||
uniform float g_ShadingAmount; // {"material":"shadingamount","label":"ui_editor_properties_shading_amount","default":1.0,"range":[0,2]}
|
||||
uniform vec3 g_ShadingHigh; // {"material":"shadingtinthigh","label":"ui_editor_properties_tint_high","type":"color","default":"1 1 1"}
|
||||
uniform vec3 g_ShadingLow; // {"material":"shadingtintlow","label":"ui_editor_properties_tint_low","type":"color","default":"0 0 0"}
|
||||
uniform float g_ShadingDirection; // {"material":"shadingdirection","label":"ui_editor_properties_shading_direction","default":3.14159265358,"range":[0,6.28],"direction":true,"conversion":"rad2deg"}
|
||||
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
varying vec3 v_TexCoordPerspective;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 srcCoords = v_TexCoord.xy;
|
||||
vec2 rippleCoords = v_TexCoord.xy;
|
||||
float rippleMask = 1.0;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
rippleCoords = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
|
||||
rippleMask *= step(abs(rippleCoords.x - 0.5), 0.5);
|
||||
rippleMask *= step(abs(rippleCoords.y - 0.5), 0.5);
|
||||
#endif
|
||||
|
||||
vec4 albedo = texSample2D(g_Texture0, rippleCoords);
|
||||
albedo *= albedo;
|
||||
|
||||
vec2 dir = vec2(albedo.x - albedo.z, albedo.y - albedo.w);
|
||||
|
||||
//float pi = 3.14159265359;
|
||||
float distortAmt = 3.0 * g_RippleStrength;
|
||||
//distortAmt *= length(dir) * 1.0 * abs(sin(2.0 * atan2(dir.x, dir.y)));
|
||||
|
||||
vec2 offset = dir;
|
||||
offset *= -0.1 * distortAmt * rippleMask;
|
||||
//offset.y = 0;
|
||||
//offset.x = 0;
|
||||
|
||||
vec4 screen = texSample2D(g_Texture1, srcCoords + offset);
|
||||
//vec4 albedoOld = texSample2D(g_Texture2, v_TexCoord.xy);
|
||||
|
||||
#if SHADING
|
||||
vec2 shadingDir = dir;
|
||||
float shadingLength = max(0.99, length(shadingDir));
|
||||
shadingDir = mix(shadingDir, shadingDir / shadingLength, step(1.0, shadingLength));
|
||||
float shading = dot(rotateVec2(vec2(0, -1), g_ShadingDirection), shadingDir);
|
||||
|
||||
screen.rgb = mix(screen.rgb, screen.rgb * mix(g_ShadingLow, CAST3(1.0) + g_ShadingHigh, shading * 0.5 + 0.5), abs(shading * g_ShadingAmount) * rippleMask);
|
||||
#endif
|
||||
|
||||
gl_FragColor = screen;
|
||||
|
||||
|
||||
//vec4 dirColorTest = vec4(dir * 0.5 + 0.5, 0.0, 1.0);
|
||||
//gl_FragColor = dirColorTest;
|
||||
|
||||
//gl_FragColor += vec4(distortAmt, distortAmt, distortAmt, 1);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
|
||||
|
||||
#include "common_perspective.h"
|
||||
|
||||
uniform mat4 g_ModelViewProjectionMatrix;
|
||||
|
||||
attribute vec3 a_Position;
|
||||
attribute vec2 a_TexCoord;
|
||||
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
uniform vec2 g_Point0; // {"material":"point0","label":"p0","default":"0 0"}
|
||||
uniform vec2 g_Point1; // {"material":"point1","label":"p1","default":"1 0"}
|
||||
uniform vec2 g_Point2; // {"material":"point2","label":"p2","default":"1 1"}
|
||||
uniform vec2 g_Point3; // {"material":"point3","label":"p3","default":"0 1"}
|
||||
varying vec3 v_TexCoordPerspective;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
|
||||
|
||||
v_TexCoord = a_TexCoord.xy;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
mat3 xform = inverse(squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3));
|
||||
v_TexCoordPerspective = mul(vec3(a_TexCoord.xy, 1.0), xform);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
|
||||
// [COMBO] {"material":"ui_editor_properties_reflection","combo":"REFLECTION","type":"options","default":0}
|
||||
|
||||
uniform float g_Frametime;
|
||||
uniform vec4 g_Texture0Resolution;
|
||||
|
||||
uniform sampler2D g_Texture0; // {"hidden":true}
|
||||
uniform sampler2D g_Texture1; // {"label":"ui_editor_properties_collision_mask","mode":"opacitymask","combo":"MASK","paintdefaultcolor":"0 0 0 1","painttexturescale":1}
|
||||
|
||||
uniform float g_RippleSpeed; // {"material":"ripplespeed","label":"ui_editor_properties_ripple_speed","default":1.0,"range":[0,2]}
|
||||
uniform float g_RippleDecay; // {"material":"rippledecay","label":"ui_editor_properties_ripple_decay","default":1.0,"range":[0,4]}
|
||||
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
varying vec3 v_TexCoordPerspective;
|
||||
#endif
|
||||
|
||||
vec4 sampleF(vec4 a, vec4 b, vec4 c)
|
||||
{
|
||||
//float sb = step(length(a), length(b));
|
||||
//float sc = step(max(length(a), length(b)), length(c));
|
||||
//return mix(mix(a, b, sb), c, sc);
|
||||
//return a;
|
||||
|
||||
return max(a, max(b, c));
|
||||
|
||||
//vec4 f = max(a, max(b, c));
|
||||
|
||||
//float maxAmt = max(f.x, max(f.y, max(f.z, f.w)));
|
||||
//float totalAmt = dot(CAST4(1.0), f);
|
||||
|
||||
//if (totalAmt <= maxAmt)
|
||||
// f *= 0.95;
|
||||
//return f;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 srcCoords = v_TexCoord.xy;
|
||||
|
||||
vec4 albedo = texSample2D(g_Texture0, srcCoords);
|
||||
vec2 simTexel = 1.0 / g_Texture0Resolution.xy;
|
||||
vec2 rippleOffset = simTexel * 100 * g_RippleSpeed * g_Frametime;
|
||||
|
||||
vec2 insideRipple = rippleOffset * 1.61;
|
||||
vec2 outsideRipple = rippleOffset;
|
||||
|
||||
float reflectUp = 0;
|
||||
float reflectDown = 0;
|
||||
float reflectLeft = 0;
|
||||
float reflectRight = 0;
|
||||
|
||||
#if REFLECTION
|
||||
reflectUp = step(1.0 - simTexel.y, srcCoords.y);
|
||||
reflectDown = step(srcCoords.y, simTexel.y);
|
||||
reflectLeft = step(1.0 - simTexel.x, srcCoords.x);
|
||||
reflectRight = step(srcCoords.x, simTexel.x);
|
||||
#endif
|
||||
|
||||
vec4 uc = texSample2D(g_Texture0, srcCoords + vec2(0, -insideRipple.y));
|
||||
vec4 u00 = texSample2D(g_Texture0, srcCoords + vec2(-outsideRipple.x, -outsideRipple.y));
|
||||
vec4 u10 = texSample2D(g_Texture0, srcCoords + vec2(outsideRipple.x, -outsideRipple.y));
|
||||
|
||||
vec4 dc = texSample2D(g_Texture0, srcCoords + vec2(0, insideRipple.y));
|
||||
vec4 d01 = texSample2D(g_Texture0, srcCoords + vec2(-outsideRipple.x, outsideRipple.y));
|
||||
vec4 d11 = texSample2D(g_Texture0, srcCoords + vec2(outsideRipple.x, outsideRipple.y));
|
||||
|
||||
vec4 lc = texSample2D(g_Texture0, srcCoords + vec2(-insideRipple.x, 0));
|
||||
vec4 l00 = texSample2D(g_Texture0, srcCoords + vec2(-outsideRipple.x, -outsideRipple.y));
|
||||
vec4 l01 = texSample2D(g_Texture0, srcCoords + vec2(-outsideRipple.x, outsideRipple.y));
|
||||
|
||||
vec4 rc = texSample2D(g_Texture0, srcCoords + vec2(insideRipple.x, 0));
|
||||
vec4 r10 = texSample2D(g_Texture0, srcCoords + vec2(outsideRipple.x, -outsideRipple.y));
|
||||
vec4 r11 = texSample2D(g_Texture0, srcCoords + vec2(outsideRipple.x, outsideRipple.y));
|
||||
|
||||
vec4 up = sampleF(uc, u00, u10);
|
||||
vec4 down = sampleF(dc, d01, d11);
|
||||
vec4 left = sampleF(lc, l00, l01);
|
||||
vec4 right = sampleF(rc, r10, r11);
|
||||
//vec4 up = texSample2D(g_Texture0, srcCoords + vec2(0, -offsetScale.y));
|
||||
//vec4 down = texSample2D(g_Texture0, srcCoords + vec2(0, offsetScale.y));
|
||||
//vec4 left = texSample2D(g_Texture0, srcCoords + vec2(-offsetScale.x, 0));
|
||||
//vec4 right = texSample2D(g_Texture0, srcCoords + vec2(offsetScale.x, 0));
|
||||
|
||||
float reflectionScale = 1;
|
||||
|
||||
#if MASK
|
||||
|
||||
vec2 maskCoords = srcCoords;
|
||||
#if PERSPECTIVE == 1
|
||||
maskCoords = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
|
||||
#endif
|
||||
|
||||
float maskCenter = 1.0 - step(0.5, texSample2D(g_Texture1, maskCoords).r);
|
||||
float maskUp = 0.0;
|
||||
float maskDown = 0.0;
|
||||
float maskLeft = 0.0;
|
||||
float maskRight = 0.0;
|
||||
|
||||
#if REFLECTION
|
||||
maskUp = texSample2D(g_Texture1, maskCoords + vec2(0, -simTexel.y)).r * maskCenter;
|
||||
maskDown = texSample2D(g_Texture1, maskCoords + vec2(0, simTexel.y)).r * maskCenter;
|
||||
maskLeft = texSample2D(g_Texture1, maskCoords + vec2(-simTexel.x, 0)).r * maskCenter;
|
||||
maskRight = texSample2D(g_Texture1, maskCoords + vec2(simTexel.x, 0)).r * maskCenter;
|
||||
#endif
|
||||
|
||||
reflectDown = step(0.01, reflectDown + maskUp);
|
||||
reflectUp = step(0.01, reflectUp + maskDown);
|
||||
reflectRight = step(0.01, reflectRight + maskLeft);
|
||||
reflectLeft = step(0.01, reflectLeft + maskRight);
|
||||
#endif
|
||||
|
||||
//reflectUp *= reflectionScale;
|
||||
//reflectDown *= reflectionScale;
|
||||
//reflectLeft *= reflectionScale;
|
||||
//reflectRight *= reflectionScale;
|
||||
|
||||
vec4 sample;
|
||||
vec4 force = vec4(0, 0, 0, 0);
|
||||
|
||||
float componentScale = 1 / 3.0;
|
||||
|
||||
vec4 reflectionMask = (CAST4(1.0) - vec4(reflectRight, reflectDown, reflectLeft, reflectUp) * 0.9) * componentScale;
|
||||
|
||||
force.xzy += up.xzy * reflectionMask.xzy;
|
||||
force.xzw += down.xzw * reflectionMask.xzw;
|
||||
force.xyw += left.xyw * reflectionMask.xyw;
|
||||
force.zyw += right.zyw * reflectionMask.zyw;
|
||||
|
||||
//force += up * componentScale;
|
||||
//force += down * componentScale;
|
||||
//force += left * componentScale;
|
||||
//force += right * componentScale;
|
||||
|
||||
#if REFLECTION
|
||||
vec4 forceCopy = force;
|
||||
|
||||
//force.y *= 1.0 - reflectDown;
|
||||
force.y += forceCopy.w * reflectionScale * reflectDown;
|
||||
force.w *= 1.0 - reflectDown;
|
||||
|
||||
//force.w *= 1.0 - reflectUp;
|
||||
force.w += forceCopy.y * reflectionScale * reflectUp;
|
||||
force.y *= 1.0 - reflectUp;
|
||||
|
||||
//force.x *= 1.0 - reflectRight;
|
||||
force.x += forceCopy.z * reflectionScale * reflectRight;
|
||||
force.z *= 1.0 - reflectRight;
|
||||
|
||||
//force.z *= 1.0 - reflectLeft;
|
||||
force.z += forceCopy.x * reflectionScale * reflectLeft;
|
||||
force.x *= 1.0 - reflectLeft;
|
||||
|
||||
//force = normalize(force) * length(forceCopy);
|
||||
#endif
|
||||
|
||||
#if MASK
|
||||
force *= maskCenter;
|
||||
#endif
|
||||
|
||||
float decay = 1.5;
|
||||
|
||||
float drop = max(1.001 / 255.0, decay / 255.0 * (g_Frametime / 0.02) * g_RippleDecay);
|
||||
force -= drop;
|
||||
|
||||
albedo = force;
|
||||
|
||||
//albedo = vec4(0, 0, 0, 0);
|
||||
|
||||
gl_FragColor = albedo;
|
||||
|
||||
//gl_FragColor = texSample2D(g_Texture0, srcCoords) - drop;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
|
||||
|
||||
#include "common_perspective.h"
|
||||
|
||||
uniform mat4 g_ModelViewProjectionMatrix;
|
||||
|
||||
attribute vec3 a_Position;
|
||||
attribute vec2 a_TexCoord;
|
||||
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
uniform vec2 g_Point0; // {"material":"point0","label":"p0","default":"0 0"}
|
||||
uniform vec2 g_Point1; // {"material":"point1","label":"p1","default":"1 0"}
|
||||
uniform vec2 g_Point2; // {"material":"point2","label":"p2","default":"1 1"}
|
||||
uniform vec2 g_Point3; // {"material":"point3","label":"p3","default":"0 1"}
|
||||
varying vec3 v_TexCoordPerspective;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(a_Position, 1.0);
|
||||
|
||||
v_TexCoord.xy = a_TexCoord.xy;
|
||||
|
||||
#if PERSPECTIVE == 1
|
||||
mat3 xform = (squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3));
|
||||
v_TexCoordPerspective = mul(vec3(a_TexCoord.xy, 1.0), xform);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "FX Preview",
|
||||
"type": "scene2d"
|
||||
}
|
||||
Reference in New Issue
Block a user