Q2 ref_soft replacement with colored light

Discuss anything not covered by any of the other categories.
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Q2 ref_soft replacement with colored light

Post by qbism »

Anyone want to betatest a replacement ref_soft.dll that adds colored lighting and widescreen waterwarp support to the Quake 2 software renderer? Alphatest and transparency are improved as a bonus. Not to mention the ddraw palette problem fixed- this one only uses DIB even for fullscreen! Knightmare's 'unofficial Q2 patch' 3.24 is supported, although haven't tried it on any others.

[EDIT: r_coloredlights 0 and fullscreen mode fixed. I hope. Same download links.]
[EDIT2: Added r_lightsaturation cvar for colored light]
[EDIT3: Minor speed improvement, darklight works, and just one (the pretty one!) colored light mode.]
[EDIT4: Unsigned short fix (thanks to Knightmare for the tip) http://forums.inside3d.com/viewtopic.php?f=3&t=5308]


Oh, yeah, and there's a cvar called 'sw_transmooth' that dithers transparent surfaces.

Download dll [edit-updated link]: http://qbism.com/_extfiles/ref_soft_color.zip

Source code: http://qbism.com/_extfiles/ref_soft_color_src.zip

Notes about the code- It can be copied into the 3.24 source folder. (Make a backup for this purpose.) But I don't have VC 6, so I built it with VS 2013 (project included in the ref_soft folder).
This started with the colored light code leilei added to stock Q2. Shaded light was completed among other things with head-scratching and borrowed pieces of engoo. Waterwarp improvement and dithering are from AROS Quake2.

Image
That orange. r_lightsaturation = 2
Last edited by qbism on Sun Jun 22, 2014 4:23 pm, edited 5 times in total.
dwere
Posts: 11
Joined: Tue Dec 31, 2013 11:19 pm

Re: Q2 ref_soft replacement with colored light

Post by dwere »

Looks better than I thought it would. But I can't set fullscreen mode for some reason. I'm using the aformentioned 3.24 exe.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Q2 ref_soft replacement with colored light

Post by leileilol »

BTW, r_coloredlights 2 enables 3dfxgl.dll-estimated gamma corrected lighting


Also I can't go fullscreen either and the rendering feels slow at 1280x960. Wish this retained the ASM...
i should not be here
dwere
Posts: 11
Joined: Tue Dec 31, 2013 11:19 pm

Re: Q2 ref_soft replacement with colored light

Post by dwere »

It's a shame r_coloredlights 0 works as 1. It would be nice to have an all-purpose dll.
Spiney
Posts: 63
Joined: Mon Feb 13, 2012 1:35 pm

Re: Q2 ref_soft replacement with colored light

Post by Spiney »

Don't have Q2 handy, but is it possible to do dithering for multitexture blending? That would be really cool.

edit: just to be clear, I meant mixing color of lighting and level textures "as if" in 24 bit and turning it to 8 bit dither. Not bilinear filtering with dither.
Last edited by Spiney on Mon May 19, 2014 11:38 am, edited 2 times in total.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Q2 ref_soft replacement with colored light

Post by leileilol »

Engoo has a dithering mode so yes it would be possible.
i should not be here
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: Q2 ref_soft replacement with colored light

Post by qbism »

fullscreen: Probably lost something in the /win32 source files. Might have missed something in a diff.

r_coloredlights 0: It's broken but should be easy fix.

asm: Not sure how to get it to compile in Visual Studio.

dither: currently implemented for transparencies, r_transmooth 0/1 cvar.

I wonder if there should be a saturation factor for colored lights. SW colored light looks more saturated than GL.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Q2 ref_soft replacement with colored light

Post by leileilol »

Again, wrong term of 'dither'. That is a pixel filtering technique. What I refer to is color reduction via dithering.
i should not be here
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: Q2 ref_soft replacement with colored light

Post by qbism »

Please re-download via links above, I attempted to fix fullscreen and r_coloredlights = 0 modes.

The code uses an ordered dithered kernel per http://www.flipcode.com/archives/Textur ... real.shtml
It is only implemented on transparent R_DrawSpan polys. It looks good on turbulent spans, but a mixed bag everywhere else. I haven't looked at how engoo does it.

BTW, anyone ported Q1 or Q2 code base including asm from VC++ 6 to VS 2008 or higher? When I tried it, compiler doesn't give errors but linker can't find the objs.
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: Q2 ref_soft replacement with colored light

Post by qbism »

Just fixed a bug with transparent flags in r_poly, and added r_lightsaturation cvar.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Q2 ref_soft replacement with colored light

Post by revelator »

if i remember correctly you need to encapsulate the asm calls in quotes eg " " in msvc after version 6.
Productivity is a state of mind.
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: Q2 ref_soft replacement with colored light

Post by qbism »

Thanks, but now I think that inline asm works as-is. The .asm were the trouble. These files compiled by checking masm in Build Customizations menu. I attempted to disable asm functions that would require modification for colored lighting. Everything compiled without error but dll crashes on map load. I'm just going to leave asm off.

Color-reduction dither- this is a big improvement for Quake, but Q2 is not so bad without it. Probably won't go through the expense of the extra lookups:

Code: Select all

							if (dodith){
								det++;
								if (det > 3) det = 0;
						llight = smoothtable[llightd][det]; // leilei - dithered shading	
						if (coloredlights){
							llightrgb[0] = smoothtable[llightrgbd[0]][det];
							llightrgb[1] = smoothtable[llightrgbd[1]][det];
							llightrgb[2] = smoothtable[llightrgbd[2]][det];
						}
Someone could add it easily though.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Q2 ref_soft replacement with colored light

Post by leileilol »

The dithering I refer to involves the span drawing code along with the surfmip code (to build a 15bpp surfacecache for the spans to dither with).

Play Engoo with Colored Lighting set to "Ultra (Dither)" in 320x200 or so, take a screen capture then zoom in to see what I mean.

And it's worth knowing you'll never need a table bigger than 18-bit since 256 color palettes work strictly in an 18-bit color depth. and a dithering table for 18-bit would be huge so stick to 15bpp for that for now.


The code you just picked is just regards to models, which is intended to apply noise to the light to rough out the banded lighting lookup. Also note that I did not implement model colored lighting the same way in Q2 - I cheated with a post-color calculation, so this feature ported over would be completely useless.
i should not be here
dwere
Posts: 11
Joined: Tue Dec 31, 2013 11:19 pm

Re: Q2 ref_soft replacement with colored light

Post by dwere »

I played the entire Ground Zero with this. Everything was fine until the last level. There's a room containing an unusual lighting trick - a sphere emitting "black light" constantly fading in and out. Everything works as it should with r_coloredlights 0:
http://i.imgur.com/8QMgvkm.png

r_coloredlights 1:
http://i.imgur.com/LETqeGl.png

r_coloredlights 2:
http://i.imgur.com/qS04Ymp.png
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Q2 ref_soft replacement with colored light

Post by revelator »

i was refering to the .asm files :)
though im not sure if quake2 uses the same method.
quake1 used a tool called gas2masm to convert gnu style asm to masm.
Productivity is a state of mind.
Post Reply