Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
1.5 KiB

; STATIC: "REFLECT" "0..1"
; STATIC: "REFRACT" "0..1"
ps.1.4
; T2 - refraction
; T3 - normal map
; T4 - reflection
; TC0 - normal map coords
; TC1 - proj tex coords (reflection)
; TC2 - proj tex coords (refraction)
; TC3 - tangent space view vec
; TC4 - displacement scale
; sample normal map
texld r3, t0
#if REFLECT
; reflection coords
texcrd r4.xy, t1_dw.xyw
#endif
#if REFRACT
; refraction coords
texcrd r2.xy, t2_dw.xyw
#endif
; tangent space eye vector
texld r1, t5 ; <---- Normalizing CUBE MAP here!!!
; reflection/refraction scale (x,y)
texcrd r0.xyz, t4.xyz
; perturb coords by constant displacement
; and by normal map alpha (which has 1/(2**miplevel in it)
mul r0.rg, r0, r3.a
#if REFLECT
mad r4.rg, r3_bx2, r0.x, r4
#endif
#if REFRACT
mad r2.rg, r3_bx2, r0.y, r2
#endif
; stuff something into z so that texld will deal
#if REFLECT
mov r4.b, c5
#endif
#if REFRACT
mov r2.b, c5
#endif
phase
#if REFLECT
; reflection
texld r4, r4
#endif
#if REFRACT
; refraction
texld r2, r2
#endif
#if REFLECT
; N.V
dp3_sat r1.a, r3_bx2, r1_bx2
#endif
#if REFRACT
; tint refraction
mul r2.rgb, r2, c1
#endif
#if REFLECT
; tint reflction
mul r4.rgb, r4, c4
; (1-N.V) ^ 5
+mul r0.a, 1-r1.a, 1-r1.a
mul r0.a, r0.a, r0.a
mul_sat r0.a, r0.a, 1-r1.a
#endif
#if !REFLECT && !REFRACT
; This is wrong!!!!
mov r0.rgba, c0
#endif
#if !REFLECT && REFRACT
mov r0.rgba, r2
#endif
#if REFLECT && !REFRACT
mov r0.rgba, r4
#endif
#if REFLECT && REFRACT
; reflection * fresnel + refraction * ( 1 - fresnel )
lrp r0.rgba, r0.a, r4, r2
#endif