opengl es 2.0 - cocos2d, Splitting an image into serpate R B G channels? -
i want create effect after character gets killed, red, blue, green color channels of characters sprite separate different directions.
something similar > http://active.tutsplus.com/tutorials/effects/create-a-retro-crt-distortion-effect-using-rgb-shifting/
how go doing this?
you add different offsets when looking individual colors in fragment shader. make efficient should render intermediate buffer first.
here example of how it:
vec4 mainold( vec2 offset ) { ... (gl_fragcoord.xy + offset) ... } void main( void ) { vec4 foo; foo.r = mainold(vec2(-3.0, 0.0)).r; foo.g = mainold(vec2(0.0, 5.0)).g; foo.b = mainold(vec2(0.0, 0.0)).b; foo.a = mainold(vec2(0.0, 0.0)).a; gl_fragcolor = foo; }
basically original shader called 3 times that's bit inefficient, why suggested buffer may premature optimization.
you can @ result of above code in actual shader here: http://glsl.heroku.com/e#7971.0 (not sure how persistent these links are, sorry)
Comments
Post a Comment