<?xml version="1.0" encoding="utf-8" ?> 
<shader compiler="xmlshader" name="std_lighting_nofog">

<!--
<technique priority="150">
  <pass>
      <buffer name="vertices" destination="position" />
      <buffer name="colors" destination="primary color" />
      <buffer name="texture coordinates" destination="texture coordinate 0" />
      <texture name="tex diffuse" destination="unit 0" />
  </pass>
</technique>-->

    <technique priority="200">
      <pass>
	<?if vars."tex diffuse".texture ?>
	  <texture name="tex diffuse" destination="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" />
	<?endif?>
	<vp plugin="glfixed">
	  <fixedvp>
	    <?if !vars."tex diffuse".texture ?>
	      <constantcolor layer="diffuse" type="shadervar">mat flatcolor</constantcolor>
	    <?endif?>
	  </fixedvp>
	</vp>
	<fp plugin="glfixed">
	  <fixedfp>
	    <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?>
		<coloroperation operation="replace" />
	      <?endif?>
	      <alphasource num="1" source="primary color" modifier="alpha"/>
	      <alphaoperation operation="modulate" />
	    </layer>
	    <?if vars."tex lightmap".texture ?>
	      <layer name="lightmap">
		<colorsource num="0" source="previous layer" modifier="color"/>
		<colorsource num="1" source="texture" modifier="color"/>
		<coloroperation operation="modulate" scale="2" />
		<alphasource num="0" source="previous layer" modifier="alpha"/>
		<alphaoperation operation="replace" />
	      </layer>
	    <?endif?>
	  </fixedfp>
	</fp>
      </pass>
    </technique>

    <technique priority="75">
      <pass>
	<buffer source="normal" destination="normal" />
	<texture name="tex diffuse" destination="unit 0" />
	<vp plugin="software" />
	<fp plugin="software" />
      </pass>
    </technique>
    <technique priority="50">
      <pass>     
        <?if !vars."tex diffuse".texture ?>
          <texture name="standardtex white" destination="unit 0" />
        <?else?>
          <texture name="tex diffuse" destination="unit 0" />
        <?endif?>
      </pass>
      <!-- @@@ Flat materials -->
      <?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?>
    </technique>
</shader>

