void DeferredContainer::makeTarget() {
    if(Window::getInstance()->getSize() == gBuffer.getSize()) return;
    vec2ui size = Window::getInstance()->getSize();
    GBDepth = Texture2D(size, TextureFormat::DEPTH_COMPONENT32F);
    GBDepth.setFilter(GL_NEAREST, GL_NEAREST);
    GBColor0 = Texture2D(size, TextureFormat::RGBA16F);
    GBColor0.setFilter(GL_NEAREST, GL_NEAREST);
    GBColor1 = Texture2D(size, TextureFormat::RGBA16F);
    GBColor1.setFilter(GL_NEAREST, GL_NEAREST);
    gBuffer = RenderTarget(size.x, size.y);
    gBuffer.setTexture(RenderTargetBase::DEPTH, &GBDepth); //Z-BUFFER
    gBuffer.setTexture(RenderTargetBase::COLOR0, &GBColor0); //COLOR
    gBuffer.setTexture(RenderTargetBase::COLOR1, &GBColor1); //NORMAL, BRIGHTNESS, SPECULAR FACTOR
    if(sunTarget.getSize() == vec2ui(0)) { //invalid (this is the first makeTarget() )
        SDepth = Texture2DArray(vec3ui(4096,4096, NUM_SUN_CASCADES), TextureFormat::DEPTH_COMPONENT32F);
        SDepth.setFilter(GL_LINEAR, GL_LINEAR);
        SDepth.setComparison(GL_GREATER);
        sunTarget = RenderTargetLayered(4096, 4096, NUM_SUN_CASCADES);
        sunTarget.setTexture(RenderTargetBase::DEPTH, &SDepth); //Z-BUFFER

        SDepthTrans = Texture2DArray(vec3ui(4096,4096, NUM_SUN_CASCADES), TextureFormat::DEPTH_COMPONENT32F);
        SDepthTrans.setFilter(GL_LINEAR, GL_LINEAR);
        SDepthTrans.setComparison(GL_GREATER);
        sunTargetTrans = RenderTargetLayered(4096, 4096, NUM_SUN_CASCADES);
        sunTargetTrans.setTexture(RenderTargetBase::DEPTH, &SDepthTrans); //Z-BUFFER
    }
}
Example #2
0
void Guldmannen::Level::SetTile(int x, int y, int _id, int _layer)
{
	if(x >= width || x < 0)
		return;
	else if(y >= height || y < 0)
		return;
	else if( _layer < 0 || _layer > 3)
		return;
	else
	{
		Tiles[ (x + (y*width)) ]->id[_layer] = _id;
		if(Tiles[ (x + (y*width)) ]->graphic_id[_layer] == -1)
		{
			graphical_tiles.push_back(new RenderImage(tileSheet,true));
			Tiles[ (x + (y*width)) ]->graphic_id[_layer] = graphical_tiles.size()-1;

			if(_layer == 2)
				graphical_tiles.back()->SetZ(0.5 + (0.0001*((y*32)+32)));
			else
				graphical_tiles.back()->SetZ(0.4 + (0.1*_layer));

			graphical_tiles.back()->SetSize(vec2ui(32,32));
			graphical_tiles.back()->SetPosition(x*32,y*32);
		}
		graphical_tiles[ Tiles[ (x + (y*width)) ]->graphic_id[_layer] ]->SetTexClip(32, 32, ((_id)%(tileSheet->Width/32))*32, (((_id*32)-((_id*32)%tileSheet->Width))/tileSheet->Width)*32);
	}
}
Example #3
0
    vec2ui Material::getParam(const char *name, vec2ui defaultVal) 
    {
      ParamMap::iterator it = params.find(name);
      if (it != params.end()) {
        assert( it->second->type == Param::UINT_2 && "Param type mismatch" );
        return vec2ui(it->second->ui[0], it->second->ui[1]);
      }

      return defaultVal;
    }
void TestLinAlg()
{
    // Instantiate templates, check sizes, make sure operators compile etc.

    static_assert(sizeof(Vec2f)     == 8  , "Vec2f size test failed"    );
    static_assert(sizeof(Vec3f)     == 12 , "Vec3f size test failed"    );
    static_assert(sizeof(Vec4f)     == 16 , "Vec4f size test failed"    );
    static_assert(sizeof(Vec2d)     == 16 , "Vec2d size test failed"    );
    static_assert(sizeof(Vec3d)     == 24 , "Vec3d size test failed"    );
    static_assert(sizeof(Vec4d)     == 32 , "Vec4d size test failed"    );
    static_assert(sizeof(Vec2i)     == 8  , "Vec2i size test failed"    );
    static_assert(sizeof(Vec3i)     == 12 , "Vec3i size test failed"    );
    static_assert(sizeof(Vec4i)     == 16 , "Vec4i size test failed"    );
    static_assert(sizeof(Vec2ui)    == 8  , "Vec2ui size test failed"   );
    static_assert(sizeof(Vec3ui)    == 12 , "Vec3ui size test failed"   );
    static_assert(sizeof(Vec4ui)    == 16 , "Vec4ui size test failed"   );
    static_assert(sizeof(Matrix44f) == 64 , "Matrix44f size test failed");
    static_assert(sizeof(Matrix44d) == 128, "Matrix44d size test failed");

    Vec2f vec2f(0.0f, 0.0f);
    Vec3f vec3f(0.0f, 0.0f, 0.0f);
    Vec4f vec4f(0.0f, 0.0f, 0.0f, 0.0f);
    Vec2d vec2d(0.0, 0.0);
    Vec3d vec3d(0.0, 0.0, 0.0);
    Vec4d vec4d(0.0, 0.0, 0.0, 0.0);
    Vec2i vec2i(-1, -1);
    Vec3i vec3i(-1, -1, -1);
    Vec4i vec4i(-1, -1, -1, -1);
    Vec2ui vec2ui(0, 0);
    Vec3ui vec3ui(0, 0, 0);
    Vec4ui vec4ui(0, 0, 0, 0);
    float f = 0.0f;
    bool b = false;

    b = (vec3f == vec3f);
    b = (vec3f != vec3f);
    vec3f = Vec3f(1.0f) + Vec3f(2.0f);
    vec3f = Vec3f(1.0f) - Vec3f(2.0f);
    vec3f = Vec3f(1.0f) * Vec3f(2.0f);
    vec3f = Vec3f(1.0f) / Vec3f(2.0f);
    vec3f = Vec3f(1.0f) * f;
    vec3f = f * Vec3f(1.0f);
    vec3f = Vec3f(1.0f) / f;
    vec3f = -Vec3f(1.0f);
    vec3f += Vec3f(1.0f);
    vec3f -= Vec3f(1.0f);
    vec3f *= Vec3f(1.0f);
    vec3f /= Vec3f(1.0f);
    vec3f *= f;
    vec3f /= f;
    f = vec3f[0];
    vec3f[0] = f;
    f = Length(vec3f);
    f = LengthSquared(vec3f);
    vec3f = Normalize(vec3f);
    f = Dot(Vec3f(1.0f), Vec3f(2.0f));
    vec3f = Vec3f(1.0f) ^ Vec3f(2.0f);

    Matrix44f matf;
    matf.Identity();
    Matrix44d matd;
    matf.RotationX(1);
    matf.RotationY(1);
    matf.RotationZ(1);
    matf.Scaling(1);
    b = matf == matf;
    matf = matf * matf;
    matf.BuildLookAtMatrix(Vec3f(0.0f, 10.0f, 10.0f), Vec3f(0.0f));
    matf.BuildProjection(90.0f, 4.0f / 3.0f, 1.0f, 1000.0f);
    Vec3f out;
    matf.Transf3x3(vec3f, out);
    matf.Transf4x4(vec3f, out);
    matf.Transpose3x3();
    matf.Transpose4x4();
    matf.Invert();
}