Parallax Maps?
Moderator: Moderators
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Parallax Maps?
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?
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Parallax Maps?
Most of the evo maps have them (assuming by parallax you mean a normalmap).
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Parallax Maps?
I'm think more along the lines of..
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
from the pastebin in kloot's postparallaxHeightTex (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
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
I'll post screens, with my test map and findings, when I get back to my desktop.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).
Re: Parallax Maps?
Noone has done parallax before, should be useful for sand dunes and stuff.
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Parallax Maps?
Its pretty hard to capture the effect in an image, I do have one but its of what I presume is a bugAnarchid wrote:Can i has screenshot? :0

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)
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.Beherith wrote:Noone has done parallax before, should be useful for sand dunes and stuff.
Re: Parallax Maps?
Does the stretching happen at coordinates that are multiples of 1024?
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Parallax Maps?
Yes I believe they did, Is it something to do with my image format?
Re: Parallax Maps?
added appropriate tag to the mapinfo.lua wiki page.
Re: Parallax Maps?
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.
A hacky workaround is to make sure parallax is 0 on a grid of 1024.
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Parallax Maps?
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).
Which would have to be something like this
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..

but the closest I can get is this..

For example, if I wanted the parallax to be completely neutral I would need f == 0 (I assume)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
Which would have to be something like this
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 == 0h = (0 * 65280 + 0 * 256) / 65536
s = (parallaxHeightTex.b)
b = (0.5 - 0.5)
f = 0 * s + 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..

but the closest I can get is this..

Re: Parallax Maps?
Thanks for testing my undocumented junk.
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: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.
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).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.
- Funkencool
- Posts: 542
- Joined: 02 Dec 2011, 22:31
Re: Parallax Maps?
Okay, now it all makes more sensekloot 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).

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.