Alright here is the source I have so far. This is the first HLSL source I have tried to convert so it may be a little sloppy. You can compile it and see the errors that I got:


// start

//
// HLSL Parallax Shader
//

Material mat_parallax
{

effect = "

// VertexShader ------------------

float4x4 matWorldViewProj;
float4x4 matWorld;
float4 light_position = ( 100, 100, 100, 0); // just used these settings for testing
float4 vecViewPos;


texture entSkin1;
texture entSkin2;
texture entSkin3;

sampler base_map = sampler_state
{
texture = (entSkin1);
};

sampler bump_map = sampler_state
{
texture = (entSkin2);
};

sampler height_map = sampler_state
{
texture = (entSkin3);
};

struct VS_INPUT_STRUCT
{
float4 position : POSITION;
float3 tangent : TANGENT;
float3 normal : NORMAL;
float3 texcoord0 : TEXCOORD0;
};

struct VS_OUTPUT_STRUCT
{
float4 position : POSITION;
float2 bump_map : TEXCOORD0;
float3 tangentlight : TEXCOORD1;
float3 half_angle : TEXCOORD2;
float3 tangenteye : TEXCOORD3;
};

VS_OUTPUT_STRUCT main( VS_INPUT_STRUCT vsInStruct )
{
VS_OUTPUT_STRUCT vsOutStruct;
vsOutStruct.position = mul( matWorldViewProj, vsInStruct.position );

float3 position = mul( matWorld, vsInStruct.position );

vsOutStruct.bump_map = vsInStruct.texcoord0;

float3x3 tangentspace_matrix = float3x3( vsInStruct.tangent, cross( vsInStruct.tangent, vsInStruct.normal ), vsInStruct.normal );
float3x3 objectspace_light_vector = mul( ( matWorld * -1 ), light_position ) - vsInStruct.position;

vsOutStruct.tangentlight = mul( tangentspace_matrix, objectspace_light_vector );

float3 objectspace_view_vector = mul( ( matWorld * -1 ), vecViewPos ) - vsInStruct.position;

vsOutStruct.tangenteye = mul( tangentspace_matrix, objectspace_view_vector );
vsOutStruct.half_angle = vsOutStruct.tangentlight + vsOutStruct.tangenteye;

return vsOutStruct;
};

// PixelShader -------------------

float bumpiness;
float parallax;
float specular_power;
float4 ambient;
float4 diffuse;
float4 specular;

struct PS_INPUT_STRUCT
{
float2 bump_map : TEXCOORD0;
float3 tangentlight : TEXCOORD1;
float3 half_angle : TEXCOORD2;
float3 tangenteye : TEXCOORD3;
};

struct PS_OUTPUT_STRUCT
{
float4 color0 : COLOR0;
};

float2 ParallaxTexCoord( float2 oldcoord, sampler height_map, float3 vecViewPos, float parallax_amount )
{
return( tex2D( height_map, oldcoord )
* parallax_amount - parallax_amount * 0.5 )
* vecViewPos + oldcoord;
};

PS_OUTPUT_STRUCT main( PS_INPUT_STRUCT psInStruct )
{
PS_OUTPUT_STRUCT psOutStruct;
float3 vecViewPos = normalize( psInStruct.tangenteye );
float2 modified_texcoord = ParallaxTexCoord( psInStruct.bump_map, height_map, vecViewPos, parallax );
float3 base = tex2D( base_map, modified_texcoord );
float3 bump = tex2D( bump_map, modified_texcoord );
float3 normalized_light_vector = normalize( psInStruct.tangentlight );
float3 normalized_half_angle = normalize( psInStruct.half_angle );
float3 smooth = float3( 0.5, 0.5, 1 );
bump = lerp( smooth, bump, bumpiness );
bump = normalize( ( bump * 2.0f ) - 1.0f );
float3 n_dot_l = dot( bump, normalized_light_vector );
float3 n_dot_h = dot( bump, normalized_half_angle );
psOutStruct.color0.rgb = (
ambient +
diffuse * max( 0, n_dot_l ) +
specular * pow( max ( 0, n_dot_h ), specular_power )
) * base;
psOutStruct.color0.a = 1.0f;

return psOutStruct;

};

technique Parallax
{
pass P0
{

VertexShader = compile vs_2_0 vsOutStruct();
PixelShader = compile ps_2_0 psOutStruct();
}
}


";

}


action hlsl_parallax
{

my.material = mat_parallax;

}

// finish




I hope that this can help someone because I haven't found out what is wrong yet.


M3PHiSTO


"you give me the reason, you give me control, i gave you my purity, my purity you stole, did you think i wouldn't recognize this compromise? am i just too stupid to realize?" - Trent Reznor (NiN) Yahoo Messager ID: SHATT3R3DFA1TH