POV-Ray : Newsgroups : povray.binaries.animations : parallax mapping (504k mpeg 1) Server Time
1 Nov 2024 09:20:58 EDT (-0400)
  parallax mapping (504k mpeg 1) (Message 1 to 4 of 4)  
From: Tek
Subject: parallax mapping (504k mpeg 1)
Date: 9 Apr 2004 04:03:48
Message: <407658e4@news.povray.org>
I was inspired by Samuel Benge's fake volumetrics post in p.b.i. It reminded me
of a technique I know of for real time graphics called "parallax mapping". So I
decided to implement it in pov! :)

What you are looking at is a flat plane (okay, right now what you're looking at
is an e-mail, but you get my drift). The illusion of bumps is acheived using 2
tricks: firstly pov's "normal" command which we know and love, and secondly a
displacement applied to the texture in the direction of the camera according to
a height field. Both the pigment and the normal map are displaced (otherwise
they wouldn't line up).

What this does is fake the effect of different perspective on deeper points on
the surface, even though all the points are actually at the same height. The
limitation of parallax mapping is that there's no occlusion (since each point on
the surface only reads the height once), which means you get errors when you
view the surface at a shallow angle. Also there's a small inherent inaccuracy,
which causes the surface to creep around slightly.

It's pretty neat, but I'm not convinced it's that much use in povray. Still,
might be good if you need a cheap surface displacement and normal maps aren't
enough.

Here's the code for the effect. I've only done the maths for a horizontal plane,
but it is possible to implement the technique for a surface at any angle:

plane {
 #declare planeY = -4;
 y, planeY

 #declare camHeightAbovePlane = camPos.y - planeY;
 #declare bumpDepth = .5;
 #declare q = 1/(1 + bumpDepth/max(camHeightAbovePlane,.001));

 #declare camPosX = camPos.x; #declare camPosY = camPos.y; #declare camPosZ =
camPos.z;

 pigment {
  function {
   Colour( camPosX + (x-camPosX)*(Height(x,0,z).x*(1-q) + q), 0, camPosZ +
(z-camPosZ)*(Height(x,0,z).x*(1-q) + q) ).x
  }
 }
 normal {
  //slightly bizarre, use the height map for the bumps, but displace it by
itself
  function {
   Height( camPosX + (x-camPosX)*(Height(x,0,z).x*(1-q) + q), 0, camPosZ +
(z-camPosZ)*(Height(x,0,z).x*(1-q) + q) ).x
  } -2
 }
 finish { ambient 0 diffuse 1 }
}


-- 
Tek
www.evilsuperbrain.com


Post a reply to this message


Attachments:
Download 'parallax mapping000.m1v.mpg' (505 KB)

From: Dave Matthews
Subject: Re: parallax mapping (504k mpeg 1)
Date: 9 Apr 2004 17:06:50
Message: <4077106a$1@news.povray.org>
Cool.

Damn.  Now I have to puzzle this out.  Another Friday afternoon shot. 
Anyway, it's turning cold and windy outside, so I might as well stay put.

Thanks, I guess.

Dave Matthews


Post a reply to this message

From: Tek
Subject: Re: parallax mapping (504k mpeg 1)
Date: 9 Apr 2004 23:14:44
Message: <407766a4$1@news.povray.org>
"Dave Matthews" <dma### [at] nospamnet> wrote in message
news:4077106a$1@news.povray.org...
> Damn.  Now I have to puzzle this out.  Another Friday afternoon shot.
> Anyway, it's turning cold and windy outside, so I might as well stay put.

Well maybe I can simplify it for you: Render an image with the camera above a
checkered plane, now render the same image with the plane twice as far away from
the camera. if you compare the two images you'll see the squares in the second
one are exactly half the size of the squares in the first.

i.e. it looks identical to if you rendered the plane in the first position with
the squares scaled by 0.5 (provided the centre of scaling is in line with the
camera).

Parallax mapping uses this effect to give the appearance that some points are
lower than others, when they're actually just scaled within the plane.

Are we confused yet? ;)

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Dan P
Subject: Re: parallax mapping (504k mpeg 1)
Date: 10 Apr 2004 16:05:09
Message: <40785375$1@news.povray.org>
Tek wrote:

> I was inspired by Samuel Benge's fake volumetrics post in p.b.i. It reminded me
> of a technique I know of for real time graphics called "parallax mapping". So I
> decided to implement it in pov! :)
> 
<snip:technical />

Wow! Kick ass!

-- 
Respectfully,
Dan P
http://<broken link>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.