Gamestudio Links
Zorro Links
Newest Posts
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
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,403 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
problem with parallax from aum 53 #110024
01/30/07 16:58
01/30/07 16:58
Joined: Jun 2004
Posts: 15
Netherlands
M
michel Offline OP
Newbie
michel  Offline OP
Newbie
M

Joined: Jun 2004
Posts: 15
Netherlands
I am trying to get this shader work i use the model that comes with the aum and this code:

Code:
 material mat_parallax {

flags=tangent;

effect="

float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matViewInv;

float3x3 WldToTan;

float4 vecViewPos;
float4 vecViewDir;

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

texture entSkin1;
texture entSkin2;
texture entSkin3;

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


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;
};



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.005;

//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();
}
}


";
}

action parallax_fx // attach this action to the model that's got 3 skins
{
my.material = mat_parallax;
while (1)
{
my.pan += 2 * time;
wait (1);
}
}

// move the dynamic light around the model (place several dynamic lights if you want)
action dynamic_light // attach this action to a small model
{
my.invisible = on;
my.passable = on;
my.lightrange = 500; // play with this value
my.red = 200; // play with the values for red, green and blue
my.green = 20;
my.blue = 200;
my.cast = on;
}



in my level i have placed the model and attached the action and i have a model with the light action and this is my result:



what could be the problem?

(ps. please forive me for my english )

o btw i am using 3dgs v6.50.2
and my pc:
p4 3,40 ghz with a nvidea geforce 6600

oh and another quistion is the sphere website down? (http://matt.brightwatch.com/sphere/sphere.htm)

Last edited by michel; 01/30/07 17:06.
Re: problem with parallax from aum 53 [Re: michel] #110025
01/30/07 17:09
01/30/07 17:09
Joined: Nov 2000
Posts: 1,534
hamburg
Samb Offline
Serious User
Samb  Offline
Serious User

Joined: Nov 2000
Posts: 1,534
hamburg
you have to place a dynamic light near the cube

Re: problem with parallax from aum 53 [Re: Samb] #110026
01/30/07 17:10
01/30/07 17:10
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline
Senior Developer
Thomas_Nitschke  Offline
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
Yep, looks as if the lightrange were too small.


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: problem with parallax from aum 53 [Re: Thomas_Nitschke] #110027
01/30/07 17:15
01/30/07 17:15
Joined: Jun 2004
Posts: 15
Netherlands
M
michel Offline OP
Newbie
michel  Offline OP
Newbie
M

Joined: Jun 2004
Posts: 15
Netherlands
i don't think that's the problem:



and i have tried to place it on other places... with the same result

Re: problem with parallax from aum 53 [Re: Thomas_Nitschke] #110028
01/30/07 17:16
01/30/07 17:16
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Search for this line:
Out.Tex = inTex.xy * 1.5; //Scale the texture UV's
and change it to:
Out.Tex = inTex.xy * 1; //Scale the texture UV's

Re: problem with parallax from aum 53 [Re: michel] #110029
01/30/07 17:16
01/30/07 17:16
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline
User
bstudio  Offline
User

Joined: Aug 2006
Posts: 652
Netherlands
check the dynamic flag of the light. so you make it dynamic instead of static, because static lights don't work with parallax shading


BASIC programmers never die, they GOSUB and don't RETURN.
Re: problem with parallax from aum 53 [Re: michel] #110030
01/30/07 17:16
01/30/07 17:16
Joined: Jun 2003
Posts: 1,017
Germany
T
Thomas_Nitschke Offline
Senior Developer
Thomas_Nitschke  Offline
Senior Developer
T

Joined: Jun 2003
Posts: 1,017
Germany
Okay, but it still seems strange to me that the dynamic light is not even visible on the floor. It should!


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?
Re: problem with parallax from aum 53 [Re: Thomas_Nitschke] #110031
01/30/07 17:21
01/30/07 17:21
Joined: Jun 2004
Posts: 15
Netherlands
M
michel Offline OP
Newbie
michel  Offline OP
Newbie
M

Joined: Jun 2004
Posts: 15
Netherlands
@ slin:
nop this don't work

@ bstudio:
i use this action for the light
action dynamic_light // attach this action to a small model{ my.invisible = on; my.passable = on; my.lightrange = 500; // play with this value my.red = 200; // play with the values for red, green and blue my.green = 20; my.blue = 200; my.cast = on;}

and @ the matrix:
it is visible on the floor a bit pink/purple

Re: problem with parallax from aum 53 [Re: michel] #110032
01/30/07 17:27
01/30/07 17:27
Joined: Jun 2004
Posts: 15
Netherlands
M
michel Offline OP
Newbie
michel  Offline OP
Newbie
M

Joined: Jun 2004
Posts: 15
Netherlands

Re: problem with parallax from aum 53 [Re: michel] #110033
01/30/07 17:38
01/30/07 17:38
Joined: Jun 2004
Posts: 15
Netherlands
M
michel Offline OP
Newbie
michel  Offline OP
Newbie
M

Joined: Jun 2004
Posts: 15
Netherlands
does it work for anyone? maybe it is a problem with 3dgs 6.50.2

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