示例#1
0
GlTexture getGlTexture(const TexturePtr& outputTexture)
{
	GlTexture glTexture;
	glTexture.width = outputTexture->getWidth();
	glTexture.height = outputTexture->getHeight();
	glTexture.depth = outputTexture->getDepth();
	glTexture.target = toGlTargetType(outputTexture->getType());
	glTexture.textureId = outputTexture->_getGlTextureId();
	return glTexture;
}
示例#2
0
    //-----------------------------------------------------------------------------------
    RenderTarget* CompositorPass::calculateRenderTarget( size_t rtIndex,
                                                         const CompositorChannel &source )
    {
        RenderTarget *retVal;

        if( !source.isMrt() && !source.textures.empty() &&
            source.textures[0]->getTextureType() > TEX_TYPE_2D )
        {
            //Who had the bright idea of handling Cubemaps differently
            //than 3D textures is a mystery. Anyway, deal with it.
            TexturePtr texturePtr = source.textures[0];

            if( rtIndex >= texturePtr->getDepth() && rtIndex >= texturePtr->getNumFaces() )
            {
                size_t maxRTs = std::max<size_t>( source.textures[0]->getDepth(),
                                                    source.textures[0]->getNumFaces() );
                OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS,
                        "Compositor pass is asking for a 3D/Cubemap/2D_array texture with "
                        "more faces/depth/slices than what's been supplied (Asked for slice '" +
                        StringConverter::toString( rtIndex ) + "', RT has '" +
                        StringConverter::toString( maxRTs ) + "')",
                        "CompositorPass::calculateRenderTarget" );
            }

            /*//If goes out bounds, will reference the last slice/face
            rtIndex = std::min( rtIndex, std::max( source.textures[0]->getDepth(),
                                                    source.textures[0]->getNumFaces() ) - 1 );*/

            TextureType textureType = texturePtr->getTextureType();
            size_t face = textureType == TEX_TYPE_CUBE_MAP ? rtIndex : 0;
            size_t slice= textureType != TEX_TYPE_CUBE_MAP ? rtIndex : 0;
            retVal = texturePtr->getBuffer( face )->getRenderTarget( slice );
        }
        else
        {
            retVal = source.target;
        }

        return retVal;
    }
示例#3
0
文件: Main.cpp 项目: fohr/Graphtane
	//! Implementation of VolumeRenderableMaterialFactory
	MaterialPtr createMaterial(const SparseVolumeMaterialConfig& config) const
	{
		TexturePtr densityTexture = getGridForRole(config.leafAtlases, GridTextureRole_Diffuse);
		assert(densityTexture);

		TexturePtr normalTexture = getGridForRole(config.leafAtlases, GridTextureRole_Normal);
		TexturePtr temperatureTexture = getGridForRole(config.leafAtlases, GridTextureRole_Temperature);

		MaterialPtr material(new Material);

		glm::vec3 densityTextureSize(densityTexture->getWidth(), densityTexture->getHeight(), densityTexture->getDepth());

		// Main technique
		{
			TechniquePtr technique(new Technique(m_volumeShader));
			{
				Vec3ShaderParameterPtr boxModelSizeParameter(new Vec3ShaderParameter("volumeSize_modelSpace", config.boxSize));
				technique->addCustomShaderParameter(boxModelSizeParameter);

				Vec3ShaderParameterPtr oneOnVolumeTextureSizeParameter(new Vec3ShaderParameter("oneOnVolumeTextureSize", 1.0f / densityTextureSize));
				technique->addCustomShaderParameter(oneOnVolumeTextureSizeParameter);

				technique->setAlphaBlendingMode(AlphaBlendingMode_PreMultiplied);

				int maxLeafCountPerInternalNode = config.maxLeafCountPerInternalNodeDimension * config.maxLeafCountPerInternalNodeDimension * config.maxLeafCountPerInternalNodeDimension;

				technique->addCustomShaderParameter(ShaderParameterPtr(new IntShaderParameter("firstInternalNodeIndex", config.firstInternalNodeIndex)));
				technique->addCustomShaderParameter(ShaderParameterPtr(new IntShaderParameter("maxLeafCountPerInternalNode", maxLeafCountPerInternalNode)));
				technique->addCustomShaderParameter(ShaderParameterPtr(new IVec3ShaderParameter("maxLeafCountPerAtlasDimension", config.maxLeafCountPerAtlasDimension)));
				technique->addCustomShaderParameter(ShaderParameterPtr(new IntShaderParameter("maxLeafCountPerInternalNodeDimension", config.maxLeafCountPerInternalNodeDimension)));
				
				float thresholdAlpha = m_transparent ? 0.001 : 0.2;
				technique->addCustomShaderParameter(ShaderParameterPtr(new FloatShaderParameter("thresholdAlpha", thresholdAlpha)));

				float opacityMultiplier = m_transparent ? m_opacityMultiplier : 200.0;
				technique->addCustomShaderParameter(ShaderParameterPtr(new FloatShaderParameter("opacityMultiplier", opacityMultiplier)));

				{
					TextureUnit unit(densityTexture, "albedoSampler");
					technique->addTextureUnit(unit);
				}

				if (normalTexture)
				{
					TextureUnit unit(normalTexture, "normalSampler");
					technique->addTextureUnit(unit);
				}

				if (temperatureTexture)
				{
					TextureUnit unit(temperatureTexture, "temperatureSampler");
					technique->addTextureUnit(unit);
				}

				TextureUnit unit(m_temperatureRampTexture, "temperatureRampSampler");
				technique->addTextureUnit(unit);

				{
					TextureUnit unit(config.nodeIndirectionTexture, "nodeIndirectionSampler");
					technique->addTextureUnit(unit);
				}
			}

			material->setTechnique(technique);
		}

		return material;
	}
void TextureToolWindow::updateControls(String texName)
{
    try
    {
        bool exists = TextureManager::getSingleton().resourceExists(texName);
        if (!exists)
        {
            mTxt->setCaption(convertToMyGUIString("Texture not found:\n" + texName));
            mBtnSavePNG->setEnabled(false);
            return;
        }

        TexturePtr tex = TextureManager::getSingleton().getByName(texName);
        if (tex.isNull())
        {
            mTxt->setCaption(convertToMyGUIString("Error loading texture:\n" + texName));
            mBtnSavePNG->setEnabled(false);
            return;
        }

        String str = "#aa0000" + texName + "#000000\n";
        str += "#00aa00res: #000000" + TOSTRING(tex->getWidth()) + " x " + TOSTRING(tex->getHeight()) + " pixels\n";
        str += "#00aa00size: #000000" + formatBytes(tex->getSize()) + "\n";
        str += "#00aa00format: #000000" + PixelUtil::getFormatName(tex->getFormat()) + "\n";
        if (tex->getNumFaces() > 1)
            str += "#00aa00faces: #000000" + TOSTRING(tex->getNumFaces()) + "\n";
        if (tex->getFSAA() > 0)
            str += "#00aa00FSAA: #000000" + TOSTRING(tex->getFSAA()) + "\n";
        if (tex->getNumMipmaps() > 0)
            str += "#00aa00mipmaps: #000000" + TOSTRING(tex->getNumMipmaps()) + "\n";

        String typeStr = "";
        switch (tex->getTextureType())
        {
        case TEX_TYPE_1D: typeStr = "1D";
            break;
        case TEX_TYPE_2D: typeStr = "2D";
            break;
        case TEX_TYPE_3D: typeStr = "3D";
            break;
        case TEX_TYPE_CUBE_MAP: typeStr = "Cube Map";
            break;
        }
        str += "#00aa00type: #000000" + typeStr + "\n";

        String usageStr = "";
        if (tex->getUsage() & TU_STATIC)
            usageStr += "static,\n";
        if (tex->getUsage() & TU_DYNAMIC)
            usageStr += "dynamic,\n";
        if (tex->getUsage() & TU_WRITE_ONLY)
            usageStr += "write only,\n";
        if (tex->getUsage() & TU_STATIC_WRITE_ONLY)
            usageStr += "static write only,\n";
        if (tex->getUsage() & TU_DYNAMIC_WRITE_ONLY)
            usageStr += "dynamic write only,\n";
        if (tex->getUsage() & TU_DYNAMIC_WRITE_ONLY_DISCARDABLE)
            usageStr += "dynamic write only discardable,\n";
        if (tex->getUsage() & TU_AUTOMIPMAP)
            usageStr += "automipmap,\n";
        if (tex->getUsage() & TU_RENDERTARGET)
            usageStr += "rendertarget,\n";
        if (tex->getUsage() & TU_DEFAULT)
            usageStr += "default\n";

        str += "#00aa00usage: #000000" + usageStr + "\n";
        if (tex->getDepth() > 1)
            str += "#00aa00depth: #000000" + TOSTRING(tex->getDepth()) + "\n";

        mTxt->setCaption(convertToMyGUIString(str));
        mImage->setImageTexture(texName);
        mBtnSavePNG->setEnabled(true);
    }
    catch (Exception& e)
    {
        UTFString str = "Exception while opening texture:" + e.getFullDescription();
        RoR::App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_MSGTYPE_INFO, str, "error.png");
    }
}