Jump to content
The Dark Mod Forums

TDM Engine Development Page


zergrush

Recommended Posts

Allready did, still not working :/

 

old code reverted

/*
====================
RB_RenderDrawSurfListWithFunction

The triangle functions can check backEnd.currentSpace != surf->space
to see if they need to perform any new matrix setup.  The modelview
matrix will already have been loaded, and backEnd.currentSpace will
be updated after the triangle function completes.
====================
*/
void RB_RenderDrawSurfListWithFunction( drawSurf_t **drawSurfs, int numDrawSurfs, 
											  void (*triFunc_)( const drawSurf_t *) ) {
	const drawSurf_t		*drawSurf;
	backEnd.currentSpace = NULL;

	for ( int i = 0  ; i < numDrawSurfs ; i++ ) {
		drawSurf = drawSurfs[i];

		// change the matrix if needed
		// Note (Serp) : this used to be ( drawSurf->space != backEnd.currentSpace) however, since it's always going to be NULL... 
		// Note (SteveL) : FIXME: It *won't* always be NULL, we're in a loop and it gets set at the end. This change might be wiping out 
		// all (marginal) benefits from sorting DrawSurfs by material, as it'll cause a blocking change in GL state on every draw. However, 
		// reverting the change causes all static solid surfaces to become invisible. Don't know why.
		// Note (duzenko): is the "return" causing it?
		const bool cacheMatrix = true;
		if ( cacheMatrix ) {
			if ( drawSurf->space != backEnd.currentSpace ) {
				qglLoadMatrixf( drawSurf->space->modelViewMatrix );
				//backEnd.currentSpace = drawSurf->space;
			}
		} else {
			if ( drawSurf->space ) {
				qglLoadMatrixf( drawSurf->space->modelViewMatrix );
			} else {
				return; // duzenko: what is this supposed to mean???
			}
		}

		if ( drawSurf->space->weaponDepthHack ) {
			RB_EnterWeaponDepthHack();
		}

		if ( drawSurf->space->modelDepthHack != 0.0f ) {
			RB_EnterModelDepthHack( drawSurf->space->modelDepthHack );
		}

		// change the scissor if needed
		if ( r_useScissor.GetBool() && !backEnd.currentScissor.Equals( drawSurf->scissorRect ) ) {
			backEnd.currentScissor = drawSurf->scissorRect;
			qglScissor( backEnd.viewDef->viewport.x1 + backEnd.currentScissor.x1, 
				backEnd.viewDef->viewport.y1 + backEnd.currentScissor.y1,
				backEnd.currentScissor.x2 + 1 - backEnd.currentScissor.x1,
				backEnd.currentScissor.y2 + 1 - backEnd.currentScissor.y1 );
		}

		// render it
		triFunc_( drawSurf );

		if ( drawSurf->space->weaponDepthHack || drawSurf->space->modelDepthHack != 0.0f ) {
			RB_LeaveDepthHack();
		}

		//if( !cacheMatrix )
		if ( drawSurf->space != backEnd.currentSpace )
			backEnd.currentSpace = drawSurf->space;
	}
}

/*
======================
RB_RenderDrawSurfChainWithFunction
======================
*/
void RB_RenderDrawSurfChainWithFunction( const drawSurf_t *drawSurfs, 
										void (*triFunc_)( const drawSurf_t *) ) {
	GL_CheckErrors();
	const drawSurf_t		*drawSurf;

	backEnd.currentSpace = NULL;

	for ( drawSurf = drawSurfs ; drawSurf ; drawSurf = drawSurf->nextOnLight ) {
		// change the matrix if needed
		// Note (Serp) : this used to be ( drawSurf->space != backEnd.currentSpace) however, since it's always going to be NULL...
		if ( drawSurf->space ) 
			qglLoadMatrixf( drawSurf->space->modelViewMatrix );
		else
			return;

		// change the scissor if needed
		if ( r_useScissor.GetBool() && !backEnd.currentScissor.Equals( drawSurf->scissorRect ) ) {
			const idScreenRect &r = drawSurf->scissorRect;
			if ( r.x1 <= r.x2 && r.y1 <= r.y2 ) { // duzenko: FIXME find out why they are negative sometimes
				backEnd.currentScissor = drawSurf->scissorRect;
				/*qglScissor( backEnd.viewDef->viewport.x1 + backEnd.currentScissor.x1,
					backEnd.viewDef->viewport.y1 + backEnd.currentScissor.y1,
					backEnd.currentScissor.x2 + 1 - backEnd.currentScissor.x1,
					backEnd.currentScissor.y2 + 1 - backEnd.currentScissor.y1 );*/
				FB_ApplyScissor();
			} else
				continue; // duzenko: why bother
		}

		if ( drawSurf->space->weaponDepthHack ) 
			RB_EnterWeaponDepthHack();

		if ( drawSurf->space->modelDepthHack ) 
			RB_EnterModelDepthHack( drawSurf->space->modelDepthHack );

		// render it
		triFunc_( drawSurf );

		if ( drawSurf->space->weaponDepthHack || drawSurf->space->modelDepthHack ) 
			RB_LeaveDepthHack();

		backEnd.currentSpace = drawSurf->space;
	}
	GL_CheckErrors();
}

i have a copy of the source code before any of my changes so that i can easily revert things if they break.

I checked the other reverts also and they are an exact match besides the formatting changes, but i doubt formatting would cause this.

 

Reverting the above fixes lightning changes but causes skyportals to bleed through solids at extreme distances like this

 

e1eyv7.jpg

 

one step back the stair and its gone

 

1fgxmf.jpg

 

but theres one problem with the old code, it newer runs qglLoadMatrixf in RB_RenderDrawSurfListWithFunction because drawsurf->space is newer set,

if i comment out qglLoadMatrixf in my own version of RB_RenderDrawSurfListWithFunction light works fine also but then skyportals bleed through.

Link to comment
Share on other sites

Done.

/*
====================
RB_RenderDrawSurfListWithFunction

The triangle functions can check backEnd.currentSpace != surf->space
to see if they need to perform any new matrix setup.  The modelview
matrix will already have been loaded, and backEnd.currentSpace will
be updated after the triangle function completes.
====================
*/
void RB_RenderDrawSurfListWithFunction( drawSurf_t **drawSurfs, int numDrawSurfs, void ( *triFunc_ )( const drawSurf_t * ) ) {
	GL_CheckErrors();

	backEnd.currentSpace = nullptr;

	/* Reverted all the unnessesary gunk here */
	for ( int i = 0  ; i < numDrawSurfs ; i++ ) {
		const drawSurf_t *drawSurf = drawSurfs[i];

		if ( drawSurf->space != backEnd.currentSpace ) {
			qglLoadMatrixf( drawSurf->space->modelViewMatrix );
		}

		if ( drawSurf->space->weaponDepthHack ) {
			RB_EnterWeaponDepthHack ();
		}

		if ( drawSurf->space->modelDepthHack != 0.0f ) {
			RB_EnterModelDepthHack ( drawSurf->space->modelDepthHack );
		}

		/* change the scissor if needed
		#7627 revelator */
		if ( r_useScissor.GetBool() && !backEnd.currentScissor.Equals( drawSurf->scissorRect ) ) {
			backEnd.currentScissor = drawSurf->scissorRect;
			glScissor( backEnd.viewDef->viewport.x1 + backEnd.currentScissor.x1,
			           backEnd.viewDef->viewport.y1 + backEnd.currentScissor.y1,
			           backEnd.currentScissor.x2 + 1 - backEnd.currentScissor.x1,
			           backEnd.currentScissor.y2 + 1 - backEnd.currentScissor.y1 );
		}

		// render it
		triFunc_( drawSurf );

		if ( drawSurf->space->weaponDepthHack || drawSurf->space->modelDepthHack != 0.0f ) {
			RB_LeaveDepthHack ();
		}

		// mark currentSpace if we have drawn.
		backEnd.currentSpace = drawSurf->space;
	}
	GL_CheckErrors();
}

/*
======================
RB_RenderDrawSurfChainWithFunction
======================
*/
void RB_RenderDrawSurfChainWithFunction( const drawSurf_t *drawSurfs, void ( *triFunc_ )( const drawSurf_t * ) ) {
	GL_CheckErrors();

	backEnd.currentSpace = nullptr;

	/* Reverted all the unnessesary gunk here */
	for ( const drawSurf_t *drawSurf = drawSurfs; drawSurf; drawSurf = drawSurf->nextOnLight ) {
		if ( drawSurf->space != backEnd.currentSpace ) {
			qglLoadMatrixf( drawSurf->space->modelViewMatrix );
		}

		if ( drawSurf->space->weaponDepthHack ) {
			RB_EnterWeaponDepthHack ();
		}

		if ( drawSurf->space->modelDepthHack != 0.0f ) {
			RB_EnterModelDepthHack ( drawSurf->space->modelDepthHack );
		}

		/* change the scissor if needed
		#7627 revelator reverted and cleaned up. */
		if ( r_useScissor.GetBool() && !backEnd.currentScissor.Equals( drawSurf->scissorRect ) ) {
            const idScreenRect &r = drawSurf->scissorRect;
            if ( r.x1 <= r.x2 && r.y1 <= r.y2 ) { // duzenko: FIXME find out why they are negative sometimes
                backEnd.currentScissor = drawSurf->scissorRect;
                FB_ApplyScissor();
            } else {
                continue; // duzenko: why bother
            }
		}

		// render it
		triFunc_( drawSurf );

		if ( drawSurf->space->weaponDepthHack || drawSurf->space->modelDepthHack != 0.0f ) {
			RB_LeaveDepthHack ();
		}

		// mark currentSpace if we have drawn.
		backEnd.currentSpace = drawSurf->space;
	}
	GL_CheckErrors();
}

Removed all the unnessesary gunk, lights works

Link to comment
Share on other sites

            const idScreenRect &r = drawSurf->scissorRect;
            if ( r.x1 <= r.x2 && r.y1 <= r.y2 ) { // duzenko: FIXME find out why they are negative sometimes
                backEnd.currentScissor = drawSurf->scissorRect;
                FB_ApplyScissor();
            } else {
                continue; // duzenko: why bother
            }

Can skip most of the checking in this part as well without breaking things it seems.

fhDoom checks for scissor width / height there so it seems it is not totally on the wrong track, but i wonder about that continue; fhDoom simply returns there if scissor width / height does not match the viewport width / height.

But even that seems a bit of a stretch, because we basically newer draw the triFunc_ pointer if it fails. But if theres some hidden logic to it im all ears. If i should guess what would be appropriate then we do it with duzenkos check so that scissoring only runs if dimensions are not negative but remove the continue; part so that we dont suddenly skip rendering something. Not sure if i make sense ?.

 

crucible of omens is so far the only map where i had the skyportal bleeding through bug, so there might be something that needs looking at there.

Link to comment
Share on other sites

The portal issue in Crucible is present in my old 2.04 SS build so it's likely just a bit

of really aggressive func_portal work to make that area play smooth. We really need

auto-billboards like Overgrowth has to mask func_portals with a static screenshot of the

view behind them.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

but theres one problem with the old code, it newer runs qglLoadMatrixf in RB_RenderDrawSurfListWithFunction because drawsurf->space is newer set,

if i comment out qglLoadMatrixf in my own version of RB_RenderDrawSurfListWithFunction light works fine also but then skyportals bleed through.

Sorry, don't understand

 

See attached

post-3508-0-46900000-1534922144_thumb.png

Link to comment
Share on other sites

Its a loop, think of it this way

 

backend.currentspace is set to NULL at start

 

if ( drawSurf->space != backEnd.currentSpace ) load the matrix cause drawSurf->space is not "allways" equal to backEnd.currentSpace which is NULL at start

 

if ( drawSurf->space->weaponDepthHack ) do a depth hack on viewmodel, this is set elsewhere

 

if ( drawSurf->space->modelDepthHack != 0.0f ) do a depth hack on other models ditto

 

backend.currentscissor = empty

 

if ( r_useScissor.GetBool() && !backEnd.currentScissor.Equals( drawSurf->scissorRect ) ) do scissoring and set backEnd.currentScissor to the value of drawSurf->scissorRect; to mark it as equal so that we dont have to run it again

 

triFunc_( drawSurf ); render whatever function we need to run with the above, for instance RB_T_BlendLight

 

if ( drawSurf->space->weaponDepthHack || drawSurf->space->modelDepthHack != 0.0f ) disable depth hacks

 

backEnd.currentSpace = drawSurf->space; tell the loop that we are done and set backEnd.currentSpace to the value of drawSurf->space which is not NULL

 

 

what the old code did was

 

 

if ( drawSurf->space ) load the matrix if drawSurf->space != NULL or else return from the function, well we just disabled the rest of the code if that happened

 

if ( r_useScissor.GetBool() && !backEnd.currentScissor.Equals( drawSurf->scissorRect ) ) same as original with one twist

 

we had a continue after the above if the scissor was negative skipping triFunc_( drawSurf ); and newer disabling depth hacks, so we where newer rendering any function that went through here in case the scissor was negative, luckily that seems to not happen often

 

if ( drawSurf->space->weaponDepthHack ) same as old one

 

if ( drawSurf->space->modelDepthHack ) ditto

 

triFunc_( drawSurf ); ditto

 

if ( drawSurf->space->weaponDepthHack || drawSurf->space->modelDepthHack ) ditto

 

backEnd.currentSpace = drawSurf->space; ditto

 

luckily the conditions that i mentioned above dont happen often, but as steveL also pointed out

 

// Note (SteveL) : FIXME: It *won't* always be NULL, we're in a loop and it gets set at the end. This change might be wiping out

// all (marginal) benefits from sorting DrawSurfs by material, as it'll cause a blocking change in GL state on every draw

 

and he was absolutely right.

 

Clear now how this function works ? :)

  • Like 1
Link to comment
Share on other sites

try replacing it with this just for laughs, but be aware that the console spam will pretty much kill performance.

void RB_RenderDrawSurfChainWithFunction( const drawSurf_t *drawSurfs, void ( *triFunc_ )( const drawSurf_t * ) ) {
	GL_CheckErrors();

	backEnd.currentSpace = nullptr;

	/* Reverted all the unnessesary gunk here */
	for ( const drawSurf_t *drawSurf = drawSurfs; drawSurf; drawSurf = drawSurf->nextOnLight ) {
		if ( drawSurf->space != backEnd.currentSpace ) {
			common->Printf( "Yay i just loaded the matrix\n" );
			qglLoadMatrixf( drawSurf->space->modelViewMatrix );
		}

		if ( drawSurf->space->weaponDepthHack ) {
			common->Printf( "Yay i just ran a depth hack on viewmodels\n" );
			RB_EnterWeaponDepthHack ();
		}

		if ( drawSurf->space->modelDepthHack != 0.0f ) {
			common->Printf( "Yay i just ran a depth hack on other models\n" );
			RB_EnterModelDepthHack ( drawSurf->space->modelDepthHack );
		}

		/* change the scissor if needed
		#7627 revelator reverted and cleaned up. */
		if ( r_useScissor.GetBool() && !backEnd.currentScissor.Equals( drawSurf->scissorRect ) ) {
			common->Printf( "Yay i just ran the scissor\n" );
			backEnd.currentScissor = drawSurf->scissorRect;
			FB_ApplyScissor();
		}

		// render it
		common->Printf( "Yay i just ran a function\n" );
		triFunc_( drawSurf );

		if ( drawSurf->space->weaponDepthHack || drawSurf->space->modelDepthHack != 0.0f ) {
			common->Printf( "Booh i just disabled the depth hacks\n" );
			RB_LeaveDepthHack ();
		}

		// mark currentSpace if we have drawn.
		common->Printf( "Yay i just determined that i need to run again\n" );
		backEnd.currentSpace = drawSurf->space;
	}
	GL_CheckErrors();
}

You will see it works as said ;)

  • Like 1
Link to comment
Share on other sites

heres one with a bit more explanation

 

crystalgrave2_1_2018_08_22_13_44_11.jpg

 

as you can see it is not allways NULL

 

edit: the i determined that i need to run again should be dont need to run again, i forgot to add that to the console print.

 

but basically its sound now, this is the way id did it originally and it works so please do not do something in there unless you are absolutely 100% certain that it wont affect things down the line.

If say you want to make sure the scissor does not run on negative scissor values, then make a seperate function to do that and then load it where the scissor code was, so that it does not affect the rest of the function.

i allready did that with the FB_ApplyScissor function.

  • Like 1
Link to comment
Share on other sites

Yep. That one can be improved via: g_enablePortalsky 1

 

The default option "2" has trouble with the way Biker arranged the portals up there.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

The portal in BCD closes too early as seen with r_showportals 1.

Is it worth investigating?

 

BTW wow that mission is heavy...

After a quick look, the portal is opened/closed by a FuncPortal event, based on the condition "square-distance > 1562500.00". Case closed?

 

@revelator

Did you test that negative r_softshadowsquality is working? It's not for me.

		glScissor( x, y, width, height );

This might break the Linux build.

Please see https://ci.appveyor.com/project/thedarkmod/trunk/build/2.07.20 for more details

Link to comment
Share on other sites

 

glScissor( x, y, width, height ); This might break the Linux build.

 

 

did i forget to prefix it with q ? :mellow: ill check in a min.

 

 

Did you test that negative r_softshadowsquality is working? It's not for me

 

Might be because the scissor check in FB_ApplyScissor discards negative values, ill just remove the check and all should pass then.

Link to comment
Share on other sites

Ah not all negative values will work i just noticed, for instance if set to -1 the shadows break up all over the place, but using the same values as set by the menu just with - in front they work but they are not soft.

 

Also they dont show up correctly in screenshots agh :( but with 6 24 46 96 values they work fine, much higher than that and some weird things happen,

so we should probably clamp them to some reasonable values.

 

If we want to use negative values for softness also we could probably convert the negative values to positive ones if we want, or does linux expect negative values ?

Link to comment
Share on other sites

Ah GL_INVALID_VALUE is generated if either width or height is negative. so yes it was the check for negative values causing this.

Sadly glScissor expects positive values or things will break according to khronos it seems.

 

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glScissor.xhtml

 

and same goes for viewport it seems.

 

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glViewport.xhtml

Link to comment
Share on other sites

Negative values only mean that shadows are drawn in the low-res stencil buffer. It's not softening anything at the moment but it must still show correct, although pixelated shadows at values -25, -50, -100.

Please check that it works that way.

Link to comment
Share on other sites

Ah i see now, you allready made changes to correct it.

 

I had some trouble understanding exactly what you wanted so i surmised that it might have been from the code i accidentally deleted,

but i could not find anything that differed from previous code besides the changes you comitted later, and they where also yanked in.

 

Well atleast my utility functions should make it a bit more fun :) no need for qglColor3f or qglColor4f or qglColor4ub just use GL_FloatColor or GL_ByteColor the overloads will handle the rest.

Not that i hope anyone would use the old immediate mode functions for anything in an engine like idtech4, but seems some of the code still uses them.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • Ansome

      Finally got my PC back from the shop after my SSD got corrupted a week ago and damaged my motherboard. Scary stuff, but thank goodness it happened right after two months of FM development instead of wiping all my work before I could release it. New SSD, repaired Motherboard and BIOS, and we're ready to start working on my second FM with some added version control in the cloud just to be safe!
      · 0 replies
    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
×
×
  • Create New...