; terrain render pixel shader ; ; 4 layers batch render ; ; t0 is color texture of layer 1 ; t1 is color texture of layer 2 ; t2 is color texture of layer 3 ; t3 is color texture of layer 4 ; t4 is mask texture of the first 4 layer ; alpha - layer 1 mask ; red - layer 2 mask ; green - layer 3 mask ; blue - layer 4 mask ; t5 is the light map ; c2 is the mask texture's channel mask ps.1.4 def c0, 1.0, 1.0, 1.0, 1.0 texld r0, t0 texld r1, t1 texld r2, t2 texld r4, t4 ; apply mask texture's mask mul r4.rgb, r4, c2 ; first layer, begin the iteration mul r0.rgb, r0, r4.b mul r5.r, r0.a, r4.b +mov r0.a, r4.b ; blend with previous layers' result lrp r0.rgb, r4.g, r1, r0 +lrp r0.a, r4.g, c0.a, r0.a ; blend with previous layers' result lrp r0.rgb, r4.r, r2, r0 +lrp r0.a, r4.r, c0.a, r0.a ; accumulate specular lrp r1.r, r4.g, r1.a, r5.r lrp r1.r, r4.r, r2.a, r1.r ; back up r0.a for phase 2, r4.a will be reloaded through texld mov r1.g, r0.a phase texld r3, t3 texld r5, t5 texld r4, t4 mov r0.a, r1.g mul r4.a, r4.a, c2.a ; blend with previous layers' result lrp r0.rgb, r4.a, r3, r0 +lrp r0.a, r4.a, c0.a, r0.a ; accumulate specular lrp r1.r, r4.a, r3.a, r1.r ; apply specular map mul r2.rgb, r1.r, v1 mad r0.rgb, r5, r2, r0 ; multiply with light map mul_x2 r0.rgb, r0, r5
ProZiomalXD