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

Rend2 SP #1179

Draft
wants to merge 94 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
a3aa7dd
Copy all rend2 files to sp directory
SomaZ Oct 2, 2023
07ab3b0
[vanilla] LS_NONE -> LS_LSNONE
SomaZ Oct 2, 2023
99a8eec
COM_GetCurrentParseLine fix
SomaZ Oct 2, 2023
c27c4b4
Prepare qcommon and rd-common
SomaZ Oct 2, 2023
33045e1
Patch rend2 for sp
SomaZ Oct 2, 2023
3b7df7a
Move mp rend2 to shared folder
SomaZ Oct 3, 2023
bef35ee
[SP] rit.Malloc -> rit.Z_Malloc
SomaZ Oct 3, 2023
76f8b6c
[MP] Get rid of _skinSurface_t
SomaZ Oct 3, 2023
a8b019a
[Rend2] Fix cg_showtris depthtest
SomaZ Oct 3, 2023
9c85f09
[SP] Match R_LerpTag with MP API
SomaZ Oct 4, 2023
b43770d
[SP] Match R_LerpTag with MP API for the UI too
SomaZ Oct 4, 2023
0397ddb
[SP] Match G2_SetupModelPointers with MP version
SomaZ Oct 4, 2023
a12a5a0
[rend2] make sp renderer use the shared rend2 files
SomaZ Oct 4, 2023
7464c90
Remove duplicate files
SomaZ Oct 4, 2023
e05b65a
Fix incorrect texture coordnates
SomaZ Oct 5, 2023
ef4da7b
[rend2] WIP Weather functions
SomaZ Oct 5, 2023
5e34341
[rend2-sp] Fix broken endscreen yavin2
SomaZ Oct 5, 2023
36d7672
[rend2-sp] Fix ParseSessions
SomaZ Oct 5, 2023
12b51bf
[rend2-sp] Add missing G2 functions
SomaZ Oct 6, 2023
156d92a
[rend2-sp] Add OpenJO cmake config
SomaZ Oct 6, 2023
c3bc53d
[rend2-sp] Add basic JO support
SomaZ Oct 7, 2023
0aaf13b
[rend2] Fix ghoul2 cache crashes
SomaZ Oct 7, 2023
0f2c420
[rend2] Increase max fog count
SomaZ Oct 7, 2023
080de13
[rend2-sp] Fix force push refraction and force speed doppelgaenger
SomaZ Oct 7, 2023
de7f309
[rend2-sp] Add SP tcGen environment
SomaZ Oct 7, 2023
4c11f83
[rend2-sp] Fix SP force lightning
SomaZ Oct 7, 2023
0f7bbea
[rend2-sp] Add missing entity surface render types
SomaZ Oct 7, 2023
05a2357
[rend2] Add md3 animations back, just CPU for now
SomaZ Oct 7, 2023
8dbeb54
[rend2-sp] Fix ghoul2 saber marks
SomaZ Oct 8, 2023
ac4eb0e
[rend2-sp] Enabling additional sp g2 gore features
SomaZ Oct 8, 2023
5b035b5
[rend2-sp] Fix vid_restart and changing renderers
SomaZ Oct 8, 2023
6128f8e
[rend2] Add missing weather functions
SomaZ Oct 8, 2023
077848e
[SP] Increase REF_API_VERSION & UI_API_VERSION
SomaZ Oct 8, 2023
a82a42c
[rend2-sp] Attempt fixing non Windows builds
SomaZ Oct 9, 2023
0093a2b
[rend2] Fix viewport when RDF_NOWORLDMODEL
SomaZ Oct 9, 2023
98508ec
[rend2-sp] Implement RDF_doLAGoggles
SomaZ Oct 9, 2023
030c784
[rend2] Init Uniforms for the splashScreenShader
SomaZ Oct 9, 2023
6db4a17
[rend2-sp] Fix LA Goggles
SomaZ Oct 11, 2023
1c0e11e
[rend2-sp] Fix fog assignments
SomaZ Oct 11, 2023
32c0fb1
[rend2-sp] Make level end screenshot work correctly
SomaZ Oct 11, 2023
b3e5f53
[rend2-sp] Implement screen dissolve
SomaZ Oct 11, 2023
64a9266
[rend2] Don't draw shadowmap shadows for g2 effects
SomaZ Oct 11, 2023
3b966a4
[rend2] Fallback to surface normal for lighting vectors when lightgri…
SomaZ Oct 13, 2023
293ccdc
[rend2] Fix depth writes for shaders with blendFunc & sort opaque
SomaZ Oct 13, 2023
5d0191b
[rend2] Load weather images as SRGB in hdr lighting conditions
SomaZ Oct 22, 2023
9ae08ab
[rend2] Fix fog color in hdr lighting conditions
SomaZ Oct 22, 2023
35b799f
[SP] Match AddPolyToScene with MP
SomaZ Oct 25, 2023
51ff8fa
[SP/MP] Match most of tr_types.h
SomaZ Dec 12, 2023
3cdbeee
[rend2] Fix compile after rebase
SomaZ Dec 12, 2023
fc77a23
[rend2] Fix misc_bsp related crash
SomaZ Jan 2, 2024
9ca479d
[rend2] Revert VIS related change
SomaZ Jan 2, 2024
cb5a8c1
[rend2] Fix overly bright ibl cloth specular
SomaZ Feb 16, 2024
494abea
[rend2] Reduce goreVBO size
SomaZ Feb 16, 2024
a257512
[rend2] Fix alphaGen portal
SomaZ Feb 18, 2024
49adb74
Merge branch 'rend2' into rend2-unified-wip
SomaZ Feb 19, 2024
15aae39
[rend2-sp] Add r_patchStitching for consistency
SomaZ Feb 19, 2024
b5b6122
[rend2] Fix refraction rendering again
SomaZ Feb 19, 2024
6994d4c
[rend2] Fix rendering misc_bsps
SomaZ Feb 19, 2024
e09e1cb
[rend2] No need to seperate entity types in sp/mp anymore
SomaZ Feb 19, 2024
05415f8
[rend2] Fix volume shadow inaccuracies
SomaZ Feb 19, 2024
442abe3
[rend2] Fix out-of-bounds crash with weather
SomaZ Feb 20, 2024
9a61f07
[rend2] Fix sprites related compiler warning
SomaZ Mar 2, 2024
857fda5
[rend2] Reset output in R_LoadHDRImage
SomaZ Mar 7, 2024
33e276d
[rend2] Fix ghoul2 related crash, when other model type was loaded in…
SomaZ Mar 18, 2024
c3c2e75
[rend2] Fix incorrect player light vector
SomaZ Mar 20, 2024
f67f20e
[rend2] Fix incorrect lightgrid sampling
SomaZ Mar 21, 2024
4ea36f6
[rend2] Get rid of unneeded hdr lighting scaling
SomaZ Mar 21, 2024
e477758
[rend2] Fixing autosprite deforms on non world surfaces
SomaZ Mar 21, 2024
5f0a58a
[rend2] Don't scale dynamic lights when not normalized
SomaZ Mar 21, 2024
e996441
[rend2] Limit light loop in lightall shader
SomaZ Mar 21, 2024
f652863
[rend2] Fix some compiler warnings
SomaZ Apr 4, 2024
b80f721
[rend2] Track viewport and blend states
SomaZ Apr 9, 2024
b688bdf
Merge branch 'rend2' into rend2-unified-wip
SomaZ Apr 9, 2024
433837f
[rend2] Fixing local position based rgb and tc Gens
SomaZ Apr 17, 2024
7433777
[rend2] Fix parallax mapping on alpha tested stages
SomaZ Apr 23, 2024
08ad1d1
[rend2] Reduce goreVBO size revisited
SomaZ Apr 25, 2024
7c21d86
[rend2-sp] Fix precaching related memory leaks
SomaZ Apr 26, 2024
90ee6f7
[rend2-sp] Some g2 gore code cleanup
SomaZ Apr 26, 2024
e34bf59
[rend2] Fix compiler warning
SomaZ Apr 29, 2024
8fc4b24
[rend2] Update glext.h
SomaZ Apr 29, 2024
e656514
[rend2] Fix shaders with time offsets
SomaZ Apr 29, 2024
804c500
[rend2] Remove some unused variables
SomaZ Apr 29, 2024
62a14d9
[rend2] Fix skipping depth pass for refractive surfaces
SomaZ May 1, 2024
7c91d16
[rend2] Attempt at fixing UI scene rending on AMD
SomaZ May 1, 2024
c0ba7af
[rend2] Don't setup world draws when RDF_NOWORLDMODEL
SomaZ May 1, 2024
9ff929c
[rend2] Don't add portal views when there's no world to render
SomaZ May 1, 2024
166e83b
[rend2] Fix typo and fix ubos in sp port
SomaZ May 2, 2024
63599ed
Merge branch 'rend2' into rend2-unified-wip
SomaZ May 2, 2024
649a57f
[rend2] Fix vertex lit shaders with lightmap stage
SomaZ May 3, 2024
4d58063
[rend2] Fix specular image gen related memory leak
SomaZ May 3, 2024
b86845c
[rend2] Rework precaching to init the renderer now
SomaZ May 3, 2024
97e902a
[rend2] Get rid of alphatest and glow shader permutations
SomaZ May 3, 2024
1ac5652
[rend2] Fixing shaders spriteUbo again
SomaZ May 6, 2024
6029f91
[rend2] Fix korriban shaders with multiply blend stages
SomaZ May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -44,10 +44,12 @@ option(BuildMPRend2 "Whether to create projects for the EXPERIMENTAL MP rend2 re
option(BuildSPEngine "Whether to create projects for the SP engine (openjk_sp.exe)" ON)
option(BuildSPGame "Whether to create projects for the SP gamecode (jagamex86.dll)" ON)
option(BuildSPRdVanilla "Whether to create projects for the SP default renderer (rdsp-vanilla_x86.dll)" ON)
option(BuildSPRend2 "Whether to create projects for the EXPERIMENTAL SP rend2 renderer (rdsp-rend2_x86.dll)" ON)

option(BuildJK2SPEngine "Whether to create projects for the jk2 SP engine (openjo_sp.exe)" OFF)
option(BuildJK2SPGame "Whether to create projects for the jk2 sp gamecode mod (jk2gamex86.dll)" OFF)
option(BuildJK2SPRdVanilla "Whether to create projects for the jk2 sp renderer (rdjosp-vanilla_x86.dll)" OFF)
option(BuildJK2SPRdRend2 "Whether to create projects for the EXPERIMENTAL jk2 SP rend2 renderer (rdjosp-rend2_x86.dll)" OFF)

option(BuildTests "Whether to build automatic unit tests (requires Boost)" OFF)

Expand Down Expand Up @@ -161,6 +163,7 @@ endif()
set(SPEngine "openjk_sp.${Architecture}")
set(SPGame "jagame${Architecture}")
set(SPRDVanillaRenderer "rdsp-vanilla_${Architecture}")
set(SPRend2 "rdsp-rend2_${Architecture}")
set(MPEngine "openjk.${Architecture}")
set(MPVanillaRenderer "rd-vanilla_${Architecture}")
set(MPDed "openjkded.${Architecture}")
Expand All @@ -171,6 +174,7 @@ set(MPRend2 "rd-rend2_${Architecture}")
set(JK2SPEngine "openjo_sp.${Architecture}")
set(JK2SPGame "jospgame${Architecture}")
set(JK2SPVanillaRenderer "rdjosp-vanilla_${Architecture}")
set(JK2SPRend2Renderer "rdjosp-rend2_${Architecture}")
set(AssetsPk3 "openjk-${Architecture}.pk3")
# Library names
set(MPBotLib "botlib")
Expand Down
5 changes: 5 additions & 0 deletions code/CMakeLists.txt
Expand Up @@ -29,6 +29,11 @@ endif(BuildSPGame)
# Add Modular Renderer project
add_subdirectory("${SPDir}/rd-vanilla")

# Add rend2 JKA Renderer Project
if(BuildSPRend2 OR BuildJK2SPRdRend2)
add_subdirectory("${SPDir}/rd-rend2")
endif(BuildSPRend2 OR BuildJK2SPRdRend2)

# Add Engine Project
if(BuildSPEngine OR BuildJK2SPEngine)
# Libraries
Expand Down
2 changes: 1 addition & 1 deletion code/client/cl_cgame.cpp
Expand Up @@ -1006,7 +1006,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
case CG_R_GETLIGHTING:
return re.GetLighting( (const float * ) VMA(1), (float *) VMA(2), (float *) VMA(3), (float *) VMA(4) );
case CG_R_ADDPOLYTOSCENE:
re.AddPolyToScene( args[1], args[2], (const polyVert_t *) VMA(3) );
re.AddPolyToScene( args[1], args[2], (const polyVert_t *) VMA(3), 1 );
return 0;
case CG_R_ADDLIGHTTOSCENE:
re.AddLightToScene( (const float *) VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) );
Expand Down
2 changes: 1 addition & 1 deletion code/client/cl_cin.cpp
Expand Up @@ -1667,7 +1667,7 @@ static void CIN_AddTextCrawl()

// render it out
re.ClearScene();
re.AddPolyToScene( cinTable[CL_handle].hCRAWLTEXT, 4, verts );
re.AddPolyToScene( cinTable[CL_handle].hCRAWLTEXT, 4, verts, 1 );
re.RenderScene( &refdef );

//time's up
Expand Down
7 changes: 1 addition & 6 deletions code/client/cl_main.cpp
Expand Up @@ -1055,11 +1055,6 @@ int get_com_frameTime( void )
return com_frameTime;
}

void *CL_Malloc(int iSize, memtag_t eTag, qboolean bZeroit, int iAlign)
{
return Z_Malloc(iSize, eTag, bZeroit);
}

/*
============
CL_InitRef
Expand Down Expand Up @@ -1153,7 +1148,7 @@ void CL_InitRef( void ) {
RIT(SV_Trace);
RIT(S_RestartMusic);
RIT(Z_Free);
rit.Malloc=CL_Malloc;
RIT(Z_Malloc);
RIT(Z_MemSize);
RIT(Z_MorphMallocTag);

Expand Down
2 changes: 1 addition & 1 deletion code/client/cl_ui.cpp
Expand Up @@ -264,7 +264,7 @@ void CL_InitUI( void ) {
#endif
uii.R_ClearScene = re.ClearScene;
uii.R_AddRefEntityToScene = re.AddRefEntityToScene;
uii.R_AddPolyToScene = re.AddPolyToScene;
uii.R_AddPolyToScene = re.AddPolyToScene;
uii.R_AddLightToScene = re.AddLightToScene;
uii.R_RenderScene = re.RenderScene;

Expand Down
4 changes: 2 additions & 2 deletions code/ghoul2/G2.h
Expand Up @@ -215,8 +215,8 @@ void G2_GetBoltMatrixLow(CGhoul2Info &ghoul2,int boltNum,const vec3_t scale,mdx
void G2_TimingModel(boneInfo_t &bone,int time,int numFramesInFile,int &currentFrame,int &newFrame,float &lerp);


bool G2_SetupModelPointers(CGhoul2Info_v &ghoul2); // returns true if any model is properly set up
bool G2_SetupModelPointers(CGhoul2Info *ghlInfo); // returns true if the model is properly set up
qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); // returns true if any model is properly set up
qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo); // returns true if the model is properly set up

//#ifdef _G2_GORE // These exist regardless, non-gore versions are empty
void G2API_AddSkinGore(CGhoul2Info_v &ghoul2,SSkinGoreData &gore);
Expand Down
29 changes: 28 additions & 1 deletion code/qcommon/q_shared.cpp
Expand Up @@ -157,7 +157,7 @@ void COM_EndParseSession( void )
#endif
}

int COM_GetCurrentParseLine( int index )
int COM_GetCurrentParseLine( void )
{
if(parseDataCount < 0)
Com_Error(ERR_FATAL, "COM_GetCurrentParseLine: parseDataCount < 0 (be sure to call COM_BeginParseSession!)");
Expand Down Expand Up @@ -518,6 +518,33 @@ void SkipBracedSection ( const char **program) {
} while (depth && *program);
}

/*
=================
SkipBracedSection

The next token should be an open brace or set depth to 1 if already parsed it.
Skips until a matching close brace is found.
Internal brace depths are properly skipped.
=================
*/
qboolean SkipBracedSection (const char **program, int depth) {
char *token;

do {
token = COM_ParseExt( program, qtrue );
if( token[1] == 0 ) {
if( token[0] == '{' ) {
depth++;
}
else if( token[0] == '}' ) {
depth--;
}
}
} while( depth && *program );

return (qboolean)( depth == 0 );
}

/*
=================
SkipRestOfLine
Expand Down
1 change: 1 addition & 0 deletions code/qcommon/q_shared.h
Expand Up @@ -368,6 +368,7 @@ qboolean COM_ParseVec4( const char **buffer, vec4_t *c);

void COM_MatchToken( char**buf_p, char *match );

qboolean SkipBracedSection (const char **program, int depth);
void SkipBracedSection (const char **program);
void SkipRestOfLine ( const char **data );

Expand Down
127 changes: 126 additions & 1 deletion code/qcommon/qfiles.h
Expand Up @@ -192,6 +192,131 @@ typedef struct {
} md3Header_t;


/*
==============================================================================

MDR file format

==============================================================================
*/

/*
* Here are the definitions for Ravensoft's model format of md4. Raven stores their
* playermodels in .mdr files, in some games, which are pretty much like the md4
* format implemented by ID soft. It seems like ID's original md4 stuff is not used at all.
* MDR is being used in EliteForce, JediKnight2 and Soldiers of Fortune2 (I think).
* So this comes in handy for anyone who wants to make it possible to load player
* models from these games.
* This format has bone tags, which is similar to the thing you have in md3 I suppose.
* Raven has released their version of md3view under GPL enabling me to add support
* to this codebase. Thanks to Steven Howes aka Skinner for helping with example
* source code.
*
* - Thilo Schulz (arny@ats.s.bawue.de)
*/

#define MDR_IDENT (('5'<<24)+('M'<<16)+('D'<<8)+'R')
#define MDR_VERSION 2
#define MDR_MAX_BONES 128

typedef struct {
int boneIndex; // these are indexes into the boneReferences,
float boneWeight; // not the global per-frame bone list
vec3_t offset;
} mdrWeight_t;

typedef struct {
vec3_t normal;
vec2_t texCoords;
int numWeights;
mdrWeight_t weights[1]; // variable sized
} mdrVertex_t;

typedef struct {
int indexes[3];
} mdrTriangle_t;

typedef struct {
int ident;

char name[MAX_QPATH]; // polyset name
char shader[MAX_QPATH];
int shaderIndex; // for in-game use

int ofsHeader; // this will be a negative number

int numVerts;
int ofsVerts;

int numTriangles;
int ofsTriangles;

// Bone references are a set of ints representing all the bones
// present in any vertex weights for this surface. This is
// needed because a model may have surfaces that need to be
// drawn at different sort times, and we don't want to have
// to re-interpolate all the bones for each surface.
int numBoneReferences;
int ofsBoneReferences;

int ofsEnd; // next surface follows
} mdrSurface_t;

typedef struct {
float matrix[3][4];
} mdrBone_t;

typedef struct {
vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
vec3_t localOrigin; // midpoint of bounds, used for sphere cull
float radius; // dist from localOrigin to corner
char name[16];
mdrBone_t bones[1]; // [numBones]
} mdrFrame_t;

typedef struct {
unsigned char Comp[24]; // MC_COMP_BYTES is in MatComp.h, but don't want to couple
} mdrCompBone_t;

typedef struct {
vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame
vec3_t localOrigin; // midpoint of bounds, used for sphere cull
float radius; // dist from localOrigin to corner
mdrCompBone_t bones[1]; // [numBones]
} mdrCompFrame_t;

typedef struct {
int numSurfaces;
int ofsSurfaces; // first surface, others follow
int ofsEnd; // next lod follows
} mdrLOD_t;

typedef struct {
int boneIndex;
char name[32];
} mdrTag_t;

typedef struct {
int ident;
int version;

char name[MAX_QPATH]; // model name

// frames and bones are shared by all levels of detail
int numFrames;
int numBones;
int ofsFrames; // mdrFrame_t[numFrames]

// each level of detail has completely separate sets of surfaces
int numLODs;
int ofsLODs;

int numTags;
int ofsTags;

int ofsEnd; // end of file
} mdrHeader_t;

/*
==============================================================================

Expand Down Expand Up @@ -341,8 +466,8 @@ typedef struct {
#define MAXLIGHTMAPS 4
#define LS_NORMAL 0x00
#define LS_UNUSED 0xfe
#define LS_NONE 0xff
#define MAX_LIGHT_STYLES 64
#define LS_LSNONE 0xff

typedef struct {
vec3_t xyz;
Expand Down
6 changes: 6 additions & 0 deletions code/qcommon/tags.h
Expand Up @@ -67,6 +67,12 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
TAGDEF(POINTCACHE), // weather effects
TAGDEF(NEWDEL),
TAGDEF(MINIZIP),

TAGDEF(GRIDMESH), // some specific temp workspace that only seems to be in the MP codebase
TAGDEF(GENERAL),
TAGDEF(GHOUL2_GORE),
TAGDEF(TEMP_HUNKALLOC),

TAGDEF(COUNT)

//////////////// eof //////////////
Expand Down
8 changes: 4 additions & 4 deletions code/rd-common/tr_public.h
Expand Up @@ -30,7 +30,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "../ghoul2/G2.h"
#include "../ghoul2/ghoul2_gore.h"

#define REF_API_VERSION 18
#define REF_API_VERSION 19

typedef struct {
void (QDECL *Printf) ( int printLevel, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
Expand All @@ -40,7 +40,7 @@ typedef struct {
int (*Milliseconds) ( void );

void (*Hunk_ClearToMark) ( void );
void* (*Malloc) ( int iSize, memtag_t eTag, qboolean zeroIt, int iAlign );
void* (*Z_Malloc) ( int iSize, memtag_t eTag, qboolean zeroIt, int iAlign );
int (*Z_Free) ( void *memory );
int (*Z_MemSize) ( memtag_t eTag );
void (*Z_MorphMallocTag) ( void *pvBuffer, memtag_t eDesiredTag );
Expand Down Expand Up @@ -178,7 +178,7 @@ typedef struct {
// Nothing is drawn until R_RenderScene is called.
void (*ClearScene)( void );
void (*AddRefEntityToScene)( const refEntity_t *re );
void (*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts );
void (*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys );
void (*AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
void (*RenderScene)( const refdef_t *fd );
qboolean(*GetLighting)( const vec3_t org, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir);
Expand Down Expand Up @@ -225,7 +225,7 @@ typedef struct {
int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );

//model stuff
void (*LerpTag)( orientation_t *tag, qhandle_t model, int startFrame, int endFrame,
int (*LerpTag)( orientation_t *tag, qhandle_t model, int startFrame, int endFrame,
float frac, const char *tagName );
void (*ModelBounds)( qhandle_t model, vec3_t mins, vec3_t maxs );

Expand Down