I'm able to do the shaders, but the necessary parameters, like the light position are not sent.
Here's the modified ogre-v1-6-0RC1\ogre\Samples Cellshader script (modify my second example with the textured cube as I can't send files by now).
shadercube.material file :
Code: Select all
// -------------------------------
// Cel Shading Section
// -------------------------------
vertex_program Ogre/CelShadingVP asm
{
source Example_CelShading.vs_2_0
syntax vs_2_0
default_params
{
param_named_auto lightPosition light_position_object_space 0
param_named_auto eyePosition camera_position_object_space
param_named_auto worldViewProj worldviewproj_matrix
param_named shininess float 10
}
}
fragment_program Ogre/CelShadingFP asm
{
source Example_CelShading.ps_2_0
syntax ps_2_0
}
material shader
{
technique
{
pass
{
vertex_program_ref Ogre/CelShadingVP
{
// map shininess from custom renderable param 1
param_named_auto shininess custom 1
}
fragment_program_ref Ogre/CelShadingFP
{
// map diffuse from custom renderable param 2
param_named_auto diffuse custom 2
// map specular from custom renderable param 2
param_named_auto specular custom 3
}
texture_unit
{
texture cel_shading_diffuse.png 1d
tex_address_mode clamp
filtering none
}
texture_unit
{
texture cel_shading_specular.png 1d
tex_address_mode clamp
filtering none
tex_coord_set 1
}
texture_unit
{
texture cel_shading_edge.png 1d
tex_address_mode clamp
filtering none
tex_coord_set 2
}
}
}
}
Example_CelShading.ps_2_0 file :
Code: Select all
ps_2_0
// cgc version 2.1.0012, build date Oct 15 2008
// command line args: -profile ps_2_0
// source file: Example_CelShading.cg
//vendor NVIDIA Corporation
//version 2.1.0.12
//profile ps_2_0
//program main_fp
//semantic main_fp.diffuse
//semantic main_fp.specular
//semantic main_fp.diffuseRamp
//semantic main_fp.specularRamp
//semantic main_fp.edgeRamp
//var float diffuseIn : $vin.TEXCOORD0 : TEX0 : 0 : 1
//var float specularIn : $vin.TEXCOORD1 : TEX1 : 1 : 1
//var float edge : $vin.TEXCOORD2 : TEX2 : 2 : 1
//var float4 colour : $vout.COLOR : COL : 3 : 1
//var float4 diffuse : : c[0] : 4 : 1
//var float4 specular : : c[1] : 5 : 1
//var sampler1D diffuseRamp : : texunit 0 : 6 : 1
//var sampler1D specularRamp : : texunit 1 : 7 : 1
//var sampler1D edgeRamp : : texunit 2 : 8 : 1
//const c[2] = 0.5
dcl_2d s0
dcl_2d s1
dcl_2d s2
def c2, 0.50000000, 0, 0, 0
dcl t0.x
dcl t1.x
dcl t2.x
mov r1.x, t0
mov r1.y, c2.x
mov r2.x, t1
mov r2.y, c2.x
mov r0.y, c2.x
mov r0.x, t2
texld r0, r0, s2
texld r2, r2, s1
texld r1, r1, s0
mul r2, r2.x, c1
mad r1, r1.x, c0, r2
mul r0, r0.x, r1
mov oC0, r0
Example_CelShading.vs_2_0 file :
Code: Select all
vs_2_0
// cgc version 2.1.0012, build date Oct 15 2008
// command line args: -profile vs_2_0
// source file: Example_CelShading.cg
//vendor NVIDIA Corporation
//version 2.1.0.12
//profile vs_2_0
//program main_vp
//semantic main_vp.lightPosition
//semantic main_vp.eyePosition
//semantic main_vp.shininess
//semantic main_vp.worldViewProj
//var float4 position : $vin.POSITION : ATTR0 : 0 : 1
//var float3 normal : $vin.NORMAL : ATTR1 : 1 : 1
//var float4 oPosition : $vout.POSITION : HPOS : 2 : 1
//var float diffuse : $vout.TEXCOORD0 : TEX0 : 3 : 1
//var float specular : $vout.TEXCOORD1 : TEX1 : 4 : 1
//var float edge : $vout.TEXCOORD2 : TEX2 : 5 : 1
//var float3 lightPosition : : c[4] : 6 : 1
//var float3 eyePosition : : c[5] : 7 : 1
//var float4 shininess : : c[6] : 8 : 1
//var float4x4 worldViewProj : : c[0], 4 : 9 : 1
//const c[7] = 0 1
def c7, 0.00000000, 1.00000000, 0, 0
dcl_position v0
dcl_normal v1
add r1.xyz, -v0, c5
dp3 r1.w, r1, r1
add r0.xyz, -v0, c4
dp3 r0.w, r0, r0
rsq r1.w, r1.w
rsq r0.w, r0.w
mul r0.xyz, r0.w, r0
mul r2.xyz, r1.w, r1
add r3.xyz, r0, r2
dp3 r1.x, r3, r3
rsq r1.w, r1.x
dp3 r0.w, v1, v1
rsq r0.w, r0.w
mul r1.xyz, r0.w, v1
dp3 r0.x, r1, r0
mul r3.xyz, r1.w, r3
max r1.w, r0.x, c7.x
dp3 r0.y, r1, r3
max r3.x, r0.y, c7
sge r0.y, c7.x, r1.w
sge r0.x, r1.w, c7
mul r2.w, r0.x, r0.y
pow r0, r3.x, c6.x
max r0.y, -r2.w, r2.w
mov r0.z, r0.x
slt r0.y, c7.x, r0
add r0.x, -r0.y, c7.y
mul oT1.x, r0, r0.z
dp3 r0.x, r1, r2
mov oT0.x, r1.w
max oT2.x, r0, c7
dp4 oPos.w, v0, c3
dp4 oPos.z, v0, c2
dp4 oPos.y, v0, c1
dp4 oPos.x, v0, c0