Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

shaderEnvMap.frag 793 Bytes
Newer Older
1
2
//ShaderEnvMap::fragmentShaderText

kvanhoey's avatar
kvanhoey committed
3
PRECISION;
Sylvain Thery's avatar
Sylvain Thery committed
4
VARYING_FRAG vec3 EyeVector, Normal, LightDir;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifdef WITH_COLOR
VARYING_FRAG vec3 Color;
#endif
uniform vec4 materialDiffuse;
uniform vec4 materialAmbient;
uniform samplerCube EnvMap;
uniform float blendCoef;

FRAG_OUT_DEF;
void main()
{
	vec3 N = normalize (Normal);
	vec3 L = normalize (LightDir);
	float lambertTerm = dot(N,L);

	vec4 finalColor = materialAmbient;
	
	#ifdef DOUBLE_SIDED
	if (lambertTerm < 0.0)
	{
		N = -1.0*N;
		lambertTerm = -1.0*lambertTerm;
	#else
	if (lambertTerm > 0.0)
	{
	#endif
		#ifndef WITH_COLOR
		vec4 col = materialDiffuse;
		#else
		vec4 col = vec4(Color,0.0) ;
		#endif
		
		vec3 R  = reflect(-EyeVector,N);
Sylvain Thery's avatar
Sylvain Thery committed
38
		finalColor += mix(col,textureCube(EnvMap,R),blendCoef) * lambertTerm;
39
	}	
40
	FRAG_OUT=finalColor;
41
}