Пример #1
0
	ShaderPtr Shader::createSimpleLambertShader()
	{
		ShaderPtr shader = Shader::load(base::Path( BASE_PATH ) + "/gfx/glsl/simpleLambert");
		shader->setUniform( "l", math::Vec3f( 1.0f, 1.0f, 1.0f ).normalized() );
		shader->setUniform( "diffuse", math::Vec3f(0.5f, 0.5f, 0.5f));
		shader->setUniform( "kd", 1.0f );
		shader->setUniform( "ambient", math::Vec3f(0.05f, 0.05f, 0.05f));
		shader->setUniform( "ka", 1.0f );
		shader->setUniform( "l", math::Vec3f(1.0f, 1.0f, 1.0f).normalized() );
		return shader;
	}
Пример #2
0
void DemoSceneManager::drawModel2(const std::string &name, GLenum mode)
{
    Model::GroupMap &groups = getModel(name)->getGroups();
    for (auto i = groups.begin(); i != groups.end(); ++i)
    {
        Geometry &geometry = i->second;
        MaterialPtr material = geometry.getMaterial();
        ShaderPtr shader = material->getShader();
        if (shader.get())
        {
            vmml::frustum<float> _projectionMatrix(-1.0f,1.0f,-1.0f,1.0f,0.2f,100.0f);
            //            vmml::frustum<float> _projectionMatrix(vmml::frustum<float>::DEFAULT);
            _projectionMatrix.set_perspective(0.0f, _projectionMatrix.get_width()/_projectionMatrix.get_height(), _projectionMatrix.near_plane(), _projectionMatrix.far_plane());
            std::cout << _projectionMatrix.compute_matrix();
            //            shader->setUniform("ProjectionMatrix", vmml::mat4f::IDENTITY);
            shader->setUniform("ProjectionMatrix", _projectionMatrix.compute_matrix());
            
            shader->setUniform("ViewMatrix", _viewMatrix);
            shader->setUniform("ModelMatrix", _modelMatrix);
            
            vmml::mat3f normalMatrix;
            vmml::compute_inverse(vmml::transpose(vmml::mat3f(_modelMatrix)), normalMatrix);
            shader->setUniform("NormalMatrix", normalMatrix);
            
            shader->setUniform("EyePos", _eyePos);
            
            shader->setUniform("LightPos", vmml::vec4f(0.0f, 1.f, .5f, 1.f));
            shader->setUniform("Ia", vmml::vec3f(1.f));
            shader->setUniform("Id", vmml::vec3f(1.f));
            shader->setUniform("Is", vmml::vec3f(1.f));
        }
        else
        {
            util::log("No shader available.", util::LM_WARNING);
        }
        geometry.draw(mode);
    }
}
Пример #3
0
	ShaderPtr Shader::createSimpleConstantShader( float r, float g, float b )
	{
		ShaderPtr shader = Shader::create().attachPS(base::Path( BASE_PATH ) + "/gfx/glsl/constant.ps.glsl").attachVS(base::Path( BASE_PATH ) + "/gfx/glsl/constant.vs.glsl");
		shader->setUniform( "color", math::Vec3f(r, g, b) );
		return shader;
	}