;---------------------------------------------------------------- ; 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 ;---------------------------------------------------------------- ps.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, 0.0f ; RED def c2, 0.0f, 1.0f, 0.0f, 0.0f ; GREEN def c3, 0.0f, 0.0f, 1.0f, 0.0f ; BLUE def c4, 0.0f, 0.0f, 0.0f, 1.0f ; ALPHA 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 mov r0, t0 ; Use Texture #0 by default dp3 r1.rgba, v0, c1 ; Determine how bright the R channel is in the Diffuse colour, store the 0-1 result in r1 lrp r0, r1, t1, r0 ; Blend in Texture #1 depending on the brightness of the Diffuse R channel dp3 r1.rgba, v0, c2 ; Determine how bright the G channel is in the Diffuse colour, store the 0-1 result in r1 lrp r0, r1, t2, r0 ; Blend in Texture #2 depending on the brightness of the Diffuse G channel dp3 r1.rgba, v0, c3 ; Determine how bright the B channel is in the Diffuse colour, store the 0-1 result in r1 lrp r0, r1, t3, r0 ; Blend in Texture #3 depending on the brightness of the Diffuse B channel