Parallax Maps?

Parallax Maps?

Discuss maps & map creation - from concept to execution to the ever elusive release.

Moderator: Moderators

Post Reply
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Parallax Maps?

Post by Funkencool »

I have a some questions regarding this, but before I get to those I have only one. Has anyone actually used this on a map, i.e. does a map with a parallax map exist that I can look into?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Parallax Maps?

Post by Forboding Angel »

Most of the evo maps have them (assuming by parallax you mean a normalmap).
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Parallax Maps?

Post by Funkencool »

I'm think more along the lines of..
parallaxHeightTex (RGBA)
should be the same size as specularTex

modifies the diffuse, normal, and specular
TEXTURE COORDINATES before sampling is done

height, scale, and bias parameters are packed
as follows to produce a texel offset-factor f

h = (parallaxHeightTex.r * 65280 + parallaxHeightTex.g * 256) / 65536
s = (parallaxHeightTex.b)
b = (parallaxHeightTex.a - 0.5)
f = h * s + b
from the pastebin in kloot's post


I've been testing it some more and I think I have everything in order. When it's working right it looks good, though it appears to be a little buggy (at least on my setup), and doesn't appear to use occlusion?

Only relevent bit I could find
Kloot wrote:I never got around to documenting the newer/more advanced features (the changelog references them, but they didn't gain any interest from mappers), so you'll have to make do with this draft (and this old screenshot).
I'll post screens, with my test map and findings, when I get back to my desktop.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Parallax Maps?

Post by Anarchid »

Can i has screenshot? :0
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Parallax Maps?

Post by Beherith »

Noone has done parallax before, should be useful for sand dunes and stuff.
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Parallax Maps?

Post by Funkencool »

Anarchid wrote:Can i has screenshot? :0
Its pretty hard to capture the effect in an image, I do have one but its of what I presume is a bug
Image
It's a little hard to see but theres a grid like pattern throughout the whole map where the pixels are stretched. I have no idea why, and I can't seem to get rid of it.
Anyway that's just a plain flat grass map but parallax adds a sense of depth when changing the view (and the normals add the shading)
Beherith wrote:Noone has done parallax before, should be useful for sand dunes and stuff.
Unfortunately it doesn't effect splatting, in fact it sort of clashes with it. I suppose it would be useful in replacing splatted dunes, but that would require high res ssmf maps.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Parallax Maps?

Post by Beherith »

Does the stretching happen at coordinates that are multiples of 1024?
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Parallax Maps?

Post by Funkencool »

Yes I believe they did, Is it something to do with my image format?
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Parallax Maps?

Post by enetheru »

added appropriate tag to the mapinfo.lua wiki page.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Parallax Maps?

Post by Beherith »

You should file a bug report, and attach your map to it. I think something may be wrong in the engine, because map gets rendered in patched of 1024.

A hacky workaround is to make sure parallax is 0 on a grid of 1024.
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Parallax Maps?

Post by Funkencool »

Alright I've messed around with it some more and I've seemed to get it working. I'm on a 1024x1024 map with a 4096x4096 spec/parallax map and all is well. It seems though that its near impossible to get the settings right (they appear to be too sensitive).
height, scale, and bias parameters are packed
as follows to produce a texel offset-factor f

h = (parallaxHeightTex.r * 65280 + parallaxHeightTex.g * 256) / 65536
s = (parallaxHeightTex.b)
b = (parallaxHeightTex.a - 0.5)
f = h * s + b
For example, if I wanted the parallax to be completely neutral I would need f == 0 (I assume)

Which would have to be something like this
h = (0 * 65280 + 0 * 256) / 65536
s = (parallaxHeightTex.b)
b = (0.5 - 0.5)
f = 0 * s + 0
So I set my r,g channels to zero(black) and my alpha channel to .5 (or 128/256 in 8bit), and leave blue channel or 's' alone since it doesn't matter in this example. That should make f == 0

Yet ingame it still wants to "raise" everything, as if the b>0 (In other words, it seems to be biased 'up')
Then if I try "lowering" everything by i.e. setting the alpha channel to the next lowest number which is 127/256 in 8bit.
Everything now appears "below" the surface.

Basically I want this..
Image

but the closest I can get is this..
Image
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Parallax Maps?

Post by Kloot »

Thanks for testing my undocumented junk.
Funkencool wrote:It's a little hard to see but theres a grid like pattern throughout the whole map where the pixels are stretched. I have no idea why, and I can't seem to get rid of it.
On SMF maps the main texture gets split up into squares, and if the parallax offset pushes a texel's coordinates to a neighboring square during rendering then its value is undefined (read: clamped to the border) which produces stretching artefacts.

Funkencool wrote:For example, if I wanted the parallax to be completely neutral I would need f == 0 (I assume)

So I set my r,g channels to zero(black) and my alpha channel to .5 (or 128/256 in 8bit), and leave blue channel or 's' alone since it doesn't matter in this example. That should make f == 0

Yet ingame it still wants to "raise" everything, as if the b>0 (In other words, it seems to be biased 'up')
Then if I try "lowering" everything by i.e. setting the alpha channel to the next lowest number which is 127/256 in 8bit.
Everything now appears "below" the surface.
That happens because neither 127 nor 128 is a midpoint of the range [0, 255] but the bias constant is exactly 0.5, so there will always be a non-zero offset (negative and positive) with those parameters. Mathematically there is just one real way to neutralize it: set r = 127, g = 255, b = 255, a = 0 (or r = 128, g = 0).
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Parallax Maps?

Post by Funkencool »

kloot wrote:That happens because neither 127 nor 128 is a midpoint of the range [0, 255] but the bias constant is exactly 0.5, so there will always be a non-zero offset (negative and positive) with those parameters. Mathematically there is just one real way to neutralize it: set r = 127, g = 255, b = 255, a = 0 (or r = 128, g = 0).
Okay, now it all makes more sense :-)
I'll mess with it some more and see if I can come up with something that looks good.

Also just so it's out there, I would have to say it's biggest downfall is that it doesn't effect the splat texture, but it might still have its uses.
Post Reply

Return to “Map Creation”