// black_skirt_tetra

:int foundShader 0

:if ($GLSL) {
	:set foundShader 1
	:CERR "GLSL WAS SENSED"
	:GLSLshader

	:vshader "varying vec4 color;"
	:vshader "varying vec2 texture_coordinate;"
	:vshader "varying vec2 texture_coordinateB;"
	:vshader "void main() {"
	:vshader "  texture_coordinate = vec2(gl_MultiTexCoord0);"
	:vshader "  texture_coordinateB = vec2(gl_MultiTexCoord1);"
	:vshader "  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
	:vshader "  color = vec4(gl_Color.r,gl_Color.g,gl_Color.b,1);"
	:vshader "}"
  
	:fshader "varying vec4 color;"
	:fshader "varying vec2 texture_coordinate;"
	:fshader "varying vec2 texture_coordinateB;"
	:fshader "uniform sampler2D tex1,tex2,tex3;"
	:fshader "void main() {"
	:fshader "  gl_FragColor = color*texture2D(tex1, texture_coordinate) + texture2D(tex2, texture_coordinateB)*texture2D(tex3, texture_coordinate);"
	:fshader "}"

	:set diffuseMultiply .7
	:addStage {
		:chans 4
		:tex body.sgi
		:combine MODULATE
		:uvIndex 0
		:useAlpha
	}
	:addStage {
		:chans 3
		:tex global/arrays/enviro3.sgi
		:combine ADD
		:uvIndex 1
	}
	:addStage {
		:chans 4
		:tex {
			:buffer -name spec -chans 4 -file spec.sgi
			:mult spec 1 1 1 0
		}
		:combine ADD
		:uvIndex 1
		:useAlpha
	}
	:normalsToTexture 1
	:reflectionTexScale 1.5

	:dontUpdate uv
}
:else {
	:if ($canDoMultAdd) {
		:if ($maxTexUnits >= 3) {
			:set foundShader 1	
			:reflectionTexScale 1.5
			:addStage {
				:chans 3
				:tex global/arrays/enviro3.sgi
				:arg2 TEXTURE
				:combine SELECTARG2
				:uvIndex 1
			}
			:addStage {
				:chans 3
				:tex spec.sgi
				:arg1 CURRENT
				:arg2 TEXTURE
				:combine MODULATE
				:uvIndex 0
			}
			:addStage {
				:chans 4
				:tex body.sgi
				:arg1 DIFFUSE
				:arg2 TEXTURE
				:combine MULTIPLYADD
				:uvIndex 0
				:useAlpha
			}
			
			:normalsToTexture 1
			:set diffuseMultiply .7
		}
		:elseif ($maxTexUnits >= 2) {
			:set foundShader 1	
			:addStage {
				:chans 4
				:tex body.sgi
				:arg1 DIFFUSE
				:arg2 TEXTURE
				:combine MODULATE
				:uvIndex 0
				:useAlpha
			}
			:addStage {
				:chans 3
				:tex spec.sgi
				:arg1 SPECULAR
				:arg2 TEXTURE
				:combine MULTIPLYADD
				:uvIndex 0
			}
			:set diffuseMultiply .7
			:specularColorReflection global/arrays/enviroFloat.image
		}
	}
}

:if ($foundShader == 0) {
	:addStage {
		:chans 4
		:tex {
			:buffer -name body -chans 4 -file body.sgi
			:buffer -name spec -file spec.sgi
			:mult body .5 .5 .5 1
			:add body spec .5 .5 .5 0
		}
		:arg1 DIFFUSE
		:arg2 TEXTURE
		:combine MODULATE2X
		:uvIndex 0
		:useAlpha
	}
	:set diffuseMultiply .6
}

:dontUpdate uv

:lighting 0

:doAlphaMultWhenOpaque 0
:doAlphaMultWhenTransparent 1
