mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-04 21:31:11 -05:00
47 lines
855 B
Text
47 lines
855 B
Text
|
struct v2f {
|
||
|
vec4 pos;
|
||
|
vec2 uv;
|
||
|
};
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform vec4 _MainTex_TexelSize;
|
||
|
|
||
|
vec2 maxMag (in vec2 a, in vec2 b)
|
||
|
{
|
||
|
float ma;
|
||
|
float mb;
|
||
|
ma = dot(a, a);
|
||
|
mb = dot(b, b);
|
||
|
return mix (a, b, vec2(step(ma, mb)));
|
||
|
}
|
||
|
vec4 TileMax (in v2f i)
|
||
|
{
|
||
|
vec2 uvCorner;
|
||
|
vec2 mx;
|
||
|
vec2 v;
|
||
|
uvCorner = i.uv;
|
||
|
mx = vec2(texture2D( _MainTex, uvCorner));
|
||
|
int j = 0;
|
||
|
for ( ; (j < 8); (j++))
|
||
|
{
|
||
|
int l = 0;
|
||
|
for ( ; (l < 8); (l++))
|
||
|
{
|
||
|
v = texture2D (_MainTex, (uvCorner + (vec2(float(l),float(j)) * _MainTex_TexelSize.xy))).xy;
|
||
|
mx = maxMag(mx, v);
|
||
|
}
|
||
|
}
|
||
|
return vec4(mx, 0.0, 0.0);
|
||
|
}
|
||
|
|
||
|
varying vec2 xlv_TEXCOORD0;
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
vec4 c;
|
||
|
v2f ii;
|
||
|
ii.pos = vec4(0.0);
|
||
|
ii.uv = xlv_TEXCOORD0;
|
||
|
c = TileMax(ii);
|
||
|
gl_FragData[0] = c;
|
||
|
}
|