<shader compiler="xmlshader" name="reflectsphere">
  <technique priority="150">
    <pass>
      <!--<mixmode><copy/></mixmode>-->
      <buffer source="texture coordinate lightmap" destination="texture coordinate 1" />
      <buffer source="normal" destination="normal"/>
      <vp plugin="glfixed">
        <fixedvp>  
          <constantcolor layer="2" type="shadervar">reflection opacity</constantcolor>
          <texgen layer="2" type="reflection" mapping="sphere" />
        </fixedvp>
      </vp>
      <texture name="tex diffuse" destination="unit 0" />
      <texture name="tex lightmap" destination="unit 1" />
      <texture name="tex reflection" destination="unit 2" />
      <fp plugin="glfixed">
        <fixedfp>
	  <layer>
	      <colorsource num="0" source="texture" modifier="color"/>
	      <coloroperation operation="modulate" />
	      <alphasource num="0" source="texture" modifier="alpha"/>
	      <alphaoperation operation="replace" />
	  </layer>
	  <layer>
	      <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>
	  <layer>
	      <colorsource num="0" source="previous layer" modifier="color"/>
	      <colorsource num="1" source="texture" modifier="color"/>
	      <colorsource num="2" source="constant color" modifier="one minus alpha"/>
	      <coloroperation operation="interpolate" />
	      <alphasource num="0" source="previous layer" modifier="alpha"/>
	      <alphaoperation operation="replace"/>
	  </layer>
        </fixedfp>
      </fp>
    </pass>
  </technique>
  <technique priority="100">
    <pass>
      <!--<mixmode><copy/></mixmode>-->
      <buffer source="texture coordinate lightmap" destination="texture coordinate 1" />
      <vp plugin="glfixed">
        <fixedvp>  
          <constantcolor layer="0" type="shadervar">reflection opacity</constantcolor>
          <!--<ambient/>-->
        </fixedvp>
      </vp>
      <texture name="tex diffuse" destination="unit 0" />
      <texture name="tex lightmap" destination="unit 1" />
      <fp plugin="glfixed">
        <fixedfp>
	  <layer>
	      <colorsource num="0" source="constant color" modifier="one minus color"/>
	      <colorsource num="1" source="texture" modifier="color"/>
	      <coloroperation operation="modulate" />
	      <alphasource num="0" source="texture" modifier="alpha"/>
	      <alphaoperation operation="replace" />
	  </layer>
	  <layer>
	      <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>
        </fixedfp>
      </fp>
    </pass>
    <pass>
      <mixmode><srcalphaadd /></mixmode>
      <buffer source="normal" destination="normal"/>
      <vp plugin="glfixed">
        <fixedvp>  
          <texgen layer="0" type="reflection" mapping="sphere" />
          <constantcolor layer="0" type="shadervar">reflection opacity</constantcolor>
        </fixedvp>
      </vp>
      <texture name="tex reflection" destination="unit 0" />
      <fp plugin="glfixed">
        <fixedfp>
          <layer>
            <colorsource num="0" source="texture" modifier="color"/>
	    <colorsource num="0" source="constant color" modifier="color"/>
	    <coloroperation operation="modulate" />
          </layer>
        </fixedfp>
      </fp>
    </pass>
  </technique>
  <technique priority="75">
      <pass>
	<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" />
      </pass>
  </technique>
</shader>
