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 forum.
※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 Sequoia] (Updated October 22, 2024)
Live2D Cubism Editor 5.1.02 now supports macOS Sequoia.
Other Live2D Cubism products currently released are not guaranteed to work on macOS Sequoia.
Please refrain from upgrading macOS, as it may not operate properly.

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.