Commit Graph

123 Commits

Author SHA1 Message Date
Zack Middleton 98b9008c0d OpenGL2: Use CPU vertex animation if too few vertex attributes
OpenGL ES has a minimum of 8 vertex attributes while desktop OpenGL has
a minimum of 16. Vertex animation uses attributes 10 to 12.
2024-06-05 21:36:48 -05:00
Zack Middleton b25a3c6e4d OpenGL2: Add run-time support for unsigned short indexes
OpenGL ES 2 is only required to support unsigned short for indexes.
2024-06-05 21:36:05 -05:00
Zack Middleton 3b984d2b51 OpenGL2: Add OpenGL ES 2.0+ support
This mainly targets OpenGL ES 2.0 but it also supports compiling GLSL as
ESSL 3.00. It's missing support for framebuffer objects which should be
possible on ES 2. (Though using renderbuffers instead of textures.)

opengl1 cvars that are not supported will display a message and disable
the cvar. This has not been reviewed for new opengl2 cvars. Enabling
cvars may cause rendering issues. Some of the broken cvars may be
possible to support using OpenGL ES 3 features.

The game displays okay with the default cvars.
2024-06-05 21:33:08 -05:00
Zack Middleton eaefa35580 OpenGL2: Fix merged lightmap hacks to have real lightmap index
This fixes the texcoord range to be 0.0 to 1.0 for external lightmaps in
shaders that also have an internal lightmap. (Instead of 2.0 to 3.0 for
example.) This only affects clampMap as repeating wrapping sampled the
correct location. I haven't found such a shader but I need to get real
lightmap index for future merged lightmap hacks.
2024-02-10 16:23:54 -05:00
Zack Middleton 93abc60a5b OpenGL2: Fix applying tcMod turb
Shader stage tcMods for matrix and turb effects need to be applied in
order for turb to be correct and all tcMod turb need to be applied
instead of only the last one.

Quake 3's textures/liquids/slime1 had tcMod turb and then tcMod scale.
OpenGL2 applied the matrix first and then turb which had the wrong result.
2024-01-18 03:16:39 -05:00
Zack Middleton a81df34905 OpenGL2: Fix border for cg_viewsize using HDR/FB-MSAA w/postProcess
If using renderFBO (r_hdr 1 or r_ext_framebuffer_multisample > 0) and
r_postProcess 1, the viewport border (cg_viewsize < 100) which is drawn
before the world scene was drawn to the renderFBO but not copied to the
default framebuffer.

Now 2D before the world scene is drawn to the default framebuffer
directly for r_postProcess 1 like 2D drawn after the world scene.
2023-11-18 22:03:22 -05:00
James Canete 69ec389335 Add r_parallaxMapOffset. 2021-07-05 21:59:20 -07:00
Zack Middleton d404519cce Fix rendering IQM models between model frames
For lerped frames (refEntity_t frame not equal oldframe) IQM joint
matrices may have incorrect axis scale. This can cause significant model
distortion. The matrix lerp is linear causing each vector to move in a
straight line between frames instead of arcing like a circle. Each joint
frame can have a different scale so can't just normalize the joint
matrix.

Store joints as quaternions and spherical lerp between them and then
convert to a matrix. For my test model, setting up the skeleton is four
times slower now but it still seems to be fast enough to be usable.
2019-04-29 15:01:47 -05:00
James Canete d068e1dce1 Add r_parallaxMapShadows. 2019-02-06 01:10:42 -08:00
Zack Middleton 11337c9fa2 OpenGL2: Add GPU vertex skinning for IQM models
Using GPU vertex skinning is significantly faster than CPU vertex
skinning. Especially since OpenGL2 has to run R_VaoPackNormal() and
R_VaoPackTangent() each vertex each frame which causes CPU vertex
skinning to be significantly slower than OpenGL1 renderer.
2018-07-27 17:40:25 -05:00
Zack Middleton cccd283be8 Improve IQM CPU vertex skinning performance
Only calculate vertex blend matrix for each unique bone indexes/weights
combination once per-surface instead of recalculating for each vertex.
For best performance the model surfaces needs to use few vertex bone
indexes and weights combinations.

Unroll loops so GCC better optimizes them.

In my tests drawing animated IQM may take 50% as long in opengl1 and
70% as long in opengl2. It will vary by model though and might not
help much at all.

Made unanimated IQM models skip matrix math altogether.
2018-07-27 17:40:21 -05:00
Zack Middleton fdc08e860e Improve IQM loading
- Only allocate memory for vertex arrays that are present in the IQM
file and are actually used (may not have colors or blend index/weights,
don't load tangents in opengl1). (Colors is fixed to next commit.)
- Explicitly handle loading IQM files without meshes (bones only).
- Better IQM validation. Header data offset 0 mean data is not present
in file. Check if required vertex arrays are present.

This involved a lot of white space changes and moving code around.
2018-07-27 17:40:16 -05:00
Zack Middleton 14cc4cc6cb OpenGL2: Fix world VAO cache drawing when glIndex_t is unsigned short
OpenGL ES is only required to support unsigned short for element buffer
values.

R_DrawElements() firstIndex argument was glIndex_t which caused element
indexes to wrap around to 0 when glIndex_t is an unsigned short.
(glIndex_t is an index into the vertexes buffer, not element buffer.)
Change it to 'int' like tess.firstIndex which is passed to
R_DrawElements().

World VAO cache buffer size allowed storing more vertexes than unsigned
short glIndex_t could reference. This resulted in the vertex indexes in
the element buffer wrapping around to 0.
2018-07-20 23:40:31 -05:00
Zack Middleton d861a4f427 Load OpenGL ES 2.0 function procs
Load functions procs supported by OpenGL ES 2.0, though there is not a
compatible renderer yet. Change argument for GLimp_Init from coreContext
to fixedFunction.
2018-07-20 23:40:21 -05:00
Zack Middleton 7391215bd4 Don't load non-core GL functions for OpenGL 3.2 core context
Also declare the GL functions in tr_local.h so there is compile error
for non-core GL functions instead of SEGFAULT from dereferencing a NULL
pointer.

Disable the non-functional stencil shadow code that hasn't been updated
to use OpenGL 3.2 core compatible drawing.
2018-07-20 23:40:17 -05:00
SmileTheory c0c45d325d OpenGL2: Readd r_deluxeSpecular.
https://github.com/ioquake/ioq3/issues/369
2018-05-14 18:30:59 -07:00
Edward Betts fe42b8653d Correct spelling mistakes. 2017-11-22 01:40:20 -06:00
Zack Middleton c9d12aa3f3 Add common OpenGL version parsing + OpenGL 3 fixes
- Parse OpenGL version in sdl_glimp.c to share with both renderers.
- Add GL_VERSION_ATLEAST(major, minor) macro.
- Get address of glGetStringi if using OpenGL 3.
- Fix glConfig.extensions_string when using GL3 core context in
opengl2 renderer.
- Make opengl1 renderer's gfxinfo support qglGetStringi too.
2017-10-01 23:09:20 -05:00
Zack Middleton 59b1262b82 Fix floating point precision loss in renderer [part 2]
Fix floatTime using float precision instead of double using GCC.
Fix R_BindAnimatedImage to be in sync with function table.
Fix vertexDeform bulge, vertexDeform normals, noise wave function
at high level time.

Revert unnecessary float -> double conversions.
2017-08-03 00:14:22 -05:00
Zack Middleton 30fdd88c9f Fix floating point precision loss in renderer [part 1]
Patch for https://bugzilla.icculus.org/show_bug.cgi?id=5931 by
Eugene C. from 2013 plus recent fix for tcMod rotate.

I merged the changes into the OpenGL2 renderer though the fix for
tcMod turb doesn't translate.
2017-08-02 23:44:44 -05:00
SmileTheory d549b642bc OpenGL2: Use an OpenGL 3.2 core context if available. 2017-07-13 12:03:10 -07:00
Zack Middleton 904bbc1a8f Allow more than 32 surfaces in skin files
Models don't have a surface limit; skins shouldn't either. Some player
models require more than 32 surfaces since vanilla Quake 3 did not
enforce the limit.

Skins are now limited to 256 surfaces because having no limit would
require parsing the skin file twice. The skin surfaces are dynamically
allocated so it doesn't increase memory usage when less surfaces
are used.
2017-07-04 14:06:09 -05:00
Zack Middleton 5aa7fb39c2 OpenGL2: Remove two unused cvars and update readme 2017-07-02 16:47:55 -05:00
SmileTheory e03cdf444c OpenGL2: Remove SF_VAO_MESH. 2017-06-16 16:52:53 -07:00
SmileTheory c65d2c2657 Add vao cache for static surfaces.
Remove support for draw range elements, multi draw arrays, world vao creation, surface merging.
2017-04-28 02:13:25 -07:00
SmileTheory 0672905ef1 OpenGL2: Detect Intel graphics and avoid/use certain operations there.
Also use qglCopyTextureSubImage2DEXT instead of qglCopyTextureImage2DEXT.
2016-12-07 22:30:55 -08:00
SmileTheory 2349ef038e OpenGL2: Don't interleave texCoords and lightCoords in tess. 2016-11-25 01:17:46 -08:00
SmileTheory ba59df8c8c OpenGL2: Remove check for GL_ARB_texture_non_power_of_two.
Core in OpenGL 2.0.
2016-10-21 16:58:42 -07:00
SmileTheory 41ae7815c9 OpenGL2: Remove half float support.
Not enough accuracy for textures larger than 1024x1024, such as merged lightmaps.
2016-10-20 20:09:12 -07:00
SmileTheory aa79738c50 OpenGL2: Store vertex colors and hdr lightmaps/lightgrid as RGBA16. 2016-10-11 03:28:20 -07:00
SmileTheory 239f539702 OpenGL2: Non-square merged lightmaps. 2016-10-10 03:06:03 -07:00
SmileTheory 8749d62bbd OpenGL2: Remove per fragment tangent space calculation code. 2016-09-14 03:57:51 -07:00
SmileTheory 4faf1008a0 OpenGL2: Remove map color scaling and r_forceSunMapLightScale.
Also simplify overbright code in ComputeShaderColors().
2016-09-14 02:59:54 -07:00
SmileTheory 927c9cc23c OpenGL2: Make R_FreeSurfaceGridMeshData() static. 2016-09-07 14:59:19 -07:00
SmileTheory dfbaf50324 OpenGL2: Store normals/tangents as int16_t[4]. 2016-09-06 00:57:15 -07:00
SmileTheory fe8ac838e2 OpenGL2: Preallocate grid surfaces like other BSP surfaces. 2016-08-14 22:22:20 -07:00
SmileTheory 716438168f OpenGL2: Use loader for all extension funcs. 2016-07-26 00:41:31 -07:00
SmileTheory 251c983681 OpenGL2: Require OpenGL 2.0. 2016-07-24 21:29:13 -07:00
SmileTheory 1f6703821f OpenGL2: Some FBO cleanup, and add non-depth blur to blur shader. 2016-04-05 02:37:05 -07:00
SmileTheory 5738d09969 OpenGL2: Add r_glossType. 2016-03-07 03:30:16 -08:00
SmileTheory 90d6f941f8 OpenGL2: Add r_shadowBlur. 2016-03-07 02:27:03 -08:00
SmileTheory 871872689e OpenGL2: Add named cubemaps and per-map env.json parsing. 2016-02-10 16:25:32 -08:00
SmileTheory ad952b9537 OpenGL2: Merge several cvars into r_pbr.
r_glossIsRoughness, r_specularIsMetallic, r_framebufferGamma, r_tonemapGamma, r_materialGamma, r_lightGamma
2016-02-01 21:37:23 -08:00
SmileTheory f70e9dac01 OpenGL2: Direct state access, part 2: Uniforms. 2016-01-18 23:30:36 -08:00
SmileTheory 275317fefb OpenGL2: Direct state access, part 1: Texture binds 2016-01-18 04:46:01 -08:00
SmileTheory e2b2437966 OpenGL2: Add r_cubemapSize. 2015-12-24 16:34:58 -08:00
SmileTheory c3216f54d2 OpenGL2: Replace r_exportCubemaps cvar with exportCubemaps command. 2015-12-23 09:58:11 -08:00
SmileTheory a6a6162f04 OpenGL2: Add r_exportCubemaps for saving cubemaps on map load. 2015-12-22 05:04:07 -08:00
SmileTheory cbfc3471bc OpenGL2: Switch to RGTC from LATC for normal maps.
Also added a RGTC compressor as a workaround on Intel graphics.
2015-12-15 03:23:55 -08:00
SmileTheory f9c72eee69 OpenGL2: Parse radius entries from misc_cubemap entities. 2015-12-09 02:00:40 -08:00