コード例 #1
0
    void setUpBaseParameters(const GpuProgramParametersSharedPtr& params)
    {
        assert(params.isNull()==false);

        struct AutoParamPair { String name; GpuProgramParameters::AutoConstantType type; };

        //A list of auto params that might be present in the shaders generated
        static const AutoParamPair AUTO_PARAMS[] = {
            { "vpWidth",            GpuProgramParameters::ACT_VIEWPORT_WIDTH },
            { "vpHeight",           GpuProgramParameters::ACT_VIEWPORT_HEIGHT },
            { "worldView",          GpuProgramParameters::ACT_WORLDVIEW_MATRIX },
            { "invProj",            GpuProgramParameters::ACT_INVERSE_PROJECTION_MATRIX },
            { "invView",            GpuProgramParameters::ACT_INVERSE_VIEW_MATRIX },
            { "flip",               GpuProgramParameters::ACT_RENDER_TARGET_FLIPPING },
            { "lightDiffuseColor",  GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR },
            { "lightSpecularColor", GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR },
            { "lightFalloff",       GpuProgramParameters::ACT_LIGHT_ATTENUATION },
            { "lightPos",           GpuProgramParameters::ACT_LIGHT_POSITION_VIEW_SPACE },
            { "lightDir",           GpuProgramParameters::ACT_LIGHT_DIRECTION_VIEW_SPACE },
            { "spotParams",         GpuProgramParameters::ACT_SPOTLIGHT_PARAMS },
            { "farClipDistance",    GpuProgramParameters::ACT_FAR_CLIP_DISTANCE },
            { "shadowViewProjMat",  GpuProgramParameters::ACT_TEXTURE_VIEWPROJ_MATRIX }
        };
        int numParams = sizeof(AUTO_PARAMS) / sizeof(AutoParamPair);
        
        for (int i=0; i<numParams; i++)
        {
            if (params->_findNamedConstantDefinition(AUTO_PARAMS[i].name))
            {
                params->setNamedAutoConstant(AUTO_PARAMS[i].name, AUTO_PARAMS[i].type);
            }
        }
    }
コード例 #2
0
ファイル: DepthOfFieldEffect.cpp プロジェクト: tizbac/ror-ng
void DepthOfFieldEffect::notifyMaterialSetup(uint32 passId, MaterialPtr& material)
{
	switch (passId)
	{
	case BlurPass:
		{
			//float pixelSize[2] = {
			//	1.0f / (gEnv->ogreViewPort->getActualWidth() / BLUR_DIVISOR),
			//	1.0f / (gEnv->ogreViewPort->getActualHeight() / BLUR_DIVISOR)};

			// Adjust fragment program parameters
			Ogre::Vector3 ps = Ogre::Vector3(1.0f / (mWidth / BLUR_DIVISOR),1.0f / (mHeight / BLUR_DIVISOR), 1.0f);
			float pixelSize[3] = { ps.x, ps.y, ps.z };
			GpuProgramParametersSharedPtr fragParams = material->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
			if ((!fragParams.isNull())&&(fragParams->_findNamedConstantDefinition("pixelSize")))
				fragParams->setNamedConstant("pixelSize", pixelSize, 1, 3);

			break;
		}

	case OutputPass:
		{
			float pixelSizeScene[3] = {
				1.0f / mWidth,
				1.0f / mHeight,
				0};

			float pixelSizeBlur[3] = {
				1.0f / (mWidth / BLUR_DIVISOR),
				1.0f / (mHeight / BLUR_DIVISOR),
				0};

			// Adjust fragment program parameters
			GpuProgramParametersSharedPtr fragParams =
				material->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
			if ((!fragParams.isNull())&&(fragParams->_findNamedConstantDefinition("pixelSizeScene")))
				fragParams->setNamedConstant("pixelSizeScene", pixelSizeScene,1,3);
			if ((!fragParams.isNull())&&(fragParams->_findNamedConstantDefinition("pixelSizeBlur")))
				fragParams->setNamedConstant("pixelSizeBlur", pixelSizeBlur,1,3);

			break;
		}
	}
}
コード例 #3
0
	//---------------------------------------------------------------------
	void GpuProgramUsage::recreateParameters()
	{
		// Keep a reference to old ones to copy
		GpuProgramParametersSharedPtr savedParams = mParameters;

		// Create new params
		mParameters = mProgram->createParameters();

		// Copy old (matching) values across
		// Don't use copyConstantsFrom since program may be different
		if (!savedParams.isNull())
			mParameters->copyMatchingNamedConstantsFrom(*savedParams.get());

		mRecreateParams = false;

	}
コード例 #4
0
ファイル: DepthOfFieldEffect.cpp プロジェクト: tizbac/ror-ng
void DepthOfFieldEffect::preViewportUpdate(const Ogre::RenderTargetViewportEvent& evt)
{

	float dofParams[4] = {mNearDepth, mFocalDepth, mFarDepth, mFarBlurCutoff};

	// Adjust fragment program parameters for depth pass
	GpuProgramParametersSharedPtr fragParams =
		mDepthTechnique->getPass(0)->getFragmentProgramParameters();
	if ((!fragParams.isNull())&&(fragParams->_findNamedConstantDefinition("dofParams")))
		fragParams->setNamedConstant("dofParams", dofParams,1,4);		

	evt.source->setVisibilityMask(~DEPTHMAP_DISABLED);

	// Add 'this' as a RenderableListener to replace the technique for all renderables
	RenderQueue* queue = evt.source->getCamera()->getSceneManager()->getRenderQueue();
	queue->setRenderableListener(this);
}