// Stars Sky

cbuffer PER_BATCH : register(b0)
{
  float4 StarSize : packoffset(c0);
}

cbuffer STATIC_INSTANCE : register(b2)
{
  row_major float3x4 ObjWorldMatrix : packoffset(c0);
}

cbuffer PER_FRAME : register(b3)
{
  float4 g_VS_WorldViewPos : packoffset(c6);
  row_major float4x4 g_VS_ViewProjZeroMatr : packoffset(c10);
}



// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main( 
  float4 v0 : POSITION0,
  float2 v1 : TEXCOORD0,
  float4 v2 : COLOR0,
  out float4 o0 : SV_Position0,
  out float4 o1 : COLOR0,
  out float2 o2 : TEXCOORD0)
{
  const float4 icb[] = { { 0.897907794, -0.347608536, 0, 0},
                              { 0.550299287, 0.273586661, 0, 0},
                              { 0.823886, 0.0988530666, 0, 0},
                              { 0.922739, -0.122108862, 0, 0},
                              { 0.800630152, -0.0889568031, 0, 0},
                              { 0.711673379, 0.158864424, 0, 0},
                              { 0.870537817, 0.0854845569, 0, 0},
                              { 0.956022382, -0.0581145398, 0, 0} };
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.w = -g_VS_WorldViewPos.x + ObjWorldMatrix._m03;
  r0.xyz = ObjWorldMatrix._m00_m01_m02;
  r0.x = dot(r0.xyzw, v0.xyzw);
  r1.w = -g_VS_WorldViewPos.y + ObjWorldMatrix._m13;
  r1.xyz = ObjWorldMatrix._m10_m11_m12;
  r0.y = dot(r1.xyzw, v0.xyzw);
  r1.w = -g_VS_WorldViewPos.z + ObjWorldMatrix._m23;
  r1.xyz = ObjWorldMatrix._m20_m21_m22;
  r0.z = dot(r1.xyzw, v0.xyzw);
  r0.w = v0.w;
  r1.x = dot(g_VS_ViewProjZeroMatr._m00_m01_m02_m03, r0.xyzw);
  r1.y = dot(g_VS_ViewProjZeroMatr._m10_m11_m12_m13, r0.xyzw);
  r1.z = dot(g_VS_ViewProjZeroMatr._m30_m31_m32_m33, r0.xyzw);
  o0.xyzw = r1.xyzz;
  
  float4 stereo = StereoParams.Load(0);
  o0.x += stereo.x * stereo.y;
  
  r0.xy = float2(256,256) * v0.xy;
  r0.xy = frac(r0.xy);
  r0.y = 1 + r0.y;
  r0.x = r0.y * StarSize.w + r0.x;
  r0.x = frac(r0.x);
  r0.x = 8 * r0.x;
  r0.y = frac(r0.x);
  r0.x = (int)r0.x;
  r0.x = r0.y * icb[r0.x+0].y + icb[r0.x+0].x;
  r0.y = v2.w * -7.94000006 + 6.5;
  r0.y = -1.44000006 + -r0.y;
  r0.y = 0.928771198 * r0.y;
  r0.y = exp2(r0.y);
  r0.x = r0.x * r0.y;
  o1.xyz = v2.zyx * r0.xxx;
  o1.w = r0.x;
  o2.xy = StarSize.xy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.2.34 on Fri Apr 29 16:36:56 2016
//
//
// Buffer Definitions: 
//
// cbuffer PER_BATCH
// {
//
//   float4 StarSize;                   // Offset:    0 Size:    16
//
// }
//
// cbuffer STATIC_INSTANCE
// {
//
//   row_major float3x4 ObjWorldMatrix; // Offset:    0 Size:    48
//
// }
//
// cbuffer PER_FRAME
// {
//
//   float4 g_VS_WorldViewPos;          // Offset:   96 Size:    16
//   row_major float4x4 g_VS_ViewProjZeroMatr;// Offset:  160 Size:    64
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PER_BATCH                         cbuffer      NA          NA    0        1
// STATIC_INSTANCE                   cbuffer      NA          NA    2        1
// PER_FRAME                         cbuffer      NA          NA    3        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float       
// COLOR                    0   xyzw        2     NONE   float   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// COLOR                    0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xy          2     NONE   float   xy  
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_immediateConstantBuffer { { 0.897907794, -0.347608536, 0, 0},
                              { 0.550299287, 0.273586661, 0, 0},
                              { 0.823886, 0.0988530666, 0, 0},
                              { 0.922739, -0.122108862, 0, 0},
                              { 0.800630152, -0.0889568031, 0, 0},
                              { 0.711673379, 0.158864424, 0, 0},
                              { 0.870537817, 0.0854845569, 0, 0},
                              { 0.956022382, -0.0581145398, 0, 0} }
dcl_constantbuffer cb0[1], immediateIndexed
dcl_constantbuffer cb2[3], immediateIndexed
dcl_constantbuffer cb3[14], immediateIndexed
dcl_input v0.xyzw
dcl_input v2.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_temps 2
add r0.w, cb2[0].w, -cb3[6].x
mov r0.xyz, cb2[0].xyzx
dp4 r0.x, r0.xyzw, v0.xyzw
add r1.w, cb2[1].w, -cb3[6].y
mov r1.xyz, cb2[1].xyzx
dp4 r0.y, r1.xyzw, v0.xyzw
add r1.w, cb2[2].w, -cb3[6].z
mov r1.xyz, cb2[2].xyzx
dp4 r0.z, r1.xyzw, v0.xyzw
mov r0.w, v0.w
dp4 r1.x, cb3[10].xyzw, r0.xyzw
dp4 r1.y, cb3[11].xyzw, r0.xyzw
dp4 r1.z, cb3[13].xyzw, r0.xyzw
mov o0.xyzw, r1.xyzz
mul r0.xy, v0.xyxx, l(256.000000, 256.000000, 0.000000, 0.000000)
frc r0.xy, r0.xyxx
add r0.y, r0.y, l(1.000000)
mad r0.x, r0.y, cb0[0].w, r0.x
frc r0.x, r0.x
mul r0.x, r0.x, l(8.000000)
frc r0.y, r0.x
ftoi r0.x, r0.x
mad r0.x, r0.y, icb[r0.x + 0].y, icb[r0.x + 0].x
mad r0.y, v2.w, l(-7.940000), l(6.500000)
add r0.y, -r0.y, l(-1.440000)
mul r0.y, r0.y, l(0.928771198)
exp r0.y, r0.y
mul r0.x, r0.y, r0.x
mul o1.xyz, r0.xxxx, v2.zyxz
mov o1.w, r0.x
mov o2.xy, cb0[0].xyxx
ret 
// Approximately 32 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
