cartoon looking,

Posted By: DeD

cartoon looking, - 08/18/09 20:01

hi whats the best way to make a levle look cartoon.
i mean what kind of texturs an shaders would you recomend.
Posted By: DeD

Re: cartoon looking, - 08/18/09 20:54

i waas reading about the toon shader in another post, but when i add the mtl.wdl to my script, the toon shader is not in the list of actions.

can you help me?
Posted By: MoRRoW

Re: cartoon looking, - 08/18/09 22:41

Hey youīre using C-Script "i add the mtl.wdl to my script"?
Do you read this:
http://www.coniserver.net/wiki/index.php/Toonshading_with_Outline
That are Scriptīs for both,C-Script and Lite-C.
For me it works without problems.
Posted By: DeD

Re: cartoon looking, - 08/18/09 22:47

ok i look at that page, how do i use that code in my project?
Posted By: MoRRoW

Re: cartoon looking, - 08/18/09 23:03

After you created the toon.fx you have to #include it into your project,and because it is an post-process shader i think you want to add it to your camera, so you have to add the following to your main function
function main()
{
pp_set(camera,Toon_mat);
....
}
Iīm not an expert in this Task but for me it works.

Itīs late and i have to work tomorrow so Iīm away.Play around a little bit.Will look for this thread tomorrow.
Posted By: DeD

Re: cartoon looking, - 08/18/09 23:08

ok cheers
Posted By: DeD

Re: cartoon looking, - 08/18/09 23:21

im havin trouble makin the toon.fx file,
i put the code from that page an save it as toon.fx
an declair it in my main script, but when i run it, it give me a load of errors.
i dont think im makin the fx file right.
Posted By: MoRRoW

Re: cartoon looking, - 08/18/09 23:57

You donīt need to apply.The shader is already applied to your Camera.
function main()
{
pp_set(camera,Toon_mat); <-------the shader with Material Toon_Mat is applied to the Camera.



}
And donīt forget to define the Material before Calling it with this:
MATERIAL* Toon_mat =
{
effect = "Toon_.fx";
}

function Toon_set_Value(r,g,b,threshold)
{
Toon_mat.skill1 = floatv(r); //4 looks okay
Toon_mat.skill2 = floatv(g); //same as above
Toon_mat.skill3 = floatv(b); //same as above
Toon_mat.skill4 = floatv(threshold); //0.01
}
Needs to be above main function.

Your Edit:Paste the code in SED save it as Toon_.fx
and include.
Donīt forget what I wrote above about defining the Material.

Bye

Posted By: DeD

Re: cartoon looking, - 08/19/09 00:32

ok i made the fx file, i looked at some other shader files from the shader collection from au resources,

i made the toon.wdl file with the code below, but i save it as shader.wdl. (dont think the name matters here)

//Toon Shading with Outline
material Toon_mat
{
effect = "Toon.fx";
}

function Toon_set_Value(r,g,b,threshold)
{
Toon_mat.skill1 = floatv(r); //4 looks okay
Toon_mat.skill2 = floatv(g); //same as above
Toon_mat.skill3 = floatv(b); //same as above
Toon_mat.skill4 = floatv(threshold); //0.01
}



I then made the toon.fx file with this code.

////Makes Details invisible and the colors a bit more intensive,
////which gives the Level a toon like look this is combined with a sobel edge filter
////which causes some kind of outlining

float4 vecSkill1; //"Color Details" in xyz and threshold in w
float4 vecViewPort;

Texture entSkin1;
sampler2D smpSource = sampler_state { texture = <entSkin1>; };

float4 dirtyToonPS( float2 Tex : TEXCOORD0 ) : COLOR0
{
half4 color = tex2D(smpSource,Tex.xy);
color.r = round(color.r*vecSkill1.r)/vecSkill1.r;
color.g = round(color.g*vecSkill1.g)/vecSkill1.g;
color.b = round(color.b*vecSkill1.b)/vecSkill1.b;

const float threshold = vecSkill1.w;

const int NUM = 9;
const float2 c[NUM] =
{
float2(-0.0078125, 0.0078125),
float2( 0.00 , 0.0078125),
float2( 0.0078125, 0.0078125),
float2(-0.0078125, 0.00 ),
float2( 0.0, 0.0),
float2( 0.0078125, 0.007 ),
float2(-0.0078125,-0.0078125),
float2( 0.00 , -0.0078125),
float2( 0.0078125,-0.0078125),
};

int i;
float3 col[NUM];
for (i=0; i < NUM; i++)
{
col[i] = tex2D(smpSource, Tex.xy + 0.2*c[i]);
}

float3 rgb2lum = float3(0.30, 0.59, 0.11);
float lum[NUM];
for (i = 0; i < NUM; i++)
{
lum[i] = dot(col[i].xyz, rgb2lum);
}
float x = lum[2]+ lum[8]+2*lum[5]-lum[0]-2*lum[3]-lum[6];
float y = lum[6]+2*lum[7]+ lum[8]-lum[0]-2*lum[1]-lum[2];
float edge =(x*x + y*y < threshold)? 1.0:0.0;

color.rgb *= edge;
return color;
}

technique postFX
{
pass p1
{
PixelShader = compile ps_2_0 dirtyToonPS();
}
}

saved that as toon.fx

and then in my main script i included.... include <shader.wdl>;

but then when i had the pp_set(camera,Toon_mat); into my main function.
i get a error... bad perameter unknown function.

another thing there is know cam, code in my main script. as im useing the car script template.
Posted By: MoRRoW

Re: cartoon looking, - 08/19/09 04:35

What Version of GStudio are you using?
Posted By: DeD

Re: cartoon looking, - 08/19/09 06:08

a7 7.77, but im useing c script. an not lite c
Posted By: Cowabanga

Re: cartoon looking, - 08/19/09 11:49

Why not upgrading to 7.80 ??
Posted By: DeD

Re: cartoon looking, - 08/19/09 18:03

dint know it was out,not got round to it yet.
have i got that right then? with the scripts
cus i still not sure how you call it in the main
Posted By: DeD

Re: cartoon looking, - 08/19/09 18:08

Heres my main script...


path "C:\\Program Files\\GStudio7\\template_6"; // Path to A6 templates directory
path "C:\\Program Files\\GStudio7\\template_6\\code"; // Path to A6 template code subdirectory
path "C:\\Program Files\\GStudio7\\templates\\images"; // Path to template image subdirectory
path "C:\\Program Files\\GStudio7\\templates\\sounds"; // Path to template sound subdirectory
path "C:\\Program Files\\GStudio7\\templates\\models"; // Path to template model subdirectory

/////////////////////////////////////////////////////////////////
// Filename of the starting level.
string level_str = <pub1.WMB>; // give file names in angular brackets

////////////////////////////////////////////////////////////////////////////
// Included files
include <gid01.wdl>; // global ids
include <display00.wdl>; // basic display settings
include <cameraSelect.wdl>;
include <cameraTarget.wdl>;
include <camera3rd01.wdl>;
include <plSelect.wdl>;
include <miscInput01.wdl>;
include <trigger00.wdl>;
include <particle00.wdl>;
include <plCar01.wdl>;
include <sky01.wdl>;
include <shader.wdl>;




/////////////////////////////////////////////////////////////////
// Desc: The main() function is started at game start
function main()
{
// set some common flags and variables
// freeze all entity functions
freeze_mode = 1;
// no level has been loaded yet...
gid01_level_state = gid01_level_not_loaded;

// entry: Warning Level (0,1, or 2)
// entry_help: Sets sensitivity to warnings (0 = none, 1 = some, 2 = all).
warn_level = 2; // announce bad texture sizes and bad wdl code


// entry: Starting Mouse Mode (0, 1, or 2)
mouse_mode = 0;

// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// now load the level
level_load(level_str);

wait(2); // let level load
// level should be loaded at this point...
gid01_level_state = gid01_level_loaded;

//+++ load starting values


// un-freeze the game
freeze_mode = 0;

// save start of game here
wait(6); // allow time for functions that wait for "gid01_level_loaded" to load
file_delete("start0.SAV"); // remove any old savefile
wait(1);
if( game_save("start",0,SV_ALL) <= 0)
{
diag("\nWARNING! main - Cannot save 'start' of level (ignore on restarts).");
}
else
{
diag("\nWDL: main - Game 'start' saved.");
}


// main game loop
while(1)
{
if(gid01_level_state != gid01_level_loaded)
{
freeze_mode = 1; // pause the game
while(gid01_level_state != gid01_level_loaded) { wait(1); }
freeze_mode = 0; // resume the game
}
wait(1);
}





}


// Desc: this is the function used to restart the game.
function main_restart_game()
{
// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// freeze the game
freeze_mode = 1;

if( game_load("start",0) <= 0)
{
diag("\nWARNING! main_restart_game - Cannot load 'start' of level.");
}
else
{
diag("\nWDL: main_restart_game - Game 'start' loaded");
}


// un-freeze the game
freeze_mode = 0;
}


// Desc: this is the function used to quit the game.
function main_quit()
{
//+++ // save global skills & strings
exit;
}

/////////////////////////////////////////////////////////////////
// The following definitions are for the pro edition window composer
// to define the start and exit window of the application.
WINDOW WINSTART
{
TITLE "3D GameStudio";
SIZE 480,320;
MODE IMAGE; //STANDARD;
BG_COLOR RGB(240,240,240);
FRAME FTYP1,0,0,480,320;
// BUTTON BUTTON_START,SYS_DEFAULT,"Start",400,288,72,24;
BUTTON BUTTON_QUIT,SYS_DEFAULT,"Abort",400,288,72,24;
TEXT_STDOUT "Arial",RGB(0,0,0),10,10,460,280;
}

/* no exit window at all..
WINDOW WINEND
{
TITLE "Finished";
SIZE 540,320;
MODE STANDARD;
BG_COLOR RGB(0,0,0);
TEXT_STDOUT "",RGB(255,40,40),10,20,520,270;

SET FONT "",RGB(0,255,255);
TEXT "Any key to exit",10,270;
}*/


/////////////////////////////////////////////////////////////////
//INCLUDE <debug.wdl>;
Posted By: DeD

Re: cartoon looking, - 08/23/09 21:28

still cant get this to work. please help...
© 2024 lite-C Forums