Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

If you have any questions, reports, suggestions, or requests about Live2D, please send them to this community.
※We cannot guarantee statements or answers from Live2D staff. Thank you for your understanding in advance.
 
Live2D Cubism
Cubism Products and Downloads
Cubism product manuals and tutorials
Cubism Editor Manual    Cubism Editor Tutorial    Cubism SDK Manual    Cubism SDK Tutorial
[About macOS Ventura 13.0] (12/20/2022)
The currently released Live2D Cubism SDK is not guaranteed to work with macOS Ventura.
Please refrain from upgrading the macOS as they may not work properly.
The Cubism Editor license file may be lost after the macOS upgrade.
Please make sure to deactivate the Cubism Editor license before upgrading the macOS.
For more details
[NOTICE]
About the support for Mac models
Cubism Editor is not supported with Apple M1 processors.
Please refer to System Requirements for details.
We will not respond to any related inquiries with this message.

Changing model fragment shader(android opengl es)

I am trying to change a model color, adding effects to it using fragment shader
how do I get/change the model fragment shader in order to get needed wanted effect of my implementation
Tagged:

Comments

  • Hello, @catCoder
    Thank you for your contact.
    This is Live2D Support.

    Please check CubismRenderer_OpenGLES2.cpp in CubismSdkForNative Framework.
    It defines a fragment shader around which the FragShaderSrc variable is defined.
    Please follow that description and add a shader with color and effect processing.

    After adding the shaders, load them with the CubismShader_OpenGLES2::GenerateShaders function.
    Please replace the items that set the shaders for each application in the CubismShader_OpenGLES2::SetupShaderProgram function.

    hope that helps!
  • I read the code and from what I understood adding a new shader to CubismRenderer_OpenGLES2 will change all the models in the application with that shader.
    How do I add a new shader only for specific model/s in the app?
    (please excuse me I am new to the subject of Opengl es).
  • Hi, @catCoder

    As a prerequisite, the shaders are designed to be the same for all models.

    If you want to set a different shader for a specific model, you need to get the CubismModel using the CubismShader_OpenGLES2::SetupShaderProgram function.
    Please use the model information to identify your model and switch the shader to be set.

    hope that helps!
  • edited November 2021
    I was able to pass the model name and filter for the shader I want for a specific model.
    I now face a different problem I try to add phong light to the shader but I don't understand how to calculate the normals for the model vertex positions
    can you explain the line in the SetupShaderProgram() method:

    glVertexAttribPointer(shaderSet->AttributePositionLocation, 2, GL_FLOAT, GL_FALSE, sizeof(csmFloat32) * 2, vertexArray);

    from what I think the vertexArray hold vec2 positions with stride Length of 2.
    if so what is stored in the other positions of the vertexArray?
  • Hello, @catCoder

    glVertexAttribPointer() is a method provided by OpenGL, so please refer to the official OpenGL documentation.

    The arguments are as follows.
    shaderSet->AttributePositionLocation is the index of the shader
    vertexArray is the model's vertex array obtained using csmGetDrawableVertexPositions().

    hope that helps!
Sign In or Register to comment.