Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated example - deferred rendering #4706

Closed
wants to merge 15 commits into from
Closed

Conversation

MikiZX1
Copy link
Contributor

@MikiZX1 MikiZX1 commented Jan 18, 2025

Example - deferred rendering updated to work for both Desktop and Web (using GLES3).

This one example will require custom compile command:
emcc -o shaders/shaders_deferred_render.html shaders/shaders_deferred_render.c -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O3 -I. -I../src -I../src/external -L. -L../src -L../src -sTOTAL_MEMORY=134217728 -sFORCE_FILESYSTEM=1 -sEXPORTED_RUNTIME_METHODS=ccall -sMINIFY_HTML=0 -sUSE_GLFW=3 -sFULL_ES3=1 -sASYNCIFY --shell-file ../src/shell.html ../src/libraylib.web.a -DPLATFORM_WEB --preload-file ./shaders/resources/shaders/glsl100/gbuffer.vs@resources/shaders/glsl100/gbuffer.vs --preload-file ./shaders/resources/shaders/glsl100/gbuffer.fs@resources/shaders/glsl100/gbuffer.fs --preload-file ./shaders/resources/shaders/glsl100/deferred_shading.vs@resources/shaders/glsl100/deferred_shading.vs --preload-file ./shaders/resources/shaders/glsl100/deferred_shading.fs@resources/shaders/glsl100/deferred_shading.fs

For this example to work on the Web, raylib for web will need to be built with these commands:
emcc -c rcore.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES3
emcc -c rshapes.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES3
emcc -c rtextures.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES3
emcc -c rtext.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES3
emcc -c rmodels.c -Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES3
emcc -c utils.c -Os -Wall -DPLATFORM_WEB
emcc -c raudio.c -Os -Wall -DPLATFORM_WEB
emar rcs libraylib.web.a rcore.o rshapes.o rtextures.o rtext.o rmodels.o utils.o raudio.o

When creating a new sphere mesh with high number of slices/rings the top and bottom parts of the generated sphere are removed. This happens because the triangles in those parts, due to high resolution, end up being very small and are removed as part of the 'par_shapes' library's optimization. Adding par_shapes_set_epsilon_degenerate_sphere(0.0); before generating the sphere mesh sets the threshold for removal of small triangles is removed and the sphere is returned to raylib correctly.
@raysan5
Copy link
Owner

raysan5 commented Jan 18, 2025

@MikiZX1 I'm afraid I'm not merging this change. The shaders are placed in glsl100 directory, that leads to confusion and it defines custom implementations that are not really required if working on OpenGL ES 3.x, raylib should already support them for that backend, no custom functions should be required.

@raysan5 raysan5 closed this Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants