UQE Ultimate Quake Engine ?

Discuss anything not covered by any of the other categories.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

I would have alook at the source if i could but it seems the site has a captcha which none of my browsers will show :S so i cannot download it.
Productivity is a state of mind.
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: UQE Ultimate Quake Engine ?

Post by qbism »

revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

And then it wants me to install a browser addon eh ??? no thanks. :P
Productivity is a state of mind.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

Sandboxed the site and got the source.

A few things i notice.

Its based on the old jshexen2 source from the dev of Qoole with additions from UQE and some work from him self.
Project file is made for msvc6 and some of the typedefs are incompatible with msvc2010 so i cannot compile it as is.
So i might try and move stuff from the source to hammer of thyrion source which compiles fine with msvc2010.
Productivity is a state of mind.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

Ok added DDS texture support and texture lerping.

loading charsets / fonts etc. needs some work (wrong scaling) conback works though.

theres also some suspicious code here according to intels compiler.

memmove(dat->data + 157*85, dat->data + 157*104, 157*(112 - 104));
warning #170: pointer points outside of underlying object.

looks good else :)

DDS is working allthough i think my conversion may be wrong it loads them but some textures have a blue tint.
Productivity is a state of mind.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

ok DDS needs special handling and cannot just be converted like other textures.
For one if it has an alpha channel things will look really wrong when converted to DDS.

Besides that i think i fixed all the texture flags to be correct now.
I only got one bugger with a sprite that seems to be missing an alpha channel but its not related to the external version as the ingame version also bugs out.
The one in question is the magic missile from the necromancer which has square dark borders. I cannot fix this bug in code so a new version has to be made.
All other sprites seem to behave as they should.

resting my case and uploading the final version soon :)
im not going to make it a project of mine (got to many allready heh) but since hammer of thyrion allready has a maintainer hees welcome to use my changes.
Productivity is a state of mind.
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: UQE Ultimate Quake Engine ?

Post by toneddu2000 »

[UTournament Voice]reckless is in a coding spree![/UTournament Voice] :D
Meadow Fun!! - my first commercial game, made with FTEQW game engine
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

Productivity is a state of mind.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

necro missile is a content bug :) replace the ball.mdl with the one from portals and all is good.

DDS loader code here if anyone want to toy with it.

Im not sure but i think it may be buggy ?.

Code: Select all

/*
=============
DDS LOADING
=============
*/
typedef struct
{
	unsigned int dwColorSpaceLowValue;
	unsigned int dwColorSpaceHighValue;
} dds_colorkey;

typedef struct
{
	unsigned int magic;
	unsigned int dwSize;
	unsigned int dwFlags;
	unsigned int dwHeight;
	unsigned int dwWidth;
	long lPitch;
	unsigned int dwDepth;
	unsigned int dwMipMapCount;
	unsigned int dwAlphaBitDepth;
	unsigned int dwReserved;
	void *lpSurface;
	dds_colorkey ddckCKDestOverlay;
	dds_colorkey ddckCKDestBlt;
	dds_colorkey ddckCKSrcOverlay;
	dds_colorkey ddckCKSrcBlt;
	unsigned int dwPFSize;
	unsigned int dwPFFlags;
	unsigned int dwFourCC;
	unsigned int dwRGBBitCount;
	unsigned int dwRBitMask;
	unsigned int dwGBitMask;
	unsigned int dwBBitMask;
	unsigned int dwRGBAlphaBitMask;
	unsigned int dwCaps;
	unsigned int dwCaps2;
	unsigned int dwCaps3;
	unsigned int dwVolumeDepth;
	unsigned int dwTextureStage;
} dds_header;

typedef struct
{
	unsigned char r;
	unsigned char g;
	unsigned char b;
} dds_color;

enum
{
	DDS_ERROR = -1,
	DDS_RGB,
	DDS_RGBA,
	DDS_DXT1,
	DDS_DXT2,
	DDS_DXT3,
	DDS_DXT4,
	DDS_DXT5
};

enum 
{
	DDPF_ALPHAPIXELS = 0x01,
	DDPF_FOURCC = 0x04,
	DDPF_RGB = 0x40,
	DDPF_RGBA = 0x41
};

byte *LoadDDS(char *name, FILE *fin)
{
	int				format, image_size, x, y, w, h, i, j;
	unsigned char	*image_rgba, *buf, *src, *dest;
	unsigned int	c0, c1;
	dds_header		header;
	dds_color		color[4];

	/* load file */
	if (!fin && FS_OpenFile(name, &fin, NULL) == -1)
	{
		return NULL;
	}
	fread(&header, sizeof(dds_header), 1, fin);

	if(header.magic != ('D' | 'D' << 8 | 'S' << 16 | ' ' << 24))
	{
		Con_Printf ("%s : Malformed dds image\n", name);
		goto BadDDS;
	}

	if	(header.dwPFFlags & DDPF_FOURCC)
	{
		if		(header.dwFourCC == ('D' | ('X' << 8) | ('T' << 16) | ('1' << 24))) format = DDS_DXT1;
		else if	(header.dwFourCC == ('D' | ('X' << 8) | ('T' << 16) | ('2' << 24))) format = DDS_DXT2;
		else if	(header.dwFourCC == ('D' | ('X' << 8) | ('T' << 16) | ('3' << 24))) format = DDS_DXT3;
		else if	(header.dwFourCC == ('D' | ('X' << 8) | ('T' << 16) | ('4' << 24))) format = DDS_DXT4;
		else if	(header.dwFourCC == ('D' | ('X' << 8) | ('T' << 16) | ('5' << 24))) format = DDS_DXT5;
		else 																		format = DDS_ERROR;
	}
	else if	(header.dwPFFlags == DDPF_RGB && header.dwRGBBitCount == 24) 
	{
		format = DDS_RGB;
	}
	else if	(header.dwPFFlags == DDPF_RGBA && header.dwRGBBitCount == 32)
	{
		format = DDS_RGBA;
	}

	if	(format == DDS_ERROR) 
	{
		goto BadDDS;
	}

	if(format == DDS_DXT2 || format == DDS_DXT4)
	{
		goto BadDDS;
	}
	image_width = w = header.dwWidth;
	image_height = h = header.dwHeight;
	image_size = (w * h * 4);
	image_rgba = (byte *) calloc(image_size, 1);

	if(format == DDS_RGB) 
	{
		buf = (byte *) malloc(w * h * 3);
		fread(buf, w * h * 3, 1, fin);
		src = buf;
		dest = image_rgba;

		for(y = 0; y < h; y++) 
		{
			for(x = 0; x < w; x++) 
			{
				*dest++ = *src++;
				*dest++ = *src++;
				*dest++ = *src++;
				*dest++ = 255;
			}
		}
		free(buf);
	}
	else if(format == DDS_RGBA)
	{
		buf = (byte *) malloc(w * h * 4);
		fread(buf, w * h * 4, 1, fin);
		src = buf;
		dest = image_rgba;

		for(y = 0; y < h; y++)
		{
			for(x = 0; x < w; x++)
			{
				*dest++ = *src++;
				*dest++ = *src++;
				*dest++ = *src++;
				*dest++ = *src++;
			}
		}
		free(buf);
	}
	else 
	{
		buf = (byte *) malloc(w * h);
		src = buf;
		fread(buf, w * h, 1, fin);

		for(y = 0; y < h; y += 4)
		{
			for(x = 0; x < w; x += 4)
			{
				unsigned long alpha = 0;
				unsigned int a0 = 0;
				unsigned int a1 = 0;

				if(format == DDS_DXT3) 
				{
					alpha = *(unsigned long*)src;
					src += 8;
				} 
				else if(format == DDS_DXT5) 
				{
					alpha = (*(unsigned long *)src) >> 16;
					a0 = src[0];
					a1 = src[1];
					src += 8;
				}
				c0 = *(unsigned short *)(src + 0);
				c1 = *(unsigned short *)(src + 2);
				src += 4;

				color[0].r = ((c0 >> 11) & 0x1f) << 3;
				color[0].g = ((c0 >> 5) & 0x3f) << 2;
				color[0].b = (c0 & 0x1f) << 3;
				color[1].r = ((c1 >> 11) & 0x1f) << 3;
				color[1].g = ((c1 >> 5) & 0x3f) << 2;
				color[1].b = (c1 & 0x1f) << 3;

				if(c0 > c1) 
				{
					color[2].r = (color[0].r * 2 + color[1].r) / 3;
					color[2].g = (color[0].g * 2 + color[1].g) / 3;
					color[2].b = (color[0].b * 2 + color[1].b) / 3;
					color[3].r = (color[0].r + color[1].r * 2) / 3;
					color[3].g = (color[0].g + color[1].g * 2) / 3;
					color[3].b = (color[0].b + color[1].b * 2) / 3;
				} 
				else 
				{
					color[2].r = (color[0].r + color[1].r) / 2;
					color[2].g = (color[0].g + color[1].g) / 2;
					color[2].b = (color[0].b + color[1].b) / 2;
					color[3].r = 0;
					color[3].g = 0;
					color[3].b = 0;
				}

				for(i = 0; i < 4; i++) 
				{
					unsigned int index = *src++;
					unsigned char *dest = image_rgba + (w * (y + i) + x) * 4;

					for(j = 0; j < 4; j++) 
					{
						*dest++ = color[index & 0x03].r;
						*dest++ = color[index & 0x03].g;
						*dest++ = color[index & 0x03].b;

						if(format == DDS_DXT1) 
						{
							*dest++ = ((index & 0x03) == 3 && c0 <= c1) ? 0 : 255;
						}
						else if(format == DDS_DXT3) 
						{
							*dest++ = (unsigned char)((alpha & 0x0f) << 4);
							alpha >>= 4;
						}
						else if(format == DDS_DXT5) 
						{
							unsigned int a = (unsigned int)(alpha & 0x07);

							if(a == 0) 
							{
								*dest++ = a0;
							}
							else if(a == 1) 
							{
								*dest++ = a1;
							}
							else if(a0 > a1) 
							{
								*dest++ = ((8 - a) * a0 + (a - 1) * a1) / 7;
							}
							else if(a > 5) 
							{
								*dest++ = (a == 6) ? 0 : 255;
							}
							else 
							{
								*dest++ = ((6 - a) * a0 + (a - 1) * a1) / 5;
							}
							alpha >>= 3;
						} 
						else 
						{
							*dest++ = 255;
						}
						index >>= 2;
					}
				}
			}
		}
		free(buf);
	}
	fclose(fin);
	return image_rgba;

BadDDS:;
	fclose (fin);
	return NULL;
}
Productivity is a state of mind.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: UQE Ultimate Quake Engine ?

Post by Spike »

GL_EXT_texture_compression_s3tc
void (APIENTRY *qglCompressedTexImage2DARB) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3


those defines are the 'internalformat' argument you should be using for the relevent compression type. Use it instead of glTexImage2D.
If you're loading a dds texture without supporting the mipmaps, as well as decompressing any compression then you basically defeat the entire point of supporting dds textures in the first place.

plus decompression of dxt textures is supposedly patented, so the only legal way is to get the licensed driver to do it for you. I'm not sure but that patent MAY have been invalidated, but I've not really validated those claims so check yourself.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

Thanks spike :)
I guess it must have been cause else the Doom3 source release would be in trouble as it uses DDS hmm ?.

Ill check but in case its ok ill use your input to finish it up :)
Productivity is a state of mind.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: UQE Ultimate Quake Engine ?

Post by Spike »

doom3 has tga fallbacks in case the drivers don't support s3tc extensions. the patent is on dxt1/3/5 not on dds, like I say, use the s3tc extension, get the licensed drivers to do the decoding, and there's no patent in your code costing you money and thus no gpl nonredistributability issues (beyond what should reasonably be arguable as part of the system).
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

Ill check it out thanks.
Productivity is a state of mind.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: UQE Ultimate Quake Engine ?

Post by revelator »

Think i found where it was mentioned.
In September 2011, Intel employee Ian Romanick mentioned that the S3TC patent had been marked as invalid in patent litigation between Apple and HTC
Its not been tried in court yet so probably better to do it your way untill we know for sure.
Productivity is a state of mind.
xaGe
Posts: 465
Joined: Wed Mar 01, 2006 8:29 am
Location: Upstate, New York
Contact:

Re: UQE Ultimate Quake Engine ?

Post by xaGe »

I've always loved Hexen2 with the newhexen engine myself. If only hexen 2 would run in Darkplaces..drrooool.... :lol:
Post Reply