stuff
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
|
||||
// [COMBO] {"material":"ui_editor_properties_blend_mode","combo":"BLENDMODE","type":"imageblending","default":0}
|
||||
|
||||
#include "common_blending.h"
|
||||
|
||||
varying vec4 v_TexCoord;
|
||||
varying vec3 v_PointerUV;
|
||||
|
||||
uniform float g_Multiply; // {"material":"ui_editor_properties_multiply","default":1,"range":[0.0, 10.0]}
|
||||
uniform float g_PointerScale; // {"material":"ui_editor_particle_element_exponent","default":5,"range":[0.01, 20.0]}
|
||||
|
||||
#if OPACITYMASK == 1
|
||||
varying vec2 v_TexCoordOpacity;
|
||||
#endif
|
||||
|
||||
uniform sampler2D g_Texture0; // {"material":"ui_editor_properties_framebuffer","hidden":true}
|
||||
uniform sampler2D g_Texture1; // {"material":"ui_editor_properties_blend_texture","mode":"rgbmask","default":"util/white"}
|
||||
uniform sampler2D g_Texture2; // {"material":"ui_editor_properties_sprite","default":"particle/halo"}
|
||||
uniform sampler2D g_Texture3; // {"material":"ui_editor_properties_opacity_mask","mode":"opacitymask","default":"util/white","combo":"OPACITYMASK"}
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
|
||||
vec4 mask = texSample2D(g_Texture1, v_TexCoord.zw);
|
||||
float blend = mask.a * g_Multiply;
|
||||
|
||||
#if OPACITYMASK == 1
|
||||
blend *= texSample2D(g_Texture3, v_TexCoordOpacity).r;
|
||||
#endif
|
||||
|
||||
// Complete unproject per pixel
|
||||
vec2 unprojectedUVs = v_PointerUV.xy / v_PointerUV.z;
|
||||
|
||||
vec2 texS = v_TexCoord.xy;
|
||||
texS.y = 1.0 - texS.y;
|
||||
unprojectedUVs = (texS - unprojectedUVs);
|
||||
unprojectedUVs = saturate(unprojectedUVs);
|
||||
|
||||
// Scale sprite image around center
|
||||
unprojectedUVs -= 0.5;
|
||||
unprojectedUVs *= g_PointerScale;
|
||||
unprojectedUVs += 0.5;
|
||||
|
||||
vec2 blendSample = texSample2D(g_Texture2, unprojectedUVs).ra;
|
||||
blend *= blendSample.x * blendSample.y;
|
||||
|
||||
//blend = 0;
|
||||
//albedo.rgb = vec3(unprojectedUVs.xy, 0);
|
||||
|
||||
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, mask.rgb, blend);
|
||||
|
||||
gl_FragColor = albedo;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
uniform mat4 g_ModelViewProjectionMatrix;
|
||||
uniform vec4 g_Texture1Resolution;
|
||||
|
||||
#if OPACITYMASK == 1
|
||||
uniform vec4 g_Texture3Resolution;
|
||||
|
||||
varying vec2 v_TexCoordOpacity;
|
||||
#endif
|
||||
|
||||
attribute vec3 a_Position;
|
||||
attribute vec2 a_TexCoord;
|
||||
|
||||
varying vec4 v_TexCoord;
|
||||
|
||||
uniform mat4 g_ModelViewProjectionMatrixInverse;
|
||||
|
||||
uniform vec4 g_Texture0Resolution;
|
||||
uniform vec2 g_PointerPosition;
|
||||
|
||||
varying vec3 v_PointerUV;
|
||||
|
||||
void main() {
|
||||
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
|
||||
v_TexCoord.xy = a_TexCoord;
|
||||
v_TexCoord.zw = vec2(v_TexCoord.x * g_Texture1Resolution.z / g_Texture1Resolution.x,
|
||||
v_TexCoord.y * g_Texture1Resolution.w / g_Texture1Resolution.y);
|
||||
|
||||
#if OPACITYMASK == 1
|
||||
v_TexCoordOpacity = vec2(v_TexCoord.x * g_Texture3Resolution.z / g_Texture3Resolution.x,
|
||||
v_TexCoord.y * g_Texture3Resolution.w / g_Texture3Resolution.y);
|
||||
#endif
|
||||
|
||||
vec2 pointer = g_PointerPosition;
|
||||
pointer.y = 1.0 - pointer.y; // Flip pointer screen space Y to match texture space Y
|
||||
v_PointerUV = mul(vec4(pointer * 2 - 1, 0.0, 1.0), g_ModelViewProjectionMatrixInverse).xyw;
|
||||
v_PointerUV.xy *= 1.0 / g_Texture0Resolution.xy;
|
||||
}
|
||||
Reference in New Issue
Block a user