;---------------------------------------------------------------- ; Heightmap.NVP ; A pixel shader for our Heightmap renderer. Takes 4 input textures ; and blends them together depending on the channels in the current ; Diffuse color. Works like this: ; 1) Use full Texture 0 by default ; 2) Blend in Texture 1 depending on the brightness of the Diffuse R channel ; 3) Blend in Texture 2 depending on the brightness of the Diffuse G channel ; 4) Blend in Texture 3 depending on the brightness of the Diffuse B channel ; ; TimS August 28 2002 ;---------------------------------------------------------------- xps.1.1 ; Declare pixel shader version ;---------------------------------------------------------------- ; Declare constants for isolating the various colour channels in the ; Diffuse colour. We use one per R,G or B channel, and Dot Product it ; by the Diffuse colour, giving us a 0-1 range of values indicating ; how bright that channel in the Diffuse colour is. ;---------------------------------------------------------------- def c1, 1.0f, 0.0f, 0.0f, 1.0f ; RED //def c2, 0.0f, 1.0f, 0.0f, 0.0f ; GREEN //def c3, 0.0f, 0.0f, 1.0f, 0.0f ; BLUE tex t0 ; We want to access Texture #0 tex t1 ; We want to access Texture #1 tex t2 ; We want to access Texture #2 tex t3 ; We want to access Texture #3 dp3 r1.rgb, v0, c1 ; Determine how bright the R channel is in the Diffuse colour, store the 0-1 result in r1 +mov r1.a, v0.b lrp r0, r1, t1, t0 ; Blend in Texture #1 depending on the brightness of the Diffuse R channel lrp r0, v0.a, t2, r0 ; Blend in Texture #2 depending on the brightness of the Diffuse G channel lrp r0, r1.a, t3, r0 ; Blend in Texture #3 depending on the brightness of the Diffuse B channel ; r1 * v1 * t1 ;+v0.a * v1 * t2 ;+r1.a * v1 * t3 // spec = mix1 * tex1 // spec += mix2 * tex2 // spec += mix3 * tex3 mul r0.a, r1.b, t1.b mad r0.a, v0.a, t2.b, r0.a mad r0.a, r1.a, t3.b, r0.a // color = color + spec * vertexspecular mad r0.rgb, r0.a, v1, r0 xfc zero, zero, r0, zero, zero, zero, r0.a