Parallax Maps?
Posted: 27 Nov 2012, 22:32
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?
Open Source Realtime Strategy Game Engine
https://springrts.com/phpbb/
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'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).
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
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.
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
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
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.
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).