axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

Live2d demo crash #1403

Closed RGAA-Software closed 1 year ago

RGAA-Software commented 1 year ago
  1. I known the reason of the crash is mismatched GLSL version. 20231024235324

  2. After modified the glsl at here(the screenshot is origin code, I've modified ,such as: attribute -> in; gl_FragColor -> out fragColor...): 20231024235845

I still get the crash at here:

20231024235400

Any idea ? Thank you very much!

rh101 commented 1 year ago

The screenshots you provided show that the shader code is embedded into your CPP code, and if that is the case, then that is most likely the problem. EDIT: Sorry, I misread, and just realised that it's the Live2D test that you're referring to. The issue is the same though, and it needs to be updated in order for it to work. You can do that yourself and submit a PR if you wish.

Axmol 2.0 requires that the shader source code is in separate files, as they are processed during build time to generate the correct shaders for different platforms.

Refer to #1279 for all the information you require in order to get it working. The information on that page should perhaps be placed somewhere that is more accessible, so that is something that should be addressed.

Note, the only issue I can see is this part of the shader:

#if defined(AX_USE_METAL)
        "    gl_Position = vec4(position.x, -position.y, position.z, 1.0);"
#else
        "    gl_Position = vec4(position, 1.0);"
#endif

I'm not sure if it is possible to add conditionals like that. @halx99 Is that possible with the axslc implementation? If not, is there a way to have 2 different source files and be selective about which one the axslc processes for a given platform? Nevermind, I just noticed that it can be done:

#if defined(METAL)
#endif 
rh101 commented 1 year ago

No need to do anything. A PR will be up soon with the updates to get Live2D working with Axmol 2.x.

It's working with Axmol 2.x now: image

RGAA-Software commented 1 year ago

Thank you very much!