void ShaderBumpMap::Use(CL_GraphicContext &gc)
{
	if (!material_updated)
	{
		material_updated = true;
		program_object.set_uniform1f("MaterialShininess", material_shininess);
		program_object.set_uniform4f("MaterialEmission", material_emission);
		program_object.set_uniform4f("MaterialSpecular", material_specular);
		program_object.set_uniform4f("MaterialAmbient", material_ambient);
	}

	if (!light_updated)
	{
		light_updated = true;
		program_object.set_uniform4f("LightVector", light_vector);
		CL_Vec4f light_halfvector(0.0f, 0.0f, 1.0f, 0.0f);
		light_halfvector += light_vector;
		light_halfvector.normalize3();
		program_object.set_uniform4f("LightHalfVector", light_halfvector);
		program_object.set_uniform4f("LightSpecular", light_specular);
		program_object.set_uniform4f("LightDiffuse", light_diffuse);
		program_object.set_uniform4f("LightAmbient", light_ambient);
	}

	gc.set_program_object(program_object);
}
Beispiel #2
0
void ShaderColor::Use(CL_GraphicContext &gc)
{
	if (!material_updated)
	{
		material_updated = true;
		program_object.set_uniform1f("MaterialShininess", material_shininess);
		program_object.set_uniform4f("MaterialEmission", material_emission);
		program_object.set_uniform4f("MaterialSpecular", material_specular);
		program_object.set_uniform4f("MaterialAmbient", material_ambient);
	}

	if (!light_updated)
	{
		light_updated = true;
		program_object.set_uniform3f("LightVector", light_vector);
		CL_Vec3f light_halfvector(0.0f, 0.0f, 1.0f);
		light_halfvector += light_vector;
		light_halfvector.normalize();
		program_object.set_uniform3f("LightHalfVector", light_halfvector);
		program_object.set_uniform4f("LightSpecular", light_specular);
		program_object.set_uniform4f("LightDiffuse", light_diffuse);
	}

	if (!spot_light_updated)
	{
		spot_light_updated = true;
		program_object.set_uniform3f("SpotLight_Position", spot_light_position);
		program_object.set_uniform3f("SpotLight_Direction", spot_light_direction);
		program_object.set_uniform4f("SpotLight_Specular", spot_light_specular);
		program_object.set_uniform4f("SpotLight_Diffuse", spot_light_diffuse);

		float cos_cutoff = cos(spot_light_cutoff * CL_PI / 180.0f);

		program_object.set_uniform1f("SpotLight_SpotCosCutoff", cos_cutoff);
		program_object.set_uniform1f("SpotLight_SpotExponent", spot_light_exponent);
	}

	gc.set_program_object(program_object);
}
Beispiel #3
0
void Shader::Set(CL_GraphicContext &gc, int textureID)
{
		if(textureID != -1)
        {
        	program_object.set_uniform1i("HasTexture", 1);
			program_object.set_uniform1i("Texture", textureID);
		}
        else
		{
        	program_object.set_uniform1i("HasTexture", 0);
		}

		program_object.set_uniform1f("MaterialShininess", material_shininess);
		program_object.set_uniform4f("MaterialEmission", material_emission);
		program_object.set_uniform4f("MaterialSpecular", material_specular);
		program_object.set_uniform3f("LightPosition", light_position);
		CL_Vec3f light_halfvector(0.0f, 0.0f, 1.0f);
		light_halfvector += light_position;
		light_halfvector.normalize();
		program_object.set_uniform3f("LightHalfVector", light_halfvector);
		program_object.set_uniform4f("LightSpecular", light_specular);
		program_object.set_uniform4f("LightDiffuse", light_diffuse);
}