<shader compiler="xmlshader" name="sky_scattering">
  <shadervars>
    <!-- beta1 = Rayleigh -->
    <!-- .2
    <shadervar name="beta' 1" type="vector3">8.3215e-06, 1.4072e-05, 2.9180e-05</shadervar>
    <shadervar name="beta' 1" type="vector3">3.3286e-05, 5.6288e-05, 1.1672e-04</shadervar>
    <shadervar name="beta' 1" type="vector3">4.1608e-06, 7.0360e-06, 1.4590e-05</shadervar>
    -->
      <?if vars."sky base color".w &gt; 0 ?>
      <shadervar name="beta' 1" type="expression">
	  <sexp>
	    (make-vector 
		(* 0.0000001 (elt1 "sky base color"))
		(* 0.0000001 (elt2 "sky base color"))
		(* 0.0000001 (elt3 "sky base color"))
		0)
	  </sexp>
      </shadervar>
      <?else ?>
    <shadervar name="beta' 1" type="vector3">1.6643e-08, 2.8144e-08, 5.8360e-08</shadervar>
      <?endif ?>
    <!-- beta2 = Mie -->
    <!-- .01
    <shadervar name="beta' 2" type="vector3">1.3338e-05, 1.7345e-05, 2.4976e-05</shadervar>
    <shadervar name="beta' 2" type="vector3">0.00026676, 0.00034689, 0.00049952</shadervar>
    <shadervar name="beta' 2" type="vector3">0.00066689, 0.00086723, 0.00124881</shadervar>
    -->
      <?if vars."sky sun-glow color".w &gt; 0 ?>
      <shadervar name="beta' 2" type="expression">
	  <sexp>
	    (make-vector 
		(* 0.0000001 (elt1 "sky sun-glow color"))
		(* 0.0000001 (elt2 "sky sun-glow color"))
		(* 0.0000001 (elt3 "sky sun-glow color"))
		0)
	  </sexp>
 	</shadervar>
      <?else ?>
    <shadervar name="beta' 2" type="vector3">1.3338e-07, 1.7345e-07, 2.4976e-07</shadervar>
      <?endif ?>
    <!--
    <shadervar name="beta1 + beta2" type="vector3">0.00019683, 0.00030978, 0.00059405</shadervar>
    <shadervar name="beta1 + beta2" type="vector3">0.0017058, 0.0024231, 0.0040585</shadervar>
    <shadervar name="beta1 + beta2" type="vector3">0.0029400, 0.0038177, 0.0055016</shadervar>
    -->
    <shadervar name="beta1 + beta2" type="vector3">8.5292e-07, 1.2115e-06, 2.0293e-06</shadervar>
    <!-- g = .8, hg = 1-g^2, 1+g, 2g -->
      <?if vars."sky sun size".w &gt; 0 ?>
      <shadervar name="hg" type="expression">
	  <sexp>
	    (make-vector 
		"sky sun size" 0.5 0.5 0)
	  </sexp>
      </shadervar>
      <?else ?>
    <shadervar name="hg" type="vector3">0.36, 1.8, 1.6</shadervar>
      <?endif ?>
    <!-- inscatter = .3 -->
    <shadervar name="inscattering term" type="vector3">0.4, 0.4, 0.4</shadervar>
  </shadervars>
  
  <technique priority="50">
    <pass>
      <mixmode><copy /></mixmode>
      <vp plugin="glarb" file="/shader/scattering.avp" />
      <texture destination="unit 0" name="standardtex white" />
      <fp plugin="glfixed">
        <fixedfp>
          <layer>
            <colorsource num="0" source="primary color" modifier="color" />
            <coloroperation operation="replace" />
          </layer>
        </fixedfp>
      </fp>
    </pass>
  </technique>

  <fallbackshader name="std_lighting" />
</shader>
