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
    }
}
示例#2
0
	int test()
	{
		int Error(0);

		std::vector<entry> Tests;
		Tests.push_back(entry(gli::FORMAT_RGBA8_UINT_PACK8, gli::texture2DArray::texelcoord_type(4), 64 * 2));
		Tests.push_back(entry(gli::FORMAT_R8_UINT_PACK8, gli::texture2DArray::texelcoord_type(4), 16 * 2));
		Tests.push_back(entry(gli::FORMAT_RGB_DXT1_UNORM_BLOCK8, gli::texture2DArray::texelcoord_type(4), 8 * 2));
		Tests.push_back(entry(gli::FORMAT_RGB_DXT1_UNORM_BLOCK8, gli::texture2DArray::texelcoord_type(2), 8 * 2));
		Tests.push_back(entry(gli::FORMAT_RGB_DXT1_UNORM_BLOCK8, gli::texture2DArray::texelcoord_type(1), 8 * 2));
		Tests.push_back(entry(gli::FORMAT_RGBA_DXT5_UNORM_BLOCK16, gli::texture2DArray::texelcoord_type(4), 16 * 2));

		for(std::size_t i = 0; i < Tests.size(); ++i)
		{
			gli::texture2DArray Texture2DArray(
				Tests[i].Format,
				gli::texture2DArray::texelcoord_type(4),
				gli::texture2DArray::size_type(2),
				gli::texture2DArray::size_type(1));

			Error += Texture2DArray.size() == Tests[i].Size ? 0 : 1;
			assert(!Error);
		}

		for(std::size_t i = 0; i < Tests.size(); ++i)
		{
			gli::texture2DArray Texture2DArray(
				Tests[i].Format,
				gli::texture2DArray::texelcoord_type(4),
				gli::texture2DArray::size_type(2),
				gli::texture2DArray::size_type(1));

			gli::texture2D Texture2D = Texture2DArray[0];

			Error += Texture2DArray.size() == Tests[i].Size ? 0 : 1;
			assert(!Error);
		}

		return Error;
	}
示例#3
0
	int test()
	{
		int Error(0);

		{
			gli::texture2DArray Texture2DArray(gli::FORMAT_RGBA8_UINT_PACK8, gli::texture2DArray::texelcoord_type(2), 2, 1);
			assert(!Texture2DArray.empty());

			gli::texture2D Texture0 = Texture2DArray[0];
			gli::texture2D Texture1 = Texture2DArray[1];
		
			std::size_t Size0 = Texture0.size();
			std::size_t Size1 = Texture1.size();

			Error += Size0 == sizeof(glm::u8vec4) * 4 ? 0 : 1;
			Error += Size1 == sizeof(glm::u8vec4) * 4 ? 0 : 1;

			for(std::size_t i = 0; i < 4; ++i)
			{
				*(Texture0.data<glm::u8vec4>() + i) = glm::u8vec4(255, 127, 0, 255);
				*(Texture1.data<glm::u8vec4>() + i) = glm::u8vec4(0, 127, 255, 255);
			}

			glm::u8vec4 * PointerA = Texture0.data<glm::u8vec4>();
			glm::u8vec4 * PointerB = Texture1.data<glm::u8vec4>();

			glm::u8vec4 * Pointer0 = Texture2DArray.data<glm::u8vec4>() + 0;
			glm::u8vec4 * Pointer1 = Texture2DArray.data<glm::u8vec4>() + 4;

			Error += PointerA == Pointer0 ? 0 : 1;
			Error += PointerB == Pointer1 ? 0 : 1;

			glm::u8vec4 ColorA = *Texture0.data<glm::u8vec4>();
			glm::u8vec4 ColorB = *Texture1.data<glm::u8vec4>();

			glm::u8vec4 Color0 = *Pointer0;
			glm::u8vec4 Color1 = *Pointer1;

			Error += ColorA == Color0 ? 0 : 1;
			Error += ColorB == Color1 ? 0 : 1;

			Error += glm::all(glm::equal(Color0, glm::u8vec4(255, 127, 0, 255))) ? 0 : 1;
			Error += glm::all(glm::equal(Color1, glm::u8vec4(0, 127, 255, 255))) ? 0 : 1;
		}

		return Error;
	}
示例#4
0
	int run()
	{
		int Error(0);

		gli::texture Texture(gli::TARGET_1D, gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture::extent_type(1), 1, 1, 1);
		gli::texture1d Texture1D(Texture);
		gli::texture1d_array Texture1DArray(Texture);
		gli::texture2d Texture2D(Texture);
		gli::texture2d_array Texture2DArray(Texture);
		gli::texture3d Texture3D(Texture);
		gli::texture_cube TextureCube(Texture);
		gli::texture_cube_array TextureCubeArray(Texture);

		Error += Texture == Texture1D ? 0 : 1;
		Error += Texture != Texture1DArray ? 0 : 1;
		Error += Texture != Texture2D ? 0 : 1;
		Error += Texture != Texture2DArray ? 0 : 1;
		Error += Texture != Texture3D ? 0 : 1;
		Error += Texture != TextureCube ? 0 : 1;
		Error += Texture != TextureCubeArray ? 0 : 1;

		gli::texture Texture1D_B(Texture1D);
		gli::texture Texture1DArray_B(Texture1DArray);
		gli::texture Texture2D_B(Texture2D);
		gli::texture Texture2DArray_B(Texture2DArray);
		gli::texture Texture3D_B(Texture3D);
		gli::texture TextureCube_B(TextureCube);
		gli::texture TextureCubeArray_B(TextureCubeArray);

		Error += Texture == Texture1D_B ? 0 : 1;
		Error += Texture != Texture1DArray_B ? 0 : 1;
		Error += Texture != Texture2D_B ? 0 : 1;
		Error += Texture != Texture2DArray_B ? 0 : 1;
		Error += Texture != Texture3D_B ? 0 : 1;
		Error += Texture != TextureCube_B ? 0 : 1;
		Error += Texture != TextureCubeArray_B ? 0 : 1;

		Error += Texture1D == Texture1D_B ? 0 : 1;
		Error += Texture1DArray == Texture1DArray_B ? 0 : 1;
		Error += Texture2D == Texture2D_B ? 0 : 1;
		Error += Texture2DArray == Texture2DArray_B ? 0 : 1;
		Error += Texture3D == Texture3D_B ? 0 : 1;
		Error += TextureCube == TextureCube_B ? 0 : 1;
		Error += TextureCubeArray == TextureCubeArray_B ? 0 : 1;

		return Error;
	}
示例#5
0
int run()
{
    int Error(0);

    gli::texture Texture(gli::TARGET_1D, gli::FORMAT_RGBA8_UNORM, gli::texture::texelcoord_type(1), 1, 1, 1);
    gli::texture1D Texture1D(Texture);
    gli::texture1DArray Texture1DArray(Texture);
    gli::texture2D Texture2D(Texture);
    gli::texture2DArray Texture2DArray(Texture);
    gli::texture3D Texture3D(Texture);
    gli::textureCube TextureCube(Texture);
    gli::textureCubeArray TextureCubeArray(Texture);

    Error += Texture == Texture1D ? 0 : 1;
    Error += Texture != Texture1DArray ? 0 : 1;
    Error += Texture != Texture2D ? 0 : 1;
    Error += Texture != Texture2DArray ? 0 : 1;
    Error += Texture != Texture3D ? 0 : 1;
    Error += Texture != TextureCube ? 0 : 1;
    Error += Texture != TextureCubeArray ? 0 : 1;

    gli::texture Texture1D_B(Texture1D);
    gli::texture Texture1DArray_B(Texture1DArray);
    gli::texture Texture2D_B(Texture2D);
    gli::texture Texture2DArray_B(Texture2DArray);
    gli::texture Texture3D_B(Texture3D);
    gli::texture TextureCube_B(TextureCube);
    gli::texture TextureCubeArray_B(TextureCubeArray);

    Error += Texture == Texture1D_B ? 0 : 1;
    Error += Texture != Texture1DArray_B ? 0 : 1;
    Error += Texture != Texture2D_B ? 0 : 1;
    Error += Texture != Texture2DArray_B ? 0 : 1;
    Error += Texture != Texture3D_B ? 0 : 1;
    Error += Texture != TextureCube_B ? 0 : 1;
    Error += Texture != TextureCubeArray_B ? 0 : 1;

    Error += Texture1D == Texture1D_B ? 0 : 1;
    Error += Texture1DArray == Texture1DArray_B ? 0 : 1;
    Error += Texture2D == Texture2D_B ? 0 : 1;
    Error += Texture2DArray == Texture2DArray_B ? 0 : 1;
    Error += Texture3D == Texture3D_B ? 0 : 1;
    Error += TextureCube == TextureCube_B ? 0 : 1;
    Error += TextureCubeArray == TextureCubeArray_B ? 0 : 1;

    return Error;
}
示例#6
0
ShadowMaps::ShadowMaps(GraphicContext &gc, const Resource<Texture2DArray> &init_shadow_maps, int shadow_map_size, int max_active_maps, TextureFormat format)
: shadow_maps(init_shadow_maps), used_entries(0), unused_entries(0)
{
	framebuffers.reserve(max_active_maps);
	views.reserve(max_active_maps);
	shadow_maps.set(Texture2DArray(gc, shadow_map_size, shadow_map_size, max_active_maps, format));

	Texture2D depth_texture(gc, shadow_map_size, shadow_map_size, tf_depth_component32);
	for (int i = 0; i < max_active_maps; i++)
	{
		FrameBuffer fb(gc);
		fb.attach_color(0, shadow_maps.get(), i);
		fb.attach_depth(depth_texture);
		framebuffers.push_back(fb);

		views.push_back(shadow_maps->create_2d_view(i, tf_rg32f, 0, 1));

		free_indexes.push_back(i);
	}
}
示例#7
0
	Texture2DArray Texture::to_texture_2d_array() const
	{
		return Texture2DArray(impl);
	}