//HUD VS 1.
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v1.3.16 on Sat Jan 15 21:22:16 2022
//
//
// Buffer Definitions:
//
// cbuffer ConstBuf__modelData
// {
//
//   struct ModelData
//   {
//
//       uint lightGroupID;             // Index:    0
//       uint modelFlags;               // Index:    0.y
//       float lodFade;                 // Index:    0.z
//       float displacementBlend;       // Index:    0.w
//       int turbulenceDataIdx;         // Index:    1
//       int instanceOffset;            // Index:    1.y
//       int characterFxIdx;            // Index:    1.z
//       uint debugRenderChannel;       // Index:    1.w
//       uint decayWriteOffset;         // Index:    2
//       uint decayWriteMaxCount;       // Index:    2.y
//       uint decayAtomicCounterIndex;  // Index:    2.z
//       float modelAlpha;              // Index:    2.w
//       float emissiveScale;           // Index:    3
//       float desaturationScale;       // Index:    3.y
//       float decayCoverageEstimation; // Index:    3.z
//       float3 quantScale;             // Index:    4
//       float3 quantBias;              // Index:    5
//
//   } resourceTables__modelData;       // Index:    0-5.z            Components:    23
                                        // Textures:  t15-t17
//
// }
//
// cbuffer ConstBuf__viewData
// {
//
//   struct ViewData
//   {
//
//       float4x4 view;                 // Index:    0
//       float4x4 invView;              // Index:    4
//       float4x4 proj;                 // Index:    8
//       float4x4 invViewProjNoZReproj; // Index:   12
//       float4x4 viewProj;             // Index:   16
//       float4x4 invViewProj;          // Index:   20
//       float4x4 previousViewProj;     // Index:   24
//       float4 prevLodEyePos;          // Index:   28
//       float4 lodEyePos;              // Index:   29
//       float4 viewDirDepthBias;       // Index:   30
//       float3 eyePos;                 // Index:   31
//       float2 viewportSize;           // Index:   32
//       float2 invViewportSize;        // Index:   32.z
//       float4 mirrorPlaneWS;          // Index:   33
//       float2 mirrorViewportSize;     // Index:   34
//       float2 opaqueRefractionViewportSize;// Index:   34.z
//       float windTime;                // Index:   35
//       float deltaTime;               // Index:   35.y
//       float depthReprojectScale;     // Index:   35.z
//       float depthReprojectBias;      // Index:   35.w
//       uint shadowViewType;           // Index:   36
//       float normalDepthBias;         // Index:   36.y
//       float noNormalAA;              // Index:   36.z
//       float noNormalFromAlpha;       // Index:   36.w
//       float noOpaqueTransparency;    // Index:   37
//       float translucentAmount;       // Index:   37.y
//       uint framePhase;               // Index:   37.z
//       float cameraAmbientExposure;   // Index:   37.w
//       float fxExposure;              // Index:   38
//       float fxAmbientExposure;       // Index:   38.y
//       uint checkerboardPhase;        // Index:   38.z
//       float sparkleIntensityScale;   // Index:   38.w
//
//   } resourceTables__viewData;        // Index:    0-38             Components:   156
//
// }
//
// Resource bind info for resourceTables__modelData.instancingBuffer
// {
//
//   struct InstancingData
//   {
//
//       float4x3 transformCurrentFrame;// Index:    0
//       float4x3 transformPrevFrame;   // Index:    3
//       uint vertColOffset;            // Index:    6
//       uint packedLodFadeDisplacementTurbulenceIdx;// Index:    6.y
//
//   } $Element;                        // Index:    0-6.y            Components:    26
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// resourceTables__modelData.instancingBuffer    texture  struct         r/o   17        1
// ConstBuf__modelData               cbuffer      NA          NA    1        1
// ConstBuf__viewData                cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz
// TEXCOORD                 0   xy          1     NONE   float   xy
// NORMAL                   0   xyz         2     NONE   float   xyz
// TANGENT                  0   xyzw        3     NONE   float   xyzw
// SV_InstanceID            0   x           4   INSTID    uint   x
// SV_VertexID              0   x           5   VERTID    uint   x
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// VERT_ID                  0   x           1     NONE    uint   x
// TEXCOORD                 0   xy          2     NONE   float   xy
// NORMAL                   0   xyz         3     NONE   float   xyz
// TANGENT                  0   xyz         4     NONE   float   xyz
// BINORMAL                 0   xyz         5     NONE   float   xyz
// TEXCOORD                 8   xyz         6     NONE   float   xyz
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb1[6], immediateIndexed
dcl_constantbuffer cb3[28], immediateIndexed
dcl_constantbuffer cb12[1], immediateIndexed
dcl_resource_texture2d (float,float,float,float) t110
dcl_resource_structured t17, 104
dcl_input v0.xyz
dcl_input v1.xy
dcl_input v2.xyz
dcl_input v3.xyzw
dcl_input_sgv v4.x, instance_id
dcl_input_sgv v5.x, vertex_id
dcl_output_siv o0.xyzw, position
dcl_output o1.x
dcl_output o2.xy
dcl_output o3.xyz
dcl_output o4.xyz
dcl_output o5.xyz
dcl_output o6.xyz
dcl_temps 50
dcl_resource_texture2d (float,float,float,float) t125
dcl_resource_texture1d (float,float,float,float) t120
ld_indexable(texture2d)(float,float,float,float) r40.xyzw, l(0, 0, 0, 0), t125.xyzw
ld_indexable(texture1d)(float,float,float,float) r33.xyzw, l(3, 0, 0, 0), t120.xyzw
ld_indexable(texture1d)(float,float,float,float) r35.xyzw, l(10, 0, 0, 0), t120.xyzw
ld_indexable(texture1d)(float,float,float,float) r36.xyzw, l(11, 0, 0, 0), t120.xyzw
iadd r0.x, v4.x, cb1[1].y
ld_structured_indexable(structured_buffer, stride=104)(mixed,mixed,mixed,mixed) r1.xyzw, r0.x, l(0), t17.xyzw
mov r2.x, r1.w
ld_structured_indexable(structured_buffer, stride=104)(mixed,mixed,mixed,mixed) r3.xyzw, r0.x, l(16), t17.xyzw
mov r2.y, r3.w
ld_structured_indexable(structured_buffer, stride=104)(mixed,mixed,mixed,mixed) r4.xyzw, r0.x, l(32), t17.xyzw
mov r2.z, r4.w
mad r0.yzw, v0.xxyz, cb1[4].xxyz, cb1[5].xxyz
dp3 r5.x, r0.yzwy, r1.xyzx
dp3 r5.y, r0.yzwy, r3.xyzx
dp3 r5.z, r0.yzwy, r4.xyzx
add r2.xyz, r2.xyzx, r5.xyzx
mov r2.w, l(1.000000)
dp4 r10.x, r2.xyzw, cb3[16].xyzw
dp4 r10.y, r2.xyzw, cb3[17].xyzw
dp4 r10.z, r2.xyzw, cb3[18].xyzw
dp4 r10.w, r2.xyzw, cb3[19].xyzw


//ld_structured_indexable(structured_buffer, stride=104)(mixed,mixed,mixed,mixed) r1.w, r0.x, l(100), t17.xxxx
//
//ieq r42.x, r10.w, l(1.0)
//if_nz r42.x
//
//add r41.x, l(1.0), -r3.w
//mul r41.x, r41.x, r40.y
//mul r41.x, r41.x, l(-1.0)
//
////mul r40.w, r40.y, v0.z
////mul r40.w, r40.w, l(1.0)
//add r40.w, r10.w, -r41.x
//mad r10.x, r40.x, r40.w, r10.x
//
//endif

//w depth of 1.
ieq r41.x, r10.w, l(1.0)

//If filter_index lower than 0.1. For static depth.
lt r41.y, r33.x, l(0.1)

//If filter_index is 2, for fully dynamic PS.
ieq r41.z, r33.x, l(2.0)

//If filter_index is 5, to allow PS to change convergence scaling.
ieq r41.w, r33.x, l(5.0)

//If filter_index is 4, to use centered dynamic depth but shifted vertically.
ieq r42.y, r33.x, l(4.0)

//If filter_index is 1, to use centered dynamic depth.
ieq r42.z, r36.x, l(1.0)

//Both filter_index 2 and 5 are allowed dynamic depth.
//or r41.w, r41.w, r41.z

//Static depth if in menu preset.
//or r41.y, r41.y, r42.z

//If w depth higher than 0.85, normal. If not, possibility of reduced convergence scaling.
ge r42.x, r10.w, l(0.85)

//Coordinates allowed dynamic depth. Experimental.
//lt r43.z, r10.y, l(-0.65)
//and r43.z, r43.z, r41.z
//or r41.y, r41.y, r43.z

or r41.y, r41.y, r41.w
if_z r41.x
if_nz r42.x
add r40.w, r10.w, -r40.y
mad r10.x, r40.x, r40.w, r10.x
else
if_nz r41.w
mul r40.w, r40.y, l(0.45)
add r40.w, r10.w, -r40.w
mad r10.x, r40.x, r40.w, r10.x
else
add r40.w, r10.w, -r40.y
mad r10.x, r40.x, r40.w, r10.x
endif
endif
else
  if_nz r41.y
    //Static depth. Coordinates for button prompts in tutorials.
	ge r43.x, r10.x, l(-0.3)
	lt r43.y, r10.x, l(0.3)
	ge r43.z, r10.y, l(-0.882222)
	lt r43.w, r10.y, l(-0.722222)
	and r43.x, r43.x, r43.y
	and r43.x, r43.x, r43.z
	and r43.x, r43.x, r43.w
	if_z r43.x
    mad r10.x, r40.x, r35.x, r10.x
	endif
  else
    //Dynamic depth.
    
    ld_indexable(texture2d)(float,float,float,float) r20.xy, l(0, 0, 0, 0), t125.xyzw
    ne r20.z, r20.x, l(0.000000)
    if_nz r20.z
      add r20.z, -r20.y, l(0.000100)
      mul r20.w, r20.x, r20.z
	  
	  //Samples more useful when multiplying by zero, but no popout.
	  //mul r20.w, r20.w, l(0.0)
	  
      mad r20.z, -r20.z, r20.x, r20.x
      mul r20.y, r20.y, r20.x
	  //Convergence multiplier.
      mul r20.y, r20.y, l(10.00)
      resinfo_indexable(texture2d)(float,float,float,float)_uint r22.xy, l(0), t110.xyzw
      iadd r22.zw, r22.xxxy, l(0, 0, -1, -1)
      utof r22.xyzw, r22.xyzw
	  
	  //o0.y depth. Else for center.
	  if_nz r41.z
		mad r23.x, r10.y, l(-0.500000), l(0.500000)
		mul r22.y, r22.y, r23.x
	  else
	    if_nz r42.y
		  mul r22.y, r22.y, l(0.437500)
		else
	      mul r22.y, r22.y, l(0.500000)
	    endif
	  endif
      
      min r22.y, r22.w, r22.y
      ftoi r23.y, r22.y
      mov r23.zw, l(0,0,0,0)
      mov r22.y, l(0)
      mov r22.w, r20.w
      mov r24.x, r20.w
      mov r24.yz, l(0,0,0,0)
      loop
        uge r24.w, r24.y, l(500)
        mov r24.z, l(0)
        breakc_nz r24.w
        mad r24.x, r20.z, l(0.002000), r24.x
		
		//o0.x depth.
		if_nz r41.z
		  add r24.w, r10.x, r24.x
		endif
		//0.46 instead of 0.5 to compensate 2D depth buffer.
        mad r24.w, r24.w, l(0.500000), l(0.460000)
        mul r24.w, r22.x, r24.w
        max r24.w, r24.w, l(0.000000)
        min r24.w, r22.z, r24.w
        ftoi r23.x, r24.w
        ld_indexable(texture2d)(float,float,float,float) r23.x, r23.xyzw, t110.xyzw
        ne r24.w, r23.x, l(1.000000)
        add r25.x, r23.x, l(0.000000)
        mul r25.x, r25.x, l(0.000100)
        div r25.x, l(0.000100), r25.x
        add r23.x, r23.x, r25.x
        and r23.x, r23.x, r24.w
        eq r24.w, r23.x, l(0.000000)
        if_nz r24.w
          mov r22.y, r20.x
          mov r24.z, l(-1)
          break
        endif
        add r25.x, r20.x, -r24.x
        div r25.x, r20.y, r25.x
        lt r23.x, r23.x, r25.x
        if_nz r23.x
          mov r22.y, l(0)
          mov r24.z, l(0)
          break
        endif
        mov r22.w, r24.x
        iadd r24.y, r24.y, l(1)
        mov r24.xyz, r24.xywx
        mov r22.y, l(0)
      endloop
      movc r20.x, r24.z, r22.y, r22.w
    else
      mov r20.x, l(0)
    endif
    add r10.x, r20.x, r10.x

    //End dynamic depth.
  endif
endif

mov o0.xyzw, r10.xyzw
ld_structured_indexable(structured_buffer, stride=104)(mixed,mixed,mixed,mixed) r1.w, r0.x, l(100), t17.xxxx
bfi o1.x, l(24), l(0), v5.x, r1.w
mov o2.xy, v1.xyxx
mad r2.xyz, v2.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 r5.x, r2.xyzx, r1.xyzx
dp3 r5.y, r2.xyzx, r3.xyzx
dp3 r5.z, r2.xyzx, r4.xyzx
dp3 r1.w, r5.xyzx, r5.xyzx
rsq r1.w, r1.w
mul r2.xyz, r1.wwww, r5.xyzx
mov o3.xyz, r2.xyzx
mad r5.xyzw, v3.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), l(-1.000000, -1.000000, -1.000000, -1.000000)
dp3 r1.x, r5.xyzx, r1.xyzx
dp3 r1.y, r5.xyzx, r3.xyzx
dp3 r1.z, r5.xyzx, r4.xyzx
dp3 r1.w, r1.xyzx, r1.xyzx
rsq r1.w, r1.w
mul r1.xyz, r1.wwww, r1.xyzx
mov o4.xyz, r1.xyzx
mul r3.xyz, r1.yzxy, r2.zxyz
mad r1.xyz, r2.yzxy, r1.zxyz, -r3.xyzx
mul r1.xyz, r5.wwww, r1.xyzx
dp3 r1.w, r1.xyzx, r1.xyzx
rsq r1.w, r1.w
mul r1.xyz, r1.wwww, r1.xyzx
and r1.w, l(16), cb1[0].y
movc r1.w, r1.w, l(-1.000000), l(1.000000)
mul o5.xyz, r1.xyzx, r1.wwww
ld_structured_indexable(structured_buffer, stride=104)(mixed,mixed,mixed,mixed) r1.xyzw, r0.x, l(48), t17.wxyz
dp3 r2.x, r0.yzwy, r1.yzwy
ld_structured_indexable(structured_buffer, stride=104)(mixed,mixed,mixed,mixed) r3.xyzw, r0.x, l(64), t17.xyzw
ld_structured_indexable(structured_buffer, stride=104)(mixed,mixed,mixed,mixed) r4.xyzw, r0.x, l(80), t17.xyzw
mov r1.y, r3.w
dp3 r2.y, r0.yzwy, r3.xyzx
dp3 r2.z, r0.yzwy, r4.xyzx
mov r1.z, r4.w
add r0.xyz, r1.xyzx, r2.xyzx
mov r0.w, l(1.000000)
dp4 o6.x, r0.xyzw, cb3[24].xyzw
dp4 o6.y, r0.xyzw, cb3[25].xyzw
dp4 o6.z, r0.xyzw, cb3[27].xyzw
ret
// Approximately 59 instruction slots used

///////////////////////////////// HLSL Code /////////////////////////////////
// // ---- Created with 3Dmigoto v1.3.16 on Sat Jan 15 21:22:16 2022
//
// struct InstancingData
// {
//     float4x3 transformCurrentFrame;// Offset:    0
//     float4x3 transformPrevFrame;   // Offset:   48
//     uint vertColOffset;            // Offset:   96
//     uint packedLodFadeDisplacementTurbulenceIdx;// Offset:  100
// };
//
// cbuffer ConstBuf__modelData : register(b1)
// {
//
//   struct
//   {
//     uint lightGroupID;
//     uint modelFlags;
//     float lodFade;
//     float displacementBlend;
//     int turbulenceDataIdx;
//     int instanceOffset;
//     int characterFxIdx;
//     uint debugRenderChannel;
//     uint decayWriteOffset;
//     uint decayWriteMaxCount;
//     uint decayAtomicCounterIndex;
//     float modelAlpha;
//     float emissiveScale;
//     float desaturationScale;
//     float decayCoverageEstimation;
//     float3 quantScale;
//     float3 quantBias;
//   } resourceTables__modelData : packoffset(c0);
//
//
// StructuredBuffer<InstancingData> resourceTables__modelData.instancingBuffer : register(t17);
//
//
// // 3Dmigoto declarations
// #define cmp -
// Texture1D<float4> IniParams : register(t120);
// Texture2D<float4> StereoParams : register(t125);
//
//
// void main(
//   float4 v0 : POSITION0,
//   float2 v1 : TEXCOORD0,
//   float3 v2 : NORMAL0,
//   float4 v3 : TANGENT0,
//   uint v4 : SV_InstanceID0,
//   uint v5 : SV_VertexID0,
//   out float4 o0 : SV_POSITION0,
//   out uint o1 : VERT_ID0,
//   out float2 o2 : TEXCOORD0,
//   out float3 o3 : NORMAL0,
//   out float3 o4 : TANGENT0,
//   out float3 o5 : BINORMAL0,
//   out float3 o6 : TEXCOORD8)
// {
//   Textures: = t15-t17 + ;
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_input_sgv v4.x, instance_id
// // Needs manual fix for instruction:
// // unknown dcl_: dcl_input_sgv v5.x, vertex_id
//   float4 r0,r1,r2,r3,r4,r5;
//   uint4 bitmask, uiDest;
//   float4 fDest;
//
//   r0.x = [v4.x].val[resourceTables__modelData.instanceOffset/4];
//   r0.y = [v4.x].val[resourceTables__modelData.instanceOffset/4+1];
//   r0.z = [v4.x].val[resourceTables__modelData.instanceOffset/4+2];
//   r0.w = [v4.x].val[resourceTables__modelData.instanceOffset/4+3];
//   stride=104)(mixed = r1.x;
//   r2.x = [r1.w].val[/4];
//   r2.y = [r1.w].val[/4+1];
//   r2.z = [r1.w].val[/4+2];
//   r2.w = [r1.w].val[/4+3];
//   stride=104)(mixed = r3.x;
//   r2.x = [r3.w].val[/4];
//   r2.y = [r3.w].val[/4+1];
//   r2.z = [r3.w].val[/4+2];
//   r2.w = [r3.w].val[/4+3];
//   stride=104)(mixed = r4.x;
//   r2.z = r4.w *  + ;
//   r0.yzw = dot(v0.xxy, resourceTables__modelData.quantScale.xxy);
//   r5.x = dot(r0.yzw, r1.xyz);
//   r5.y = dot(r0.yzw, r3.xyz);
// }
//////////////////////////////// HLSL Errors ////////////////////////////////
// error X3506: unrecognized compiler target '                                        // Textures:  t15-t17'
/////////////////////////////////////////////////////////////////////////////
