Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (monarch), 1,259 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
decals with parallax mapping #137790
06/24/07 09:28
06/24/07 09:28
Joined: May 2003
Posts: 567
Spain, Canary Islands
Felixsg Offline OP
User
Felixsg  Offline OP
User

Joined: May 2003
Posts: 567
Spain, Canary Islands
The time to update the decals system are long
why not added the parallax decals

also why not update the parallax mapping with oclusion

article with decal parallax mapping

Decal parallax mapping (with and without oclussion)

also the parallax mapping with oclusion

Ati parallax mapping with oclussion

Last edited by Felixsg; 06/24/07 09:30.
Re: decals with parallax mapping [Re: Felixsg] #137791
06/24/07 11:04
06/24/07 11:04
Joined: Oct 2006
Posts: 91
G
Ghost Offline
Junior Member
Ghost  Offline
Junior Member
G

Joined: Oct 2006
Posts: 91
Great suggestion. Parallax mapping options built-in to the new decals system would put A7 ahead of a lot other indie engines in this area -a nice reward for loyal users having to make do with the old system for so long.

Re: decals with parallax mapping [Re: Ghost] #137792
06/24/07 12:46
06/24/07 12:46
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
parallax mapping can already be implemented through a shader. just assign such a shader to mat_sprite and you have your parallax-mapped decal.

Re: decals with parallax mapping [Re: Joey] #137793
06/24/07 20:57
06/24/07 20:57
Joined: Oct 2006
Posts: 91
G
Ghost Offline
Junior Member
Ghost  Offline
Junior Member
G

Joined: Oct 2006
Posts: 91
@Joey

yes I realise it's possible to write a parallax shader, but the point was it would be nice if the parallax and the occlusion were built-in and optimised by Conitec when they upgraded the decal system, so it's easy to use for all the non-programers/artist types using 3DGS.

Re: decals with parallax mapping [Re: Ghost] #137794
06/24/07 21:57
06/24/07 21:57
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
i see, and i know it's that much more work to code the shader yourself, so i support that suggestion.

Re: decals with parallax mapping [Re: Joey] #137795
12/06/07 00:03
12/06/07 00:03
Joined: Aug 2007
Posts: 17
S
sCKan Offline
Newbie
sCKan  Offline
Newbie
S

Joined: Aug 2007
Posts: 17
//Use this shader for apply parallax on 3dgs geometry :
//first import a texture and rename it as mtl_parallax <-- this is the same name of yor material and this texture should be flat


//and activate
d3d_automaterial = 1

//create 2 images with normal map and height map
bmap normal = <normal.tga>; //normal map for your texture mtl_parallax
bmap height = <height.tga>; //heigh map for your texture mtl_parallax

//create a material mtl_parallax <<-- same name of your texture
mtl_paralax
{
//asigm normal & height map
skin1 = normal;
skin2 = height;
flags = tangent;
effect = "parallax.fx";
}

/////////////////////////////////////////////////////////////////

//copy the next code in a file named parallax.fx
//*******************************************
parallax.fx

float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matViewInv;
float3x3 WldToTan;
float4 vecViewPos;
float4 vecViewDir;
float4 vecLight;
float4 vecLightPos[8];
float4 vecLightColor[8];

texture entSkin1;
texture mtlSkin1;
texture mtlSkin2;

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

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

sampler sHeightMap = sampler_state
{
Texture = <mtlSkin2>;
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; //Scale the texture UV's

float4 Pos_World = mul( inPosition, matWorld);

float LightRange1 = 0.003;
float LightRange2 = 0.005;

//light 1
float3 Light1 = Pos_World - vecLightPos[0];
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[1];
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[0])+
((shadow2 * (color * diff2 + (spec2)) * (1 -Attenuation2))*vecLightColor[1])
);
// return (0.2 * color + color* diff1 * vecLightColor[0]+diff2 * vecLightColor[1]);
}


technique Parallax
{
pass P0
{
VertexShader = compile vs_2_0 main_vs();
PixelShader = compile ps_2_0 main_ps();
}
}



//////////////////////////////////////////////////





//if you want to use this on models just change
texture mtlSkin1; // for texture entSkin2;
texture mtlSkin2; // for texture entSkin3;

//and the samples lines
sampler sBumpMap = sampler_state
{
Texture = <entSkin2>; <<-----------------------
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};

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


//and asign the normal image as skin2 in your model
//and asign the height image as skin3 in your model




//create a material
mtl_paralaxModel
{
flags = tangent;
effect = "parallax.fx";
}

//and assign it to your model
//Enjoy it !!!!!!


Web Master
Re: decals with parallax mapping [Re: sCKan] #137796
12/06/07 01:21
12/06/07 01:21
Joined: May 2003
Posts: 567
Spain, Canary Islands
Felixsg Offline OP
User
Felixsg  Offline OP
User

Joined: May 2003
Posts: 567
Spain, Canary Islands
thanks sckan


Moderated by  aztec, Spirit 

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