nbarkhina / N64Wasm

A web based N64 Emulator
https://www.neilb.net/n64wasm/
MIT License
619 stars 122 forks source link

WebGL 2.0 does not have more advanced shaders. #55

Closed BeezBumba closed 1 month ago

BeezBumba commented 3 months ago

I've been playing this rom hack of the Super Mario 64 game and in a certain level some textures just appear as white, but other emulators the texture is colored. This is not something only on this rom hack, it's also on another one. The first two are the same game(Return to Yoshi's Island DEMO 64) and the last 2 are a different game(That Time I Became Friends With The Royal Scuttlebug Family And Fell From Space, Yeah the long name is intentional). I think this has something to do with vertex colors because you can still see the grass texture, it's just white. The ones that do have color I used the ParaLLel RetroArch core. Screenshot 2024-06-13 174826 Screenshot 2024-06-13 175229 Screenshot 2024-06-13 175713 Screenshot 2024-06-13 180110

nbarkhina commented 3 months ago

Not too sure about this one... you can try taking a look at the file Glide64_Ini.c

https://github.com/nbarkhina/N64Wasm/blob/master/code/src/glide2gl/src/Glide64/Glide64_Ini.c

it has a bunch of game specific hacks. Perhaps it's not detecting the rom hack as super Mario 64, or you can play around with the different settings in that file.

BeezBumba commented 3 months ago

What was the need for all of these game specific settings?

BeezBumba commented 3 months ago

Although it might not be that because in software rendering mode (angrylion) I can see the color.

nbarkhina commented 3 months ago

I don't think software rendering uses those game specific settings, thats only when it does hardware acceleration. it's basically different settings that work better for certain games.

BeezBumba commented 2 months ago

I have a idea, the games was using a multitexture for the grass. maybe for some reason the color texture did not load in and only the detail texture loaded. I know using 2 textures require 2 cycle mode, so does your emulator use 1 cycle or 2 cycle mode?

nbarkhina commented 2 months ago

I'm really not sure but if parallel on retroarch works this is basically the same emulator. It's possible something is different on web since that uses OpenGL ES vs OpenGL proper on Desktop.

BeezBumba commented 2 months ago

I mean does the angrylion mode still use OpenGL?

nbarkhina commented 2 months ago

Angrylion does not use OpenGL. It's fully software based renderer which is why it's accurate at the cost of speed.

BeezBumba commented 2 months ago

What version of OpenGL ES is it using?

BeezBumba commented 2 months ago

nevermind why cant you just use opengl instead of opengl ES on browser?

nbarkhina commented 2 months ago

Browsers only support OpenGL ES

BeezBumba commented 2 months ago

It might just be a problem with OpenGL ES, because I also emailed a person named Kaze Emanuar that said every triangle has a shader on it that finds the right pixel colors. Those shaders just don't work for some reason on the emulator or I guess OpenGL ES. What version is the OpenGL ES you are using, now might be the time to just get every detail, in case if there could be a solution.

nbarkhina commented 2 months ago

It uses OpenGL ES 3.00

BeezBumba commented 2 months ago

Is it possible to use openGL ES 3.2?

BeezBumba commented 2 months ago

3.2 introduces geometry shaders. In my previous response, I know that a every triangle has a shader that find the right pixel colors. , and triangles are geometry. So, this could fix the issue.

nbarkhina commented 2 months ago

in mymain.cpp search for the line

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);

you can try playing around with that by adding another line

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

and see if the browser will use that or not

BeezBumba commented 2 months ago

Gave me these errors when trying 3.1 and 3.2

n64wasm.js:1 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getParameter')
    at _glGetString (n64wasm.js:1:214421)
    at n64wasm.wasm:0xf17a0
    at Module._main (n64wasm.js:1:245516)
    at Object.callMain (n64wasm.js:1:250491)
    at MyClass.LoadEmulator (script.js:225:20)
BeezBumba commented 2 months ago

Appears that ANGLE has not made support for openGL ES 3.2 yet and we just have to wait.

BeezBumba commented 1 month ago

Is it possible to use WebGPU?

BeezBumba commented 1 month ago

https://developer.chrome.com/blog/from-webgl-to-webgpu/