Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 05:41
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, AndrewAMD), 1,278 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 8 1 2 3 4 5 6 7 8
Re: HLSL Parallax Mapping [Re: M3PHiSTOPH3L3S] #34771
10/16/04 23:24
10/16/04 23:24
Joined: Oct 2003
Posts: 151
Watseka, Illinois
M3PHiSTOPH3L3S Offline OP
Member
M3PHiSTOPH3L3S  Offline OP
Member

Joined: Oct 2003
Posts: 151
Watseka, Illinois
well when i got home last night I tried to use matWorldInv and it still didn't work. If I set it to vs and ps version 2.0 it compiles but shows nothing. If it is compiled under 3.0 it shows the model but no effect. I don't know. Anyone have any other suggestions? I'm starting to have doubt about getting this to work...

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
Re: HLSL Parallax Mapping [Re: M3PHiSTOPH3L3S] #34772
10/17/04 02:58
10/17/04 02:58
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Well... I got sidetracked from my version and played aroudn with your code. The textures show, but I think all I am getting is regular Bumpmapping.

None the less, hope you can figure out what I am missing here

** I cannot answer any questions about this one because I cannot figure out how to get the offset working right, yet.

Code:
/**************************************************************
Attempting to get Parallax Bumpmapping to work.
10/16/04: I think right now only Bumpmapping
is actually happening
**************************************************************/


/*************************************************************
Make noFog == True, or add fog vertex code
to allow material to show on model.

For this testing I used a flat terrain.
**************************************************************/


function parabump_init{

mat_inverse(mtl.matrix, matworld);

bmap_to_mipmap(mtl.skin1);
bmap_to_mipmap(mtl.skin2);
bmap_to_mipmap(mtl.skin3);
}




bmap tex0 = <rockwall_CM.tga>; //RGB Colormap
bmap tex1 = <rockwall_NM.tga>; //RGB Normalmap
bmap tex2 = <rockwall_HM.tga>; //RGB Heightmap



material parabump_fx {
flags=tangent;
Skin1=tex0;
Skin2=tex1;
Skin3=tex2;
event = parabump_init;


effect="


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

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

texture mtlSkin1;
texture mtlSkin2;
texture mtlSkin3;

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

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

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

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

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

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

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

vsOutStruct.bump_map = vsInStruct.texcoord0;

float3x3 tangentspace_matrix = float3x3( vsInStruct.tangent,cross( vsInStruct.tangent,vsInStruct.normal

),vsInStruct.normal);
float3 objectspace_light_vector = mul( matMtl, -vecSunDir ) - vsInStruct.position;

vsOutStruct.tangentlight = mul( tangentspace_matrix,objectspace_light_vector );

float3 objectspace_view_vector = mul( matMtl, vecViewPos ) - vsInStruct.position;

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

return vsOutStruct;
};

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

float bumpiness = 0.5;
float parallax = 5.5;
float specular_power = 0.5;
float4 vecAmbient;
float4 vecDiffuse;
float4 vecSpecular;
float vecViewDir;
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 eye_vec, float parallax_amount )
{
return (tex2D( height_map, oldcoord )
* parallax_amount + parallax_amount * 0.5)
* (0.0,0.0,0.0) + oldcoord
;
};

PS_OUTPUT_STRUCT mainPS( PS_INPUT_STRUCT psInStruct )
{
PS_OUTPUT_STRUCT psOutStruct;
float3 eye_vec = normalize( psInStruct.tangenteye );
float2 modified_texcoord = ParallaxTexCoord( psInStruct.bump_map, height_map, eye_vec, 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 = (
vecAmbient +
vecDiffuse * max( 0, n_dot_l ) +
vecSpecular * 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 mainVS();
PixelShader = compile ps_2_0 mainPS();
}
}
";
}

action parabump{

my.material = parabump_fx;

}



Re: HLSL Parallax Mapping [Re: Steempipe] #34773
10/17/04 02:59
10/17/04 02:59
Joined: Oct 2002
Posts: 815
NY USA
R
Red Ocktober Offline
Developer
Red Ocktober  Offline
Developer
R

Joined: Oct 2002
Posts: 815
NY USA
hey Steem... got time to add a quick screenshot of the results your gettin...

thx

--Mike

Re: HLSL Parallax Mapping [Re: Red Ocktober] #34774
10/17/04 03:23
10/17/04 03:23
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
If playing with the eye_vec variable and also the tweakables, I get super strange projections.... This shot is none of that, however.



Re: HLSL Parallax Mapping [Re: Steempipe] #34775
10/17/04 03:31
10/17/04 03:31
Joined: Oct 2002
Posts: 815
NY USA
R
Red Ocktober Offline
Developer
Red Ocktober  Offline
Developer
R

Joined: Oct 2002
Posts: 815
NY USA
i may be wrong, and just seeing the tricks the texture is playing on me, but from that shot, it looks as if you raise the bumps a lil that you might have something...

... the reflection on the edge of the bricks seem to me that it may be working,

or i might be missing the whole thing entirely...

--Mike

Re: HLSL Parallax Mapping [Re: Red Ocktober] #34776
10/17/04 03:40
10/17/04 03:40
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
It is working to a degree... thing is that I cannot figure out how to get more relief with the thing. When I try, I get some crazy results. I get a relief mapped texture, but not in the right places or scale.

I tried until nearly blowing a gasket, so I must decompress alittle

Re: HLSL Parallax Mapping [Re: Steempipe] #34777
10/17/04 04:23
10/17/04 04:23
Joined: Oct 2002
Posts: 815
NY USA
R
Red Ocktober Offline
Developer
Red Ocktober  Offline
Developer
R

Joined: Oct 2002
Posts: 815
NY USA
... yeah, i'm sure this stuff can get a lil aggravating (frustrating) at times.

yeah, take a break man.

this stuff IS rocket science


hey, i appreciate you posting the stuff and showing the rest of us (me) what you've accomplished.

--Mike

Re: HLSL Parallax Mapping [Re: Steempipe] #34778
10/17/04 07:05
10/17/04 07:05
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
You seemed to be closer at this pic:



Can you post that version of code? So, that a comparison of both might give an idea how to proceed?

Re: HLSL Parallax Mapping [Re: Red Ocktober] #34779
10/17/04 09:00
10/17/04 09:00
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Quote:

... yeah, i'm sure this stuff can get a lil aggravating (frustrating) at times.

yeah, take a break man.

this stuff IS rocket science


hey, i appreciate you posting the stuff and showing the rest of us (me) what you've accomplished.

--Mike




Thanks!

Pappenheimer: It my come down to that (posting the other code), but I have a few more ideas to try first before I take the "garbage" that litters my FX file out. Right now it may be more confusing than anything. Good suggestion, however.

Here is what I am fighting on this one (my version). If you look at the texture it is looking like this...



Re: HLSL Parallax Mapping [Re: Red Ocktober] #34780
10/17/04 09:07
10/17/04 09:07
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Hey Steempipe,

If you can just post your other code (or PM/email it to me (rhuarc@shadowforgeserver.net)) and let me know how you were trying to get it working with more parallax in this one (that was putting it in the wrong places) I'm sure I can figure it out from here. I've got a few good ideas as to what the problem is...

-Rhuarc


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Page 3 of 8 1 2 3 4 5 6 7 8

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1