@natweiss wrote:
I have a fragment shader that basically converts texture coordinates (UV) to sprite frame coordinates (a subset of the total UV), then blurs the current pixel based on that spriteframe-relative Y pos. Pixels at y == 0 (again, in sprite frame coordinates) are not blurred at all. Pixels at y == 1 are blurred to the max.
The way I'm currently accomplishing this is to pass in two uniforms:
- vec2 containing the sprite frame's origin
- vec2 containing the sprite frame's size
Now this performs badly with lots of sprites because custom uniforms cannot currently be batched by cocos2d-x. An ideal solution would be to use a vertex shader and no custom uniforms.
I've tried messing with
a_position
and even multiplying it by the MV matrix and the P matrix, but no luck. It would help if somebody could explain what exactly isa_position
within the cocos2d-x paradigm.I see that cocos2d-x already has
a_texCoord
,a_texCoord1
,a_texCoord2
,a_texCoord3
. It appears that 1-3 are not being used.Would it be possible to go about passing in the current sprite frame's origin as
a_texCoord1
and size asa_texCoord2
? If so, where in cocos2d-x' rendering code would I start doing that?I'm looking at
Texture2D::drawAtPoint
andTexture2D::drawInRect
maybe but not sure if these are the right places or if this crazy strategy is even on the right track.
Posts: 6
Participants: 2