Gamestudio Links
Zorro Links
Newest Posts
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
3 registered members (AndrewAMD, Nymphodora, VoroneTZ), 1,485 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
DX9 Toon shader #65736
03/07/06 15:51
03/07/06 15:51
Joined: Mar 2006
Posts: 24
A
Atsu Offline OP
Newbie
Atsu  Offline OP
Newbie
A

Joined: Mar 2006
Posts: 24
Hi, I'm just starting with 3DGS and I was thinking about using these shaders with my game: http://www.single-cell.net/3dgs/downloads.htm

Unfortunately when I try to run my level with that script added it gives this error message:
------------------------------------------------------------------------------
< bmap_to_cubemap(mat_ToonShader.skin1)>
toonshaderdx9.wdl 22:0 Error(58): Parameter unknown mat_ToonShader keyword

< }>
toonshaderdx9.wdl 23:0 Error(96): Syntax error - nonexistent/empty function mtl_toon_init

Script error
Engine Shutdown.
-----------------------------------------------------------------------------
I read from the previous post (http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/450277/page/0/fpart/1/vc/1) that there had been similar issues with this script, but those matters weren't solved. Also, is there any other toon shaders I could use, if this won't work? I have checked Wiki, but those there didn't work either. My card is Radeon 9600 which supports 2.0 shaders.

And heres the script I'm using:
------------------------------------------------------------------------------
// Simple Toon Shader
// Works with vs1.1 and ps1.2 - so it will work on most cards
// Works with DX 9 so it works with the 6.30 and above
// This is a modified version of ventilators original Simple Toon shader.

// To make this work you copy this stuff or add ths script.
// You also need two image files:
// 1 - tsnormalise.tga - which will get made into a normalisation cube map
// 2 - A shade map that determines the level and numer of shade bands in the paint section
// By default this shader uses ts2tone.tga which gives two tone shading.

// Normaliser cubemap sprite
bmap bmp_normalizationcube=<tsnormalise.tga>;
// Paint shade map for toonshader
bmap bmp_tstonemap=<ts2tone.tga>; // <<< CHANGE THIS TO CHANGE PAINT SHADING

// This Starter function takes the normaliser sprite and convirts it to a D3D cubemap
// This function is started on game start and needs to occur before the toon shader will work
// It creates a cubemap and assigns it to the shaders skin1 texture.
starter mtl_toon_init()
{
bmap_to_cubemap(mat_ToonShader.skin1);
}

// Ink and paint toon shader - Takes light direction from sun direction vector
material mat_ToonShader
{
skin1=bmp_normalizationcube; // This is the normalisation cubemap created by the starter function
skin2=bmp_tstonemap; // This is the shademap that determines the "shading" of the paint part of the shader

effect
"
texture entSkin1; // The models skin texture
texture mtlSkin1; // The normalisation map
texture mtlSkin2; // The tone map
matrix matWorldViewProj;
matrix matWorld;
vector vecSunDir; // Sun direction vector

technique TwoToneToon
{
// -------------- Painter --------------------
pass p0
{
texture[0]=<mtlSkin1>; // The normalisation map
texture[1]=<mtlSkin2>; // The shade map
texture[2]=<entSkin1>; // The models skin texture

addressU[1]=clamp;
addressU[2]=wrap;
addressV[2]=wrap;
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

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.xyz // output light direction to oT1
mov oT2.xy,v7.xy // output uvs to ot2
};
pixelShader=asm
{
ps.1.2
tex t0 // fetch normalized normal
texdp3tex t1,t0_bx2
tex t2 // sample color map
mul r0,t2,t1 // modulate with shading
};
}
// -------------- Outliner -------------------
pass p1
{
CULLMODE=CW;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[16]=0.8; // outline_thickness, def0.8 << CHANGE THIS TO CHANGE OUTLINE THICKNESS

vertexShader=asm
{
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord v7

mov r0,v0
mul r1,c16.x,v3 // Scale the normal
add r0.xyz,r0.xyz,r1.xyz // Shell offset (vertex pos + Scaled Normal)
m4x4 oPos,r0,c0 // Transorm position to clip space
};
pixelShader=asm
{
ps.1.1
def c0,0,0,0,1 // outline rgba << CHANGE THIS TO CHANGE OUTLINE COLOUR
mov r0,c0
};
}
} // End of technique

technique fallback // empty fallback causes normal rendering without outline
{
pass p0 { }
}
"; // end of effect
}

Re: DX9 Toon shader [Re: Atsu] #65737
03/07/06 18:31
03/07/06 18:31
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
This doesn't look like a shader issue to me, but rather a small mistake in your C-Script part. I think you have to put the material-Definition first and afterwards the starter-function, otherwise you cannot use the material in the starter simply because it has not been initialized yet. I hope this is clear


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: DX9 Toon shader [Re: Thomas_Nitschke] #65738
03/07/06 18:56
03/07/06 18:56
Joined: Mar 2006
Posts: 24
A
Atsu Offline OP
Newbie
Atsu  Offline OP
Newbie
A

Joined: Mar 2006
Posts: 24
Nope, doesn't seem to work. I get all kinds of errors when trying with that.

Edit: oh, btw. Readme which came with the shaders says "by changing the material name to mat_model it will automatically be applied to all models."

With that and renaming (no idea what this would change, just testing :P)
bmap_to_cubemap(mat_ToonShader.skin1); to bmap_to_cubemap(mat_model.skin1); actually got the game running, but I can't see any difference on the models. Renaming only the material name to mat_model gives the same errors as earlier.

Last edited by Atsu; 03/07/06 19:10.
Re: DX9 Toon shader [Re: Atsu] #65739
03/07/06 19:05
03/07/06 19:05
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
Well, if it's really the shader-code itself causing the trouble, I'm the wrong one since, unfortunately, I don't have a clue about shaders at all
Anyway, would you mind posting those "all kinds of" errors so we can at least have a guess or two whether it is related to C-Script or to the shader code?


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: DX9 Toon shader [Re: Thomas_Nitschke] #65740
03/07/06 19:19
03/07/06 19:19
Joined: Mar 2006
Posts: 24
A
Atsu Offline OP
Newbie
Atsu  Offline OP
Newbie
A

Joined: Mar 2006
Posts: 24
< material mat_model ^starter mtl_toon_init() {>
toonshaderdx9.wdl 23:2 Error(17): Too many parameters starter

< bmap_to_cubemap(mat_model.skin1);>
toonshaderdx9.wdl 24:0 Error(0): Keyword unknown mat_model bmp_to_cubemap

< skin1=bmp_normalizationcube;>
toonshaderdx9.wdl 29:0 Error(19): Parameter unknown skin1 bad keyword in {}

< skin2=bmp_normalizationcube;>
toonshaderdx9.wdl 30:0 Error(19): Parameter unknown skin2 bad keyword in {}

Re: DX9 Toon shader [Re: Atsu] #65741
03/07/06 20:47
03/07/06 20:47
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
In place of your starter, try:

function makecube() {
bmap_to_cubemap(mtl.skin1);
}



material mat_ToonShader
{
skin1=bmp_normalizationcube;
skin2=bmp_tstonemap;

event = makecube;

effect = " .............

Re: DX9 Toon shader [Re: Steempipe] #65742
03/08/06 07:18
03/08/06 07:18
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
As I supposed, these are C-Script related errors. Dumb me, now that you posted them, I can spot them so why couldn't I before?

First of all, do as Steempipe said. Secondly, pay special attention to
Code:

effect = "bablablabl";


since the "=" was missing in your code. Steempipe also wrote "bmap_to_cubemap(mtl.skin1);" where you obviously forgot the "a", resulting in bmp_to_cubemap etc.
Have a look for those small mistakes, they can screw up your whole script. Other than that, it looks as if it should be working


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: DX9 Toon shader [Re: Thomas_Nitschke] #65743
03/08/06 13:30
03/08/06 13:30
Joined: Mar 2006
Posts: 24
A
Atsu Offline OP
Newbie
Atsu  Offline OP
Newbie
A

Joined: Mar 2006
Posts: 24
Oops. I was running the script with a trial version of 3DGS which doesn't support shaders (I thought it was based on the commercial version, not the extra version). So that's pretty much the only problem I suppose. Sorry for wasting your time. I'll give this a try again when I buy the full version.

Thanks for your help anyway.

Re: DX9 Toon shader [Re: Atsu] #65744
03/08/06 14:25
03/08/06 14:25
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
Oops! Okay, possibly we should've asked you for your version anyway
No problem.


Formerly known as The Matrix - ICQ 170408644 I've been here for much longer than most people think. So where's my "Expert" status?

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