Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, ozgur), 1,240 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Beginner question? #253940
02/27/09 21:52
02/27/09 21:52
Joined: Aug 2003
Posts: 716
Canada, Toronto
thegamedesigner Offline OP
User
thegamedesigner  Offline OP
User

Joined: Aug 2003
Posts: 716
Canada, Toronto
Hello, I have two materials, one which is the basic metal, and other is a toon shader.

I want to change the toon shader so it only does the outline, and not the toon paint bit. I want to replace the toon paint with metal.

What I hope to end up with is two materials, one metal, the other metal with an outline.

Metal material:

material mtl_metal
{
ambient_blue = 0;
ambient_green = 0;
ambient_red = 128;
diffuse_blue = 170;
diffuse_green = 170;
diffuse_red = 200;//200
specular_blue = 255;
specular_green = 255;
specular_red = 255;
power = 10;
}

Toon:

material mtl_toon//white
{
skin1=bmp_normalizationcube;
skin2=bmp_toonlookup;
event=mtl_toon_init;
effect
"
texture entSkin1;
texture mtlSkin1;
texture mtlSkin2;
matrix matWorldViewProj;
matrix matWorld;
vector vecSkill41;
vector vecSunDir;

technique toon
{
//-------------------------------paint
pass p0
{
texture[0]=<mtlSkin1>;
texture[1]=<mtlSkin2>;
texture[2]=<entSkin1>;

addressU[1]=clamp;

magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;

vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;

vertexShaderConstant[16]=<vecSunDir>;

vertexShader=
asm
{
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

m4x4 oPos,v0,c0 // transform position to clip space
m3x3 r0,v3,c4 // transform normal to world space
dp3 r0.w,r0,r0 // renormalize it
rsq r0.w,r0.w
mul r0,r0,r0.w
mov oT0.xyz,r0.xyz // output normal to oT0
mov oT1.xyz,-c16 // output light direction to oT1
mov oT2.xy,v7.xy // output uvs to oT2
};
pixelShader=
asm
{
ps.1.3
tex t0 // fetch normalized normal
texdp3tex t1,t0_bx2 // light.normal=u -> use u to lookup in t1
// _bx2 -> 0..1 of normcube will be -1..1
tex t2 // sample color map
mul r0,t2,t1 // modulate with shading
};
}
//--------------------------------------------ink
pass p1
{
cullMode=cw;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[16]=<vecSkill41>; // outline_thickness, 0, 0, 0
vertexShader=
asm
{
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

mov r0,v0
mul r1,c16.x,v3 // scale normal
add r0.xyz,r0.xyz,r1.xyz // shell offset
//(vertex position + scaled normal)
m4x4 oPos,r0,c0 // transform position to clip space
};
pixelShader=
asm
{
ps.1.3
def c0,0,0,255,1 // outline rgba
mov r0,c0
};
}
}
";
}


How do I do this? I'd guess its simple to someone who understands the above text?

Thanks for any help,
Michael.


My games - www.spyeart.com
Re: Beginner question? [Re: thegamedesigner] #254212
03/01/09 18:51
03/01/09 18:51
Joined: Aug 2003
Posts: 716
Canada, Toronto
thegamedesigner Offline OP
User
thegamedesigner  Offline OP
User

Joined: Aug 2003
Posts: 716
Canada, Toronto
Nobody? I just want to have metal units with a outline, like in red alert 3.


My games - www.spyeart.com
Re: Beginner question? [Re: thegamedesigner] #254375
03/02/09 21:08
03/02/09 21:08
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Here's the effect:

Code:
float4x4 matWorldViewProj;
float4x4 matWorld;


float  Thickness = 10;
float4 Color = {0, 0, 0, 1};



struct VS_IN
{
	float4 Pos	: POSITION;
	float3 Nor	: NORMAL;
}

struct VS_OUT
{
	float4 Pos	: POSITION;
}


VS_OUT VS(VS_IN In)
{
	VS_OUT Out;
	//
	Out.Pos = mul(In.Pos, matWorldViewProj);
	float3 wNor = normalize(mul(In.Nor, matWorld));
	Out.Pos.xyz += wNor * Thickness;
}


float4 PS() : COLOR
{
	return Color;
}


technique metaloutline
{
    pass p1
    {
    	cullMode = CW;
        VertexShader = compile vs_2_0 VS();
        PixelShader = compile ps_2_0 PS();
    }
    pass p2
    {
    	cullMode = CCW;
        VertexShader = null;
        PixelShader = null;
    }
}



...I just wrote this, it's untested. Adjust the variables "Thickness" & "Color" to your needs. If it doesn't work, hopefully someone can spot the problem and fix it because I'm barely on the boards anymore... good luck.


xXxGuitar511
- Programmer

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