/*======================================================================================

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkOpenGLVolumeRayCastEntityShaders.h
	Version:		$Revision: 2901 $
	Date:			$Date: 2012-04-03 11:42:33 +0200 (Di, 03 Apr 2012) $

	Copyright (c) 2010-2011
	Pattern Recognition Lab, 
    University Erlangen-Nuremberg, Germany
    All rights reserved.

	This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
	See RITKCopyright.txt for more information.

	http://www5.informatik.uni-erlangen.de/research/software/ritk

========================================================================================*/


#ifndef SHADERS_H__
#define SHADERS_H___


static const char *OpenGLVolumeRayCasetEntity_FragmentShader = "					\
	uniform sampler2D m_MainTexture;												\
	uniform sampler1D m_LUTTexture;													\
																					\
	void main()																		\
	{																				\
		vec4 PrimaryColor = texture2D(m_MainTexture, gl_TexCoord[0].st);			\
		if ( abs(PrimaryColor.r) < 7e-2 && 0 )										\
		{																			\
			discard;																\
		}						 													\
		else																		\
		{																			\
			float r = clamp(PrimaryColor.r,0.,1.);									\
			gl_FragColor = texture1D(m_LUTTexture, r);								\
			/*gl_FragColor = PrimaryColor;*/										\
			gl_FragColor.a = PrimaryColor.r;										\
		}																			\
	}																				\
";


static const char *OpenGLVolumeRayCasetEntity_VertexShader = "						\
	void main()																		\
	{																				\
		gl_TexCoord[0] = gl_MultiTexCoord0;											\
		gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;						\
	}																				\
";






#if 0

const char *OpenGLVolumeRayCasetEntity_FragmentShader = "																													\
	uniform sampler2D m_MainTexture;																																		\
	uniform int m_DiscardInvalidFragments;																																	\
	varying float ValidFlag;																																				\
																																											\
	void main()																																								\
	{																																										\
		if ( m_DiscardInvalidFragments && abs(ValidFlag-1) > 1e-6 )																											\
		{																																									\
			vec4 c;																																							\
			c.a = 0.2f;																																						\
			c.r = 128.f;																																					\
			gl_FragColor = c;																																				\
			discard;																																						\
		}						 																																			\
		else																																								\
		{																																									\
			vec4 PrimaryColor = texture2D(m_MainTexture, gl_TexCoord[0].st);																								\
			gl_FragColor = PrimaryColor;																																	\
		}																																									\
	}																																										\
";


const char *OpenGLVolumeRayCasetEntity_VertexShader = "									\
	uniform sampler2D m_FlagTexture;													\
																						\
	varying float ValidFlag;															\
																						\
	void main()																			\
	{																					\
		gl_TexCoord[0] = gl_MultiTexCoord0;												\
		gl_TexCoord[1] = gl_MultiTexCoord1;												\
		gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;							\
																						\
		unsigned char Flag = 255*texture2D(m_FlagTexture, gl_TexCoord[0].st).r;			\
		ValidFlag = Flag&0x00000001;													\
																						\
	}																					\
";

#endif

#endif // SHADERS_H___