// STARS PIXEL SHADER
//
// FIXED STAR SIZE + TWINKLE + HORIZON EXTINCTION
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 g_vDitherSettings;          // Index:    0.xyzw           Components:     4
//   float3 g_vMoonLightDir;            // Index:    1.xyz            Components:     3 [unused]
//   float4 g_vMoonColor;               // Index:    2.xyzw           Components:     4 [unused]
//   float4 g_vGlowColor;               // Index:    3.xyzw           Components:     4 [unused]
//   float4x4 g_mMoonMatrix;            // Index:    4 5 6 7          Components:    16 [unused]
//   float4x4 g_mGlowMatrix;            // Index:    8 9 10 11        Components:    16 [unused]
//   float4x4 g_mViewProj;              // Index:   12 13 14 15       Components:    16 [unused]
//   float4x4 g_mView;                  // Index:   16 17 18 19       Components:    16 [unused]
//   float4x4 g_mProj;                  // Index:   20 21 22 23       Components:    16 [unused]
//   float4 g_vOrigin;                  // Index:   24.xyzw           Components:     4 [unused]
//   float4 g_vSize;                    // Index:   25.xyzw           Components:     4 [unused]
//   float4 g_vAppear;                  // Index:   26.xyzw           Components:     4 [unused]
//   float4 g_avRND[4];                 // Index:   27 28 29 30       Components:    16 [unused]
//   float4 g_avMASK[4];                // Index:   31 32 33 34       Components:    16 [unused]
//      = 0x3f800000 0x00000000 0x00000000 0x00000000
//        0x00000000 0x3f800000 0x00000000 0x00000000
//        0x00000000 0x00000000 0x3f800000 0x00000000
//        0x00000000 0x00000000 0x00000000 0x3f800000
//   float4 g_vRotation;                // Index:   35.xyzw           Components:     4 [unused]
//   float4 g_vScreenPos;               // Index:   36.xyzw           Components:     4 [unused]
//   float4 g_vTCoords;                 // Index:   37.xyzw           Components:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// DitherSampler                     sampler      NA          NA    0        1
// mySampler                         sampler      NA          NA    1        1
// mySampler                         texture  float4          2d    0        1
// g_tDither                         texture  float4          3d    1        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// COLOR                    0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xy          2     NONE   float   xy
// TEXCOORD                 1   xyzw        3     NONE   float   xy w
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[1], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture3d (float,float,float,float) t1
dcl_input_ps linear v1.xyzw /// xyz = color  w = twinkle
dcl_input_ps linear v2.xy
dcl_input_ps linear v3.xyw
dcl_output o0.xyzw
dcl_temps 3


sample r0.xyzw, v2.xyxx, t0.xyzw, s1 // orig tex sample
//////////////// NEWNEWNENWENWNEWNENWENWE \/\/\/\/\/\\/\/\/
mul r1.xyz, r0.wwww, v1.xyzx  /// multi color by alpha
mul r1.xyz, r1.xyzx, v1.wwww  /// multi color by twinkle from vs
mul r1.xyz, r1.xyzx, l(3.0)   /// HACK for bightness need to do something better
mov o0.xyzw, r1.xyzy
/////////////// OLD SHADER \/\/\/\/\/
//  mul r0.xyzw, r0.xyzw, v1.xyzw
//  div r1.xy, v3.xyxx, v3.wwww
//  mul r1.z, r0.w, l(255.000000)
//  round_ni r1.z, r1.z
//  mad r2.xy, r1.xyxx, cb0[0].xyxx, cb0[0].zwzz
//  mad r2.z, r0.w, l(255.000000), -r1.z
//  sample_l r2.xyzw, r2.xyzx, t1.xyzw, s0, l(0.000000)
//  lt r0.w, l(0.500000), r2.y
//  if_nz r0.w
//       add r1.z, r1.z, l(1.000000)
//  endif
//  mul o0.w, r1.z, l(0.00392156979)
//  mov o0.xyz, r0.xyzx
ret
