Parallax mapping

Jun 5, 2011 at 8:18 AM

You can use slightly different bump code that generates better bump effect in my opinion and is just slightly more complex...

// Bump

if (Booleans01.y == 1.0f)


// Parallax bump code

float3x3 tbnXf = float3x3(In.tangentW,In.binormalW,In.normalW);

float4 reliefTex = tex2D(BumpSampler,uv);

float height = reliefTex.w * 0.06 - 0.03;

uv += height * mul(tbnXf,normalize(In.positionW)).xy;

// normal map

float3 tNorm = - float3(0.5,0.5,0.5);

// transform tNorm to world space

normalW = normalize(normalW + normalize(tNorm.x*In.tangentW -

tNorm.y*In.binormalW +















Jun 5, 2011 at 10:11 AM

This is somehting I was thinking of for the next release.

However, I want this to be an "opt-in" feature of the effect, and as the pixel shader of Basic Effect / 3dirLightsBasicEffect and SkinnedEffect are quite long, I hope there is still enough instructions available to introduce Parallax bump mapping.

Jun 5, 2011 at 10:23 AM

Secondly, Parallax Bump Mapping requires an Height Map (or height information in the alpha channel of the Normal Map). I think we should let developpers create their own parallax algorithm depending on the data they have as input (displacement amount should not be the same on every model, and height info can be fetched either from alpha channel of normal map or from a different texture).

I think a code sample on the effect system with a parallax implementation might be a better option.

Jun 5, 2011 at 10:26 AM

I agree with Simon,

BasicEffect must remains basic :)

The effect system allows users to provide theirs owns shaders. So a sample will be a better option.

Jun 6, 2011 at 12:54 AM

Well, we just released a new version, and with it I made a sample demonstrating a simple Parallax Bump Mapping implementation (that works with shader model 2, but that has many rendering artifacts, because of the missing occlusion part of the algorithm).

If the next beta of SL5 supports Shader model 3, I will update the sample to provide a full Parallax occlusion mapping (which provides better results, but requires far more memory bandwidth).