Gamestudio Links
Zorro Links
Newest Posts
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
0 registered members (), 1,094 guests, and 1 spider.
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 1 of 2 1 2
Level Geometry, Parallax Mapping And Glow! #42220
03/07/05 18:47
03/07/05 18:47
Joined: Jul 2003
Posts: 893
Melbourne, Australia
Matt_Coles Offline OP

User
Matt_Coles  Offline OP

User

Joined: Jul 2003
Posts: 893
Melbourne, Australia
Was playing around with these 3 things and got this result, the code is Steempipes, altered slightly for level geometry and runs on a 9800 pro 32fps average with 2 dynamic light

Enjoy





Matt Coles

Re: Level Geometry, Parallax Mapping And Glow! [Re: Matt_Coles] #42221
03/07/05 21:02
03/07/05 21:02
Joined: Mar 2005
Posts: 82
Switzerland, Oberriet
proteK Offline
Junior Member
proteK  Offline
Junior Member

Joined: Mar 2005
Posts: 82
Switzerland, Oberriet
Wow, thats nice :-)

Can you post the code if its opensource or where are these part of code?



great work :-)

protek


Cybertron G Studios Switzerland A7.06 Pro http://www.cybertron.ch Contact us protek@hispeed.ch
Re: Level Geometry, Parallax Mapping And Glow! [Re: proteK] #42222
03/08/05 06:24
03/08/05 06:24
Joined: Jul 2003
Posts: 893
Melbourne, Australia
Matt_Coles Offline OP

User
Matt_Coles  Offline OP

User

Joined: Jul 2003
Posts: 893
Melbourne, Australia
Here's the code for your wdl:

// Change the textures to your own
bmap cementcolour = <cement.bmp>;
bmap cementDOT32 = <cementDOT3.tga>;
bmap cementheightmap = <cementh.bmp>;

material cement // Your wad texture name
{
skin1 = cementcolour;
skin2 = cementDOT32;
skin3 = cementheightmap;
flags = tangent;
}

starter load_shaders()
{
d3d_automaterial=1;

effect_load(cement,"parallax.fx"); // wad texture name at beginning of brackets
}



Your Parallax.fx file:



float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matViewInv;

float3x3 WldToTan;

float4 vecViewPos;
float4 vecViewDir;

float4 vecLight;
float4 vecLightPos[8];
float4 vecLightColor[8];

texture entSkin1;
texture mtlSkin2;
texture mtlSkin3;

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


sampler sBumpMap = sampler_state
{
Texture = <mtlSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};


sampler sHeightMap = sampler_state
{
Texture = <mtlSkin3>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};



struct VS_OUTPUT
{
float4 oPosition : POSITION;
float2 Tex : TEXCOORD0;
float3 Light1 : TEXCOORD2;
float3 View1 : TEXCOORD3;
float3 Att1 : TEXCOORD4;

float3 Light2 : TEXCOORD5;
float3 View2 : TEXCOORD6;
float3 Att2 : TEXCOORD7;
};


VS_OUTPUT main_vs(float4 inPosition : POSITION, float2 inTex : TEXCOORD0, float3 inNormal : NORMAL, float3 inTangent : TEXCOORD2 )
{
VS_OUTPUT Out ;

Out.oPosition = mul(inPosition, matWorldViewProj);

WldToTan[0] = mul(inTangent, matWorld);
WldToTan[1] = mul(cross(inTangent, inNormal), matWorld);
WldToTan[2] = mul(inNormal, matWorld);

Out.Tex = inTex.xy * 1.5; //Scale the texture UV's


float4 Pos_World = mul( inPosition, matWorld);

float LightRange1 = 0.003;
float LightRange2 = 0.003;

//light 1
float3 Light1 = Pos_World - vecLightPos[1];
Out.Light1.xyz = mul(WldToTan, -Light1);

float3 Viewer1 = Pos_World - vecViewDir;
Out.View1.xzy = mul(WldToTan, -Viewer1);

Out.Att1 = Light1 * LightRange1;
//light 2
float3 Light2 = Pos_World - vecLightPos[2];
Out.Light2.xyz = mul(WldToTan, -Light2);

float3 Viewer2 = Pos_World - vecViewDir;
Out.View2.xzy = mul(WldToTan, -Viewer2);

Out.Att2 = Light2 * LightRange2;

return Out;
}

struct PS_INPUT0
{
float2 Tex : TEXCOORD0;
float3 Light1 : TEXCOORD2;
float3 View1 : TEXCOORD3;
float3 Att1 : TEXCOORD4;
float3 Light2 : TEXCOORD5;
float3 View2 : TEXCOORD6;
float3 Att2 : TEXCOORD7;

};

float4 main_ps(PS_INPUT0 IN): COLOR
{
const float HeightScale = {0.030000f};
const float BiasFilter = {0.025000f};



float3 ViewDir = normalize(IN.View1);
float4 color;
float3 bumpNormal;

float Height = HeightScale * tex2D(sHeightMap, IN.Tex) - BiasFilter;
float2 OffsetTex = Height * ViewDir + IN.Tex;
color = tex2D(sColorMap, OffsetTex);
bumpNormal =(2 * (tex2D(sBumpMap, OffsetTex )))- 1.0;
float4 gloss = tex2D( sBumpMap, OffsetTex);

//light1
float3 LightDir1 = normalize(IN.Light1);
float3 ViewDir1 = normalize(IN.View1);
float4 diff1 = saturate(dot(bumpNormal, LightDir1));
float shadow1 = saturate(2 * diff1);
float3 Reflect1 = normalize(2 * diff1 * bumpNormal - LightDir1);
float4 spec1 = pow(saturate(dot(Reflect1, ViewDir1)), 8);
float4 Attenuation1 = saturate(dot(IN.Att1, IN.Att1));

//light2
float3 LightDir2 = normalize(IN.Light2);
float3 ViewDir2 = normalize(IN.View2);
float4 diff2 = saturate(dot(bumpNormal, LightDir2));
float shadow2 = saturate(2 * diff2);
float3 Reflect2 = normalize(2 * diff2 * bumpNormal - LightDir2);
float4 spec2 = pow(saturate(dot(Reflect2,ViewDir2)), 8);
float4 Attenuation2 = saturate(dot(IN.Att2, IN.Att2));

return (
(0.2 * color) + //ambient
((shadow1 * (color * diff1 + (spec1)) * (1 -Attenuation1))*vecLightColor[1])+
((shadow2 * (color * diff2 + (spec2)) * (1 -Attenuation2))*vecLightColor[2])
);

//return (0.2 * color + color* diff1 * vecLightColor[1]+diff2 * vecLightColor[2]);

}


technique Parallax
{
pass P0
{

VertexShader = compile vs_2_0 main_vs();
PixelShader = compile ps_2_0 main_ps();
}
}



I usually make these things into demos, so one should be available shortly

Parallax Mapping is the effect used on levels to make them look more detailed, its a more complex effect than normal mapping and you can see it in games and engines such as Elder Scrolls Oblivion and the Unreal 3.0 Engine

Looks extremely awesome with moving dynamic lights lights

Enjoy,

Matt Coles

Re: Level Geometry, Parallax Mapping And Glow! [Re: Matt_Coles] #42223
03/08/05 07:26
03/08/05 07:26
Joined: Jan 2003
Posts: 142
England
Ranger1 Offline
Member
Ranger1  Offline
Member

Joined: Jan 2003
Posts: 142
England
Matt,

I'll wait until your Level comes out

But having a copy of a Wolfgang Engel Book on Shaders I Know how good this looks so thanx very much for sharing...


Whilst all Answers are replies not all replies are Answers
Re: Level Geometry, Parallax Mapping And Glow! [Re: Ranger1] #42224
03/08/05 09:26
03/08/05 09:26
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
I seem to be missing the glow...

-Rhuarc


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: Level Geometry, Parallax Mapping And Glow! [Re: Rhuarc] #42225
03/08/05 10:19
03/08/05 10:19
Joined: Jul 2003
Posts: 893
Melbourne, Australia
Matt_Coles Offline OP

User
Matt_Coles  Offline OP

User

Joined: Jul 2003
Posts: 893
Melbourne, Australia
I'll turn the bloom / glow up in the final version, it's there but it's always hard to see if the texture environment is pretty much the same. The Bloom / Glow shader, I forgot to mention is Matt A's Renderview Dll

Re: Level Geometry, Parallax Mapping And Glow! [Re: Matt_Coles] #42226
03/09/05 03:31
03/09/05 03:31
Joined: Mar 2005
Posts: 82
Switzerland, Oberriet
proteK Offline
Junior Member
proteK  Offline
Junior Member

Joined: Mar 2005
Posts: 82
Switzerland, Oberriet
Thanks a lot for the code


A programm to make good heightmaps ?

Adobe? or a other good programm



greez Protek


Cybertron G Studios Switzerland A7.06 Pro http://www.cybertron.ch Contact us protek@hispeed.ch
Re: Level Geometry, Parallax Mapping And Glow! [Re: proteK] #42227
03/09/05 03:52
03/09/05 03:52
Joined: Oct 2002
Posts: 815
NY USA
R
Red Ocktober Offline
Developer
Red Ocktober  Offline
Developer
R

Joined: Oct 2002
Posts: 815
NY USA
looks real nice Matt...

what'dya think the performance will be like on GeForce5200fx or a Radeon9200 level cards?

so far i'm kinda disappointed in any real scene use of shaders... or for that matter, anything that uses a 'material' to display the textures seem to immediately slow things down...

--Mike

Re: Level Geometry, Parallax Mapping And Glow! [Re: Red Ocktober] #42228
03/09/05 06:18
03/09/05 06:18
Joined: Jul 2003
Posts: 893
Melbourne, Australia
Matt_Coles Offline OP

User
Matt_Coles  Offline OP

User

Joined: Jul 2003
Posts: 893
Melbourne, Australia
If you turn of glow it should work ok on those cards on a decent frame rate. Note, glows not in the code above
The program I use for heightmaps is Photoshop, but there is a lot of other programs that can do that

Matt Coles

Re: Level Geometry, Parallax Mapping And Glow! [Re: Matt_Coles] #42229
03/09/05 19:47
03/09/05 19:47
Joined: Jul 2003
Posts: 893
Melbourne, Australia
Matt_Coles Offline OP

User
Matt_Coles  Offline OP

User

Joined: Jul 2003
Posts: 893
Melbourne, Australia
Demo will be appearing under Ultimate Shader Collection in User Contributions Forum :0 very soon...

Matt Coles

Page 1 of 2 1 2

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