// $Revision$ $Author$ $DateTime$ //------------------------------------------------------------------------------------------------ // // ***************** FIRAXIS GAME ENGINE ******************** // // FILE: VSTerrain_UnderdarkP1_11.vsh // // AUTHOR: Bart Muzzin - 19/03/2004 // // PURPOSE: This draw a fogged black object over where the terrain will be rendered. This is done // so that the terrain can be additive blended on top of it, without doing any real // calculations. // //------------------------------------------------------------------------------------------------ // Copyright (c) 2004 Firaxis Games, Inc. All rights reserved. //------------------------------------------------------------------------------------------------ vs_1_1 // Declare the color registers dcl_position v0 dcl_normal v1 dcl_color0 v3 // The following instructions multiply the input position by the world matrix mov r3, v0 mov r3.w, c14.x // 1 // w = 1. m4x4 r8, r3, c0 // 4 // This translates the final world position into screen space mov oPos, r8 // 1 (8) // Move the final position into the output register // Do the alpha sum of the terrain pieces dp4 oD0.a, v3, c15 // 1 // Extract all alphas by using DPs against predefined constants // Fogging calculations mul r6.w, r8.z, c8.x // 1 // sqrt( (WP - FC) dot (WP - FC) ) / (Far plane distance) = Fogging, [0..1] add r2, r6.w, -c8.y // 1 // ( Fogging - MinFogValue ) mul r2, r2, c8.z // 1 // ( Fogging - MinFogValue ) / ( 1 - MinFogValue ) sge r3, r6.w, c8.y // 1 // If (Fogging >= MinFogValue ) { r3 = 1 } else { r3 = 0 } mul r4, r3.x, r2.x // 1 (18) // Record the fogging value. // We now need to find out what the color of this vert will be, based on the alphas of ocean3, sand and sand wet. mul r6, v3.x, c91 // 1 mad r6, v3.y, c92, r6 // 1 // We don't use fogging directly, so we need to reduce the levels of things that will be fogged, // because the terrain is going to be added in an additive method. add r3, c14.x, -r4 // 1 // Take the complement of the fog value mul r11, r3, r6 // 1 (25) // Turn down the "alpha" by the amount of fog at this pixel // Now compute lighting information dp3 r9, -c10, v1 // 1 // (Light Vector) dot (Normal) (L.N) mul r9, r9, c11 // 1 // Modulate diffuse by its color add r9, r9, c12 // 1 // Add the ambient color to this value. max r9, c14.y, r9 // 1 // Clamp the minimum value to 0 min r1, c14.x, r9 // 1 // Clamp the maximum value to 1 mul r11, r11, r1 // 1 // Multiply the computed alpha sum color by the diffuse/ambient lighting // Get the final color mul r10, r4, c9 // 1 // Modulate the fog color by the fogging value. add oD0.rgb, r10, r11 // 1 (27) // Add the terrain color to the fog color, and make that the diffuse color