Yesterday I found this awsome collection and converted the first shader.
I think that IŽll go on converting them always if IŽm not motivated enough to go on with "Chopper Zone".

Normal, Parallax and Reliefmapping:
(IŽll post an example file later today or tomorrow)
The alphachannel of the normalmap gives the height.
The first Modelskin is the textur and the second the normalmap.
Only the Sunlight is supported



Code:

/*********************************************************************NVMH3****
File: $Id: //sw/devtools/ShaderLibrary/main/HLSL/relief_mapping.fx#1 $

Copyright NVIDIA Corporation 2007
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

% This material shows and compares results from four popular and
% advanced schemes for emulating displaement mapping. They are:
% Relief Mapping, Parallax Mapping, Normal Mapping, and Relief
% Mapping with Shadows. Original File by Fabio Policarpo.

keywords: material bumpmap
date: 070305

Note: Strong discontinuties in the model geometric normal (e.g., very sharp
differences from the normals in two or more parts of the same triangle)
can cause unusual overall light-attentuation errors. Re-normalizing the
rasterized normals in the pixel shader can correct this, but the case
was considered rare enough that these extra steps were eliminated for
code efficiency. If you see off lighting near sharp model edges, just
normalize "IN.normal" in the calculation of the varible "att" (shared
by all techniques).

******************************************************************************/

//// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS ////////////////

float4x4 matWorldViewProj;
float4x4 matView;
float4x4 matWorldView;

/////////////// Tweakables //////////

float4 vecSunPos;
float4 vecLight;
float3 DiffColor = {1,1,1};
float3 SpecColor = {0.75,0.75,0.75};

float PhongExp = 128.0;
float TileCount = 1;
float Depth = 0.1;

/*********** TEXTURES ***************/

texture entSkin1;

sampler2D ColorSampler = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MipFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};

texture entSkin2;

sampler2D ReliefSampler = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MipFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};

/********** CONNECTOR STRUCTURES *****************/

struct AppVertexData
{
float4 pos : POSITION;
float4 color : COLOR0;
float3 normal : NORMAL; // expected to be normalized
float2 txcoord : TEXCOORD0;
float3 tangent : TEXCOORD2; // pre-normalized
};

struct VertexOutput
{
float4 hpos : POSITION;
float2 UV : TEXCOORD0;
float3 vpos : TEXCOORD1;
float3 tangent : TEXCOORD2;
float3 binormal : TEXCOORD3;
float3 normal : TEXCOORD4;
float4 lightpos : TEXCOORD5;
float4 color : COLOR0;
};

/*** SHADER FUNCTIONS **********************************************/

VertexOutput view_spaceVS(AppVertexData IN)
{
VertexOutput OUT = (VertexOutput)0;

float3 binormal = cross(IN.normal,IN.tangent);

// isolate matWorldView rotation-only part
float3x3 modelViewRotXf;
modelViewRotXf[0] = matWorldView[0].xyz;
modelViewRotXf[1] = matWorldView[1].xyz;
modelViewRotXf[2] = matWorldView[2].xyz;
float4 Po = float4(IN.pos.xyz,1.0);
OUT.hpos = mul(Po,matWorldViewProj);

// vertex position in view space (with model transformations)
OUT.vpos = mul(Po,matWorldView).xyz;

// light position in view space
float4 Lw = float4(vecSunPos.xyz,1); // this point in world space
OUT.lightpos = mul(Lw,matWorldView); // this point in view space

// tangent space vectors in view space (with model transformations)
OUT.tangent = mul(IN.tangent,modelViewRotXf);
OUT.binormal = mul(binormal,modelViewRotXf);
OUT.normal = mul(IN.normal,modelViewRotXf);

// copy color and texture coordinates
OUT.color = IN.color; // currently ignored by all techniques
OUT.UV = TileCount * IN.txcoord.xy;

return OUT;
}

/************ PIXEL SHADERS ******************/

float4 normal_mapPS(VertexOutput IN) : COLOR
{
float3 tNorm = tex2D(ReliefSampler,IN.UV).xyz - float3(0.5,0.5,0.5);
// transform tNorm to world space
tNorm = normalize(tNorm.x*IN.tangent -
tNorm.y*IN.binormal +
tNorm.z*IN.normal);
float3 texCol = tex2D(ColorSampler,IN.UV).xyz;
// view and light directions
float3 Vn = normalize(IN.vpos);
float3 Ln = normalize(IN.lightpos.xyz-IN.vpos);
// compute diffuse and specular terms
float att = saturate(dot(Ln,IN.normal));
float diff = saturate(dot(Ln,tNorm));
float spec = saturate(dot(normalize(Ln-Vn),tNorm));
spec = pow(spec,PhongExp);
// compute final color
float3 finalcolor = vecLight.xyz*texCol +
att*(texCol*DiffColor.xyz*diff+SpecColor*spec);
return float4(finalcolor.rgb,1.0);
}

float4 parallax_mapPS(VertexOutput IN) : COLOR
{
// view and light directions
float3 Vn = normalize(IN.vpos);
float3 Ln = normalize(IN.lightpos.xyz-IN.vpos);
float2 uv = IN.UV;
// parallax code
float3x3 tbnXf = float3x3(IN.tangent,IN.binormal,IN.normal);
float4 reliefTex = tex2D(ReliefSampler,uv);
float height = reliefTex.w * 0.06 - 0.03;
uv += height * mul(tbnXf,Vn).xy;
// normal map
float3 tNorm = reliefTex.xyz - float3(0.5,0.5,0.5);
// transform tNorm to world space
tNorm = normalize(tNorm.x*IN.tangent -
tNorm.y*IN.binormal +
tNorm.z*IN.normal);
float3 texCol = tex2D(ColorSampler,uv).xyz;
// compute diffuse and specular terms
float att = saturate(dot(Ln,IN.normal));
float diff = saturate(dot(Ln,tNorm));
float spec = saturate(dot(normalize(Ln-Vn),tNorm));
spec = pow(spec,PhongExp);
// compute final color
float3 finalcolor = vecLight.xyz*texCol +
att*(texCol*DiffColor.xyz*diff+SpecColor*spec);
return float4(finalcolor.rgb,1.0);
}

//// ray-intersect functions for relief mapping //////////

float ray_intersect_rm( // use linear and binary search
in sampler2D reliefmap,
in float2 dp,
in float2 ds)
{
const int linear_search_steps=15;

// current size of search window
float size = 1.0/linear_search_steps;
// current depth position
float depth = 0.0;
// search front to back for first point inside object
for( int i=0;i<linear_search_steps-1;i++ ) {
float4 t = tex2D(reliefmap,dp+ds*depth);
if (depth<t.w)
depth += size;
}
const int binary_search_steps=5;
// recurse around first point (depth) for closest match
for( int i=0;i<binary_search_steps;i++ ) {
size*=0.5;
float4 t = tex2D(reliefmap,dp+ds*depth);
if (depth<t.w)
depth += (2*size);
depth -= size;
}
return depth;
}

float ray_intersect_rm_lin( // only linear search for shadows
in sampler2D reliefmap,
in float2 dp,
in float2 ds)
{
const int linear_search_steps=15;
// current size of search window
float size = 1.0/linear_search_steps;
// current depth position
float depth = 0.0;
// search front to back for first point inside object
for( int i=0;i<linear_search_steps-1;i++ ) {
float4 t = tex2D(reliefmap,dp+ds*depth);
if (depth<t.w)
depth += size;
}
return depth;
}

////// relief mapping pixel shaders ////////

float4 relief_map_shadowsPS(VertexOutput IN) : COLOR
{
// ray intersect in view direction
float3 p = IN.vpos;
float3 Vn = normalize(p);
float a = dot(IN.normal,-Vn);
float3 s = float3(dot(Vn,IN.tangent.xyz), dot(Vn,IN.binormal.xyz), a);
s *= Depth/a;
float2 ds = s.xy;
float2 dp = IN.UV;
float d = ray_intersect_rm(ReliefSampler,dp,ds);

// get rm and color texture points
float2 uv = dp+ds*d;
float3 texCol = tex2D(ColorSampler,uv).xyz;
float3 tNorm = tex2D(ReliefSampler,uv).xyz - float3(0.5,0.5,0.5);
tNorm = normalize(tNorm.x*IN.tangent - tNorm.y*IN.binormal + tNorm.z*IN.normal);

// compute light direction
p += Vn*d/(a*Depth);
float3 Ln = normalize(p-IN.lightpos.xyz);

// compute diffuse and specular terms
float att = saturate(dot(-Ln,IN.normal));
float diff = saturate(dot(-Ln,tNorm));
float spec = saturate(dot(normalize(-Ln-Vn),tNorm));

// ray intersect in light direction
dp+= ds*d;
a = dot(IN.normal,-Ln);
s = float3(dot(Ln,IN.tangent.xyz),dot(Ln,IN.binormal.xyz),a);
s *= Depth/a;
ds = s.xy;
dp -= ds*d;
float dl = ray_intersect_rm_lin(ReliefSampler,dp,s.xy);
if (dl<d-0.05) // if pixel in shadow
{
diff *= dot(vecLight.xyz,float3(1.0,1.0,1.0))*0.133333;
spec = 0;
}
spec = pow(spec,PhongExp);

// compute final color
float3 finalcolor = vecLight.xyz*texCol + att*(texCol*DiffColor*diff+SpecColor*spec);
return float4(finalcolor.rgb,1.0);
}

float4 relief_mapPS(VertexOutput IN) : COLOR
{
// ray intersect in view direction
float3 p = IN.vpos;
float3 Vn = normalize(p);
float a = dot(IN.normal,-Vn);
float3 s = float3(dot(Vn,IN.tangent.xyz), dot(Vn,IN.binormal.xyz), a);
s *= Depth/a;
float2 ds = s.xy;
float2 dp = IN.UV;
float d = ray_intersect_rm(ReliefSampler,dp,ds);

// get rm and color texture points
float2 uv = dp+ds*d;
float3 texCol = tex2D(ColorSampler,uv).xyz;
float3 tNorm = tex2D(ReliefSampler,uv).xyz - float3(0.5,0.5,0.5);
tNorm = normalize(tNorm.x*IN.tangent - tNorm.y*IN.binormal + tNorm.z*IN.normal);

// compute light direction
p += Vn*d/(a*Depth);
float3 Ln = normalize(p-IN.lightpos.xyz);

// compute diffuse and specular terms
float att = saturate(dot(-Ln,IN.normal));
float diff = saturate(dot(-Ln,tNorm));
float spec = saturate(dot(normalize(-Ln-Vn),tNorm));
spec = pow(spec,PhongExp);

// compute final color
float3 finalcolor = vecLight.xyz*texCol +
att*(texCol*DiffColor*diff+SpecColor*spec);
return float4(finalcolor.rgb,1.0);
}

/********************* TECHNIQUES **************/
/*
technique normal_mapping {
pass p0 {
// CullMode = CW;
VertexShader = compile vs_2_0 view_spaceVS();
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
CullMode = None;
PixelShader = compile ps_2_a normal_mapPS();
}
}
*/
/*
technique parallax_mapping {
pass p0 {
// CullMode = CW;
VertexShader = compile vs_2_0 view_spaceVS();
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
CullMode = None;
PixelShader = compile ps_2_a parallax_mapPS();
}
}
*/

technique relief_mapping {
pass p0 {
// CullMode = CW;
VertexShader = compile vs_2_0 view_spaceVS();
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
CullMode = None;
PixelShader = compile ps_2_a relief_mapPS();
}
}

/*
technique relief_mapping_shadows {
pass p0 {
// CullMode = CW;
VertexShader = compile vs_2_0 view_spaceVS();
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
CullMode = None;
PixelShader = compile ps_2_a relief_map_shadowsPS();
}
}
*/
/****************************************** EOF ***/





I hope that this could become handy for someone.

Slin