// Sky edge, below mountain height, in camp.
// Shader 66
//
// Converted from 2_0 to 3_0 so we can use if_eq statement
// to skip non-skyline textures.
//
// [VS25BC27CC] Shader 66, skydome below mountain
// Mod:
//  9B5F02CC;  Band of sky below mountain tops
//  9967B80B;  Camo skybox in Coach's brain
// No Mod:
//  1C3D546E;  Sky reflection in lake
//  8AF4FADD;  Fog in valley below cabins

	vs_3_0 
	
	def c200, 666, 40000, 999, 8000
	def c201, 1,0,1,1	// hot pink

	dcl_position v0
    dcl_normal v1
    dcl_color v2
    dcl_texcoord v3

	dcl_position o0
	dcl_color o1
	dcl_fog o2
	dcl_texcoord o3
    
	// applies wvp transform
	m4x4 r4, v0, c6
	add r4, r4, c50

	// At this point r4 is the output position.
	// For sky elements it's too close.

	// Look for key toggle to turn fix on/off
	// This makes it easier to be sure we've found them all.
	mov r30.x, c250.x
	if_eq r30.x, c200.x

		// If texture defined in DX9Settings.ini, we do the fixup, if
		// not we skip it.  Thus we only move the vertex further out
		// for the textures specified in the ini.
		// As defined in ini, c251.x == 666 if we are supposed to fix it.
		mov r30.x, c251.x
		if_eq r30.x, c200.x
			
			// Move all vertexes further out, so that it is
			// deep, skybox deep.
			mul r4, r4, c200.w
			
			// Tweak the Y parameter by 40000, because once
			// we've moved out, there was an annoying gap/tear 
			// in the skybox, and this overlaps enough to not annoy.
			// Using that large a number does not seem to cause any
			// other problems.
			add r4.y, r4.y, c200.y
		endif
	endif
	
	// Send vertex, changed or not, to the output
	mov o0, r4
	

	// Default path assumes we do not pinkify the output
	mul o1, v2, c2

	// Only do this if we have enabled pinkify.
	mov r30.y, c250.y
	if_eq r30.y, c200.x
	
		// If the current texture is in the Not Defined
		// list, then show it in hot-pink coloring.  We
		// can disable this coloring from the ini file, by
		// commenting out the ValNotDefined.
		mov r30.x, c251.x
		if_eq r30.x, c200.y
			mov o1, c201
		endif
	endif
	
	mov r11, v0
	add r7, c51, -r11
    dp3 r4.x, r7, r7
    rsq r4.x, r4.x
    rcp r4.x, r4.x
    mad r4.x, r4.x, c4.x, c4.y
    dp4 r4.y, r11, c52
    mad r4.y, r4.y, c4.z, c4.w
    min o2, r4.x, r4.y
    
	mov r0, c12
    mul r0, r0, c94
    mad o3, v3, r0, c13

// approximately 19 instruction slots used
 