Exemplo n.º 1
0
//----------------------------------------------------------------------------
void Smoke2D::CreateDrawDensityEffect (VisualEffect*& effect,
    VisualEffectInstance*& instance)
{
    PixelShader* pshader = new0 PixelShader("Wm5.DrawDensity2",
        1, 1, 0, 3, false);
    pshader->SetInput(0, "vertexTCoord", Shader::VT_FLOAT2,
        Shader::VS_TEXCOORD0);
    pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
        Shader::VS_COLOR0);
    pshader->SetSampler(0, "StateSampler", Shader::ST_2D);
    pshader->SetSampler(1, "ColorTableSampler", Shader::ST_1D);
    pshader->SetSampler(2, "VortexSampler", Shader::ST_2D);
    pshader->SetFilter(1, Shader::SF_LINEAR);
    pshader->SetTextureUnits(msDrawDensityPTextureUnits);
    pshader->SetPrograms(msDrawDensityPPrograms);

    mIP->CreateEffect(pshader, effect, instance);

    // For pseudocoloring density.
    mGrayTexture = new0 Texture1D(Texture::TF_A8R8G8B8, 8, 1);
    unsigned char* gray = (unsigned char*)mGrayTexture->GetData(0);
    gray[ 0] =   0;  gray[ 1] =   0;  gray[ 2] =   0;  gray[ 3] = 255;
    gray[ 4] =  32;  gray[ 5] =  32;  gray[ 6] =  32;  gray[ 7] = 255;
    gray[ 8] =  64;  gray[ 9] =  64;  gray[10] =  64;  gray[11] = 255;
    gray[12] =  96;  gray[13] =  96;  gray[14] =  96;  gray[15] = 255;
    gray[16] = 128;  gray[17] = 128;  gray[18] = 128;  gray[19] = 255;
    gray[20] = 160;  gray[21] = 160;  gray[22] = 160;  gray[23] = 255;
    gray[24] = 192;  gray[25] = 192;  gray[26] = 192;  gray[27] = 255;
    gray[28] = 255;  gray[29] = 255;  gray[30] = 255;  gray[31] = 255;

    mColorTexture = new0 Texture1D(Texture::TF_A8R8G8B8, 8, 1);
    unsigned char* color = (unsigned char*)mColorTexture->GetData(0);
    color[ 0] =   0;  color[ 1] =   0;  color[ 2] =   0;  color[ 3] = 255;
    color[ 4] = 255;  color[ 5] =   0;  color[ 6] = 128;  color[ 7] = 255;
    color[ 8] = 255;  color[ 9] =   0;  color[10] =   0;  color[11] = 255;
    color[12] =   0;  color[13] = 255;  color[14] =   0;  color[15] = 255;
    color[16] =   0;  color[17] = 255;  color[18] = 255;  color[19] = 255;
    color[20] =   0;  color[21] = 128;  color[22] = 255;  color[23] = 255;
    color[24] =   0;  color[25] =   0;  color[26] = 255;  color[27] = 255;
    color[28] = 255;  color[29] = 255;  color[30] = 255;  color[31] = 255;

    // For vortex-center overlay.
    mVortexTexture = new0 Texture2D(Texture::TF_A8R8G8B8, mIMaxP1,
        mJMaxP1, 1);
    memset(mVortexTexture->GetData(0), 0, 4*mNumPixels);

    instance->SetPixelTexture(0, "StateSampler",
        mIP->GetTarget(1)->GetColorTexture(0));
    instance->SetPixelTexture(0, "ColorTableSampler", mGrayTexture);
    instance->SetPixelTexture(0, "VortexSampler", mVortexTexture);

    mRenderer->Bind(mGrayTexture);
    mRenderer->Bind(mColorTexture);
    mRenderer->Bind(mVortexTexture);
}
Exemplo n.º 2
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;
	}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
LightsourceSimplePass::LightsourceSimplePass(GraphicContext &gc, const std::string &shader_path, ResourceContainer &inout)
{
	viewport = inout.get<Rect>("Viewport");
	field_of_view = inout.get<float>("FieldOfView");
	world_to_eye = inout.get<Mat4f>("WorldToEye");
	diffuse_color_gbuffer = inout.get<Texture2D>("DiffuseColorGBuffer");
	specular_color_gbuffer = inout.get<Texture2D>("SpecularColorGBuffer");
	specular_level_gbuffer = inout.get<Texture2D>("SpecularLevelGBuffer");
	self_illumination_gbuffer = inout.get<Texture2D>("SelfIlluminationGBuffer");
	normal_z_gbuffer = inout.get<Texture2D>("NormalZGBuffer");
	shadow_maps = inout.get<Texture2DArray>("ShadowMaps");
	zbuffer = inout.get<Texture2D>("ZBuffer");

	final_color = inout.get<Texture2D>("FinalColor");

	icosahedron_light_program = compile_and_link(gc, shader_path, "icosahedron");
	rect_light_program = compile_and_link(gc, shader_path, "rect");

	light_instance_texture = Texture1D(gc, max_lights * vectors_per_light, tf_rgba32f);
	light_instance_transfer = PixelBuffer(max_lights * vectors_per_light, 1, tf_rgba32f);

	icosahedron.reset(new Icosahedron(gc, true));
}
//----------------------------------------------------------------------------
bool NonlocalBlowup::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }
#ifdef RUN_CONSOLE
    RunConsole();
    return false;
#endif

    mScene = new0 Node();
    mScene->LocalTransform.SetRotate(HMatrix(
        0.80475128f, 0.59107417f, -0.054833174f, 0.0f,
        -0.17529237f, 0.32487807f, 0.92936903f, 0.0f,
        0.56714010f, -0.73829913f, 0.36505684f, 0.0f,
        0.0f, 0.0f, 0.0f, 1.0f));
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);

    TriMesh* mesh = StandardMesh(vformat).Rectangle(256, 256, 16.0f, 16.0f);
    mScene->AttachChild(mesh);

    std::string gridName = Environment::GetPathR("Grid.wmtf");
    Texture2D* gridTexture = Texture2D::LoadWMTF(gridName);
    gridTexture->GenerateMipmaps();

    Texture1D* colorTexture = new0 Texture1D(Texture::TF_A8R8G8B8, 8, 1);
    unsigned char* color = (unsigned char*)colorTexture->GetData(0);
    color[ 0] = 128;  color[ 1] = 128;  color[ 2] = 128;  color[ 3] = 255;
    color[ 4] = 255;  color[ 5] =   0;  color[ 6] = 128;  color[ 7] = 255;
    color[ 8] = 255;  color[ 9] =   0;  color[10] =   0;  color[11] = 255;
    color[12] =   0;  color[13] = 255;  color[14] =   0;  color[15] = 255;
    color[16] =   0;  color[17] = 255;  color[18] = 255;  color[19] = 255;
    color[20] =   0;  color[21] = 128;  color[22] = 255;  color[23] = 255;
    color[24] =   0;  color[25] =   0;  color[26] = 255;  color[27] = 255;
    color[28] = 255;  color[29] = 255;  color[30] = 255;  color[31] = 255;

    float dt = 0.01f, dx = 1.0f, dy = 1.0f;
    // Uncomment only one of these at a time.
    NonconvexDomain0p50(dt, dx, dy);
    //SquareSymmetric0p01(dt, dx, dy);
    //SquareSymmetric0p50(dt, dx, dy);
    //SquareSymmetric0p99(dt, dx, dy);
    //SquareGaussX0p50(dt, dx, dy);
    //SquareGaussXY0p50(dt, dx, dy);
    //SquareGaussFour0p50(dt, dx, dy);

    DisplacementEffect* effect = new0 DisplacementEffect();
    mesh->SetEffectInstance(effect->CreateInstance(mHeightTexture,
        gridTexture, colorTexture, mDomainTexture));

    // Set up the camera so that it looks at the graph from slightly above
    // the xy-plane and at a skewed angle/direction of view.
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 10000.0f);
    APoint camPosition(0.0f, 3.46f, 42.97f);
    AVector camDVector(0.0f, 0.0f, -1.0f);
    AVector camUVector(0.0f, 1.0f, 0.0f);
    AVector camRVector = camDVector.Cross(camUVector);
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    // Initial update of objects.
    mScene->Update();

    // Initial culling of scene.
    mCuller.SetCamera(mCamera);
    mCuller.ComputeVisibleSet(mScene);

    InitializeCameraMotion(0.01f, 0.01f);
    InitializeObjectMotion(mScene);
    return true;
}
Exemplo n.º 6
0
	Texture1D Texture::to_texture_1d() const
	{
		return Texture1D(impl);
	}