grass_wave.txt

(1 KB) Pobierz
; DESCRIPTION:
; Vertex shader used to render grasses with waving manipulation 
; this shader does below works:
; # vertex transform
; # output texture coordinates

vs.1.1

;------------------------------------------------------------------------------
; v0 	  = position in world space
; v1	  = index, w1, w2
; v2 	  = texture coordinates
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
; Constants specified by the app;
; c0      = (1.0, 0.0, 0.0, 1.0f/vSightRange*vSightRange)
; c1-c4	  = view matrix * projection matrix
; c5-c8   = light map texture generate matrix
; c9	  = camera's position in world space
; c10-    = wind offset index array
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
; oPos	  = Output position
; oD0	  = Diffuse
; oT0	  = base texture coordinates
; oT1	  = light map texture coords.
; oT2	  = light map night texture coords.
; oFog    = fog value
;------------------------------------------------------------------------------

; Transfrom position from world space to cuboid space and output it
mov a0.x, v1.x
mul r1, v1.y, c[10+a0.x]
add r0, v0, r1
m4x4 oPos, r0, c1
m4x4 r1, r0, c5
mov oT1, r1
mov oT2, r1

; now calculate the alpha value according to the distance to camera
sub r1, v0, c9		;to camera vector
dp3 r0, r1, r1		;distance square to camera
mul r1.w, r0.w, c0.w;   ;0~1 from camera to sight range
sub r1.w, c0.x, r1.w    ;1~0 from camera to sight range
max oD0.w, r1.w, c0.y   ;clamp if < 0

; Copy texture coordinate
mov oT0, v2

; set no fog
mov oFog, c0.x



Zgłoś jeśli naruszono regulamin