xvs.1.1 def c8, 0, 0, 0, 0 def c9, 1, 1, 1, 1 DEF c10, 3.1415927, 0.5, 6.283194, 0.1591547 DEF c11, 1.0, -0.5, 0.041666667, -0.0013888889 DEF c12, 1.0, -0.166666667, 0.0083333333, -0.0001984127 def c15, 0.2, 0.8, 20, -0.25 ; sin scalar, wind bend scalar, rotor wash distance ; c0-3 world-view-projection ; c4 - camera position ; c5 - global movement displacement ; c6 - camera view direction ; c7 - layer constants ( fadedist, 2/fadedist, fadedist/2, motionperturb ) ; c13 - wind parameters ( dirx, diry, ?, ? ) ; c14 - wind parameters ( time, vel, 1/vel, 0 ) ; c16-18 - inverse nearfield darkmap transform ; c19 - darkmap scale factor ( 1/width, 1/height, 0, 0 ) ; c20 - rotor wash ( posx, posy, mag, rtime ) ; v0 3 float vertex position ; v1 3 normpacked face normal ; v2 3 normpacked ( u, v, fade ) -- 11 bits each ; Grab worldspace postion ; Perturb based on the blend value in the w component mov r3, v0 ; mul r4, v2.z, c5 ; Scale the motion defined in c5 ; add r3.xyz, r3, r4 ; Add it to the vert pos mov r3.w, c9 ; Put a 1 in the w ; Compute wind mov r4, r3 mov r4.zw, c8.zw dp3 r5, r4, c13 mul r5, r5, c15.w mad r5.x, r5.x, c14.z, c14.x ; scalar r4.x = cos(r5.x), r4.y = sin(r5.x) MAD r4.x, r5.x, c10.w, c10.y ; bring argument into -pi, .., +pi range EXPP r4.y, r4.x MAD r4.x, r4.y, c10.z, -c10.x DST r6.xy, r4.x, r4.x ; generate 1, (r4.x)^2, .. (r4.x)^6 MUL r6.z, r6.y, r6.y MUL r6.w, r6.y, r6.z MUL r4, r6, r4.x ; generate r4.x, (r4.x)^3, .., (r4.x)^7 DP4 r4.y, r4, c12 ; compute sin(r4.x) DP4 r4.x, r6, c11 ; compute cos(r4.x) mul r4.x, r4.x, r4.x mul r4.x, r4.x, c15.x ; * ang displacement mov r5.x, c14.y mul r5.x, r5.x, c15.y ; wind scalar add r4.x, r4.x, r5.x mul r4.x, r4.x, c7.w ; motion displacement scalar sub r5, c9, v2 ; vert movement = 1 - v mul r4.x, r4.x, r5.y mul r5.xy, c13.xy, r4.xx ;*** ; mov r5, c8 ; *** temp zero out ;*** add r3.xy, r3.xy, r5.xy ; perturb ; Compute rotor wash sub r4, r3, c20 ; r4 = pos - rotorpos mov r4.zw, c8.zw ; in 2d dp3 r5, r4, r4 ; r5 = distsqr rsq r6, r5 mov r7.z, r6.x ; save 1/distance mul r7.z, r7.z, c15.z ; take c15.z / distance min r7.z, r7.z, c9 ; clamp to <= 1 mul r5, r5, r6 ; r5 = distance mul r4, r4, r6 ; r4 = normalized direction sub r5, r5, c20.w mov r7.xy, r4.xy ; save direction ; scalar r4.x = cos(r5.x), r4.y = sin(r5.x) MAD r4.x, r5.x, c10.w, c10.y ; bring argument into -pi, .., +pi range EXPP r4.y, r4.x MAD r4.x, r4.y, c10.z, -c10.x DST r6.xy, r4.x, r4.x ; generate 1, (r4.x)^2, .. (r4.x)^6 MUL r6.z, r6.y, r6.y MUL r6.w, r6.y, r6.z MUL r4, r6, r4.x ; generate r4.x, (r4.x)^3, .., (r4.x)^7 DP4 r4.y, r4, c12 ; compute sin(r4.x) DP4 r4.x, r6, c11 ; compute cos(r4.x) mul r4.x, r4.x, r4.x mul r4.x, r4.x, r7.z ; attenuate for distance mul r4.x, r4.x, c15.x ; * ang displacement mov r5.x, c20.z mul r5.x, r5.x, c15.y ; wind scalar mul r5.x, r5.x, r7.z ; attenuate for distance add r4.x, r4.x, r5.x mul r4.x, r4.x, c7.w ; motion displacement scalar ; mul r4.x, r4.x, r7.z ; attenuate for distance sub r5, c9, v2 ; vert movement = 1 - v mul r4.x, r4.x, r5.y mul r5.xy, r7.xy, r4.xx add r3.xy, r3.xy, r5.xy ; perturb ; Compute alpha fade value mov r0, r3 sub r1, r0, c[4] ; c4 = worldspace camera position dp3 r0, r1, r1 ; rsq r0, r0 ; calulate distance mul r4, r1, r0 ; Store normalized (pos - cam) rcp r0, r0 ; sub r0, c[7].x, r0 ; take fardist - dist max r0, r0, c[8] ; clamp at 0 min r0, r0, c[7].z ; clamp at alpha start dist mul r0, r0, c[7].y ; normalize ; Compute alpha face based on view inclination dp3 r5, v1, r4 ; compute dot product max r6, r5, -r5 ; take absolute value sub r5, c[9], r6 ; compute 1 - abs(dp) mul r6, r5, r5 ; compute (1-abs(dp))^2 sub r5, c[9], r6 ; compute 1 - ((1 - abs(dp))^2) mul r0.w, r5.w, r0.w ; apply to vertex alpha ; Modulate by global fade value mul r0.w, r0.w, v2.z ; multiply by vertex shade ; Transform the position into screen space. m4x4 oPos, r3, c[ 0 ] mov r1, c9 mov r1.w, r0.w mov oD0, r1 mov oT0, v2 ; new way mov r4, r3 mov r4.z, c9 mov r4.w, c8 ; r4 = posx, posy, 1, 0 m3x3 r5, r4, c16 mul r5, r5, c19 ; scale to 0..1, 0..1 mov oT1.xy, r5.xy