Limit paralax distort

Hey Is ther a way to limit how much parralax is allowed to morph an image? Cause it looks really good from most angles, but flat ones it gets completly distorted. So I guess the simples solution would be to be able to limit the maximum effect it can do, but I don’t even know if this makes sense, or is impossibble due to the way parralax works

What do you mean by distorted?

Looks greate mostly, but sometimes I from certain angels I get a far to much distorted look



http://nh-game.net/Untitled.png

oh ok,

you use a quad right?

you’d better use a grid.

the thing is light direction in the lighting shader is computed for each vertex, so for a large quad, when you look at the center, the light direction is completely wrong. giving this effect.

if you use a grid, the error is noticeable with a fair amount of cells.

Actually its just a small part of a model, I just wonder a bit since normal parallax mapping seemed to work quite good at the same model

Actually would it be possible to calculate the light direction per fragment optionally? Or this this not possible due to the principle of the paralax math?

it’s possible yes , but it will be slower, also it possibly implies one more vec3 varying…and we are short on varryings in the lighting shader.



I’ll look into this

I’m probably fuzzy on this… but if it varies then isn’t it basically the same as calculating it per pixel? And if it doesn’t vary, how do you figure out what would be good for the whole fragment? Or would you use the same varying for both endpoints? (which also doesn’t seem right since then you’d have seams)



Then again, I don’t fully understand what makes the calculation different when it’s a vertex versus a pixel. I mean, clearly if using multiple quads makes it look better then there must be some reason but it’s slipping past me at the moment.



I’m just trying to understand because I can’t reconcile it all in my head right now.

here is a drawing that explains the issue



http://i.imgur.com/lXb7V.jpg



As you can see on the picture, the computed direction is closer to the exact direction when using a grid. So the distortion on parallax is less noticeable.



I don’t know if that’s doable, but maybe using the texture coord to find the fragment position could do the trick…don’t know.

This would be far easier in a deferred rendering process…

I had this backwards: “the thing is light direction in the lighting shader is computed for each vertex, so for a large quad, when you look at the center, the light direction is completely wrong.”



But still, light/view dir is a varying… it is already different for each pixel. Just not right, apparently. So the per-pixel interpolation must not like view dir very much. So, yeah, maybe there is a correction that can be applied?



…my brain should not be doing math at the moment, I think.

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.115.3066&rep=rep1&type=pdf



What about this, at least in the conclusion they say they do it pixel based, (tho im not that good in shaders to realy understand the math behind all)

pspeed said:
I had this backwards: "the thing is light direction in the lighting shader is computed for each vertex, so for a large quad, when you look at the center, the light direction is completely wrong."

yeah sorry my mistake i meant view direction