I've been playing around a little with Doom 3's main interaction shader. This is something I likely could have done before the source release (although getting the env params from the vertex shader into the fragment shader may have been slightly tricksy), but it's fun to do it now.
So, pretty much everything that was in the vertex shader has now moved over to the fragment shader, normalization is done using math instead of the cubemap, some internal 0..1 clamping has been removed, the specular exponent has moved to math too, and the normal map has been renormalized after doing the texture lookup.
The end result is quite surprising, and looks somewhat different to the way the original game looked.
Before discussing that, it's fair to say that this is now quite a heavy fragment shader. Obviously running on Doom 3's original target hardware is out of the question; we need to jump quite a few hardware generations to get performance up again (not to mention better support for the higher instruction count). One you do get reasonable support, it runs quite well - minimal performance difference (confirming that the engine was CPU-bound on my machine) and locking at a fairly steady 60 fps (the cases where it drops below are ones where it would have done so previously anyway).
So the end result? The quality improvement is nothing short of astonishing. The original looked pretty grungy in places, but everything just smooths out now and looks really clean and solid. The bump mapping is particularly appealing, but specular highlights also tighten up and gain clarity and definition.
Did I mention bumpmaps? These turned out to be really really good. There's an extra level of quality here, and I'm frequently walking up to objects, walking around them, looking at them from different angles, trying to figure if they're actual real geometry or just bumpmapped. The original didn't survive this kind of close inspection.
Specular highlights have changed. As well as being tighter, sharper, and in no way smudgy, they're also a good deal brighter. Part of that was removal of the specular lookup texture and replacing it with a POW instruction, part of it was removal of some other clamping.
The rest of the game looks slightly darker, but it's a rich, solid-feeling darker, rather than a grubby/murky darker. I may still hack the light scale up a little.
All in all this is positive stuff. It's a worthwhile improvement to the look of the game, and is getting me more enthused about doing a mini-project with it. I'm already thinking through the ramifications of a D3D port, which would be a definite feature if I do decide to proceed.
One complicating factor is that the interaction shaders are game content, and don't fall under the GPL release. I have rewritten them significantly; the vertex shader is just simple pass-through now, and much of the fragment shader is different, but I still have doubts if even a port to HLSL would be legal (the vertex shader probably would be - I think it would be hard for anyone to claim copyright over a pass-through shader! - but the fragment shader is doubtful).
Interestingly, a solution to this question might lie in the NV20 and R200 paths. Neither of these use external shader scripts, so their setup and algorithms do fall under the GPL, and so a port of them, together with the modifications I've made, would be a legal option.
Tuesday, November 29, 2011
Doom 3 Shaders
Posted by
mhquake
at
11:07 PM
Subscribe to:
Post Comments (Atom)
13 comments:
Any chance of some screenshots, if the changes show up well in those? :)
What he said! Stop teasing us!
You might want to plug this at Doom3world :) I'm sure the 'sikkmod' people would love graphical enhancements of any kind.
But yeah, some comparative shots would be nice, I'm really curious to play trough again with an enhanced engine.
Damn... is there any code you can't mod and make awesome. Screenshots, screenshots I say! What's next. D3D Descent/Descent 2?!
I don't think screenshots would show it too well; you really need to be moving around in the world to get the full appreciation. I'll try a few later on today, compare them, and see what things look like.
There have been quite a few graphical mods by different authors for Doom3 over the years that made improvements to the shader files this way.
Things can be made to look much better, even when leaving more things in the vertex-shader, you just have to know what to move to the pixel-shader to get the visual improvements you're looking for.
An advantage of moving everything to the FS that doesn't often get mentioned is that it allows early-Z optimizations in the gfx hardware to work more efficiently.
...especially if the engine does a Z prepass... ;)
Pics or it didn't happen!
Why no screenshots? And if screens won't show it well, why not give us a video? Really...
id Software, this man deserves a job as a code optimizer.
Screenshots: http://mhquake.blogspot.com/2011/11/comparison-shots.html
Can you not give people the option of using the low-res, lower hardware requirements path ?
I'm sure many, like me, would really want to play Doom3 and mods on intel graphics laptops or older hardware.
"Can you not give people the option of using the low-res, lower hardware requirements path ?
I'm sure many, like me, would really want to play Doom3 and mods on intel graphics laptops or older hardware."
The big question is: am I even going to release anything at all? Right now my work is mainly confined to just hacking on the code and is something I do on infrequent occasion rather than being a serious project.
There are also legal concerns as I'm far from happy that my higher quality shader is legit to put out.
A "fast but ugly" code path is something that I had in mind far back in time, but I really don't have any commitments either way.
Post a Comment