<?xml version="1.0" encoding="utf-8" ?> 
<shader compiler="xmlshader" name="std_character_fixed2">
    <technique priority="200">
      <pass>
	  <!-- only vproc is different than std_lighting_fixed -->
          <vproc plugin="vproc_std">
          <vproc_std>
            <skinned_position buffer="generic 0" />
          </vproc_std>
          </vproc>
          <buffer source="generic 0" destination="position" />
	  <!-- end vproc -->
	<?if vars."tex diffuse".texture ?>
	  <texture name="tex diffuse" destination="diffuse" />
	  <buffer source="texture coordinate 0" destination="texture coordinate diffuse" />
	<?else?>
	  <!-- need to bind at least some texture -->
	  <texture name="standardtex white" destination="diffuse" />
	<?endif?>
	<?if vars."tex lightmap".texture ?>
	  <buffer source="texture coordinate lightmap" destination="texture coordinate lightmap" />
	  <texture name="tex lightmap" destination="lightmap" />
	<?else?>
	  <buffer source="color" destination="color" />
	<?endif?>
	<?Include /shader/snippets/fog-mappings.inc ?>
	<vp plugin="glfixed">
	  <fixedvp>
	    <?if !vars."tex diffuse".texture ?>
	      <constantcolor layer="diffuse" type="shadervar">mat flatcolor</constantcolor>
	    <?endif?>
	    <?if vars."tex lightmap".texture ?>
	      <constantcolor layer="lightmap" type="shadervar">dynamic ambient</constantcolor>
	    <?endif?>
	    <?Include /shader/snippets/fog-fvp.inc ?>
	  </fixedvp>
	</vp>
	<fp plugin="glfixed">
	  <fixedfp>
	    <?if vars."tex lightmap".texture ?>
	      <layer name="lightmap">
		<colorsource num="0" source="texture" modifier="color"/>
		<colorsource num="1" source="constant color" modifier="color"/>
		<coloroperation operation="add" />
		<alphasource num="0" source="texture" modifier="alpha"/>
		<alphaoperation operation="replace" />
	      </layer>
	    <?endif?>
	    <layer name="diffuse">
	      <?if vars."tex diffuse".texture ?>
		<colorsource num="0" source="texture" modifier="color"/>
		<alphasource num="0" source="texture" modifier="alpha"/>
	      <?else?>
		<colorsource num="0" source="constant color" modifier="color"/>
		<alphasource num="0" source="constant color" modifier="alpha"/>
	      <?endif?>
	      <?if !vars."tex lightmap".texture ?>
		<colorsource num="1" source="primary color" modifier="color"/>
		<coloroperation operation="modulate" />
	      <?else?>
		<colorsource num="1" source="previous layer" modifier="color"/>
		<coloroperation operation="modulate" scale="2" />
	      <?endif?>
	      <alphasource num="1" source="primary color" modifier="alpha"/>
	      <alphaoperation operation="modulate" />
	    </layer>
	    <?Include /shader/snippets/fog-ffp.inc ?>
	  </fixedfp>
	</fp>
      </pass>
    </technique>

    <!-- @@@ FIXME This technique does not seem to work
	 (fp failed to load?) -->
    <technique priority="75">
      <pass>
          <vproc plugin="vproc_std">
          <vproc_std>
            <skinned_position buffer="generic 0" />
          </vproc_std>
          </vproc>

        <buffer source="generic 0" destination="position" />
	<texture name="tex diffuse" destination="unit 0" />
	<buffer source="color" destination="color" />
	<buffer source="texture coordinate 0" destination="texture coordinate" />
	<vp plugin="software" />
	<fp plugin="software">
	  <softfp>
	    <flatcolor type="shadervar">mat flatcolor</flatcolor>
	    <?if vars."tex lightmap".texture ?>
	      <colorfactor type="float">2</colorfactor>
	    <?endif?>
	  </softfp>
	</fp>
      </pass>
    </technique>
    
    <!-- @@@ FIXME This technique is two passes so better wait until
	 vproc sharing is settled -->
    <technique priority="50">
      <pass>     
        <?if !vars."tex diffuse".texture ?>
          <texture name="standardtex white" destination="unit 0" />
        <?else?>
          <texture name="tex diffuse" destination="unit 0" />
	  <buffer source="texture coordinate 0" destination="texture coordinate 0" />
        <?endif?>
      </pass>
      <!-- @@@ FIXME Flat materials -->
      <!-- @@@ FIXME Dynamic ambient -->
      <?if vars."tex lightmap".texture ?>
        <pass>
	  <mixmode><multiply2 /></mixmode><!-- @@@ probably not always desired -->
	  <zmode><zmesh2 /></zmode>
	  <buffer source="texture coordinate lightmap" destination="texture coordinate 0" />
	  <texture name="tex lightmap" destination="unit 0" />
        </pass>
      <?endif?>
      <?Include /shader/snippets/fog-pass.inc ?>
    </technique>
    <fallbackshader name="std_lighting_fixed" file="/shader/std_lighting_fixed.xml" />
</shader>
