美文网首页
矩阵-sprite

矩阵-sprite

作者: 许彦峰 | 来源:发表于2022-05-11 09:25 被阅读0次

sprite-normal

  • cocos2d-x\cocos\renderer\ccShader_PositionTextureColor_noMVP.vert
attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec4 a_color;

#ifdef GL_ES
varying lowp vec4 v_fragmentColor;
varying mediump vec2 v_texCoord;
#else
varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
#endif

void main()
{
    gl_Position = CC_PMatrix * a_position;
    v_fragmentColor = a_color;
    v_texCoord = a_texCoord;
}
#ifdef GL_ES
precision lowp float;
#endif

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;

void main()
{
    gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord);
}

sprite size: 512*512


sprite的顶点数据

当位置在sprite.position=(0,0)点时,

void Renderer::fillVerticesAndIndices(const TrianglesCommand* cmd)
{
    const Mat4& modelView = cmd->getModelView();
}

modelView[12]=-256,即x坐标偏移
modelView[13]=-256,即y坐标偏移

相关文章

网友评论

      本文标题:矩阵-sprite

      本文链接:https://www.haomeiwen.com/subject/nfvoyrtx.html