Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
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 (7th_zorro, dr_panther), 724 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
Page 1 of 6 1 2 3 4 5 6
Normalmapping (in development) #117150
03/13/07 13:47
03/13/07 13:47
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

Is this coming out soon, I've tried 2 shaders from the forum and all I get is a black (very dark) model.

In this day and age it should be already a basic thing and specially for people like me who can't work out what I'm doing wrong


Re: Normalmapping (in development) [Re: MaxF] #117151
03/13/07 13:58
03/13/07 13:58
Joined: Oct 2005
Posts: 528
Italy
M
Mondivirtuali Offline
User
Mondivirtuali  Offline
User
M

Joined: Oct 2005
Posts: 528
Italy
Agree...a normal map template would be an excellent and very useful tool

Re: Normalmapping (in development) [Re: Mondivirtuali] #117152
03/13/07 14:13
03/13/07 14:13
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Well, you don't need to wait for the templates, normalmapping is simple:

Code:
MATERIAL mtl_bump
{
//Normal Map must be on Skin2
effect=
"
#include <transform>
#include <fog>
#include <pos>
#include <normal>
#include <tangent>

float4 vecSunDir;
float4 vecColor;

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

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

struct out_bump
{
float4 Pos: POSITION;
float Fog: FOG;
float4 Color: COLOR;
float2 Tex: TEXCOORD0;
float2 Bump: TEXCOORD1;
float3 Normal: TEXCOORD2;
float3 Light: TEXCOORD3;
};

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

Out.Pos = DoTransform(inPos);
Out.Tex = inTex;
Out.Bump = inTex; // different coordinates required for ps_1_1
Out.Color = float4(1.0,1.0,1.0,1.0);
Out.Fog = DoFog(inPos);

CreateTangents(inNormal,inTangent);
float3 N = matTangent[2];

// transform the output values into the 0..1 range
Out.Light = DoTangent(-vecSunDir) * 0.5 + 0.5;
Out.Normal = DoTangent(N) * 0.5 + 0.5;

return Out;
}


float4 ps_bump(out_bump In): COLOR
{
float4 base = tex2D(sBaseTex,In.Tex);
float3 bumpNormal = tex2D(sBump,In.Bump);
float diffuse = saturate(dot(In.Light*2 - 1,bumpNormal*2 - 1));
#ifdef SHADOW
diffuse *= saturate(4 * dot(In.Light*2 - 1,In.Normal*2 - 1));
#endif
return base * diffuse;
}

technique bump
{
pass One
{
VertexShader = compile vs_1_1 vs_bump();
PixelShader = compile ps_1_1 ps_bump();
}
}

";
}



You need 6.50, the template6 file "default.fx" must be in the path, and the model must have a normal map on its second skin. You can also save the effect to an .fx file and assign it to the model directly in MED.

Re: Normalmapping (in development) [Re: MaxF] #117153
03/13/07 14:38
03/13/07 14:38
Joined: Apr 2004
Posts: 83
DWilki Offline
Junior Member
DWilki  Offline
Junior Member

Joined: Apr 2004
Posts: 83
Fantastic! Thanks for this.

Anyone know how to make this work with dynamic lights? Also, how would this blend the shadow map in with the effect?

Re: Normalmapping (in development) [Re: DWilki] #117154
03/13/07 15:40
03/13/07 15:40
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

Easy for a guy like you

Thanks for the code will play with it, so you must use templates!


Re: Normalmapping (in development) [Re: MaxF] #117155
03/13/07 16:01
03/13/07 16:01
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
whats hard about it? you store it in an fx file, make a material with effect="file.fx"; and make your second skin in the model a normal map

Re: Normalmapping (in development) [Re: lostclimate] #117156
03/13/07 18:52
03/13/07 18:52
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
I was talking about the shader code

Last edited by MaxF; 03/13/07 18:52.

Re: Normalmapping (in development) [Re: lostclimate] #117157
03/13/07 21:01
03/13/07 21:01
Joined: Oct 2005
Posts: 528
Italy
M
Mondivirtuali Offline
User
Mondivirtuali  Offline
User
M

Joined: Oct 2005
Posts: 528
Italy
How to make an fx files?

Re: Normalmapping (in development) [Re: Mondivirtuali] #117158
03/13/07 21:27
03/13/07 21:27
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
Rightclick, new, Text. Then rename new document.txt to normalmapping.fx, open it with the standart editor and copy&past the shader code.

Re: Normalmapping (in development) [Re: TWO] #117159
03/13/07 22:10
03/13/07 22:10
Joined: Oct 2005
Posts: 528
Italy
M
Mondivirtuali Offline
User
Mondivirtuali  Offline
User
M

Joined: Oct 2005
Posts: 528
Italy
Okay, shader code done. It called mt_material1.fx
Then I try this:
I put two skins in the same (static model)(from Med), one is the normal map (obteined with Gimp from the first skin) .
Then I include the nm.fx in the try.wdl , include material.wdl in the project and assign the mt_material1 at the model.
It appairs the same (?), perhaps the two skins should named "entskin"? I should miss some passages here.

Last edited by Mondivirtuali; 03/13/07 22:12.
Page 1 of 6 1 2 3 4 5 6

Moderated by  old_bill, Tobias 

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