; 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 #ifdef REFLECT_1 ; reflection coords texcrd r4.xy, t1_dw.xyw #endif #ifdef REFRACT_1 ; 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 #ifdef REFLECT_1 mad r4.rg, r3_bx2, r0.x, r4 #endif #ifdef REFRACT_1 mad r2.rg, r3_bx2, r0.y, r2 #endif ; stuff something into z so that texld will deal #ifdef REFLECT_1 mov r4.b, c5 #endif #ifdef REFRACT_1 mov r2.b, c5 #endif phase #ifdef REFLECT_1 ; reflection texld r4, r4 #endif #ifdef REFRACT_1 ; refraction texld r2, r2 #endif #ifdef REFLECT_1 ; N.V dp3_sat r1.a, r3_bx2, r1_bx2 #endif #ifdef REFRACT_1 ; tint refraction mul r2.rgb, r2, c1 #endif #ifdef REFLECT_1 ; 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 #ifdef REFLECT_0 #ifdef REFRACT_0 ; This is wrong!!!! mov r0.rgba, c0 #endif #endif #ifdef REFLECT_0 #ifdef REFRACT_1 mov r0.rgba, r2 #endif #endif #ifdef REFLECT_1 #ifdef REFRACT_0 mov r0.rgba, r4 #endif #endif #ifdef REFLECT_1 #ifdef REFRACT_1 ; reflection * fresnel + refraction * ( 1 - fresnel ) lrp r0.rgba, r0.a, r4, r2 #endif #endif
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 5821 | Knut Wikstrom |
Added Valve Source code. This is NOT to be commited to other than new code from Valve. |