Commit graph

36 commits

Author SHA1 Message Date
Zack Middleton
4003a5b78c Fix the number of weights in the IQM model calculation
[The fourth bone influence of each vertex was ignored. --zturtleman]

Patch by Romulo Fernandes (razor85).
2021-04-03 15:40:45 -04:00
Zack Middleton
2a2646fe43 Fix IQM quat normalize fail case
Should only happen with invalid models though.
2019-05-28 21:00:02 -05:00
Zack Middleton
95b9cab4d6 Fix warnings that IQM blendWeights may not be initialized 2019-04-29 15:01:47 -05: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
Zack Middleton
c7ebe82131 Calculate bounds for unanimated IQM models
Bounds are optional for animated IQM models but are not possible to
include with unanimated models (seems intended for use with separate
model containing animations and bounds). Calculating bounds for
unanimated IQM models fixes culling and head model on HUD which
calculates position from model bounds.
2018-08-02 18:20:18 -05:00
Zack Middleton
1994801e1c Fix axis returned by IQM's LerpTag
The axis returned for IQM tag was the animation's joint rotation without
the base frame joint rotation. It only worked correct for models that
did not rotate the base frame joints.
2018-07-31 13:59:56 -05: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
6c3d92133d Fix IQM root joint backlerp when joint number is more than 0
Backlerp for root joint (joint with no parent) was always applied to
joint 0. This is an issue when a model has multiple root joints.
2018-07-27 17:40:09 -05: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
e77153766a OpenGL2: Draw sun shadows for first person IQM player models
This makes IQM have the same behavior as MD3 and MDR.
2017-06-30 14:07:26 -05:00
SmileTheory
2349ef038e OpenGL2: Don't interleave texCoords and lightCoords in tess. 2016-11-25 01:17:46 -08:00
SmileTheory
aa79738c50 OpenGL2: Store vertex colors and hdr lightmaps/lightgrid as RGBA16. 2016-10-11 03:28:20 -07:00
SmileTheory
8749d62bbd OpenGL2: Remove per fragment tangent space calculation code. 2016-09-14 03:57:51 -07:00
SmileTheory
dfbaf50324 OpenGL2: Store normals/tangents as int16_t[4]. 2016-09-06 00:57:15 -07:00
SmileTheory
1ad2b413ef Remove accidentally added increment. 2014-11-03 22:18:17 -08:00
SmileTheory
943259f6b4 OpenGL2: Support half floats for texcoords and vertex colors. 2014-11-03 19:10:35 -08:00
SmileTheory
84206c8598 OpenGL2: Vertex array object support. 2014-10-14 01:50:44 -07:00
Tim Angus
6665ea4a49 Fix renderergl2 warnings 2014-09-01 11:35:49 +01:00
SmileTheory
f6f3a19f73 OpenGL2: Support GL_ARB_vertex_type_2_10_10_10_rev for normals/tangents/lightdirs 2013-12-09 17:33:54 -08:00
SmileTheory
6e5f8cc918 OpenGL2: Calculate bitangent in shader, and store normal/tangent as normalized byte arrays. 2013-11-12 19:21:51 -08:00
Zack Middleton
0f30dad10a Merge last two commits into renderergl2 2013-10-29 23:22:02 -05:00
Zack Middleton
c28fabf505 IQM int/float vertex arrays were already swapped 2013-10-29 23:07:15 -05:00
Zack Middleton
0bf1f3d0ba Add support for IQM int blend indices and float blend weights
Integer blend indices are converted to bytes at load, ioq3 doesn't allow more than 128 joints.

Heavily based on code by @zippers.
2013-10-29 22:09:06 -05:00
Zack Middleton
1515841b38 Support IQMs with joints and no poses 2013-10-29 20:47:33 -05:00
SmileTheory
7e875c6941 #5979: Cubemap support for opengl2. 2013-09-16 00:54:26 -07:00
Zack Middleton
aa2ea68741 Fix IQM tess buffer overflow
Set the variables that use tess.numVertexes after calling RB_CHECKOVERFLOW() as it may set tess.numVertexes to 0!

Could cause visual issues and error "RB_EndSurface() - SHADER_MAX_VERTEXES hit".
2013-06-18 18:00:45 -05:00
Zack Middleton
cb2fa48d65 Only allow model meshes to have SHADER_MAX_VERTEXES - 1 vertexes
The last index is used to check for buffer overflows. See RB_CheckOverflow and RB_EndSurface.
2013-06-18 17:02:47 -05:00
/dev/humancontroller
bbd17d75ce reduce the amount of compiler warnings for variable shadowing 2013-05-30 15:43:20 -05:00
Zack Middleton
ee7bd0cae6 Show surface names in excessive vertexes and triangles warnings
Add newlines to renderergl2's R_LoadMD3 vertex and triangle warnings.
2013-05-03 14:28:18 -05:00
Zack Middleton
98dda7758f Always initialize joint_names in R_LoadIQM
Reported by MAN-AT-ARMS
2013-03-18 15:55:25 -05:00
Zack Middleton
bf962c516d Fix loading and rendering IQMs with no joints 2013-03-18 14:13:09 -05:00
Zack Middleton
89ee8b050f Fix size reserved for IQM jointMats (allocated more than used) 2013-03-08 15:28:27 -06:00
Zack Middleton
8aa6efe7b6 Fix origin returned by IQM's LerpTag
It use to return pose joint's offset from base at the lerped frame, now it returns the joint's origin at the lerped frame.

Patch by Axel Isouard and Zack Middleton.
2013-03-08 13:47:16 -06:00
Tim Angus
f6fb9eb602 renderer -> renderergl1, rend2 -> renderergl2 2013-02-15 23:46:37 +00:00
Renamed from code/rend2/tr_model_iqm.c (Browse further)