Ejemplo n.º 1
0
void ShaderNormalMapping::update(CVK::Node* node)
{
	if( node->hasMaterial())
	{
		CVK::Material* mat = node->getMaterial();

		glUniform3fv( m_diffuseID, 1, glm::value_ptr( *mat->getDiffuse()));
		glUniform3fv( m_specularID, 1, glm::value_ptr( *mat->getSpecular()));
		glUniform1f( m_shininessID, mat->getShininess());

		bool colorTexture = mat->hasTexture(CVK::COLOR_TEXTURE);
		glUniform1i( m_useColorTexture, colorTexture);
		
		if (colorTexture)
		{	
			//TODO: COLOR_TEXTURE_UNIT
			glUniform1i( m_colorTexID, 0);

			glActiveTexture(COLOR_TEXTURE_UNIT);
			CVK::Texture* colorTexture = mat->getTexture(CVK::COLOR_TEXTURE);
			colorTexture->bind();
		}

		if (mat->hasTexture(CVK::NORMAL_TEXTURE))
		{	
			//TODO: COLOR_TEXTURE_UNIT
			glUniform1i(m_normalTexID, 1);

			glActiveTexture(NORMAL_TEXTURE_UNIT);
			CVK::Texture* normalTexture = mat->getTexture(CVK::NORMAL_TEXTURE);
			normalTexture->bind();
		}
	}
}
void CVK::ShaderPhong::update( CVK::Node* node)
{

	if( node->hasMaterial())
	{
		CVK::Material* mat = node->getMaterial();
		CVK::Texture *color_texture;

		glUniform3fv( m_diffuseID, 1, glm::value_ptr( *mat->getDiffuse()));
		glUniform3fv( m_specularID, 1, glm::value_ptr( *mat->getSpecular()));
		glUniform1f( m_shininessID, mat->getShininess());
		glUniform1f( m_alphaID, mat->getAlpha());

		bool colorTexture = mat->hasTexture(COLOR_TEXTURE);
		glUniform1i( m_useColorTexture, colorTexture);

		if (colorTexture)
		{	
			//TODO: COLOR_TEXTURE_UNIT
			glUniform1i( m_colorTextureID, 0);

			glActiveTexture(COLOR_TEXTURE_UNIT);
			color_texture = mat->getTexture(COLOR_TEXTURE);
			color_texture->bind();
		}
	}
}