It looks like you're new here. If you want to get involved, click one of these buttons!
local shaderV=[[ attribute highp vec3 vVertex; attribute mediump vec2 vTexCoord; uniform highp mat4 vMatrix; varying mediump vec2 fTexCoord; void main() { vec4 vertex = vec4(vVertex,1.0); gl_Position = vMatrix*vertex; fTexCoord=vTexCoord; } ]] local scanlinesF=[[ uniform lowp sampler2D fTexture; varying mediump vec2 fTexCoord; uniform mediump vec4 fTextureSize; uniform mediump float fTime; lowp vec3 hsv2rgb(vec3 c) { lowp vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); lowp vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } void main() { mediump vec4 pixel=texture2D(fTexture, fTexCoord); mediump vec4 frag=pixel; mediump vec2 centerDir=normalize((fTextureSize.xy/2.0-fTexCoord)/fTextureSize.xy)*fTextureSize.zw; for (int k=-5;k<=5;k++) frag=frag+texture2D(fTexture, fTexCoord-centerDir*float(k)); frag=frag/12.0; if (frag.a<=0.0) discard; if (pixel.a>=1.0) gl_FragColor = pixel; else gl_FragColor = vec4(hsv2rgb(vec3(frag.a/2.0+fTime*2.0,0.7,1.0)),frag.a); } ]] local result,reply=pcall(Shader.new,shaderV,scanlinesF,Shader.FLAG_FROM_CODE,{ {name="vMatrix",type=Shader.CMATRIX,sys=Shader.SYS_WVP,vertex=true}, {name="fColor",type=Shader.CFLOAT4,sys=Shader.SYS_COLOR,vertex=false}, {name="fTexture",type=Shader.CTEXTURE,vertex=false}, {name="fTextureSize",type=Shader.CFLOAT4,sys=Shader.SYS_TEXTUREINFO,vertex=false}, {name="fTime",type=Shader.CFLOAT,sys=Shader.SYS_TIMER,vertex=false}, }, {{name="vVertex",type=Shader.DFLOAT,mult=3,slot=0,offset=0}, {name="vColor",type=Shader.DUBYTE,mult=4,slot=1,offset=0}, {name="vTexCoord",type=Shader.DFLOAT,mult=2,slot=2,offset=0}, }) PulsingEffect=reply if not result then print("Shader Compilation error:"..reply) end |
Comments
a screenshot would be nice.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: keszegh
Likes: Atavismus, antix