yes
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
|
||||
// [COMBO] {"material":"ui_editor_properties_blend_mode","combo":"BLENDMODE","type":"imageblending","default":2}
|
||||
// [COMBO] {"material":"ui_editor_properties_transform","combo":"TRANSFORMUV","type":"options","default":0}
|
||||
// [COMBO] {"material":"ui_editor_properties_transform_repeat","combo":"TRANSFORMREPEAT","type":"options","default":0,"options":{"ui_editor_properties_clip":0,"ui_editor_properties_repeat":1,"ui_editor_properties_clamp_uvs":2},"require":{"TRANSFORMUV":1}}
|
||||
// [COMBO] {"material":"ui_editor_properties_write_alpha","combo":"WRITEALPHA","type":"options","default":0}
|
||||
// [COMBO] {"material":"ui_editor_properties_number_of_textures","combo":"NUMBLENDTEXTURES","type":"options","default":1,"options":{"1":1,"2":2,"3":3,"4":4,"5":5,"6":6}}
|
||||
|
||||
#include "common_blending.h"
|
||||
|
||||
varying vec4 v_TexCoord;
|
||||
|
||||
#if NUMBLENDTEXTURES >= 2
|
||||
varying vec4 v_TexCoord23;
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 4
|
||||
varying vec4 v_TexCoord45;
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 6
|
||||
varying vec2 v_TexCoord6;
|
||||
#endif
|
||||
|
||||
uniform float g_Multiply; // {"material":"multiply","label":"ui_editor_properties_blend_amount","default":1,"range":[0.0, 2.0]}
|
||||
uniform float g_Multiply2; // {"material":"multiply2","label":"ui_editor_properties_blend_amount_2","default":1,"range":[0.0, 2.0]}
|
||||
uniform float g_Multiply3; // {"material":"multiply3","label":"ui_editor_properties_blend_amount_3","default":1,"range":[0.0, 2.0]}
|
||||
uniform float g_Multiply4; // {"material":"multiply4","label":"ui_editor_properties_blend_amount_4","default":1,"range":[0.0, 2.0]}
|
||||
uniform float g_Multiply5; // {"material":"multiply5","label":"ui_editor_properties_blend_amount_5","default":1,"range":[0.0, 2.0]}
|
||||
uniform float g_Multiply6; // {"material":"multiply6","label":"ui_editor_properties_blend_amount_6","default":1,"range":[0.0, 2.0]}
|
||||
uniform float g_AlphaMultiply; // {"material":"alpha","label":"ui_editor_properties_alpha","default":1,"range":[0.0, 1.0]}
|
||||
|
||||
#if OPACITYMASK == 1
|
||||
varying vec2 v_TexCoordOpacity;
|
||||
#endif
|
||||
|
||||
uniform sampler2D g_Texture0; // {"hidden":true}
|
||||
uniform sampler2D g_Texture7; // {"label":"ui_editor_properties_opacity_mask","mode":"opacitymask","default":"util/white","combo":"OPACITYMASK","paintdefaultcolor":"0 0 0 1"}
|
||||
uniform sampler2D g_Texture1; // {"label":"ui_editor_properties_blend_texture","mode":"rgbmask","default":"util/white"}
|
||||
|
||||
#if NUMBLENDTEXTURES >= 2
|
||||
uniform sampler2D g_Texture2; // {"label":"ui_editor_properties_blend_texture","mode":"rgbmask","default":"util/white"}
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 3
|
||||
uniform sampler2D g_Texture3; // {"label":"ui_editor_properties_blend_texture","mode":"rgbmask","default":"util/white"}
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 4
|
||||
uniform sampler2D g_Texture4; // {"label":"ui_editor_properties_blend_texture","mode":"rgbmask","default":"util/white"}
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 5
|
||||
uniform sampler2D g_Texture5; // {"label":"ui_editor_properties_blend_texture","mode":"rgbmask","default":"util/white"}
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 6
|
||||
uniform sampler2D g_Texture6; // {"label":"ui_editor_properties_blend_texture","mode":"rgbmask","default":"util/white"}
|
||||
#endif
|
||||
|
||||
float GetUVBlend(vec2 uv)
|
||||
{
|
||||
#if TRANSFORMUV == 1 && TRANSFORMREPEAT == 0
|
||||
return step(0.99, dot(step(CAST2(0.0), uv) * step(uv, CAST2(1.0)), CAST2(0.5)));
|
||||
#endif
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
|
||||
|
||||
vec2 blendUV = v_TexCoord.zw;
|
||||
#if TRANSFORMUV == 1 && TRANSFORMREPEAT == 1
|
||||
blendUV = frac(blendUV);
|
||||
#endif
|
||||
|
||||
vec4 blendColors = texSample2D(g_Texture1, blendUV);
|
||||
float blend = 1.0;
|
||||
|
||||
#if OPACITYMASK == 1
|
||||
blend *= texSample2D(g_Texture7, v_TexCoordOpacity).r;
|
||||
#endif
|
||||
|
||||
float blendAlpha = GetUVBlend(blendUV) * blend * g_Multiply * blendColors.a;
|
||||
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, blendColors.rgb, blendAlpha);
|
||||
|
||||
#if NUMBLENDTEXTURES >= 2
|
||||
blendUV = frac(v_TexCoord23.xy);
|
||||
blendColors = texSample2D(g_Texture2, blendUV);
|
||||
blendAlpha *= blendColors.a * g_Multiply2;
|
||||
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, blendColors.rgb, GetUVBlend(blendUV) * blend * g_Multiply2 * blendColors.a);
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 3
|
||||
blendUV = frac(v_TexCoord23.zw);
|
||||
blendColors = texSample2D(g_Texture3, blendUV);
|
||||
blendAlpha *= blendColors.a * g_Multiply3;
|
||||
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, blendColors.rgb, GetUVBlend(blendUV) * blend * g_Multiply3 * blendColors.a);
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 4
|
||||
blendUV = frac(v_TexCoord45.xy);
|
||||
blendColors = texSample2D(g_Texture4, blendUV);
|
||||
blendAlpha *= blendColors.a * g_Multiply4;
|
||||
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, blendColors.rgb, GetUVBlend(blendUV) * blend * g_Multiply4 * blendColors.a);
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 5
|
||||
blendUV = frac(v_TexCoord45.zw);
|
||||
blendColors = texSample2D(g_Texture5, blendUV);
|
||||
blendAlpha *= blendColors.a * g_Multiply5;
|
||||
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, blendColors.rgb, GetUVBlend(blendUV) * blend * g_Multiply5 * blendColors.a);
|
||||
#endif
|
||||
|
||||
#if NUMBLENDTEXTURES >= 6
|
||||
blendUV = frac(v_TexCoord6.xy);
|
||||
blendColors = texSample2D(g_Texture6, blendUV);
|
||||
blendAlpha *= blendColors.a * g_Multiply6;
|
||||
albedo.rgb = ApplyBlending(BLENDMODE, albedo.rgb, blendColors.rgb, GetUVBlend(blendUV) * blend * g_Multiply6 * blendColors.a);
|
||||
#endif
|
||||
|
||||
|
||||
#if WRITEALPHA
|
||||
albedo.a = blendColors.a * g_AlphaMultiply;
|
||||
#endif
|
||||
|
||||
gl_FragColor = albedo;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
uniform mat4 g_ModelViewProjectionMatrix;
|
||||
uniform vec4 g_Texture1Resolution;
|
||||
uniform vec4 g_Texture2Resolution;
|
||||
uniform vec4 g_Texture3Resolution;
|
||||
uniform vec4 g_Texture4Resolution;
|
||||
uniform vec4 g_Texture5Resolution;
|
||||
uniform vec4 g_Texture6Resolution;
|
||||
|
||||
#if OPACITYMASK == 1
|
||||
uniform vec4 g_Texture7Resolution;
|
||||
|
||||
varying vec2 v_TexCoordOpacity;
|
||||
#endif
|
||||
|
||||
#if TRANSFORMUV == 1
|
||||
uniform vec4 g_Texture0Resolution;
|
||||
#endif
|
||||
|
||||
uniform vec2 g_BlendOffset; // {"material":"blendoffset","label":"ui_editor_properties_offset","default":"0 0"}
|
||||
uniform float g_BlendAngle; // {"material":"blendangle","label":"ui_editor_properties_angle","default":0,"range":[0,6.28]}
|
||||
uniform float g_BlendScale; // {"material":"blendscale","label":"ui_editor_properties_scale","default":1,"range":[0.01,2]}
|
||||
|
||||
attribute vec3 a_Position;
|
||||
attribute vec2 a_TexCoord;
|
||||
|
||||
varying vec4 v_TexCoord;
|
||||
|
||||
#if NUMBLENDTEXTURES >= 2
|
||||
varying vec4 v_TexCoord23;
|
||||
#endif
|
||||
#if NUMBLENDTEXTURES >= 4
|
||||
varying vec4 v_TexCoord45;
|
||||
#endif
|
||||
#if NUMBLENDTEXTURES >= 6
|
||||
varying vec2 v_TexCoord6;
|
||||
#endif
|
||||
|
||||
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 NUMBLENDTEXTURES >= 2
|
||||
v_TexCoord23.xy = vec2(v_TexCoord.x * g_Texture2Resolution.z / g_Texture2Resolution.x,
|
||||
v_TexCoord.y * g_Texture2Resolution.w / g_Texture2Resolution.y);
|
||||
v_TexCoord23.zw = CAST2(0.0);
|
||||
#endif
|
||||
#if NUMBLENDTEXTURES >= 3
|
||||
v_TexCoord23.zw = vec2(v_TexCoord.x * g_Texture3Resolution.z / g_Texture3Resolution.x,
|
||||
v_TexCoord.y * g_Texture3Resolution.w / g_Texture3Resolution.y);
|
||||
#endif
|
||||
#if NUMBLENDTEXTURES >= 4
|
||||
v_TexCoord45.xy = vec2(v_TexCoord.x * g_Texture4Resolution.z / g_Texture4Resolution.x,
|
||||
v_TexCoord.y * g_Texture4Resolution.w / g_Texture4Resolution.y);
|
||||
v_TexCoord45.zw = CAST2(0.0);
|
||||
#endif
|
||||
#if NUMBLENDTEXTURES >= 5
|
||||
v_TexCoord45.zw = vec2(v_TexCoord.x * g_Texture5Resolution.z / g_Texture5Resolution.x,
|
||||
v_TexCoord.y * g_Texture5Resolution.w / g_Texture5Resolution.y);
|
||||
#endif
|
||||
#if NUMBLENDTEXTURES >= 6
|
||||
v_TexCoord6.xy = vec2(v_TexCoord.x * g_Texture6Resolution.z / g_Texture6Resolution.x,
|
||||
v_TexCoord.y * g_Texture6Resolution.w / g_Texture6Resolution.y);
|
||||
#endif
|
||||
|
||||
#if TRANSFORMUV == 1
|
||||
vec2 scaleA = g_Texture0Resolution.zw / g_Texture1Resolution.zw;
|
||||
//vec2 scaleB = g_Texture0Resolution.wz / g_Texture1Resolution.wz;
|
||||
//vec2 dir = abs(rotateVec2(vec2(1, 0), g_BlendAngle));
|
||||
|
||||
v_TexCoord.zw -= (g_BlendOffset - (g_Texture0Resolution.zw - g_Texture1Resolution.zw) * 0.5) / g_Texture0Resolution.zw;
|
||||
|
||||
v_TexCoord.zw -= CAST2(0.5);
|
||||
v_TexCoord.zw = rotateVec2(v_TexCoord.zw, g_BlendAngle);
|
||||
// Too tired now to get this right, maybe look later at this again
|
||||
//v_TexCoord.zw *= scaleA * dot(dir, vec2(1, 0)) + scaleB * dot(dir, vec2(0, 1));
|
||||
//v_TexCoord.zw *= mix(scaleA, scaleB, abs(sin(g_BlendAngle))) / g_BlendScale;
|
||||
v_TexCoord.zw *= scaleA / g_BlendScale;
|
||||
//v_TexCoord.zw *= scaleA * abs(cos(g_BlendAngle)) + scaleB * abs(sin(g_BlendAngle));
|
||||
|
||||
v_TexCoord.zw += CAST2(0.5);
|
||||
#endif
|
||||
|
||||
#if OPACITYMASK == 1
|
||||
v_TexCoordOpacity = vec2(v_TexCoord.x * g_Texture7Resolution.z / g_Texture7Resolution.x,
|
||||
v_TexCoord.y * g_Texture7Resolution.w / g_Texture7Resolution.y);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user