Displacement maps

Discussion related to the LuxRender Material system, programming API and Scene file format.

Moderators: jromang, tomb, zcott, coordinators

Displacement maps

Postby Dade » Mon Jun 02, 2008 3:57 pm

As discussed in Mantis feature #166, I wrote a first support for displacement maps. At the moment is a simple per-vertex displacement support and it uses LoopSubdiv shape support in order to tessellate the original triangle mesh.

You can use ay float texture as displacement map, for instance:

Code: Select all
Texture "displace_map" "float" "fbm" "integer octaves" [8] "float roughness" [0.500000] "vector scale" [0.100000 0.100000 0.100000] "vector rotate" [0 0 0] "vector translate" [0 0 0]

AttributeBegin
   Transform [1.0 0.0 0.0 0.0  0.0 1.0 0.0 0.0  0.0 0.0 1.0 0.0  0.74215400219 -0.382443904877 0.0311622619629 1.0]
   NamedMaterial "mat_sphere"
   Shape "loopsubdiv"
         "integer nlevels" [6]
         "string displacementmap" ["displace_map"]
         "float dmscale" [0.25]
         "integer indices" [
0 1 2
[...]


where:
- nlevels is the number of time each triangle must be subdivided;
- displacementmap is the name of a float texture;
- dmscale is a scale factor for the displacement map;
- indices, P are the same parameter of a trianglemesh (it is trivial to transform a trianglemesh in a loopsubdiv: just add the "nlevel" parameter).

Now some demo of this feature. The first image is an FBM texture applied as color (left) and applied as displacement map (right):

demo1.jpg


And the same for the Dots texture:

demo2.jpg


Indeed, I couldn't resist :mrgreen:

dm-luxball-1.jpg


Loopsubdiv shade doesn't support UV coords and it is the next thing I'm going to add.

As usual, it is the first implementation, your mileage can vary.
User avatar
Dade
Developer
 
Posts: 4851
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: Displacement maps

Postby dougal2 » Mon Jun 02, 2008 4:07 pm

bloody hell that was quick. I guess I'd better start on the loopsubdiv export module for LuxMaya.
User avatar
dougal2
Developer
 
Posts: 3075
Joined: Mon Jan 14, 2008 7:21 am

Re: Displacement maps

Postby Dade » Mon Jun 02, 2008 5:27 pm

A wrinkled Luxball:

dm-luxball-2.jpg


A wooded Luxball:

dm-luxball-3.jpg
User avatar
Dade
Developer
 
Posts: 4851
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: Displacement maps

Postby dougal2 » Mon Jun 02, 2008 5:39 pm

one small thing about the syntax. Shouldn't
Code: Select all
"string displacementmap" ["displace_map"]

be
Code: Select all
"texture displacementmap" ["displace_map"]
User avatar
dougal2
Developer
 
Posts: 3075
Joined: Mon Jan 14, 2008 7:21 am

Re: Displacement maps

Postby Radiance » Mon Jun 02, 2008 11:00 pm

what the hell is in the water in italy ?

that's great work dade, very fast :)

i'll have to conjure up some support in luxblend for this now :)

greetz,
Radiance
User avatar
Radiance
 
Posts: 3968
Joined: Wed Sep 19, 2007 2:13 am

Re: Displacement maps

Postby Radiance » Tue Jun 03, 2008 5:55 am

oki,

Dade, i've noticed that the direction is wrong.
eg >1.0 becomes a hole (inwards of the model) and <1.0 (negative) becomes a bump (extruded outwards)
i think this should be inversed so it matches with the behaviour of bumpmaps.

it's useable without support for normals, but not on a propper scene, too much weird behaviour :)

support in luxblend is nearly done, just some more testing and cleanups.

you can make some pretty awesome stuff with this and our procedurals :)

greetz,
radiance
Attachments
monkeydisp.jpg
User avatar
Radiance
 
Posts: 3968
Joined: Wed Sep 19, 2007 2:13 am

Re: Displacement maps

Postby Dade » Tue Jun 03, 2008 8:36 am

Radiance wrote:Dade, i've noticed that the direction is wrong.
eg >1.0 becomes a hole (inwards of the model) and <1.0 (negative) becomes a bump (extruded outwards)
i think this should be inversed so it matches with the behaviour of bumpmaps.


Wired, the code is

Code: Select all
Vector displacement(nn);
displacement *= displacementMap.get()->Evaluate(dg) * displacementMapScale;

verts[i] += displacement;


So the displacement should be along the direction of the normal (>0.0 => bump, <0.0 => hole).

Radiance wrote:it's useable without support for normals, but not on a propper scene, too much weird behaviour :)


Some strange behaviour could be related to the wrong values of some field I'm using in the DiferentialGeometry at the moment. I should fix that stuff today.

Radiance wrote:you can make some pretty awesome stuff with this and our procedurals :)


Eheh, I love the last Suzanne :mrgreen:
User avatar
Dade
Developer
 
Posts: 4851
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: Displacement maps

Postby Dade » Tue Jun 03, 2008 8:46 am

dougal2 wrote:one small thing about the syntax. Shouldn't
Code: Select all
"string displacementmap" ["displace_map"]

be
Code: Select all
"texture displacementmap" ["displace_map"]


You are right Dougal but I had to use "string" and not "texture" because the way the Lux parser is written. The "displacementmap" parameter is inside a Shape object and not in the definition of a Material. Shape object constructor uses ParamSet instead of TextureParams (only available for a Material).
User avatar
Dade
Developer
 
Posts: 4851
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: Displacement maps

Postby Dade » Tue Jun 03, 2008 3:44 pm

I added the support for UV coords in loopsubdiv objects, now we can use imagemap too:

luxout.jpg


Wait for Radiance for a nice artistic demonstration of this feature :mrgreen:
User avatar
Dade
Developer
 
Posts: 4851
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Re: Displacement maps

Postby Dade » Wed Jun 04, 2008 8:32 am

Added a "float dmoffset" option. It adds a constant to the displacement (i.e. using a -0.5 value for an imagemap between [0,1] can be useful).
User avatar
Dade
Developer
 
Posts: 4851
Joined: Sat Apr 19, 2008 6:04 pm
Location: Italy

Next

Return to Materials, API & Scene file format

Who is online

Users browsing this forum: No registered users and 1 guest