PDA

View Full Version : Quake4 Relief Mapping



fpo
11-06-2005, 03:16 AM
Hi... made a few optimizations to the Relief Mapping assembler shader I used for Doom3 and added depth bias to reduce aliasing on steep angles. Looks better now and runs much faster.

Also made it available for Quake4 now! Looks much better in Quake4 as the textures there are much higher resolution and normals maps covert better to depth maps than in Doom3.

So here are the two updated versions:
Quake4 Relief Mapping (http://fabio.policarpo.nom.br/files/Quake4_ReliefMapping.zip)
Doom3 Relief Mapping (http://fabio.policarpo.nom.br/files/Doom3_ReliefMapping.zip)

Instructions on how to apply the mod to Quake4 are in readme file included in zip and screenshots from same view with/without relief mapping are also there. For Quake4 you need to process three pk4 files for building the depth maps (in Doom3 just one).

On my new system Athlon64 4000 with GeForce 7800gt and 2 Gb RAM it plays very fast at 800x600. Needs to be in Ultra Quality mode for the TGA files to be loaded... I also want to modify the DDS files in order to run at lower quality modes... anyone would like to help on that?

sqrt[-1]
11-06-2005, 04:01 AM
Screenshots!

Perhaps you could have a look at the code that the guys that got Doom3 loading on a Voodoo card did. I believe they loaded the .dds files and saved out a smaller version that the card could load.

tfpsly
11-06-2005, 04:37 AM
Screenshots are in the zip files in the screenshots subdirectory. Did you read his whole post ? ;)

sqrt[-1]
11-06-2005, 04:44 AM
arrgh, That will teach be for being too excited...

fpo
11-06-2005, 05:45 AM
OK made a quick video. Stills do not capture all the effect... the correct parallax is much more evident when you move around.

Quake4 Relief Mapping Video (http://quake4.filefront.com/file/Quake4_Relief_Mapping_Video;50026)
EDITED: New link as my site bandwidth did not handle that many downloads and reached its monthly limit yesterday.

As I only applied the depth map computation to packs 10, 11 and 12 (texture folder) only static scene objects gets relief mapping. That is why all other dynamic geometry stays the same as the original game (elevators, doors, etc).

The problem with the dynamic objects is that most of them have discontinuous normal maps (many different parts put together in a same texture). This gives wrong results when processing the normal maps into depth maps. Many of them would work fine like doors but some would not look that good.

Any link for the DDS texture thing you said? Need a good DDS library for the depth map utility. Have to keep same compression and mipmaps as original files (just add an alpha channel to them).

And just one more note... relief mapping could be much more efficient if used with deferred shading. Quake4/Doom3 recalculates relief mapping for each light source. But relief mapping is constant per view and using deferred shading it could be done only once per frame for any number of lights sources (much more efficient).

SirKnight
11-07-2005, 02:15 PM
That looks really great. Too bad Q4 didn't ship like that. :D

-SirKnight

V-man
11-08-2005, 03:24 AM
Originally posted by fpo:
And just one more note... relief mapping could be much more efficient if used with deferred shading. Quake4/Doom3 recalculates relief mapping for each light source. But relief mapping is constant per view and using deferred shading it could be done only once per frame for any number of lights sources (much more efficient).Yea, I figured they do a pass per light.They don't handle 2 lights at a time or anything more?

PS : When I tried your shader the last time, mostly things looked the same. I don't know if it was me or what. Secondly, the textures don't have much detail on medium setting so it doesn't look all that great. You took the screentshots on ultra high, right?

fpo
11-08-2005, 03:36 AM
This mod only works in Ultra Quality mode. For now my normal2depth tool only process the TGA files (not the DDS ones). Ultra Quality loads the TGA files while all other quality modes uses the DDS ones.

So if you do not set Ultra Quality mode you will be loading the DDS files without any depth information included (all depth values will be 1.0 so you get no displace at all).

And Doom3/Quake4 renders a single light per pass repeating relief mapping calculations for a polygon as many times as there are lights illuminating it.

plasmonster
11-09-2005, 10:51 AM
Nice work, Fabio. This stuff is looking scary.

Korval
11-09-2005, 12:07 PM
OK made a quick video. Stills do not capture all the effect... the correct parallax is much more evident when you move around. Nice... mostly.

It's slowly becoming evident to me that these kinds of height-texture effects are never going to work 100%. And, because of the subtlety of the detail, when the approximation breaks down, it creates a sense of... strangeness about the object. If they can't get everything 100% right, then the user will occassionally get the feeling that the world is somewhat strange. The average user may not be able to tell what is strange about the world, but they will definately know that something isn't real.

And when you're getting pretty close to high-detailed reality, having something being off absolutely destroys the illusion.

It's a nice effect, but I'm would almost say that the effect falls into the space between clearly unreal and clearly real. And in the middle of that space is the uncanny valley (http://en.wikipedia.org/wiki/Uncanny_Valley) , which is a place where I believe this effect falls. It's very nearly real, but certain views of the environment cause it to break down (edge-on views, how shadows from other objects play on it, etc). Whereas a flat texture is considered really "broken" from reality (and therefore the imagination can infer what the texture is trying to convey), this relief mapping effect is mostly right, but sometimes provokes a sense of wrongness that is difficult to put one's finger on.

Another way of saying it is that it looks too good when it's working right such that when it's reaching the edge of the approximation, it looks very wrong by comparison. The totality of the world now feels very inconsistent, because what looked nearly real before now seems quite wrong.

Vexator
11-09-2005, 12:40 PM
don't forget that the d3/q4 game textures weren't designed for use with that technique.
btw what's the advantage over parallax mapping?

dorbie
11-09-2005, 10:52 PM
I know some people who fit in the uncanny valley.

Jan
11-10-2005, 12:32 AM
Originally posted by Vexator:
don't forget that the d3/q4 game textures weren't designed for use with that technique.
btw what's the advantage over parallax mapping?It's much preciser. Parallax Mapping works only on very few textures convincingly, such as brick walls. On almost every other kind of texture it looks quite bad. Also Parallax Mapping can't handle such fine detail and on "steps" inside the texture the step-edge becomes very apparent because of the distortion.

About the "too real and too unreal" issue:
I think it looks great. Yes, there are certainly cases, where you still can see, that it doesn't work absolutely real. But at least in computer games i don't think this is a problem. Computer games have never been consistent in any way. It has always been like that, that new technologies or methods were developed, that made some part of the game look more realistic. But some parts have always been less realistic.
And even if everything seems to LOOK right, you usually pretty fast get the impression that it still FEELS wrong, because of humble animations, unsuitable speech/audio, bad AI or whatever.

It is ONE piece that can be improved. But games will always feel wrong in some kind. I don't bother if it still feels wrong but at least looks better :D

Jan.

fpo
11-10-2005, 07:09 AM
I liked the definition of Uncanny Valley... interesting notion and I believe it is somewhat true.

But I think that art carefully made thinking about the limitations of this and other related pixel based displacement mapping techniques can achieve a good result. Look at the new Toy Shop demo from ATI they use something similar and fits well into the demo (although they use a much too simple depth map with rounded edge rocks for avoiding artifacts).

Also sampling step could be dynamic so that at steep angles more samples are taken. This could replace depth bias making the resulting image more 'real' as Korval says. This can be done with shader branching support available in pixel shader 3.0 for example.

knackered
11-10-2005, 07:52 AM
Originally posted by dorbie:
I know some people who fit in the uncanny valley.That's the most insightful thing I've heard anyone say in a long time.
Seriously.
It's sort of like the effect of falling in love with someone, going on picnics, boat trips, then...as the sun sets over a yellow meddow, she says something racist

plasmonster
11-10-2005, 09:23 AM
Yeah, there's no escaping the on-edge flatness, but it's well worth that small price. I've been playing with this technique for some time now and it can indeed work extremely well with the right textures. I'm blown away just looking at these screens... haven't even tried the game yet (don't really need to).

We're all fairly accustomed to some artifacts in games. I don't really see that as a show-stopper... necessary evil, perhaps, but not a show-stopper.

Uncanny valley is human-human thing, is it not? I don't get that sensation when looking at a wall, for example. But human-like animations can be a bit disturbing if close, but not quite close enough.

Vexator
11-10-2005, 11:23 AM
@fpo
would you write a glsl version of your relief mapping shader? i'd like to understand how it worls and want to test it with my own models/textures.. just don't come along with those low-level shaders :p

Korval
11-10-2005, 12:26 PM
But I think that art carefully made thinking about the limitations of this and other related pixel based displacement mapping techniques can achieve a good result.Certainly decisions on what to make displaced and what to make geometry could be made better to achieve a less jarring effect. But one of my main subconscious visual concerns is with shadows from external objects. The relief mapping approach simply doesn't handle it at all under stencil shadows. It might be able to operate under depth shadows, though it would add a level of complexity to the algorithm.

And the artifact in this case is very subtle and noticable with even a slight raised floor/wall outcropping. It's the kind of thing that a graphics programmer/artist would notice as the breakdown of an effect, but would be registerred as a non-descript oddity by the average person. It's the kind of thing that falls into the uncanny valley for most people, where the world is slightly "off" in a way that they aren't able to detect. And because it isn't obvious, it gives a very uneasy feeling about the world.


We're all fairly accustomed to some artifacts in games. I don't really see that as a show-stopper... necessary evil, perhaps, but not a show-stopper.Well, if you make a game that visually falls into the uncanny valley, it's graphics will be considered worse than more abstract graphics, even if you're modelling 80% of reality when the abstract one is only getting 40% or so. Visually, artistically, you always want to operate on one side of the valley or the other; you never want to fall into it.

Now, it may not be this particular visual effect that pushes us over into the uncanny valley (though clearly, this one needs to be massaged properly in terms of art lest its subtle artifacts cause problems). But I definately think we're visually approaching a point where we're going to start falling into the gap if we're not cognizant of it.


Uncanny valley is human-human thing, is it not?Not necessarily. That's what the article was talking about (as it was born out of robots and androids and such), but once you start applying it to Cg, it can be applied to terrain. Granted, because people know people better than rocks, the problems are going to show up more with modelling and rendering people, but the theory is relatively sound applying it to non-humans.

knackered
11-10-2005, 12:39 PM
I suppose this is a valid point, but only valid if realtime graphics were anywhere near photorealistic. They're not, they're all full of artefacts, whether it's hard edged shadows, aliasing, pixelation from shadow maps, environment mapping approximations...the list is endless, and will be for the forseable future. So, if there are so many artefacts already, why do you think this point is relevant to relief mapping particularly?

fpo
11-10-2005, 01:20 PM
Just one note on shadows... supporting correct displaced shadow volumes is easy, all you need to do is update the depth buffer adding the displace before you do stencil shadows (check it out on my papers including that).

The problem is that Doom3/Quake4 can not do it as it would require relief mapping to happen when it is doing the depth only pass (to get the displaced depth buffer).

So in a custom made engine (specially using deferred shading) it would work fine with stencil or shadow maps... so you can have correct displaced shadows with hard edges if you want (and it does not add a lot to the shader just a few more instructions in order to output depth value).

zed
11-10-2005, 03:07 PM
surely when the ability to create vertices on the card comes than all this(Relief Mapping) will be rendered obsolete?
im not knocking this technique i believe its brilliant

Korval
11-10-2005, 05:01 PM
They're not, they're all full of artefacts, whether it's hard edged shadows, aliasing, pixelation from shadow maps, environment mapping approximations...the list is endless, and will be for the forseable future.That's a graphics programmer talking, not someone viewing an image. Graphics programmers are trained to break down an image into its fundamental "effects" as well as recognize artifacts on a conscious level. Most normal people are not. They don't understand any of these concepts. They simply see an image that is "near" reality, but off in a way that they are not able to fully describe.


So, if there are so many artefacts already, why do you think this point is relevant to relief mapping particularly?As FPO pointed out, it could just be bad source data, but it's the way that the effect looks so good, but right next to a perfectly viable detailed surface can be an artifact. Like, you see a surface as being clearly rough, but change your perspective (or look down a hallway), and you can see that the surface is really just flat and some kind of trick is being employed to convince you otherwise. Or you notice how a shadow interacts incorrectly with a surface that obviously looks rough.

Bump mapping doesn't have this problem because it doesn't look good enough to. Standard bump mapping doesn't bring out the detail to the degree that relief mapping can, so there isn't the disjunction of near-reality next to a visual artifact. Or, even worse, seeing an object that looks highly detailed from one angle and moving to another where it looks (compared to the original angle) incredibly fake. It creates tension in the world; an inconsistency of experience that people aren't used to dealing with. Bump mapping may not look as good as relief mapping, but it is, at least, consistent in its appearance.

V-man
11-10-2005, 06:19 PM
Originally posted by zed:
surely when the ability to create vertices on the card comes than all this(Relief Mapping) will be rendered obsolete?
im not knocking this technique i believe its brilliantI think that's fairly obvious. Bumpmapping will be thrown away eventually.

I find that the D3 graphics are a joke in some ways. Walls are huge polygons and the texture has large objects in it.

If your bumpmaps are for slight bumps, no need for displacement techniques and bump shadows.

plasmonster
11-11-2005, 09:13 AM
It creates tension in the world; an inconsistency of experience that people aren't used to dealing with.I don't think that this concern is justified in this particular case. Game worlds are rife with textures that attempt to create the illusion of geometric depth where none exists. This technique simply seeks to enhance that illusion. That there are artifacts associated with the end result in no way distinguishes it from other attempts at manufacturing depth through the use of any number of ad hoc techniques, save that this one is among the more effective of those attempted thus far. My concern, really, is the performance hit; and as you suggest, that the artists understand the implications of adding excessive "depth" to the textures.

Needless to say, an improper application of this--and indeed any--effect could result in less that pleasing/consistent results. But visual anomalies are part and parcel of the gaming experience; they're part of a celebrated tradition embodying the best of intentions, and I think the (gaming) public understands that. I think the average gamer is only too eager to suspend disbelief (http://en.wikipedia.org/wiki/Suspension_of_disbelief) , especially when there are kingdoms to rule or untold treasures in them hills!

knackered
11-11-2005, 11:59 AM
Well, I think Korval's point is that this technique is so good, and contributes so much to the realism of the scene, that when the illusion is shattered it subtracts more from the immersive experience than it originally added. Sort of, every reaction has an equal and opposite reaction, I suppose.
As I said though, I believe this is true of other effects - a good example is the water in Far Cry, where it looks stunning until you see the artifact created by the fact that the reflection is mirrored around a perfect plane, but the texture is mapped onto a displaced plane.
I imagine we all agree though, that this is a stunning technique, and certainly worth adding to our renderers.