Salut tout le monde,
J'essaye en ce moment d'envoyer plusieurs coordonnées de textures à mon shader glsl mais j'y arrive pas.
Mon but étant de rendre un terrain avec plusieurs niveaux de textures. (en passant par les VAs et VBOs)
Voici le code coté application:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);			
 
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0_ARB);
if(mesh->GetMaterial()->GetTexture(0))
{
    glBindTexture(GL_TEXTURE_2D, mesh->GetMaterial()->GetTexture(0)->m_glName);
}
glTexCoordPointer(2, GL_FLOAT, sizeof(mythic::gpm::TERRAIN_VERTEX), &v->u0);			
 
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE1_ARB);
if(mesh->GetMaterial()->GetTexture(1))
    glBindTexture(GL_TEXTURE_2D, mesh->GetMaterial()->GetTexture(1)->m_glName);
glTexCoordPointer(2, GL_FLOAT, sizeof(mythic::gpm::TERRAIN_VERTEX), &v->u1);			
 
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE2_ARB);
if(mesh->GetMaterial()->GetTexture(2))
    glBindTexture(GL_TEXTURE_2D, mesh->GetMaterial()->GetTexture(2)->m_glName);	
glTexCoordPointer(2, GL_FLOAT, sizeof(mythic::gpm::TERRAIN_VERTEX), &v->u2);			
 
glVertexPointer(3, GL_FLOAT, sizeof(mythic::gpm::TERRAIN_VERTEX), &v->x);
glNormalPointer(GL_FLOAT, sizeof(mythic::gpm::TERRAIN_VERTEX), &v->nx);
et voici le vertex shader:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
void main()
{
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_TexCoord[1] = gl_MultiTexCoord1;
	gl_TexCoord[2] = gl_MultiTexCoord2;
 
	gl_Position = ftransform();
 
}
Et voici le fragment shader
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
//=======================================================================================
//
// Uniform samplers, will be used to render the detail layers of the terrain. except
// for the main_diffuse_map, each diffuse map is associated with one alpha map.
//
//=======================================================================================
 
uniform sampler2D main_diffuse_map;
//->
uniform sampler2D diffuse_map_1;
uniform sampler2D alpha_map_1;
//->
uniform sampler2D diffuse_map_2;
uniform sampler2D alpha_map_2;
//->
uniform sampler2D diffuse_map_3;
uniform sampler2D alpha_map_3;
//->
uniform sampler2D diffuse_map_4;
uniform sampler2D alpha_map_4;
//->
uniform sampler2D diffuse_map_5;
uniform sampler2D alpha_map_5;
//->
uniform sampler2D diffuse_map_6;
uniform sampler2D alpha_map_6;
 
//=======================================================================================
//
// Texture units support.
//
//=======================================================================================
 
uniform int texUnitSup;
 
void main()
{
	if(texUnitSup > 16)//The splatting will be done with all the splatting layers in one pass.
	{
		vec4 mainDiffMap = texture2D(main_diffuse_map, gl_TexCoord[0].st);
 
		vec4 diffMap1 = texture2D(diffuse_map_1, gl_TexCoord[1].st);
		vec4 alphaMap1 = texture2D(alpha_map_1, gl_TexCoord[2].st);
 
		vec4 diffMap2 = texture2D(diffuse_map_1, gl_TexCoord[1]);
		vec4 alphaMap2 = texture2D(alpha_map_1, gl_TexCoord[2]);
 
		vec4 diffMap3 = texture2D(diffuse_map_1, gl_TexCoord[1]);
		vec4 alphaMap3 = texture2D(alpha_map_1, gl_TexCoord[2]);
 
		vec4 diffMap4 = texture2D(diffuse_map_1, gl_TexCoord[1]);
		vec4 alphaMap4 = texture2D(alpha_map_1, gl_TexCoord[2]);
 
		vec4 diffMap5 = texture2D(diffuse_map_1, gl_TexCoord[1]);
		vec4 alphaMap5 = texture2D(alpha_map_1, gl_TexCoord[2]);
 
		vec4 diffMap6 = texture2D(diffuse_map_1, gl_TexCoord[1]);
		vec4 alphaMa6 = texture2D(alpha_map_1, gl_TexCoord[2]);
 
		gl_FragColor = mainDiffMap + (diffMap1 * alphaMap1) /*+ (diffMap2 * alphaMap2)
			                       + (diffMap3 * alphaMap3) + (diffMap4 * alphaMap4)
								   + (diffMap5 * alphaMap5) + (diffMap6 * alphaMap6)*/;
	}
	else if(texUnitSup > 8)//The splatting will be done with 5/6 splatting layers in one pass.
	{
	}
	else
	{
		//The engine is not designed fot this kind of hardware !!!
	}	
}
Ce que j'ai comme résultat avec ce code c'est que, seules les dernières coordonnées passées a glTexCoordPointer sont prisent en compte, aussi, coté shader, les coordonnées 1 et 2 (gl_MultiTexCoord1/2) ne sont pas initialisées (opengl n'a pas envoyé ces coordonnées là)
Voila, merci.