Here is a super fast way to use shaders ... Just make a Quad with a vertex buffer and set UV from -1 to 1 for each corner of the square.
The vertex buffer in the floats should look like this: NOTE. You also need an index buffer for this.
var verts = new float[20] { -1, -1, 0, -1, -1, -1, 1, 0, -1, 1, 1, 1, 0, 1, 1, 1, -1, 0, 1, -1, }; #VS attribute vec3 Position0; attribute vec2 Texcoord0; varying vec4 Position_VSPS; varying vec2 Texcoord_VSPS; uniform vec2 Location; void main() { vec3 loc = vec3(Position0.xy + Location, Position0.z); gl_Position = Position_VSPS = vec4(loc, 1); Texcoord_VSPS = loc.xy; } #END #PS varying vec4 Position_VSPS; varying vec2 Texcoord_VSPS; uniform vec2 Location; void main() { float dis = distance(Location, Texcoord_VSPS); if (.1 - dis < 0.0) discard; gl_FragData[0] = vec4(0, 0, 1, 1); } #END
source share