// Skybox / ray-traced clouds vertex shader
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.15 on Wed Mar 06 06:22:50 2019
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 ksgClipPlane;               // Offset:    0 Size:    16
//   row_major float4x4 g_mtP2W;        // Offset:   16 Size:    64
//   float4 g_vCameraDirVectors[4];     // Offset:   80 Size:    64
//   float2 g_vProjFarNear;             // Offset:  144 Size:     8
//   int g_iBayerPosNum;                // Offset:  152 Size:     4
//   float4 g_vProcSize;                // Offset:  160 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VertexID              0   x           0   VERTID    uint   x
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_ClipDistance          0   xyzw        0  CLIPDST   float   xyzw
// SV_Position              0   xyzw        1      POS   float   xyzw
// TEXCOORD                 0   xyzw        2     NONE   float   xyzw
// TEXCOORD                 1   xyz         3     NONE   float   xyz
// TEXCOORD                 2   xy          4     NONE   float   xy
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_immediateConstantBuffer { { 2, 2, 0, 0},
                              { 0, 0, 0, 0},
                              { 2, 0, 0, 0},
                              { 0, 2, 0, 0},
                              { 3, 3, 0, 0},
                              { 1, 1, 0, 0},
                              { 3, 1, 0, 0},
                              { 1, 3, 0, 0},
                              { 2, 3, 0, 0},
                              { 0, 1, 0, 0},
                              { 2, 1, 0, 0},
                              { 0, 3, 0, 0},
                              { 3, 0, 0, 0},
                              { 1, 2, 0, 0},
                              { 3, 2, 0, 0},
                              { 1, 0, 0, 0} }
dcl_constantbuffer cb0[11], dynamicIndexed
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xyzw, clip_distance
dcl_output_siv o1.xyzw, position
dcl_output o2.xyzw
dcl_output o3.xyz
dcl_output o4.xy
dcl_temps 4

dcl_resource_texture2d (float,float,float,float) t121
ld_indexable(texture2d)(float,float,float,float) r2.xyzw, l(0, 0, 0, 0), t121.xyzw

mov o0.yzw, l(0,0,0,0)
mov r0.x, cb0[9].z
utof r0.xy, icb[r0.x + 0].xyxx
add r0.xy, r0.xyxx, l(-1.500000, -1.500000, 0.000000, 0.000000)
mul r0.xy, r0.xyxx, cb0[10].zwzz
ushr r0.z, v0.x, l(1)
utof r0.z, r0.z
mad r1.x, r0.z, l(2.000000), l(-1.000000)
and r0.z, v0.x, l(1)
utof r0.z, r0.z
mad r1.y, r0.z, l(-2.000000), l(1.000000)
mad r0.xy, r0.xyxx, l(-2.000000, 2.000000, 0.000000, 0.000000), r1.xyxx
mov r0.z, cb0[9].x
mov r0.w, l(1.000000)

// Moves clouds to infinity, but has clipping:
//add r0.x, r0.x, r2.x

// Stretch to remove clipping:
//add r2.w, l(1.01), |r2.x|
//mul r0.x, r0.x, r2.w

dp4 o0.x, cb0[0].xyzw, r0.xyzw
mov o1.xyzw, r0.xyzw
mul r0.xyzw, r1.yyyy, cb0[2].xyzw
mad o4.xy, r1.xyxx, l(0.500000, -0.500000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
mad r0.xyzw, r1.xxxx, cb0[1].xyzw, r0.xyzw
mad r0.xyzw, cb0[9].xxxx, cb0[3].xyzw, r0.xyzw
add r0.xyzw, r0.xyzw, cb0[4].xyzw
div o2.xyz, r0.xyzx, r0.wwww
mov o2.w, l(1.000000)
mov r0.x, v0.x

mov r0.xyz, cb0[r0.x + 5].xyzx

// To correct the clouds (without introducing clipping or stretching) we need
// to correct g_vCameraDirVectors in world space coordinates. We don't know
// what depth this is at, but since we have four points corresponding to the
// corners of the screen we can use that to scale separation to match whatever
// scale and orientation they are in:

add r3.xyzw, cb0[7].xyzw, -cb0[5].xyzw
mul r3.xyzw, r3.xyzw, -l(0.5)
mad r0.xyz, r3.xyzw, r2.xxxx, r0.xyzw

mov o3.xyz, r0.xyz

ret
// Approximately 26 instruction slots used
