Stuck on Problems with my game.

Heyas everyone~

I have tried to put cell shading in to my projcet but it seems that it produces some unwanted results.

Also could i get a formula or a web site on how to get the vector from Hpr.

For the above image there are some boxes/lines that appear around the edges of walled platforms.

As for this image, the particle system’s particles are also affected by the cell shading. Another effect is that when the particles are over each other, a transparent circle is made aroud each picture. Its clearer on the stone. Any ways to remove the circle? ^^

The shaders i use are taken from the cartoon shader example.

This is the inkGen.sha:

//Cg
//
//Cg profile arbvp1 arbfp1

void vshader(float4 vtx_position : POSITION,
             float4 vtx_texcoord0 : TEXCOORD0,
             out float4 l_position : POSITION,
             out float4 l_texcoord0 : TEXCOORD0,
             uniform float4x4 mat_modelproj)
{
  l_position=mul(mat_modelproj, vtx_position);
  l_texcoord0 = vtx_texcoord0;
}

void fshader(float4 l_texcoord0 : TEXCOORD0,
             uniform sampler2D tex_0 : TEXUNIT0,
             uniform float4 k_cutoff : C6,
             uniform float4 k_separation : C7,
             out float4 o_color : COLOR)
{
  float4 texcoord0 = l_texcoord0 + k_separation.xyzw;
  float4 color0=tex2D(tex_0, float2(texcoord0.x, texcoord0.y));
  float4 texcoord1 = l_texcoord0 - k_separation.xyzw;
  float4 color1=tex2D(tex_0, float2(texcoord1.x, texcoord1.y));
  float4 texcoord2 = l_texcoord0 + k_separation.wzyx;
  float4 color2=tex2D(tex_0, float2(texcoord2.x, texcoord2.y));
  float4 texcoord3 = l_texcoord0 - k_separation.wzyx;
  float4 color3=tex2D(tex_0, float2(texcoord3.x, texcoord3.y));
  float4 mx = max(color0,max(color1,max(color2,color3)));
  float4 mn = min(color0,min(color1,min(color2,color3)));
  float4 trigger = saturate(((mx-mn) * 3) - k_cutoff.x);
  float thresh = dot(float3(trigger.x, trigger.y, trigger.z),float3(1,1,1));
  float4 output_color = float4 (0, 0, 0, thresh);
  o_color = output_color;
}

While this is lightingGen.sha

//Cg
//
//Cg profile arbvp1 arbfp1

void vshader(float4 vtx_position   : POSITION,
             float3 vtx_normal     : NORMAL,
             float4 vtx_color      : COLOR,
             out float4 l_position : POSITION,
             out float4 l_brite    : TEXCOORD0,
             out float4 l_color    : COLOR,
             uniform float4 mspos_light,
             uniform float4x4 mat_modelproj)
{
  l_position = mul(mat_modelproj, vtx_position);
  float3 N = normalize(vtx_normal);
  float3 lightVector = normalize(mspos_light - vtx_position);
  l_brite = max(dot(N,lightVector), 0);
  l_color = vtx_color;
}


void fshader(float4 l_brite     : TEXCOORD0, 
             float4 l_color     : COLOR,
             out float4 o_color : COLOR)
{
  if (l_brite.x<0.5) l_brite=0.8;
  else l_brite=0.9;
  o_color=l_brite * l_color;
}

How do i actually cellshade my game properly? Is there any way to edit the shader files to include the texture into the lighting? Tips and quick fixes are greatly appreciated. ^^

Well, to fix up those billboards and particles, you could try using M_dual transparency. Search the forums for an explanation.

I’m not sure what you mean by “include the texture into the lighting.”

What i meant is that when i use the current shader any textures on a model is completely ignored. It will result in 2 shades of darker and lighter based on the texture’s color. For example a tree bark texture will become a shade of light brown and dark brown. No patterns or colors other then that.

You mean you want the lighting shader to shade your textures instead of vertex colors? In that case, try thsi:

//Cg
//
//Cg profile arbvp1 arbfp1

void vshader(float4 vtx_position   : POSITION,
             float3 vtx_normal     : NORMAL,
             float2 vtx_texcoord0 : TEXCOORD0,
             out float4 l_position : POSITION,
             out float2 l_texcoord0: TEXCOORD0,
             out float4 l_brite    : TEXCOORD1,
             uniform float4 mspos_light,
             uniform float4x4 mat_modelproj)
{
  l_position = mul(mat_modelproj, vtx_position);
  float3 N = normalize(vtx_normal);
  float3 lightVector = normalize(mspos_light - vtx_position);
  l_brite = max(dot(N,lightVector), 0);
  l_texcoord0=vtx_texcoord0;
}


void fshader(float4 l_brite     : TEXCOORD1,
             float2 l_texcoord0: TEXCOORD0,
             uniform sampler2D tex_0 : TEXUNIT0, 
             out float4 o_color : COLOR)
{
  if (l_brite.x<0.5) l_brite=0.8;
  else l_brite=0.9;
  float4 texture=tex2D(tex_0, l_texcoord0); 
  o_color=l_brite * texture;
} 

I didn’t try it, though it should be working. Let me know if not.