;------------------------------------------------------------------------------ ; Loons Pixel shader to perform specular toon shading on textured prims ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ ; ; Expected vertex shaders constants ; ; ; tex layer 0 - base texture ; tex layer 1 - toon shade/outline intensity texture ; tex layer 2 - attenuation texture?? ; tex layer 3 - spotlight cubemap??? ; ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ ; pixelshader code for use with v2.8 MrDog ;------------------------------------------------------------------------------ ;#include "loonstoonshaderconsts.h" xps.1.1 ;c0 = ambient, c1 = Ilight0, c2 = Kspecular, c3 = tex offset clr ;def c6, 1.0f, 0.0f, 0.0f, 0.0f ;def c7, 0.0f, 0.5f, 0.75f, 1.0f ;def c8, 0.0f, 1.0f, 0.0f, 0.0f ;def c9, 0.0f, 0.0f, 1.0f, 0.0f tex t0 ;base texture tex t1 ;toon texture ;tex t2 ;toon specular texture ; DO_AMBIENT_PASS - ie ambient done in separate pass ;mul r0.rgb, v0, t1 ;Vdiffuse(vtx clr*light clrattenuated*spot) * Ttoon(boned(clamped(N.L)) ;mul r0.rgb, r0, t0 ; *= Tbase ;;add r0.rgb, r0.rgb, r0.rgb ;double result ;+mul r0.a, v0.a, t0.a ;Valpha * Tbase_alpha ; NOT DO_AMBIENT_PASS - ie ambient done in this pass mad r0.rgb, v0, t1, c0 ; ambient + Vdiffuse(vtx clr*light clrattenuated*spot) * Ttoon(boned(clamped(N.L)) mul r0.rgb, r0, t0 ; *= Tbase ;add r0.rgb, r0.rgb, r0.rgb ;double result +mul r0.a, v0.a, t0.a ;Valpha * Tbase_alpha ;colour/alpha post multiplier - for tinting & fadeouts mul r0.rgba, r0.rgba, c3.rgba ;mul r1.rgb, c2, t2 ;Kspecular * Ttoonspecular(attenuated*spot*N.H) ;add r0.rgb, r0, r1 ;specular + diffuse ; multiply colour using colour matrix - for kewl colourspace effects, ; eg desaturation, oversaturation, hue shifts, etc ;dp3 r0.r, r0, c3 ;dp3 r0.g, r0, c4 ;dp3 r0.b, r0, c5 ;dp3 r1.a, r0, c3 ;red ;dp3 r1.a, r0, c4 ;green ;dp3 r0.a, r0, c5 ;blue ;d0=s0 dot s1, d1=s2 dot s3. ;xdd r0,r1, s0,s1,s2,s3 ;d0=s0*s1, d1=s2*s3, d2=s0*s1 + s2*s3. ;xmma d0,d1,d2, r0,c6(1,0,0),r1,c8(0,1,0) ;mul r1.rgb, c3, r0.rrr ;mad r1.rgb, c4.rgb, r0.ggg, r1.rgb ;mad r1.rgb, c5.rgb, r0.bbb, r1.rgb ;mov r1, r0 xfc zero, zero, r0.rgb, zero, zero, zero, r0.a ;do vanilla custom xfc, which doesnt add interpolated specular ;------------------------------------------------------------------------------ ; old pixelshader code used with v2.7 MrDog ;------------------------------------------------------------------------------ ;#include "loonstoonshaderconsts.h" ;xps.1.1 ;c0 = ambient, c1 = Ilight0, c2 = Kspecular ;def c3, 0.0f, 0.5f, 0.75f, 1.0f ;tex t0 ;base texture ;tex t1 ;toon texture ;tex t2 ;toon specular texture ;mul r0.rgb, v0, t1 ;Vdiffuse * Ttoon(attenuated*spot*N.L) ;mul r0.rgb, r0, t0 ; *= Tbase ;+mul r0.a, v0.a, t0.a ;Valpha * Tbase_alpha ;mul r1.rgb, c2, t2 ;Kspecular * Ttoonspecular(attenuated*spot*N.H) ;add r0.rgb, r0, r1 ;specular + diffuse ;mul r0.rgb, r0.rgb, c1 ;lighting * Ilight0 ;xfc zero, zero, r0.rgb, zero, zero, zero, r0.a ;do vanilla custom xfc, which doesnt add interpolated specular