本文整理汇总了C++中CompositionTargetPass类的典型用法代码示例。如果您正苦于以下问题:C++ CompositionTargetPass类的具体用法?C++ CompositionTargetPass怎么用?C++ CompositionTargetPass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CompositionTargetPass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCompositor
//-----------------------------------------------------------------------
void CompositorChain::setCompositorEnabled(size_t position, bool state)
{
CompositorInstance* inst = getCompositor(position);
if (!state && inst->getEnabled())
{
// If we're disabling a 'middle' compositor in a chain, we have to be
// careful about textures which might have been shared by non-adjacent
// instances which have now become adjacent.
CompositorInstance* nextInstance = getNextInstance(inst, true);
if (nextInstance)
{
CompositionTechnique::TargetPassIterator tpit = nextInstance->getTechnique()->getTargetPassIterator();
while(tpit.hasMoreElements())
{
CompositionTargetPass* tp = tpit.getNext();
if (tp->getInputMode() == CompositionTargetPass::IM_PREVIOUS)
{
if (nextInstance->getTechnique()->getTextureDefinition(tp->getOutputName())->pooled)
{
// recreate
nextInstance->freeResources(false, true);
nextInstance->createResources(false);
}
}
}
}
}
inst->setEnabled(state);
}
示例2: fixCompositorClearColor
void TerrainManager::fixCompositorClearColor()
{
// hack
// now with extensive error checking
if (CompositorManager::getSingleton().hasCompositorChain(gEnv->mainCamera->getViewport()))
{
// //CompositorManager::getSingleton().getCompositorChain(gEnv->ogreCamera->getViewport())->getCompositor(0)->getTechnique()->getOutputTargetPass()->getPass(0)->setClearColour(fade_color);
CompositorInstance *co = CompositorManager::getSingleton().getCompositorChain(gEnv->mainCamera->getViewport())->_getOriginalSceneCompositor();
if (co)
{
CompositionTechnique *ct = co->getTechnique();
if (ct)
{
CompositionTargetPass *ctp = ct->getOutputTargetPass();
if (ctp)
{
CompositionPass *p = ctp->getPass(0);
if (p)
{
p->setClearColour(fade_color);
}
}
}
}
}
}
示例3: CreateTextureDef
void HDRCompositor::CalculateKey(void)
{
CompositionTargetPass *tp;
CompositionPass *pass;
CreateTextureDef("Key",1,1,PF_FLOAT16_RGB);
tp = m_HDRTechnique->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
tp->setOutputName("Key");
pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
if(m_AutoKeying)
{
pass->setMaterialName("AutoKey");
pass->setInput(0,"Luminance");
}
else
{
pass->setIdentifier(MID_KEY);
pass->setMaterialName("ManualKey");
// GpuProgramParameters::RealConstantEntry* entry = pass->getMaterial()->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->getNamedRealConstantEntry("Key");
// if(entry)
// entry->val[0] = m_Key;
}
}
示例4: createOriginalScene
//-----------------------------------------------------------------------
void CompositorChain::createOriginalScene()
{
/// Create "default" compositor
/** Compositor that is used to implicitly represent the original
render in the chain. This is an identity compositor with only an output pass:
compositor Ogre/Scene
{
technique
{
target_output
{
pass clear
{
/// Clear frame
}
pass render_scene
{
visibility_mask FFFFFFFF
render_queues SKIES_EARLY SKIES_LATE
}
}
}
};
*/
mOriginalSceneScheme = mViewport->getMaterialScheme();
String compName = "Ogre/Scene/" + mOriginalSceneScheme;
CompositorPtr scene = CompositorManager::getSingleton().getByName(compName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
if (scene.isNull())
{
scene = CompositorManager::getSingleton().create(compName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
CompositionTechnique *t = scene->createTechnique();
t->setSchemeName(StringUtil::BLANK);
CompositionTargetPass *tp = t->getOutputTargetPass();
tp->setVisibilityMask(0xFFFFFFFF);
{
CompositionPass *pass = tp->createPass();
pass->setType(CompositionPass::PT_CLEAR);
}
{
CompositionPass *pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERSCENE);
/// Render everything, including skies
pass->setFirstRenderQueue(RENDER_QUEUE_BACKGROUND);
pass->setLastRenderQueue(RENDER_QUEUE_SKIES_LATE);
}
/// Create base "original scene" compositor
scene = CompositorManager::getSingleton().load(compName,
ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
}
mOriginalScene = OGRE_NEW CompositorInstance(scene->getSupportedTechnique(), this);
}
示例5: Release
void HDRCompositor::Create(void)
{
Release();
m_Compositor = CompositorManager::getSingleton().create("HDR", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
m_HDRTechnique = m_Compositor->createTechnique();
//render scene
CreateTextureDef("Scene",0,0,PF_FLOAT16_RGB);
CompositionTargetPass *tp = m_HDRTechnique->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_PREVIOUS);
tp->setOutputName("Scene");
RenderDownSample();
CalculateLuminance();
CalculateKey();
if(m_GlareType || m_StarType)
{
BrightPass();
if(m_GlareType)
BuildGlare();
if(m_StarType)
BuildStar();
}
if(m_ToneMapper == TM_REINHARDLOCAL)
BuildScales();
FinalRendering();
Viewport* const vp = m_Window->getViewport(0);
Ogre::CompositorInstance* const instance = CompositorManager::getSingleton().addCompositor(vp, "HDR");
if(instance)
instance->addListener(this);
notifyViewportSize(vp->getActualWidth(), vp->getActualHeight());
Enable(m_Enable);
}
示例6: while
//---------------------------------------------------------------------
bool CompositorManager::isInputPreviousTarget(CompositorInstance* inst, const Ogre::String& localName)
{
CompositionTechnique::TargetPassIterator tpit = inst->getTechnique()->getTargetPassIterator();
while(tpit.hasMoreElements())
{
CompositionTargetPass* tp = tpit.getNext();
if (tp->getInputMode() == CompositionTargetPass::IM_PREVIOUS &&
tp->getOutputName() == localName)
{
return true;
}
}
return false;
}
示例7: preViewportUpdate
//-----------------------------------------------------------------------
void CompositorChain::preViewportUpdate(const RenderTargetViewportEvent& evt)
{
// Only set up if there is at least one compositor enabled, and it's this viewport
if(evt.source != mViewport || !mAnyCompositorsEnabled)
return;
// set original scene details from viewport
CompositionPass* pass = mOriginalScene->getTechnique()->getOutputTargetPass()->getPass(0);
CompositionTargetPass* passParent = pass->getParent();
if (pass->getClearBuffers() != mViewport->getClearBuffers() ||
pass->getClearColour() != mViewport->getBackgroundColour() ||
passParent->getVisibilityMask() != mViewport->getVisibilityMask() ||
passParent->getMaterialScheme() != mViewport->getMaterialScheme() ||
passParent->getShadowsEnabled() != mViewport->getShadowsEnabled())
{
// recompile if viewport settings are different
pass->setClearBuffers(mViewport->getClearBuffers());
pass->setClearColour(mViewport->getBackgroundColour());
passParent->setVisibilityMask(mViewport->getVisibilityMask());
passParent->setMaterialScheme(mViewport->getMaterialScheme());
passParent->setShadowsEnabled(mViewport->getShadowsEnabled());
_compile();
}
Camera *cam = mViewport->getCamera();
if (cam)
{
/// Prepare for output operation
preTargetOperation(mOutputOperation, mViewport, cam);
}
}
示例8: while
//-----------------------------------------------------------------------
void CompositorInstance::_compileTargetOperations(CompiledState &compiledState)
{
/// Collect targets of previous state
if(mPreviousInstance)
mPreviousInstance->_compileTargetOperations(compiledState);
/// Texture targets
CompositionTechnique::TargetPassIterator it = mTechnique->getTargetPassIterator();
while(it.hasMoreElements())
{
CompositionTargetPass *target = it.getNext();
TargetOperation ts(getTargetForTex(target->getOutputName()));
/// Set "only initial" flag, visibilityMask and lodBias according to CompositionTargetPass.
ts.onlyInitial = target->getOnlyInitial();
ts.visibilityMask = target->getVisibilityMask();
ts.lodBias = target->getLodBias();
ts.shadowsEnabled = target->getShadowsEnabled();
/// Check for input mode previous
if(target->getInputMode() == CompositionTargetPass::IM_PREVIOUS)
{
/// Collect target state for previous compositor
/// The TargetOperation for the final target is collected seperately as it is merged
/// with later operations
mPreviousInstance->_compileOutputOperation(ts);
}
/// Collect passes of our own target
collectPasses(ts, target);
compiledState.push_back(ts);
}
}
示例9: isInputToOutputTarget
//---------------------------------------------------------------------
bool CompositorManager::isInputToOutputTarget(CompositorInstance* inst, const Ogre::String& localName)
{
CompositionTargetPass* tp = inst->getTechnique()->getOutputTargetPass();
CompositionTargetPass::PassIterator pit = tp->getPassIterator();
while(pit.hasMoreElements())
{
CompositionPass* p = pit.getNext();
for (size_t i = 0; i < p->getNumInputs(); ++i)
{
if (p->getInput(i).name == localName)
return true;
}
}
return false;
}
示例10: _compileOutputOperation
//-----------------------------------------------------------------------
void CompositorInstance::_compileOutputOperation(TargetOperation &finalState)
{
/// Final target
CompositionTargetPass *tpass = mTechnique->getOutputTargetPass();
/// Logical-and together the visibilityMask, and multiply the lodBias
finalState.visibilityMask &= tpass->getVisibilityMask();
finalState.lodBias *= tpass->getLodBias();
if(tpass->getInputMode() == CompositionTargetPass::IM_PREVIOUS)
{
/// Collect target state for previous compositor
/// The TargetOperation for the final target is collected seperately as it is merged
/// with later operations
mPreviousInstance->_compileOutputOperation(finalState);
}
/// Collect passes
collectPasses(finalState, tpass);
}
示例11: _init
void _init(void)
{
CompositorPtr compositor = CompositorManager::getSingleton().create(
_theType(), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
CompositionTechnique *t;
CompositionTechnique::TextureDefinition *td;
CompositionTargetPass *tp;
CompositionPass *pass;
t = compositor->createTechnique();
td = t->createTextureDefinition("scene");
td->width.viewport = 1;
td->height.viewport = 1;
td->format = PF_X8R8G8B8;
td = t->createTextureDefinition("heat");
td->width.viewport = 0.5;
td->height.viewport = 0.5;
td->format = PF_X8R8G8B8;
tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_PREVIOUS);
tp->setOutputName("scene");
tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
tp->setOutputName("heat");
pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
pass->setMaterialName("PostFilters/HeatVision/LightToHeat");
pass->setInput(0, "scene");
pass->setIdentifier(0xDEADBADE);
tp = t->getOutputTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
pass->setMaterialName("PostFilters/HeatVision/Blur");
pass->setInput(0, "heat");
}
示例12: isSupported
//-----------------------------------------------------------------------
bool CompositionTechnique::isSupported(bool acceptTextureDegradation)
{
// A technique is supported if all materials referenced have a supported
// technique, and the intermediate texture formats requested are supported
// Material support is a cast-iron requirement, but if no texture formats
// are directly supported we can let the rendersystem create the closest
// match for the least demanding technique
// Check output target pass is supported
if (!mOutputTarget->_isSupported())
{
return false;
}
// Check all target passes is supported
TargetPasses::iterator pi, piend;
piend = mTargetPasses.end();
for (pi = mTargetPasses.begin(); pi != piend; ++pi)
{
CompositionTargetPass* targetPass = *pi;
if (!targetPass->_isSupported())
{
return false;
}
}
TextureDefinitions::iterator i, iend;
iend = mTextureDefinitions.end();
TextureManager& texMgr = TextureManager::getSingleton();
for (i = mTextureDefinitions.begin(); i != iend; ++i)
{
TextureDefinition* td = *i;
// Firstly check MRTs
if (td->formatList.size() >
Root::getSingleton().getRenderSystem()->getCapabilities()->getNumMultiRenderTargets())
{
return false;
}
for (PixelFormatList::iterator pfi = td->formatList.begin(); pfi != td->formatList.end(); ++pfi)
{
// Check whether equivalent supported
if(acceptTextureDegradation)
{
// Don't care about exact format so long as something is supported
if(texMgr.getNativeFormat(TEX_TYPE_2D, *pfi, TU_RENDERTARGET) == PF_UNKNOWN)
{
return false;
}
}
else
{
// Need a format which is the same number of bits to pass
if (!texMgr.isEquivalentFormatSupported(TEX_TYPE_2D, *pfi, TU_RENDERTARGET))
{
return false;
}
}
}
//Check all render targets have same number of bits
if( !Root::getSingleton().getRenderSystem()->getCapabilities()->
hasCapability( RSC_MRT_DIFFERENT_BIT_DEPTHS ) && !td->formatList.empty() )
{
PixelFormat nativeFormat = texMgr.getNativeFormat( TEX_TYPE_2D, td->formatList.front(),
TU_RENDERTARGET );
size_t nativeBits = PixelUtil::getNumElemBits( nativeFormat );
for( PixelFormatList::iterator pfi = td->formatList.begin()+1;
pfi != td->formatList.end(); ++pfi )
{
PixelFormat nativeTmp = texMgr.getNativeFormat( TEX_TYPE_2D, *pfi, TU_RENDERTARGET );
if( PixelUtil::getNumElemBits( nativeTmp ) != nativeBits )
{
return false;
}
}
}
}
// Must be ok
return true;
}
示例13: _init
void _init(void)
{
CompositorPtr compositor = CompositorManager::getSingleton().create(
_theType(), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
CompositionTechnique *t;
CompositionTechnique::TextureDefinition *td;
CompositionTargetPass *tp;
CompositionPass *pass;
t = compositor->createTechnique();
td = t->createTextureDefinition("scene");
td->width.viewport = 1;
td->height.viewport = 1;
td->format = PF_X8R8G8B8;
td = t->createTextureDefinition("blur0");
td->width.viewport = 0.5;
td->height.viewport = 0.5;
td->format = PF_X8R8G8B8;
td = t->createTextureDefinition("blur1");
td->width.viewport = 0.5;
td->height.viewport = 0.5;
td->format = PF_X8R8G8B8;
tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_PREVIOUS);
tp->setOutputName("scene");
tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
tp->setOutputName("blur0");
pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
pass->setMaterialName("PostFilters/Floodlighting/DownSample");
pass->setInput(0, "scene");
tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
tp->setOutputName("blur1");
pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
pass->setMaterialName("PostFilters/Floodlighting/BlurHorizontal");
pass->setInput(0, "blur0");
tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
tp->setOutputName("blur1");
pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
pass->setMaterialName("PostFilters/Floodlighting/BlurVertical");
pass->setInput(0, "blur0");
tp = t->getOutputTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
pass->setMaterialName("PostFilters/Floodlighting/Blend");
pass->setInput(0, "scene");
pass->setInput(1, "blur1");
pass->setIdentifier(0xDEADBADE);
mBlurAmount = 0.2f;
mShineAmount = 0.3f;
// receive default parameters from material script
if (!pass->getMaterial().isNull())
{
GpuProgramParametersSharedPtr parameters = pass->getMaterial()->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
#if OGRE_VERSION >= 0x010300
const GpuConstantDefinition* def;
def = parameters->_findNamedConstantDefinition("blur_amount");
if (def)
parameters->_readRawConstants(def->physicalIndex, 1, &mBlurAmount);
def = parameters->_findNamedConstantDefinition("shine_amount");
if (def)
parameters->_readRawConstants(def->physicalIndex, 1, &mShineAmount);
#else
GpuProgramParameters::RealConstantEntry* entry;
entry = parameters->getNamedRealConstantEntry("blur_amount");
if (entry && entry->isSet)
mBlurAmount = entry->val[0];
entry = parameters->getNamedRealConstantEntry("shine_amount");
if (entry && entry->isSet)
mShineAmount = entry->val[0];
#endif
}
}
示例14: refreshCompositor
//.........这里部分代码省略.........
mGBufferLogic = new GBufferLogic();
mGBufferLogic->setApp(this);
cmp.registerCompositorLogic("GBuffer", mGBufferLogic);
}
if (cmp.getByName("Motion Blur").isNull())
{
// Motion blur has to be created in code
CompositorPtr comp3 = cmp.create(
"Motion Blur", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
CompositionTechnique *t = comp3->createTechnique();
t->setCompositorLogicName("Motion Blur");
{
CompositionTechnique::TextureDefinition *def = t->createTextureDefinition("scene");
def->width = 0;
def->height = 0;
def->formatList.push_back(PF_R8G8B8);
}
{
CompositionTechnique::TextureDefinition *def = t->createTextureDefinition("sum");
def->width = 0;
def->height = 0;
def->formatList.push_back(PF_R8G8B8);
}
{
CompositionTechnique::TextureDefinition *def = t->createTextureDefinition("temp");
def->width = 0;
def->height = 0;
def->formatList.push_back(PF_R8G8B8);
}
/// Render scene
{
CompositionTargetPass *tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_PREVIOUS);
tp->setOutputName("scene");
}
/// Initialisation pass for sum texture
{
CompositionTargetPass *tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_PREVIOUS);
tp->setOutputName("sum");
tp->setOnlyInitial(true);
}
/// Do the motion blur
{
CompositionTargetPass *tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
tp->setOutputName("temp");
{ CompositionPass *pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
pass->setMaterialName("Ogre/Compositor/Combine");
pass->setIdentifier(120);
pass->setInput(0, "scene");
pass->setInput(1, "sum");
}
}
/// Copy back sum texture
{
CompositionTargetPass *tp = t->createTargetPass();
tp->setInputMode(CompositionTargetPass::IM_NONE);
tp->setOutputName("sum");
{ CompositionPass *pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERQUAD);
pass->setMaterialName("Ogre/Compositor/Copyback");
pass->setInput(0, "temp");
示例15: compName
//-----------------------------------------------------------------------
void CompositorChain::createOriginalScene()
{
/// Create "default" compositor
/** Compositor that is used to implicitly represent the original
render in the chain. This is an identity compositor with only an output pass:
compositor Ogre/Scene
{
technique
{
target_output
{
pass clear
{
/// Clear frame
}
pass render_scene
{
visibility_mask FFFFFFFF
render_queues SKIES_EARLY SKIES_LATE
}
}
}
};
*/
// If two viewports use the same scheme but differ in settings like visibility masks, shadows, etc we don't
// want compositors to share their technique. Otherwise both compositors will have to recompile every time they
// render. Thus we generate a unique compositor per viewport.
String compName("Ogre/Scene/");
compName += StringConverter::toString((intptr_t)mViewport);
mOriginalSceneScheme = mViewport->getMaterialScheme();
CompositorPtr scene = CompositorManager::getSingleton().getByName(compName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
if (scene.isNull())
{
scene = CompositorManager::getSingleton().create(compName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
CompositionTechnique *t = scene->createTechnique();
t->setSchemeName(StringUtil::BLANK);
CompositionTargetPass *tp = t->getOutputTargetPass();
tp->setVisibilityMask(0xFFFFFFFF);
{
CompositionPass *pass = tp->createPass();
pass->setType(CompositionPass::PT_CLEAR);
}
{
CompositionPass *pass = tp->createPass();
pass->setType(CompositionPass::PT_RENDERSCENE);
/// Render everything, including skies
pass->setFirstRenderQueue(RENDER_QUEUE_BACKGROUND);
pass->setLastRenderQueue(RENDER_QUEUE_SKIES_LATE);
}
/// Create base "original scene" compositor
scene = CompositorManager::getSingleton().load(compName,
ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
}
mOriginalScene = OGRE_NEW CompositorInstance(scene->getSupportedTechnique(), this);
}