Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,484 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
Page 5 of 6 1 2 3 4 5 6
Re: Normalmapping (in development) [Re: MaxF] #117190
03/25/07 19:51
03/25/07 19:51
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
There's a 'CreateTangents' function missing, or is that one of those things that can be found inside default.fx ? I could be doing all sorts of things wrong, however, I've got default.fx included, but this shader doesn't work here 'out of the box' I think,

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Normalmapping (in development) [Re: PHeMoX] #117191
03/26/07 04:27
03/26/07 04:27
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Phemox: You need the current Gamestudio version for this shader.

MaxF: Here's an indoor version that supports the static environment light and one dynamic light:

Code:
 MATERIAL mtl_bumpspecular
{
effect=
"
#include <transform>
#include <fog>
#include <pos>
#include <normal>
#include <tangent>
#define INDOOR
#ifdef INDOOR
#include <light>
#else
float4 vecSunDir;
float4 vecSunColor;
#endif
float4 vecLight;

texture entSkin1; // texture
texture entSkin2; // normal map

const float facAmbient = 0.2; // factors to play with
const float facBump = 0.5;
const float facSpecular = 2.0;

sampler sBaseTex = sampler_state { Texture = <entSkin1>; };
sampler sBump = sampler_state { Texture = <entSkin2>; };

struct out_specular
{
float4 Pos: POSITION;
float Fog: FOG;
float4 Color: COLOR0;
float4 Ambient: COLOR1;
float2 Tex: TEXCOORD0;
float2 Bump: TEXCOORD1;
float3 Light: TEXCOORD2;
float3 Halfway:TEXCOORD3;
};

out_specular vs_specular(
in float4 inPos: POSITION,
in float3 inNormal: NORMAL,
in float2 inTex: TEXCOORD0,
in float3 inTangent: TEXCOORD2)
{
out_specular Out;

Out.Pos = DoTransform(inPos);
Out.Tex = inTex;
Out.Bump = inTex; // different coordinate sets required for ps_1_1
Out.Ambient = facAmbient*vecLight;
Out.Fog = DoFog(inPos);

float3 P = DoPos(inPos);
#ifdef INDOOR
float3 LDir = normalize(vecLightPos[0].xyz - P);
float fDist = length(vecLightPos[0].xyz - P)/vecLightPos[0].w;
if (fDist < 1.f)
fDist = 1.f - fDist;
else
fDist = 0.f;
Out.Color = facSpecular*fDist*vecLightColor[0];
#else
float3 LDir = -vecSunDir;
Out.Color = facSpecular*vecSunColor;
#endif

CreateTangents(inNormal,inTangent);

// transform the output values into the 0..1 range
Out.Light = facBump*DoTangent(LDir) * 0.5 + 0.5;

float3 EyeDir = normalize(vecViewPos - P) + LDir;
Out.Halfway = DoTangent(EyeDir) * 0.5 + 0.5;

return Out;
}


float4 ps_specular(out_specular In): COLOR
{
float4 base = tex2D(sBaseTex,In.Tex);
float3 bumpNormal = tex2D(sBump,In.Bump);
float light = saturate(dot(In.Halfway*2 - 1,bumpNormal*2 - 1));
light *= light;
light *= light;
light *= light;
light *= light;
light += saturate(dot(In.Light*2 - 1,bumpNormal*2 - 1));
return base * (In.Ambient + light*In.Color);
}

technique specular
{
pass One
{
VertexShader = compile vs_1_1 vs_specular();
PixelShader = compile ps_1_1 ps_specular();
}
}

";
}





Re: Normalmapping (in development) [Re: jcl] #117192
03/26/07 14:29
03/26/07 14:29
Joined: Jul 2002
Posts: 1,364
Minbar
M
MaxF Offline OP
Serious User
MaxF  Offline OP
Serious User
M

Joined: Jul 2002
Posts: 1,364
Minbar
WOW JCL you are ACE, so I'll just use the other one for outdoor (works with the sun then) and this for indoor.

So kool will test it later

Last edited by MaxF; 03/26/07 14:31.
Re: Normalmapping (in development) [Re: jcl] #117193
03/26/07 14:55
03/26/07 14:55
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Quote:

Phemox: You need the current Gamestudio version for this shader.




Mmm, current version, which one would that be? A6.50.6? Because I thought I had installed that one, anyways I'll re-update then, thanks!

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Normalmapping (in development) [Re: jcl] #117194
03/27/07 04:10
03/27/07 04:10
Joined: Jul 2002
Posts: 1,364
Minbar
M
MaxF Offline OP
Serious User
MaxF  Offline OP
Serious User
M

Joined: Jul 2002
Posts: 1,364
Minbar
Hi JCL




On the left the old outside code, looks ok does not react to lights

On the right the new one you just posted, it does not matter how many times I play with the following:

const float facAmbient = 0.8; // factors to play with
const float facBump = 0.8;
const float facSpecular = 0.8;

Does not change anything, I would like it to look like the one on the left but work with (I like the specular highlights) with color level / dynamic lights.

I must be doing something wrong


Re: Normalmapping (in development) [Re: MaxF] #117195
03/27/07 08:43
03/27/07 08:43
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
If "#define INDOOR" is outcommented, the shader reacts on the sun, otherwise on dynamic lights. So the object must be in the range of at least one active dynamic light with CAST flag, or else you'll see no reflection.

If you have only static lights in your indoor level, outcomment the "#define INDOOR" line, and set the sun color to the color of your static lights.

Re: Normalmapping (in development) [Re: jcl] #117196
03/27/07 13:55
03/27/07 13:55
Joined: Jul 2002
Posts: 1,364
Minbar
M
MaxF Offline OP
Serious User
MaxF  Offline OP
Serious User
M

Joined: Jul 2002
Posts: 1,364
Minbar
Hi JCL

My lights are dynamic and are sat right next to the boxes the CAST flag is on and I get what you see in the picture.


Re: Normalmapping (in development) [Re: MaxF] #117197
03/27/07 14:51
03/27/07 14:51
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
Then I have to look into this. The shader works in my test level, but there could be something else I haven't thought about. If you upload your level, I'll check why the shader doesn't work.

Re: Normalmapping (in development) [Re: jcl] #117198
03/27/07 16:16
03/27/07 16:16
Joined: Jul 2002
Posts: 1,364
Minbar
M
MaxF Offline OP
Serious User
MaxF  Offline OP
Serious User
M

Joined: Jul 2002
Posts: 1,364
Minbar
Thanks JCL will upload it tonight


Re: Normalmapping (in development) [Re: jcl] #117199
03/28/07 00:35
03/28/07 00:35
Joined: Jul 2002
Posts: 1,364
Minbar
M
MaxF Offline OP
Serious User
MaxF  Offline OP
Serious User
M

Joined: Jul 2002
Posts: 1,364
Minbar
OK I sent you the level by email. to jcl conitec

Last edited by MaxF; 03/28/07 00:58.

Page 5 of 6 1 2 3 4 5 6

Moderated by  old_bill, Tobias 

Gamestudio download | 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