applying texture in cartoon shader(SOLVED)

thank you all for your contributions in helping me

and i am very glad to say that all that you have done was actally enough to get it to work

it was an EXTREMELY stupid typo on my part in editing the “lightingGen.sha” file which caused the shader to screw up

anyway, here is the final result, it works great, although the texture seems kind of see-through, but i think that is the faut of my texture, you all encountered this before although it wasn’t the fault of the texture? is it something i should be worried about?

and for anyone else interested in applying texture while using the cartoon shader, heres is the file to get you there, replace the stuff in “lightingGen.sha” with it, although its virtually the same as what ynjh_jo provided for me in his final solution, just for people who skip too fast ahead i guess.

//Cg
//
//Cg profile arbvp1 arbfp1

void vshader(in float2 vtx_texcoord0 : TEXCOORD0,
             out float2 l_texcoord0 : TEXCOORD0,
             float4 vtx_position   : POSITION,
             float3 vtx_normal     : NORMAL,
             float4 vtx_color      : COLOR,
             out float4 l_position : POSITION,
             out float4 l_brite,
             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;
  l_texcoord0 = vtx_texcoord0;
}


void fshader(in float2 l_texcoord0 : TEXCOORD0,
             uniform sampler2D tex_0 : TEXUNIT0,
             float4 l_brite, 
             float4 l_color     : COLOR,
             out float4 o_color : COLOR)
{
  if (l_brite.x<0.5) l_brite=0.8;
  else l_brite=1.2;
  o_color=l_brite * l_color;
  float4 texcolor = tex2D( tex_0, float2( l_texcoord0) );
  o_color = texcolor * l_brite;
}
1 Like