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 update #33

Merged
merged 6 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion codemp/rd-rend2/tr_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,11 @@ const void *RB_PostProcess(const void *data)
srcBox[1] = tr.screenSsaoImage->height - srcBox[1];
srcBox[3] = -srcBox[3];

FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);
int blendMode = GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO;
if (r_ssao->integer == 2)
blendMode = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO;

FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, blendMode);
}

if (r_dynamicGlow->integer)
Expand Down Expand Up @@ -2576,6 +2580,11 @@ const void *RB_PostProcess(const void *data)
if (1)
RB_BokehBlur(NULL, srcBox, NULL, dstBox, backEnd.refdef.blurFactor);

if (r_debugWeather->integer == 2)
{
FBO_BlitFromTexture(tr.weatherDepthImage, NULL, NULL, NULL, nullptr, NULL, NULL, 0);
}

if (0 && r_sunlightMode->integer)
{
vec4i_t dstBox;
Expand Down
17 changes: 15 additions & 2 deletions codemp/rd-rend2/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,10 @@ static void R_LoadVisibility( world_t *worldData, lump_t *l ) {
int len;
byte *buf;

len = (worldData->numClusters + 63) & ~63;
worldData->novis = (byte *)ri.Hunk_Alloc(len, h_low);
Com_Memset(worldData->novis, 0xff, len);

len = l->filelen;
if ( !len ) {
return;
Expand Down Expand Up @@ -2303,7 +2307,14 @@ static void R_LoadSubmodels( world_t *worldData, int worldIndex, lump_t *l ) {

model->type = MOD_BRUSH;
model->data.bmodel = out;
Com_sprintf( model->name, sizeof( model->name ), "*%d", i );
if (worldIndex >= 0)
{
Com_sprintf( model->name, sizeof( model->name ), "*%d-%d", worldIndex, i );
}
else
{
Com_sprintf( model->name, sizeof( model->name ), "*%d", i );
}

for (j=0 ; j<3 ; j++) {
out->bounds[0][j] = LittleFloat (in->mins[j]);
Expand Down Expand Up @@ -3750,7 +3761,9 @@ world_t *R_LoadBSP(const char *name, int *bspIndex)
}

worldIndex = *bspIndex = tr.numBspModels;
worldData = tr.bspModels[tr.numBspModels];

worldData = (world_t *)ri.Hunk_Alloc(sizeof(*worldData), h_low);
tr.bspModels[tr.numBspModels] = worldData;
++tr.numBspModels;
}

Expand Down
3 changes: 2 additions & 1 deletion codemp/rd-rend2/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ typedef struct {
void R_SetOrientationOriginAndAxis(
orientationr_t& orientation,
const vec3_t origin,
const vec3_t left,
const vec3_t forward,
const vec3_t left,
const vec3_t up);
void R_SetOrientationOriginAndAxis(
orientationr_t& orientation,
Expand Down Expand Up @@ -1803,6 +1803,7 @@ typedef struct {
int numClusters;
int clusterBytes;
const byte *vis; // may be passed in by CM_LoadMap to save space
byte *novis; // clusterBytes of 0xff (everything is visible)

char *entityString;
char *entityParsePoint;
Expand Down
27 changes: 5 additions & 22 deletions codemp/rd-rend2/tr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2217,13 +2217,13 @@ void R_RenderDlightCubemaps(const refdef_t *fd)
void R_SetOrientationOriginAndAxis(
orientationr_t& orientation,
const vec3_t origin,
const vec3_t left,
const vec3_t forward,
const vec3_t left,
const vec3_t up)
{
VectorCopy(origin, orientation.origin);
VectorCopy(left, orientation.axis[0]);
VectorCopy(forward, orientation.axis[1]);
VectorCopy(forward, orientation.axis[0]);
VectorCopy(left, orientation.axis[1]);
VectorCopy(up, orientation.axis[2]);
}

Expand Down Expand Up @@ -2757,12 +2757,9 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level)

void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce )
{
refdef_t refdef;
viewParms_t parms;
refdef_t refdef = {};
float oldColorScale = tr.refdef.colorScale;

memset( &refdef, 0, sizeof( refdef ) );
refdef.rdflags = 0;
VectorCopy(tr.cubemaps[cubemapIndex].origin, refdef.vieworg);

switch(cubemapSide)
Expand Down Expand Up @@ -2805,16 +2802,6 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene,
break;
}

refdef.fov_x = 90;
refdef.fov_y = 90;

refdef.x = 0;
refdef.y = 0;
refdef.width = tr.renderCubeFbo->width;
refdef.height = tr.renderCubeFbo->height;

refdef.time = 0;

if (!subscene)
{
RE_BeginScene(&refdef);
Expand All @@ -2829,13 +2816,9 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene,

tr.refdef.colorScale = 1.0f;

Com_Memset( &parms, 0, sizeof( parms ) );

parms.viewportX = 0;
parms.viewportY = 0;
viewParms_t parms = {};
parms.viewportWidth = tr.renderCubeFbo->width;
parms.viewportHeight = tr.renderCubeFbo->height;
parms.isPortal = qfalse;
parms.isMirror = qtrue;
parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS;
if (!bounce)
Expand Down
28 changes: 20 additions & 8 deletions codemp/rd-rend2/tr_weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,40 +92,52 @@ namespace
void GenerateDepthMap()
{
vec3_t mapSize;
vec3_t halfMapSize;
VectorSubtract(
tr.world->bmodels[0].bounds[0],
tr.world->bmodels[0].bounds[1],
mapSize);
VectorScale(mapSize, -0.5f, halfMapSize);
mapSize[2] = 0.0f;

const vec3_t forward = {0.0f, 0.0f, -1.0f};
const vec3_t left = {0.0f, 1.0f, 0.0f};
const vec3_t up = {0.0f, 0.0f, 1.0f};
const vec3_t forward = {1.0f, 0.0f, 0.0f};
const vec3_t up = {1.0f, 0.0f, 0.0f};

matrix3_t viewAxes;
vec3_t viewOrigin;
VectorMA(tr.world->bmodels[0].bounds[0], 0.5f, mapSize, viewOrigin);
VectorMA(tr.world->bmodels[0].bounds[1], 0.5f, mapSize, viewOrigin);

ri.Printf(PRINT_ALL, "Rendering weather depth from (%.f %.f %.f)\n",
viewOrigin[0], viewOrigin[1], viewOrigin[2]);

orientationr_t orientation;
R_SetOrientationOriginAndAxis(orientation, viewOrigin, left, forward, up);
R_SetOrientationOriginAndAxis(orientation, viewOrigin, forward, left, up);

refdef_t refdef = {};
refdef.width = tr.weatherDepthFbo->width;
refdef.height = tr.weatherDepthFbo->height;
VectorCopy(orientation.origin, refdef.vieworg);
for (int i = 0; i < 3; ++i)
VectorCopy(orientation.axis[i], refdef.viewaxis[i]);

RE_BeginScene(&refdef);
RE_ClearScene();

const vec3_t viewBounds[2] = {
{ 0.0f, -halfMapSize[0], -halfMapSize[1] },
{ halfMapSize[2] * 2.0f, halfMapSize[0], halfMapSize[1] }
};
ri.Printf(
PRINT_ALL,
"Weather view bounds (%f %f %f) (%f %f %f)\n",
viewBounds[0][0], viewBounds[0][1], viewBounds[0][2],
viewBounds[1][0], viewBounds[1][1], viewBounds[1][2]);

R_SetupViewParmsForOrthoRendering(
tr.weatherDepthFbo->width,
tr.weatherDepthFbo->height,
tr.weatherDepthFbo,
VPF_DEPTHCLAMP | VPF_DEPTHSHADOW | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL,
orientation,
tr.world->bmodels[0].bounds);
viewBounds);

const int firstDrawSurf = tr.refdef.numDrawSurfs;

Expand Down
6 changes: 3 additions & 3 deletions codemp/rd-rend2/tr_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ R_ClusterPVS
*/
static const byte *R_ClusterPVS (int cluster) {
if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) {
return NULL;
return tr.world->novis;
}

return tr.world->vis + cluster * tr.world->clusterBytes;
Expand All @@ -683,7 +683,7 @@ qboolean R_inPVS( const vec3_t p1, const vec3_t p2, byte *mask ) {

leafnum = ri.CM_PointLeafnum (p2);
cluster = ri.CM_LeafCluster (leafnum);
if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) )
if ( !(mask[cluster>>3] & (1<<(cluster&7))) )
return qfalse;

return qtrue;
Expand Down Expand Up @@ -754,7 +754,7 @@ static void R_MarkLeaves( void )
}

// check general pvs
if ( vis && !(vis[cluster>>3] & (1<<(cluster&7))) ) {
if ( !(vis[cluster>>3] & (1<<(cluster&7))) ) {
continue;
}

Expand Down