<shader compiler="xmlshader" name="splatting_ambient">

  <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>
    -->
    <shadervar name="beta' 1" type="vector3">8.3215e-06, 1.4072e-05, 2.9180e-05</shadervar>
    <!-- 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>
    -->
    <shadervar name="beta' 2" type="vector3">1.3338e-05, 1.7345e-05, 2.4976e-05</shadervar>
    <!--
    <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="vector4">0.00019683, 0.00030978, 0.00059405, 0.00059405</shadervar>
    <!-- g = 0.8, hg = 1-g^2, 1+g, 2g -->
    <shadervar name="hg" type="vector3">0.36, 1.8, 1.6</shadervar>
    <!-- inscatter = .3 -->
    <shadervar name="inscattering term" type="vector3">0.3, 0.3, 0.3</shadervar>

    <shadervar name="normal scale" type="expression">
      <sexp>
        (make-vector
          (elt1 "texture scale")
          (elt2 "texture scale")
        )
      </sexp>
    </shadervar>
  </shadervars> 


  <technique priority="50">
     <pass>
      <mixmode><copy/></mixmode>
     <writemask r="false" g="false" b="false" a="true"/> 
      <buffer source="normal" destination="normal" />
      <buffer source="texture coordinate 0" destination="texture coordinate 0" />
      <vp plugin="glarb" file="/shader/splatting_amb_l.avp" />
      <texture destination="unit 0" name="standardtex normalization map" />
      <texture destination="unit 1" name="tex normal" />
      <fp plugin="glfixed">
        <fixedfp>
          <layer>
 <!--           <alphasource num="0" source="primary color" modifier="alpha" />
            <alphaoperation operation="replace" /> -->
            <colorsource num="0" source="primary color" modifier="color" />
            <coloroperation operation="replace" />
          </layer>
          <layer>
 <!--           <alphasource num="0" source="previous layer" modifier="alpha"/>
            <alphaoperation operation="replace"/> -->
            <colorsource num="0" source="previous layer" modifier="color" />
            <coloroperation operation="replace" />
          </layer>
        </fixedfp>
      </fp>
    </pass>
     <pass>
      <mixmode><destalphaadd/></mixmode>
      <buffer source="normal" destination="normal" />
      <buffer source="texture coordinate 0" destination="texture coordinate 0" />
      <vp plugin="glarb" file="/shader/splatting_amb.avp" />
      <texture destination="unit 0" name="tex diffuse"/>
      <texture destination="unit 1" name="splat alpha map"/> 
       <fp plugin="glfixed">
        <fixedfp>
         <layer>
            <colorsource num="0" source="texture" modifier="color"/> 
 	    <colorsource num="1" source="primary color" modifier="color" />
            <coloroperation operation="modulate"/>
          </layer>
          <layer>
            <colorsource num="0" source="previous layer" modifier="color"/>
            <colorsource num="1" source="texture" modifier="color" />
             <coloroperation operation="modulate"/>
          <!--  <alphasource num="0" source="texture" modifier="alpha"/>
            <alphaoperation operation="replace"/> -->
          </layer>        
        </fixedfp>
      </fp>
    </pass> 
  </technique>
</shader>
