Cartoon shader help
by BBS Games · in Torque Game Engine Advanced · 05/11/2006 (8:11 am) · 3 replies
Hi all,
I'm trying to add a cartoon shader from this article http://www.booyah.com/article05-dx9.html to TSE
the code is this
Questions:
- how to provide the textures for the required look up operations?
- have to write a CustomMaterial?
I'm really new to shader programming and TSE in general so sorry if the question sounds stupid :)
I'm trying to add a cartoon shader from this article http://www.booyah.com/article05-dx9.html to TSE
the code is this
struct VS_INPUT
{
float4 position : POSITION;
float3 normal : NORMAL;
float3 diffuse : COLOR;
float2 tex0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 position : POSITION;
float3 diffuse : COLOR;
float2 tex0 : TEXCOORD0;
float2 tex1 : TEXCOORD1;
};
vector eyePos: register(c4);
vector lightPos: register(c5);
vector lightDir: register(c6);
VS_OUTPUT main(const VS_INPUT input,
uniform matrix matWorldViewProj : c0)
{
VS_OUTPUT output;
// Compute final worldviewproj transformation
output.position = mul(matWorldViewProj, input.position);
// Compute normalized vertex-to-eye vector in object space
vector vNormVertexToEye = normalize(eyePos - input.position);
// Do lookup into cartoon texture
output.tex0 = dot(input.normal, -lightDir);
// Do lookup into cartoon edge texture
output.tex1 = dot(input.normal, vNormVertexToEye);
// Output mesh material
output.diffuse = input.diffuse;
return output;
}Questions:
- how to provide the textures for the required look up operations?
- have to write a CustomMaterial?
I'm really new to shader programming and TSE in general so sorry if the question sounds stupid :)
#2
Just relax a bit.. it's not going to be an instant thing. But you'll need to complete your TSE basics education BEFORE trying to tackle this task.
Good luck and keep us up on your progress.
05/11/2006 (11:22 pm)
Also read the TDN on TSE. There are also a couple older threads that talk about making custom shaders.Just relax a bit.. it's not going to be an instant thing. But you'll need to complete your TSE basics education BEFORE trying to tackle this task.
Good luck and keep us up on your progress.
#3
I've got the simple toon shader from this forum post working!
@Randy unfortunately I don't have the time to do a good basic education...I have to learn things while adding functionality and game logic to TSE...damn time constrains!
05/12/2006 (12:50 am)
Ok, tonight I have done one step beyond :)I've got the simple toon shader from this forum post working!
@Randy unfortunately I don't have the time to do a good basic education...I have to learn things while adding functionality and game logic to TSE...damn time constrains!
Associate Andy Hawkins
DrewFX
Sorry it doesn't answer your question but I thought it might be a good place to point out these books for people getting into TSE