<shader compiler="xmlshader" name="splatting_bump">
  <technique priority="200">
    <pass>
      <mixmode><srcalphaadd/></mixmode>
      <buffer source="normal" destination="normal" />
      <buffer source="tangent" destination="texture coordinate 1" />
      <buffer source="binormal" destination="texture coordinate 2" />
      <vp plugin="glarb" file="/shader/splatting_bump.avp" />
      <texture destination="unit 0" name="standardtex normalization map" />
      <texture destination="unit 1" name="tex normal" />
      <texture destination="unit 2" name="tex diffuse"/>
      <texture destination="unit 3" name="splat alpha map"/>
      <fp plugin="glfixed">
        <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"/>
            <alphasource num="0" source="texture" modifier="alpha"/>
	    <alphaoperation operation="replace"/>
          </layer>
        </fixedfp>
      </fp>
    </pass>
  </technique>

  <technique priority="100">
    <pass>
      <mixmode><copy/></mixmode>
      <writemask r="false" g="false" b="false" a="true"/>
      <buffer source="normal" destination="normal" />
      <buffer source="tangent" destination="texture coordinate 1" />
      <buffer source="binormal" destination="texture coordinate 2" />
      <vp plugin="glarb" file="/shader/splatting_bump_a.avp" />
      <texture destination="unit 0" name="standardtex normalization map" />
      <texture destination="unit 1" name="tex normal" />
      <fp plugin="glfixed">
        <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>
      <buffer source="normal" destination="normal" />
      <buffer source="tangent" destination="texture coordinate 1" />
      <buffer source="binormal" destination="texture coordinate 2" />
      <vp plugin="glarb" file="/shader/splatting_bump_b.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="primary color" 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="texture" modifier="color"/>
            <coloroperation operation="modulate"/>
          </layer>
        </fixedfp>
      </fp>
    </pass>
  </technique>

  <!-- this technique drops the bumpmapping and lighting, for compatibility -->
  <!-- with 2 texture unit hardware -->
  <technique priority="10">
    <pass>
      <mixmode><srcalphaadd/></mixmode>
      <buffer source="normal" destination="normal" />
      <buffer source="tangent" destination="texture coordinate 1" />
      <buffer source="binormal" destination="texture coordinate 2" />
      <vp plugin="glarb" file="/shader/splatting_nobump.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"/>
            <coloroperation operation="replace"/>
          </layer>
          <layer>
            <colorsource num="0" source="previous layer" modifier="color"/>
	    <colorsource num="1" source="primary color" modifier="color"/>
            <coloroperation operation="modulate"/>
            <alphasource num="0" source="texture" modifier="alpha"/>
	    <alphaoperation operation="replace"/>
          </layer>
        </fixedfp>
      </fp>
    </pass>
  </technique>

</shader>
