Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Please limit one question/topic per post.
Please provide the following details depending on types of question

▼ For question regarding Editor, please provide:
- Live2D Software Version: (e.g. Cubism Editor 3.1.02, Euclid Editor 1.2.02)
- OS & Version: (e.g. Windows 10, macOS HighSierra)
- PC Model: (e.g. MacBookPro 2017)
- Graphics Specifications: (e.g. GeForce GTX 950M)
- Memory: (e.g. 8GB)
- Illustration Software used: (e.g. Photoshop, ClipStudio, SAI)
- Attach screenshot or capture video to show your problem:
▼ For question regarding SDK, please provide:
- For us to reproduce the issue you wish to inquire about, please provide either a minimum project file which has the issue. or specific instructions on how to reproduce the issue.
- Types and version of Cubism SDK you are using.
▼ For question regarding Cubism Software License,
For issues related to purchasing, your order, license key, and subscription, please contact us via contact form:

live2D does not work well with Sprite3D

edited February 2016 in Help
I got a problem that live2d object does not work well with Sprite3D in cocos2d-x, could anyone give me some tips?

Here is the situation:
1. There is a scene with Live2D object created by lua script;
2. close this scene, enter second scene with a Sprite3D object, the Sprite3D object just gone;
3. if delete the live2d object in first scene, or just comment draw function as below
void LAppModel::draw()
if (live2DModel == NULL)return;

live2DModel->draw(); //comment this
then re-enter second scene, the Sprite3D object appears normally;

according to information generated by Sprite3D object rendering, looks like some resources or render state belong to Sprite3D was corupted, but system throws no error.

live2D version:Live2D_SDK_OpenGL_2.0.06_1_en


  • Forget to mention: i defined a new render shader for Sprite3D, code as below:

    const char* cc3D_PositionNormalTexOutline_vert = STRINGIFY(
    attribute vec4 a_position;
    attribute vec2 a_texCoord;
    attribute vec3 a_normal;
    varying vec2 TextureCoordOut;
    varying vec3 v_normal;

    void main(void)
    vec4 ePosition = CC_MVMatrix * a_position;
    v_normal = CC_NormalMatrix * a_normal;

    TextureCoordOut = a_texCoord;
    TextureCoordOut.y = 1.0 - TextureCoordOut.y;
    gl_Position = CC_PMatrix * ePosition;
    const char* cc3D_ColorNormalTexOutline_frag = STRINGIFY(

    \n#ifdef GL_ES\n
    varying mediump vec2 TextureCoordOut;
    varying mediump vec3 v_normal;

    varying vec2 TextureCoordOut;
    varying vec3 v_normal;

    uniform vec4 u_color;

    uniform float u_falloffValue;
    uniform float u_powValue;
    uniform vec4 u_innerColor;

    void main(void)
    vec3 normal = normalize(v_normal); // vertex normal does not calculate right here

    float value = dot(normal,vec3(0.0,0.0,1.0));

    vec4 texcolor = texture2D(CC_Texture0, TextureCoordOut);

    vec4 finalcolor = texcolor*u_color;

    value = clamp(value * u_falloffValue,0.0,1.0);

    value = pow(value, u_powValue);

    float inverseValue = clamp(1.0-value,0.0,1.0);
    finalcolor = finalcolor*value + u_innerColor*inverseValue;
    finalcolor.a = value;

    gl_FragColor = finalcolor;
  • Hi Vantaci ,
    Could you please test this code?

    void LAppModel::draw()
    if (live2DModel == NULL)return;

    live2DModel->draw(); //comment this
    glFrontFace(GL_CCW);//change Front Face

    In live2DModel::draw function, we call glFrontFace(GL_CW).
    Unfortunately we forgot to restore this state in live2d::DrawProfileCocos2D::postDraw() .

    This bug will be fixed next live2d SDK version.
  • Hi Imai , thank you for the response.

    glFrontFace(GL_CCW) does work, both live2d and Sprite3D show up correctly.

    That's a great help.
    Meanwhile, there's another problem:
    We got a crash days before when using Spine and live2D object at the same time, the Spine crash during rendering,
    then we add code like this:
    void L2DSprite::onDraw(const cocos2d::Mat4 &transform, uint32_t flags)
    Director * director = Director::getInstance();

    director->loadMatrix(type, transform);

    LAppLive2DManager* Live2DMgr=LAppLive2DManager::getInstance();

    //buff error
    glBindBuffer(GL_ARRAY_BUFFER, 0); //We have to set bound buffer to 0 here
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);//We have to set bound buffer to 0 here

    Finally, after buffer was rebound to 0, the crash gone.
    I think something is wrong with buffer binding.

  • I guess you should upgrade your cocos2d-x to 3.4 and try again.
    Cocos2d-x 3.4 has fixed a bug about VAO, that VAO should be bound to 0 before VBO does. Just add GL::bindVAO(0); before glBindBuffer(GL_ARRAY_BUFFER, 0); within all cocos2d-x source code.
    If you enabled VAO configuration, you should apply this patch of cocos2d-x and do the samething on your code.
Sign In or Register to comment.