Bonjour j'aimerais pouvoir texturé un objet avec plusieurs textures(ambiant, diffuse...). Le soucis est que cela ne fonctionne pas.
Voici le code opengl :
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
 
void Material::activeTextures()
{
	unsigned int i = 0, j = 0;
	//active and bind textures
	for (i = 0; i < textures_ambiant.size(); i++)
	{
		glActiveTexture(GL_TEXTURE0 + i);
		this->textures_ambiant[i]->bind();
		glUniform1i(glGetUniformLocation(programID, ("samplerAmbiantTexture" + std::to_string(i)).c_str()), i);
		j++;
	}
	for (i = 0; i < textures_diffuse.size(); i++)
	{
		glActiveTexture(GL_TEXTURE0 + i + j);
		this->textures_diffuse[i]->bind();
		//std::cout << ("samplerDiffuseTexture" + std::to_string(i)).c_str() << std::endl;
		glUniform1i(glGetUniformLocation(programID, ("samplerDiffuseTexture" + std::to_string(i)).c_str()), i + j);
		j++;
	}
	for (i = 0; i < this->textures_specular.size(); i++)
	{
		glActiveTexture(GL_TEXTURE0 + i + j);
		this->textures_specular[i]->bind();
		glUniform1i(glGetUniformLocation(programID, ("samplerSpecularTexture" + std::to_string(i)).c_str()), i + j);
	}
}
et le render :
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
 
void DefaultMaterial::render(Model *model)
{
 
	//UNIFORMS
	//this->M *= glm::rotate(0.005f, glm::vec3(0, 1, 0));
	this->Normal_Matrix = glm::transpose(glm::inverse(this->M));
	//set the uniform variable MVP
	glUniformMatrix4fv(this->MID, 1, GL_FALSE, &M[0][0]);
	glUniformMatrix4fv(this->NMID, 1, GL_FALSE, &Normal_Matrix[0][0]);
	glUniform1fv(this->compl.ambiantID, 1, &(compl.ambiant));
	glUniform1fv(this->compl.diffuseID, 1, &(compl.diffuse));
	glUniform1fv(this->compl.specularID, 1, &(compl.specular));
 
	//OPTIONS
	//Enable culling triangles which normal is not towards the camera
	glEnable(GL_CULL_FACE);
	// Enable depth test
	glEnable(GL_DEPTH_TEST);
 
	//TEXTURES
	this->activeTextures();
 
	//BUFFERS
	for (int i = 0; i < 4; i++)
	{
		//bind UBO buffer light
		glBindBufferBase(GL_UNIFORM_BUFFER, i, this->scene->getCollector()->getLightUBO(i)->getID());
		//bind UBO lighting with program shader
		glUniformBlockBinding(this->programID, this->block_index_lights[i], i);
	}
 
	//bind UBO buffer camera
	glBindBufferBase(GL_UNIFORM_BUFFER, 4, this->scene->getCamUBO()->getID());
	//bind UBO camera with program shader
	glUniformBlockBinding(this->programID, this->block_index_camera, 4);
 
	//RENDER
	//render model
	model->render();
 
	//RELEASE
	this->releaseTextures();
	//glBindBufferBase(GL_UNIFORM_BUFFER, 0, 0);
 
}
et dans le fragment shader:
j'utilise cette variable: juste une texture "uniform sampler2D samplerDiffuseTexture0;"
Sauf que le résultat est noir, et du coup ne fonctionne pas.

Quelqu'un aurait t il une idée?
Je vous remercie d'avance