[vert.glsl]

#version 120

attribute vec2 in_Position;

varying vec2 pass_Position;

void main()
{
    pass_Position = in_Position;
    gl_Position = vec4(in_Position, 0.0, 1.0);
}

[frag.glsl]

#version 120

#if defined GL_ES
precision highp float;
#endif

uniform sampler2D u_texture;
uniform float in_Flag;
uniform vec3 in_Point;
uniform vec3 in_Color;

varying vec2 pass_Position;

void main(void)
{
    if (in_Flag == 0.0)
    {
        float tc = 0.0, ta = 0.0;
        {
            float s = 3.0 + 2.0 * in_Point.z;
            vec2 p = pass_Position - in_Point.xy * 0.9;
            float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0);
            float u = t * t * t * t;
            tc += 3.0 * t * t - 2.0 * t * t * t;
            ta += 3.0 * u * u - 2.0 * u * u * u;
        }

        gl_FragColor = vec4(tc * in_Color, ta + 0.1);
    }
    else
    {
        vec2 texcoords = pass_Position * 0.5 + vec2(0.5, 0.5);
        gl_FragColor = vec4(texture2D(u_texture, texcoords).xyz, 1.0);
    }
}

[vert.hlsl]

void main(float2 in_Position : POSITION,
          out float2 pass_Position : TEXCOORD0,
          out float4 out_Position : POSITION)
{
    pass_Position = in_Position;
    out_Position = float4(in_Position, 0.0, 1.0);
}

[frag.hlsl]

void main(in float2 pass_Position : TEXCOORD0,
          uniform sampler2D u_texture,
          uniform float in_Flag,
          uniform float3 in_Point,
          uniform float3 in_Color,
          out float4 out_FragColor : COLOR)
{
    if (in_Flag == 0.0)
    {
        float tc = 0.0, ta = 0.0;
        {
            float s = 3.0 + 2.0 * in_Point.z;
            float2 p = pass_Position - in_Point.xy * 0.9;
            float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0);
            float u = t * t * t * t;
            tc += 3.0 * t * t - 2.0 * t * t * t;
            ta += 3.0 * u * u - 2.0 * u * u * u;
        }

        out_FragColor = float4(tc * in_Color, ta + 0.1);
    }
    else
    {
        float2 texcoords = pass_Position * float2(0.5, -0.5) + float2(0.5, 0.5);
        /* FIXME: this should be passed as a uniform or something */
        texcoords += float2(0.5 / 800.0, 0.5 / 600.0);
        out_FragColor = float4(tex2D(u_texture, texcoords).xyz, 1.0);
    }
}

