//Shadows
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
//   sampler2D Base;
//   sampler2D Base2;
//   float3 Params;
//   row_major float4x4 PrevViewProjMatrix;
//   row_major float4x4 ViewProjMatrix;
//   float4 global_Data;
//   float4 global_ViewInfo;
//
//
// Registers:
//
//   Name               Reg   Size
//   ------------------ ----- ----
//   ViewProjMatrix     c0       3
//   PrevViewProjMatrix c3       3
//   Params             c6       1
//   global_ViewInfo    c218     1
//   global_Data        c219     1
//   Base               s0       1
//   Base2              s1       1
//

    ps_3_0
    def c7, 1, 30, 1.25000001e-008, -0.5
    def c8, 0, 400, 0, 0.199471146
    def c9, 0.969233215, 0.939413071, 0, 0
    defi i0, 8, 0, 0, 0
def c220, 1, 0, 0.0625, 0.5
dcl_2d s13
    dcl_texcoord v0.xy  // In<4,5>
    dcl_texcoord2 v1.xyz  // In<6,7,8>
    dcl_texcoord3 v2.xyz  // In<9,10,11>
    dcl_2d s0
    dcl_2d s1

	
////------Work out Inverse matrix------
def c201, 1, 0, 0, 0
////Initialise 
mov r9, c204
mov r10, c205
mov r11, c206
mov r12, c207

mov r13, c201.y  	
mov r13.x, c201.x  	
mov r14, c201.y  	
mov r14.y, c201.x  	
mov r15, c201.y  	
mov r15.z, c201.x  	
mov r16, c201.y  	
mov r16.w, c201.x  
	
////First row reduction
if_ne r9.x, c201.w
	rcp r3.x, r9.x
	mul r9, r9, r3.x
	mul r13, r13, r3.x
endif
if_ne r10.x, c201.w
	rcp r3.x, r10.x
	mul r10, r10, r3.x
	mul r14, r14, r3.x
endif
if_ne r11.x, c201.w
	rcp r3.x, r11.x
	mul r11, r11, r3.x
	mul r15, r15, r3.x
endif
if_ne r12.x, c201.w
	rcp r3.x, r12.x
	mul r12, r12, r3.x
	mul r16, r16, r3.x
endif
if_ne r10.x, c201.w
	sub r10, r10, r9
	sub r14, r14, r13
endif
if_ne r11.x, c201.w
	sub r11, r11, r9
	sub r15, r15, r13
endif
if_ne r12.x, c201.w
	sub r12, r12, r9
	sub r16, r16, r13
endif

////Second row reduction
if_ne r9.y, c201.w
	mov r3.y, r9.y
	rcp r3.x, r9.y
	mul r9, r9, r3.x
	mul r13, r13, r3.x
else
	mov r3.y, c201.x
endif
if_ne r10.y, c201.w
	rcp r3.x, r10.y
	mul r10, r10, r3.x
	mul r14, r14, r3.x
endif
if_ne r11.y, c201.w
	rcp r3.x, r11.y
	mul r11, r11, r3.x
	mul r15, r15, r3.x
endif
if_ne r12.y, c201.w
	rcp r3.x, r12.y
	mul r12, r12, r3.x
	mul r16, r16, r3.x
endif
if_ne r9.y, c201.w
	sub r9, r9, r10
	sub r13, r13, r14
endif
if_ne r11.y, c201.w
	sub r11, r11, r10
	sub r15, r15, r14
endif
if_ne r12.y, c201.w
	sub r12, r12, r10
	sub r16, r16, r14
endif

mul r9, r9, r3.y
mul r13, r13, r3.y

////Third row reduction
if_ne r9.z, c201.w
	mov r3.y, r9.z
	rcp r3.x, r9.z
	mul r9, r9, r3.x
	mul r13, r13, r3.x
else
	mov r3.y, c201.x
endif
if_ne r10.z, c201.w
	mov r3.z, r10.z
	rcp r3.x, r10.z
	mul r10, r10, r3.x
	mul r14, r14, r3.x
else
	mov r3.z, c201.x
endif
if_ne r11.z, c201.w
	rcp r3.x, r11.z
	mul r11, r11, r3.x
	mul r15, r15, r3.x
endif
if_ne r12.z, c201.w
	rcp r3.x, r12.z
	mul r12, r12, r3.x
	mul r16, r16, r3.x
endif
if_ne r9.z, c201.w
	sub r9, r9, r11
	sub r13, r13, r15
endif
if_ne r10.z, c201.w
	sub r10, r10, r11
	sub r14, r14, r15
endif
if_ne r12.z, c201.w
	sub r12, r12, r11
	sub r16, r16, r15
endif

mul r9, r9, r3.y
mul r13, r13, r3.y
mul r10, r10, r3.z
mul r14, r14, r3.z

////Fourth row reduction
if_ne r9.w, c201.w
	mov r3.y, r9.w
	rcp r3.x, r9.w
	mul r9, r9, r3.x
	mul r13, r13, r3.x
else
	mov r3.y, c201.x
endif
if_ne r10.w, c201.w
	mov r3.z, r10.w
	rcp r3.x, r10.w
	mul r10, r10, r3.x
	mul r14, r14, r3.x
else
	mov r3.z, c201.x
endif
if_ne r11.w, c201.w
	mov r3.w, r11.w
	rcp r3.x, r11.w
	mul r11, r11, r3.x
	mul r15, r15, r3.x
else
	mov r3.w, c201.x
endif
if_ne r12.w, c201.w
	rcp r3.x, r12.w
	mul r12, r12, r3.x
	mul r16, r16, r3.x
endif
if_ne r9.w, c201.w
	sub r9, r9, r12
	sub r13, r13, r16
endif
if_ne r10.w, c201.w
	sub r10, r10, r12
	sub r14, r14, r16
endif
if_ne r11.w, c201.w
	sub r11, r11, r12
	sub r15, r15, r16
endif
mul r9, r9, r3.y
mul r13, r13, r3.y
mul r10, r10, r3.z
mul r14, r14, r3.z
mul r11, r11, r3.w
mul r15, r15, r3.w
////--------- END INVERSE MATRIX --------------

#line 38 "c:\Develop\LSProjects\build\shared\EyesOfAChild\Code\EoCApp\build\memory"
    texld r0, v0, s1  // ::depth<0>
    mov r1.xyz, v1  // In<6,7,8>
    mad r1.xyz, r0.x, r1, v2  // ::WorldPos<0,1,2>

texldl r24, c220.z, s13
mov r20.xyz, r1.xyz
	mov r20.w, c220.x
		
	dp4 r21.x, r20, c204 //r13 //c208
	dp4 r21.y, r20, c205 //r14 //c209
	dp4 r21.z, r20, c206 //r15 //c210
	dp4 r21.w, r20, c207 //r16 //c211

	add r24.y, r21.w, -r24.y
	mul r24.x, r24.x, r24.y
	add r21.x, r21.x, -r24.x

	dp4 r20.x, r21, r13 //c204
	dp4 r20.y, r21, r14 //c205
	dp4 r20.z, r21, r15 //c206
	dp4 r20.w, r21, r16 //c207

	rcp r21.w, r20.w
	mul r20, r20, r21.w

mov r1, r20

    mov r1.w, c7.x
    dp4 r2.x, c0, r1  // ::currentCameraPos<0>
    dp4 r2.y, c1, r1  // ::currentCameraPos<1>
    dp4 r2.z, c2, r1  // ::currentCameraPos<2>
    dp4 r3.x, c3, r1  // ::previousCameraPos<0>
    dp4 r3.y, c4, r1  // ::previousCameraPos<1>
    dp4 r3.z, c5, r1  // ::previousCameraPos<2>

#line 44
    rcp r0.y, c218.x
    mul r0.z, r0.y, c6.z
    rcp r0.z, r0.z
    mul_sat r0.z, r0.z, r0.x  // ::depthBlur<0>
    add r1.xyz, r2, -r3  // ::velocity<0,1,2>

#line 49
    mul r0.w, r0.y, c7.y  // ::normalizedDragonDistance<0>
    add r0.x, -r0.x, c7.x
    mad r0.y, r0.y, -c7.y, c7.x
    add_sat r0.x, -r0.y, r0.x
    rcp r0.y, r0.w
    mad r0.x, r0.x, -r0.y, c7.x  // ::dragonMask<0>
    rcp r0.y, c219.y
    mov r1.w, -r1.x
    mul r1.xyz, r0.y, r1.wyzw
    mul r1.xyz, r1, c6.x
    mul r1.xyz, r1, c218.z
    mul r1.xyz, r1, c7.z  // ::velocity<0,1,2>
    add r0.y, -r0.z, c7.x
    mul r0.x, r0.x, r0.y
    mul r0.xyz, r0.x, r1  // ::velocity<0,1,2>
    add r1.xy, c7.w, v0
    mul r0.zw, r0.z, r1.xyxy
    mul r0.zw, r0, c6.y
    add r0.zw, r0, r0  // ::zVector<0,1>

#line 72
    dp2add r1.x, r0, r0, c8.x
    rsq r1.x, r1.x
    rcp r1.x, r1.x
    mul_sat r1.x, r1.x, c8.y

#line 68
    mov r1.yzw, c8.x  // ::blurColor<0,1,2>
    mov r2.y, c9.x  // ::g<1>
    mov r2.xz, c8.wyxw  // ::g<0>, ::i<0>
    rep i0
      mad r3.xy, r0.zwzw, -r2.z, v0  // ::TexC_Z<0,1>
      mad r3.zw, r0.xyxy, r2.z, v0.xyxy  // ::TexC_XY<0,1>
      lrp r4.xy, r1.x, r3.zwzw, r3  // ::TexC_Final<0,1>
      texld r3, r4, s0
      mad r1.yzw, r3.xxyz, r2.x, r1  // ::blurColor<0,1,2>

#line 77
      mul r2.x, r2.y, r2.x  // ::g<0>
      mul r2.y, r2.y, c9.y  // ::g<1>

#line 68
      add r2.z, r2.z, c7.x  // ::i<0>
    endrep
    mov oC0.xyz, r1.yzww  // ::main<0,1,2>
    mov oC0.w, c8.x  // ::main<3>

// approximately 57 instruction slots used (2 texture, 55 arithmetic)
 
