I have been working on an updated renderer for tremulous/ioquake3 for some time.
My primary focus hasn't been on graphical enhancements, but on compatibility and speed.
The renderer uses only OpenGL 1.1 plus extensions, if any extension is missing it falls back to a (possibly slower) render path. /r_showtris 1 shows how the triangles are rendered, blue: GLSL + VBO, green: only GLSL, yellow: only VBO, red: old GLSL.
At the heart of the patch is a Quake shader to GLSL translator which generates a GLSL program that can render any multi-stage Quake shader in a single pass. The shader syntax has deliberately not been changed.
MD3 models can be fully animated on the GPU (requires vertex-texture-fetch and floating point textures).
The static vertex data is uploaded in buffer objects and the backend tries to avoid buffer switching as far as possible. Generally the renderer tries to use a minimum of GL state changes and draw calls, often the GL calls needed for a batch are just glBindTexture and glDrawElements - no pointer setting, buffer switching or vertex data upload.
My patch definitely has less graphical features than #4358, but I think I have spent more time optimizing the backend.
Does this work with the pluggable renderer system or is it a complete replacement of the existing renderer?
Also, there is talk about an approach for the pluggable rendering wherein some common stuff is factored out. I think the discussion is in https://bugzilla.icculus.org/show_bug.cgi?id=4358 and I was wondering if you're going to go with the same approach that's being discussed there as well?
Created attachment 2915[details]
vbo2.diff
Changes:
* Added shader name to compile shader error messages.
* Changed animmap shaders (e.g. explosion shaders) to not use new GLSL (as they were not working correctly).
* Fixed compile (GLSL) shader errors I received in console (this fixed various rendering issues I had) (code added in CollapseGLSL below "*** assemble shader fragments ***").
Issues:
r_showtris draws black lines on MD3s after fixing GLSL compile errors (instead of red), sometimes the lines go between different models and/or don't cover the entire model.
TCMOD_SCROLL doesn't seem to work with MD3s using GLSL (see baseq3 title banner) and player models always use frame 0 on my computer (Ubuntu Linux using integrated NVidia 8300).
I don't have these issues on my NVidia 6600, could you disable /r_ext_geometry_shader and/or /r_ext_instanced_arrays and check if this fixes the issues ?
On my PC I get playermodels at frame 0 as well, using vbo2.diff and a Nvidia 8600M GT on x86_64 Linux.
Disabling r_ext_geometry_shader fixes this for me.
On a sidenote I get horrible framerates with the vbo2.diff patch applied. Where I'd get stable 125fps on spacemaps with much visible geometry without patch, I'd only get 10-20fps with it.
This might be by graphics card's fault, but let me know whether you'd like more information to debug the bottleneck.
Created attachment 2922[details]
vbo3.diff
Some attributes were not passed through the geometry shader, this should be fixed now.
If you have performance issues, please tell me how to reproduce this (map, location) and I'll have a look. Otherwise you could try to run with +set r_ext_debug_output 7 and check if there are any messages in the console, but currently the GL drivers don't report much useful information.
Created attachment 2923[details]
Compile shader error log
vbo3.diff (and vbo.diff) have many shader compile errors on my system. Attached log shows ioq3 (patched with vbo3.diff) starting up to q3ui and loading map q3dm17. There are various visible shader issues, such as environment map not working correctly and some model disappearing (depending on view point). Mirrors/portals in q3dm0 don't work either.
Created attachment 2924[details]
Fix GLSL shader issues using vbo3.diff (apply after vbo3.diff)
Patch fixes compile shader errors when disabling r_ext_geometry_shader.
Includes the following from my first patch;
* Changed animmap shaders (e.g. explosion shaders) to not use new GLSL (as they
were not working correctly).
* Fixed compile (GLSL) shader errors I received in console (this fixed various
rendering issues I had).
I only have player model always use frame 0 issue using my patch(es) (as that is the only time MD3s use VBOs on my computer). Disabling r_ext_geometry_shader and/or r_ext_instanced_arrays does not fix VBOs.
Created attachment 2925[details]
gpushader4.diff
The shader error seems to be a missing #extension GL_EXT_gpu_shader4 : enable, try if this fixes it (apply on top of vbo3.diff).
I still wonder why you have to enable tangents - they are only needed for the normal or parallax mapping functions.
About the mirrors/portals issue: I use the stencil buffer to clip portals/mirrors to the area of the mirror surface. This should impove fill rate a bit and allows multiple portals in the same view. I guess you have /r_stencilbits set to 0. I'll have to add a fallback for this case.
gpushader4.diff fixes all of the compile shader errors, thanks. Mirrors/portals seem to work as well.
Issues using vbo3.diff+gpushader4.diff
* Animmap doesn't work correctly using new GLSL (frames don't blend right).
* Player model VBOs stuck at frame 0.
* Railgun trail and lightning trail are not visible.
Hi Gimhael,
Are you still working on this renderer? I'm trying to add all of the renderers that are available and potentially work with ioquake3 r2224 into an unofficial OpenArena git repo.
Hi Undead,
yes, the randerer is still evolving slowly, but as I develop on Tremulous, I have to port the changes to ioq3 manually. My latest patch is vbo4.diff, the main improvement is that dynamic geometry is rendered with a streaming VBO and the old q3 dynamic lights are replaced with GLSL rendered dlights on DX10 capable hardware.
(In reply to comment #16)
> yes, the randerer is still evolving slowly, but as I develop on Tremulous, I
> have to port the changes to ioq3 manually. My latest patch is vbo4.diff, the
> main improvement is that dynamic geometry is rendered with a streaming VBO and
> the old q3 dynamic lights are replaced with GLSL rendered dlights on DX10
> capable hardware.
Ok! I added a branch for it in openarena_engine. I made your patch into a modular renderer with two exceptions: I didn't modify tr_public.h or tr_types.h. How do you want to handle that? I noticed the tr_public.h change was only enabled if RETURN_GLTIME. Since those two files are shared (always?) between modular renderers, is there another way to handle that?
For the tr_types.h change, I put the #define in tr_local.h instead. It looks like that change should be in tr_types.h but that file is included by tr_public.h. I'm trying to keep it so I can switch between opengl1 (ioquake3), openarena1 (0A 0.8.8), opengl2 (Canete's r29) and vbo1 (your vbo4.diff) on the fly with +set cl_renderer.
I see you made a lot of changes to sdl_glimp. It appears to be incompatible changes with the other renderers so I put your sdl_glimp.c in code/renderer_vbo and changed the Makefile so it would pull in your version. With the others, I added tr_extension.c but your changes look to be more invasive so creating a separate file seems justified.
Your renderer doesn't work with RAVENMD4 which OpenArena 0.8.8 enables. For this to build, I had to disable RAVENMD4.
https://github.com/undeadzy/openarena_engine/tree/vbo_renderer
Created attachment 2914 [details] vbo.diff
Created attachment 2915 [details] vbo2.diff Changes: * Added shader name to compile shader error messages. * Changed animmap shaders (e.g. explosion shaders) to not use new GLSL (as they were not working correctly). * Fixed compile (GLSL) shader errors I received in console (this fixed various rendering issues I had) (code added in CollapseGLSL below "*** assemble shader fragments ***"). Issues: r_showtris draws black lines on MD3s after fixing GLSL compile errors (instead of red), sometimes the lines go between different models and/or don't cover the entire model. TCMOD_SCROLL doesn't seem to work with MD3s using GLSL (see baseq3 title banner) and player models always use frame 0 on my computer (Ubuntu Linux using integrated NVidia 8300).
Created attachment 2922 [details] vbo3.diff Some attributes were not passed through the geometry shader, this should be fixed now. If you have performance issues, please tell me how to reproduce this (map, location) and I'll have a look. Otherwise you could try to run with +set r_ext_debug_output 7 and check if there are any messages in the console, but currently the GL drivers don't report much useful information.
Created attachment 2923 [details] Compile shader error log vbo3.diff (and vbo.diff) have many shader compile errors on my system. Attached log shows ioq3 (patched with vbo3.diff) starting up to q3ui and loading map q3dm17. There are various visible shader issues, such as environment map not working correctly and some model disappearing (depending on view point). Mirrors/portals in q3dm0 don't work either.
Created attachment 2924 [details] Fix GLSL shader issues using vbo3.diff (apply after vbo3.diff) Patch fixes compile shader errors when disabling r_ext_geometry_shader. Includes the following from my first patch; * Changed animmap shaders (e.g. explosion shaders) to not use new GLSL (as they were not working correctly). * Fixed compile (GLSL) shader errors I received in console (this fixed various rendering issues I had). I only have player model always use frame 0 issue using my patch(es) (as that is the only time MD3s use VBOs on my computer). Disabling r_ext_geometry_shader and/or r_ext_instanced_arrays does not fix VBOs.
Created attachment 2925 [details] gpushader4.diff The shader error seems to be a missing #extension GL_EXT_gpu_shader4 : enable, try if this fixes it (apply on top of vbo3.diff). I still wonder why you have to enable tangents - they are only needed for the normal or parallax mapping functions.
Created attachment 3127 [details] vbo4.diff