mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
78 lines
1.8 KiB
Text
78 lines
1.8 KiB
Text
#version 300 es
|
|
|
|
// from case 685794 at Unity; a particular form of a loop
|
|
// started to generate invalid shaders around Unity 4.6.3.
|
|
|
|
out mediump vec4 _fragData;
|
|
|
|
|
|
struct v2f_surf {
|
|
mediump vec2 uv;
|
|
highp vec4 pos;
|
|
};
|
|
uniform sampler2D _MainTex;
|
|
uniform mediump float _NumPasses;
|
|
uniform mediump vec4 _ContrastShift;
|
|
uniform mediump vec4 _SaturationShift;
|
|
uniform lowp vec4 _HueShift;
|
|
uniform lowp vec4 _LuminosityShift;
|
|
|
|
lowp vec3 TestCycle2( in lowp vec3 res, in mediump float val )
|
|
{
|
|
return ((res - 0.5) * pow( (cos(val) + 1.0), val));
|
|
}
|
|
|
|
lowp vec3 TestCycle( in lowp vec3 rgb, in mediump float passes )
|
|
{
|
|
lowp vec3 res = rgb;
|
|
// a weird form of loop that was causing a bug
|
|
highp float i = 0.0;
|
|
for ( ; (i < 4.0); i += 1.0) {
|
|
|
|
if ((i == passes)){
|
|
break;
|
|
}
|
|
if ((i == 0.0)){
|
|
res = TestCycle2( res, ((_ContrastShift.x * 3.0) + 12.0));
|
|
}
|
|
else{
|
|
if ((i == 1.0)){
|
|
res = TestCycle2( res, ((_SaturationShift.y * 3.0) + 12.0));
|
|
}
|
|
else{
|
|
if ((i == 2.0)){
|
|
res = TestCycle2( res, ((_HueShift.z * 3.0) + 12.0));
|
|
}
|
|
else{
|
|
res = TestCycle2( res, ((_LuminosityShift.x * 3.0) + 12.0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
lowp vec3 surf( in mediump vec2 uv )
|
|
{
|
|
lowp vec4 t = texture(_MainTex, uv);
|
|
if (_NumPasses > 0.0)
|
|
t.xyz = TestCycle(t.xyz, _NumPasses);
|
|
return t.xyz;
|
|
}
|
|
|
|
lowp vec4 frag_surf( in v2f_surf IN )
|
|
{
|
|
lowp vec3 col = surf( IN.uv);
|
|
return vec4( col, 1.0);
|
|
}
|
|
in mediump vec2 xlv_TEXCOORD0;
|
|
void main() {
|
|
lowp vec4 xl_retval;
|
|
v2f_surf xlt_IN;
|
|
xlt_IN.uv = vec2(xlv_TEXCOORD0);
|
|
xlt_IN.pos = vec4(0.0);
|
|
xl_retval = frag_surf(xlt_IN);
|
|
_fragData = vec4(xl_retval);
|
|
}
|
|
|