[Question] Depth Cueing fog + texture

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

[Question] Depth Cueing fog + texture

Post by NITROYUASH » September 26th, 2019, 4:44 am

Hi PSXDEV :>

Using something like DpqColor (or GTE variations like gte_dpcs), i can make a interesting effects like fog.
Thanks to SetBackColor and SetFarColor i can change front/back colors. It's looks good when i uses the non-textured objects/geometry.
► Show Spoiler
But it's works differently with the textured objects.
► Show Spoiler
I can change the color, but as you can see, i just can't hide the texture. It always visible when I try to use something other than black.

Is it possible to do something for this WITHOUT change actual texture or CLUT?

Thanks for the answers :>

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 381
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Re: [Question] Depth Cueing fog + texture

Post by LameGuy64 » September 26th, 2019, 10:59 pm

To get proper color modulation for textures, you'll have to use a method called CLUT fog, where you have multiple CLUT entries stacked vertically of the CLUT transitioning from its original colors down to a solid color of your fog. The CLUT selected is based on the depth of the polygon primitive.

Currently, there are no tools that can generate a CLUT fog, but you can procedurally generate it on the fly. I'll need a bit of time to figure this one out first before I can post a code snippet.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: [Question] Depth Cueing fog + texture

Post by NITROYUASH » September 27th, 2019, 12:13 am

Yes i saw some samples from Psy-Q. I found this example and play with it right now:

Code: Select all

/* 	Sony Computer Entertainment CLUT-FOG maker
		rtim: CLUT position (RECT)
		ctim: insert CLUT here
		num: Depth size to save in VRAM			*/
void sce_make_fog_clut(RECT *rtim, u_short *ctim, long num) {

    long i,j;
    long stp;
    long p;

    u_short newclut[256];

    CVECTOR orgc, newc;
    RECT rect;

    rect.x = rtim->x;
    rect.w = rtim->w;
    rect.h = rtim->h;

    for (i = 0; i < num; i++) {
		p = i * ONE / num;				// p = depth queue parameter

		for (j = 0; j < rtim->w; j++) {
	
		    if (ctim[j] == 0) {		// no interpolation when transparent
				newclut[j] = ctim[j];
		    } else {
				// decompose the clut into RGB
				orgc.r = (ctim[j] & 0x1f) << 3;
				orgc.g = ((ctim[j] >> 5) & 0x1f) << 3;
				orgc.b = ((ctim[j] >> 10) & 0x1f) << 3;
				stp	   = ctim[j] & 0x8000;
		
				// interpolate each RGB and BG color
				gte_DpqColor(&orgc, p, &newc);
	
				// reconstruct CLUT with FOG
				newclut[j] = stp | (newc.r >> 3)
					    		 | (((u_long)(newc.g & 0xf8)) << 2)
								 | (((u_long)(newc.b & 0xf8)) << 7);
		    }
		}

		/* next Y axis */
		rect.y = rtim->y + i;
	
		/* load to VRAM */
		LoadImage(&rect,(u_long *)newclut);
    }
}
For some reasons it will make incorrect CLUT from AGsIMAGE struct so i need to solve this problem before i am actually can test it on my 3d objects.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: [Question] Depth Cueing fog + texture

Post by NITROYUASH » September 28th, 2019, 6:52 am

I made it :>
Tested on 4b textures

Code: Select all

// DPQ FOG CLUT
typedef struct {
	u_long		*timaddr;
	CVECTOR		fog_clr;
	u_short 	cdpq;
} DPQCLUT;

int clut_dpq_fog(DPQCLUT *dclut) {

	long stp;
	long p,i,j;

	TIM_IMAGE timinfo;
	CVECTOR ccout;
	RECT rect;

	u_short *clut;
	u_short newclut[256];

	// Open TIM file
	if (OpenTIM(dclut->timaddr) != 0)
		return (-1);

	// Read TIM file data
	ReadTIM(&timinfo);

	// Load CLUT to VRAM 
	LoadImage(timinfo.crect, timinfo.caddr);
	DrawSync(0);
    
	// Transfer CLUT data to out RECT
	rect.x = timinfo.crect->x;
	rect.y = timinfo.crect->y;
	rect.w = timinfo.crect->w;
	rect.h = timinfo.crect->h;
	clut = (u_short*)timinfo.caddr;

	for (i = 0; i < dclut->cdpq; i++) {

		// p = depth queue parameter
		p = i * ONE / dclut->cdpq;

		for (j = 0; j < rect.w; j++) {

		    if (clut[j] == 0) {				// No interpolation when transparent
				newclut[j] = clut[j];
		    } else {

				// Decompose original CLUT into RGB
				dclut->fog_clr.r = (clut[j] & 0x1f) << 3;
				dclut->fog_clr.g = ((clut[j] >> 5) & 0x1f) << 3;
				dclut->fog_clr.b = ((clut[j] >> 10) & 0x1f) << 3;
				stp				 = clut[j] & 0x8000;
		
				// Interpolate each RGB and BG color
				gte_DpqColor(&dclut->fog_clr, p, &ccout);
	
				// Reconstruct CLUT with FOG
				newclut[j] = stp | (ccout.r >> 3)
					    		 | (((u_long)(ccout.g & 0xf8)) << 2)
								 | (((u_long)(ccout.b & 0xf8)) << 7);

		    }
		}

		rect.y = timinfo.crect->y + i;

		// load to VRAM
		LoadImage(&rect,(u_long *)newclut);
		DrawSync(0);
	}
	return (0);
}
► Show Spoiler
So this is why CLUT in VRAM from some games contains so many copies with different colors...

rama3
/// PSXDEV | ELITE ///
/// PSXDEV | ELITE ///
Posts: 508
Joined: April 16th, 2017, 10:54 pm

Re: [Question] Depth Cueing fog + texture

Post by rama3 » September 29th, 2019, 3:20 am

NITROYUASH and LameGuy64,
I'm terribly sorry for asking this here, but you guys seem to know your PSX dev! :p

Do you know what the maximum active video area of the console is?
It doesn't matter what the image data source is, so a CPU generated chequerboard pattern for example would work.
I just need it to occupy as much of the available display width as possible.
Any GPU dotclock is fine.

Thanks :)

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: [Question] Depth Cueing fog + texture

Post by NITROYUASH » September 29th, 2019, 10:55 pm

You mean the biggest video resolution?

If i understand you correctly:
640x480 NTSC and 640x512 PAL

rama3
/// PSXDEV | ELITE ///
/// PSXDEV | ELITE ///
Posts: 508
Joined: April 16th, 2017, 10:54 pm

Re: [Question] Depth Cueing fog + texture

Post by rama3 » September 30th, 2019, 8:42 am

And is there no way to draw outside these boundaries?
This might not be documented in any SDK.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: [Question] Depth Cueing fog + texture

Post by NITROYUASH » September 30th, 2019, 10:15 am

The only thing than you can draw outside screen resolution is the textures, UI elements (fonts, interface graphics...), CLUT (4b/8b palette) and something like this. I never saw a game that actually uses the screen more than the 640x480/512. But you can change the resolution on the fly. I mainly use 320x240 resolution. This is the most common resolution for this system, but this is the not the perfect, i read a lot about a games that runs under the non-common resolution like Wip3out (512x240).

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 381
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Re: [Question] Depth Cueing fog + texture

Post by LameGuy64 » September 30th, 2019, 1:44 pm

You can use a DR_ENV primitive to change the active drawing area to some place outside your display/draw areas for off-screen rendering. This can be used as a way to accomplish render to texture based effects.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

rama3
/// PSXDEV | ELITE ///
/// PSXDEV | ELITE ///
Posts: 508
Joined: April 16th, 2017, 10:54 pm

Re: [Question] Depth Cueing fog + texture

Post by rama3 » October 1st, 2019, 4:01 am

Perfect, thanks for letting me know. So basically "something is/may be possible" :p

The reason I'm asking is that I love the PSX as a very clean source of retro / 15kHz video.
I'd like to extend the PSX port of the 240p test suite to include such a drawing area test.
This is to help develop my open source upscaler project.
https://github.com/filipalac/240pTestSuite-PS1
https://github.com/ramapcsx2/gbs-control

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest