Displacement map shader

Hi all. I am new in vvvv. I having a problem doing a displacement map shader.I not sure if is a problem with texture coordinates or camera matrix multiplications in the shader.
The deformation is done at vertex shader to a grid by texture work in theory (moving z). When you rotate the camera you see that the mode image look right only in some camera orientations. Big thx.

The good souce code file is the second one…

displacementMapping.zip (31.6 kB)

I auto-solved the problem. The displacement is done in vertex shader, this is only possible make it a vertex shader 3.0.

The example show how a face image can deform grid. Any suggestions are welcome.

displacement.zip (66.9 kB)


I just tried the mar.canet patch and it didn’t seem to do anything - just a blank renderer. Am I missing something?

i just see a grid with a texture, no displacement there…

I supose should be your shader support… This need vertex shader 3.0. But maybe I make a mistake because I am new in vvvv.


texture access in vertexshaders is very limited. it definitely requires a vs_3_0 capable nvidia graphic card.

also it seems the texture format of the displacement texture is important. for me on a geforce6800 it only works with the 32bit floating point formats. on the displacement filetexture node you have to specify a specific 32bit format, ie:

seems mar.canet uses a newer card that supports more texture formats in vertexshaders? can you tell us which card you are using?

yep joreg, it work properly once i specify the correct format.

You should have been aware of it if already tried sanch’s displace.fx ;)

yes, it works for me after setting the texture format, but i really dont know about shaders yet, how could customize the level of displacement?

and yes again, the sanchs displacemente shader its more complete, try it…and precise the same texture format.

in the shader code there is a constant value of 15 that specifies the amount of displacement. you can easily exchange that with a value controlled via a pin. specify the variable in the parameter section like this:

float DisplacementAmount = 15; //giving it a default of 15

this will give you a pin on the effect node with that same name.
then you can use the variable DisplacementAmount instead of the constant value of 15 below in the code. voila.

Joreg it is true now is a fix amount of 1 in mine but can be defined as a global variable and an be changed from patch.

I am using a Nvidia - Geforce 8600 GT (the one in the new macbook pro).

I took a look to Sanch’s one,and do similar approach but he has a dynamic displacement texture.
Well I think it is better not make mipMapping to the displacement texture and setup as a point. MipMapping it is used to scale different texures to see well when is far away (ex: texture applied to a floor).

sampler DisplaceSampler = sampler_state
Texture = ;
MinFilter = Point;
MagFilter = POINT;
MipFilter = POINT;

And also I think it is redundant multiply the texture coordinates with the texture matrix.

lookup = mul(TexCd, tTex);

One improvement can be use the displacement and multiply to the normal of the geometry. Nice for example applied to a sphere.

float displaceVal = tex2Dlod(DisplaceSampler,
float4(tex.x, tex.y, 0, 0));
float3 displacePos = vertexPos + normal * displaceVal;

I attach the patch with the sphere displacement mapping by using normals.

displacementInSphere.zip (95.0 kB)