<shader name="light_scattering" compiler="xmlshader">
  <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">1.6643e-08, 2.8144e-08, 5.8360e-08</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-07, 1.7345e-07, 2.4976e-07</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="vector3">8.5292e-07, 1.2115e-06, 2.0293e-06</shadervar>
    <!-- g = .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.4, 0.4, 0.4</shadervar>
  </shadervars>
  <technique priority="200">
    <pass>
      <mixmode><add/></mixmode>
      <streammapping stream="vertices" destination="attribute 0" />
      <streammapping stream="normals" destination="attribute 2" />
      <streammapping stream="texture coordinates" destination="attribute 3" />
      <streammapping stream="tangents" destination="attribute 4" />
      <streammapping stream="binormals" destination="attribute 5" />
      <vp type="gl_arb_vp" file="/shader/bump_ppl_scatter.avp" />
      <texturemapping unit="0" name="standardtex normalization map" />
      <texturemapping unit="1" name="tex normal" />
      <texturemapping unit="2" name="tex diffuse"/>
      <texturemapping unit="3" name="tex diffuse"/>
      <fp type="gl_fixed_fp">
        <fixedfp>
          <layer> 
            <colorsource num="0" source="texture" modifier="color"/>
            <coloroperation operation="replace"/>
          </layer>
          <layer>
            <colorsource num="0" source="previous layer" modifier="color"/>
            <colorsource num="1" source="texture" modifier="color"/>
            <coloroperation operation="dot3"/>
          </layer>
          <layer>
            <colorsource num="0" source="previous layer" modifier="color"/>
            <colorsource num="1" source="texture" modifier="color"/> 
            <coloroperation operation="modulate"/>
          </layer>
          <layer>
            <colorsource num="0" source="previous layer" modifier="color"/>
	    <colorsource num="1" source="primary color" modifier="color"/>
            <coloroperation operation="modulate"/>
          </layer>
        </fixedfp>
      </fp>
    </pass>
    <pass>
      <mixmode><add/></mixmode>
      <streammapping stream="vertices" destination="attribute 0" />
      <vp type="gl_arb_vp" file="/shader/scattering.avp" />
      <texturemapping unit="1" name="tex normal" />
      <fp type="gl_fixed_fp">
        <fixedfp>
          <layer> 
            <colorsource num="0" source="primary color" modifier="color"/>
            <coloroperation operation="replace"/>
          </layer>
	</fixedfp>
      </fp>
    </pass>
  </technique>

  <technique priority="100">
    <pass>
      <mixmode><copy/></mixmode>
      <writemask r="false" g="false" b="false" a="true"/>
      <streammapping stream="vertices" destination="attribute 0" />
      <streammapping stream="normals" destination="attribute 2" />
      <streammapping stream="texture coordinates" destination="attribute 3" />
      <streammapping stream="tangents" destination="attribute 4" />
      <streammapping stream="binormals" destination="attribute 5" />
      <vp type="gl_arb_vp" file="/shader/bump_ppl_diffuse_a.avp" />
      <texturemapping unit="0" name="standardtex normalization map" />
      <texturemapping unit="1" name="tex normal" />
      <fp type="gl_fixed_fp">
        <fixedfp>
          <layer> 
            <colorsource num="0" source="texture" modifier="color"/>
            <coloroperation operation="replace"/>
          </layer>
          <layer>
            <colorsource num="0" source="previous layer" modifier="color"/>
            <colorsource num="1" source="texture" modifier="color"/>
            <coloroperation operation="dot3 alpha"/>
          </layer>
        </fixedfp>
      </fp>
    </pass>
    <pass>
      <mixmode><destalphaadd/></mixmode>
      <streammapping stream="vertices" destination="attribute 0" />
      <streammapping stream="normals" destination="attribute 2" />
      <streammapping stream="texture coordinates" destination="attribute 3" />
      <streammapping stream="tangents" destination="attribute 4" />
      <streammapping stream="binormals" destination="attribute 5" />
      <vp type="gl_arb_vp" file="/shader/bump_ppl_scatter_b.avp" />
      <texturemapping unit="0" name="tex diffuse"/>
      <fp type="gl_fixed_fp">
        <fixedfp>
          <layer>
            <colorsource num="0" source="texture" modifier="color"/> 
	    <colorsource num="1" source="primary color" modifier="color"/>
            <coloroperation operation="modulate"/>
          </layer>
        </fixedfp>
      </fp>
    </pass>
    <pass>
      <mixmode><add/></mixmode>
      <streammapping stream="vertices" destination="attribute 0" />
      <vp type="gl_arb_vp" file="/shader/scattering.avp" />
      <texturemapping unit="1" name="tex normal" />
      <fp type="gl_fixed_fp">
        <fixedfp>
          <layer> 
            <colorsource num="0" source="primary color" modifier="color"/>
            <coloroperation operation="replace"/>
          </layer>
	</fixedfp>
      </fp>
    </pass>
  </technique>

  <technique priority="50">
    <pass>
      <mixmode><copy/></mixmode>
      <buffer name="vertices" destination="position" />
      <buffer name="normals" destination="normal" />
      <buffer name="texture coordinates" destination="texture coordinate" />
      <vp plugin="glfixed" file="/shader/vertexlight.fvp"/>
      <texture destination="unit 0" name="tex diffuse" />
      <fp plugin="glfixed">
        <fixedfp>
          <layer>
            <colorsource num="0" source="primary color" modifier="color"/>
            <colorsource num="1" source="texture" modifier="color"/>
            <coloroperation operation="modulate"/>
          </layer>
        </fixedfp>
      </fp>
    </pass>
  </technique>

  <technique priority="0">
    <pass>
      <mixmode><copy/></mixmode>
      <buffer name="vertices" destination="position" />
      <buffer name="normals" destination="normal" />
      <buffer name="texture coordinates" destination="texture coordinate" />
      <buffer name="colors" destination="color" />
      <vp plugin="software" />
      <fp plugin="software" />
    </pass>
  </technique>

</shader>
