示例#1
0
void Camera::drawFilter() {

	if(!filterShaderMaterial)
		return;

	CoreServices::getInstance()->getRenderer()->bindFrameBufferTexture(originalSceneTexture);
//	CoreServices::getInstance()->getRenderer()->bindFrameBufferTexture(zBufferSceneTexture);	
	parentScene->Render();
	CoreServices::getInstance()->getRenderer()->unbindFramebuffers();

	ShaderBinding* materialBinding;		
	for(int i=0; i < filterShaderMaterial->getNumShaders(); i++) {
		materialBinding = filterShaderMaterial->getShaderBinding(i);
		CoreServices::getInstance()->getRenderer()->applyMaterial(filterShaderMaterial, localShaderOptions[i], i);		
		if(i==filterShaderMaterial->getNumShaders()-1) {
				CoreServices::getInstance()->getRenderer()->clearScreen();
				CoreServices::getInstance()->getRenderer()->loadIdentity();
				CoreServices::getInstance()->getRenderer()->drawScreenQuad(CoreServices::getInstance()->getRenderer()->getXRes(), CoreServices::getInstance()->getRenderer()->getYRes());		
		} else {
			for(int j=0; j < materialBinding->getNumOutTargetBindings(); j++) {
				CoreServices::getInstance()->getRenderer()->bindFrameBufferTexture(materialBinding->getOutTargetBinding(j)->texture);
				CoreServices::getInstance()->getRenderer()->drawScreenQuad(materialBinding->getOutTargetBinding(j)->width, materialBinding->getOutTargetBinding(j)->height);
				CoreServices::getInstance()->getRenderer()->unbindFramebuffers();
			}		
		}
		CoreServices::getInstance()->getRenderer()->clearShader();
		CoreServices::getInstance()->getRenderer()->loadIdentity();
	}

}
示例#2
0
void Screen::drawFilter() {
	
	if(!filterShaderMaterial)
		return;
	
	Renderer *renderer = CoreServices::getInstance()->getRenderer();
	
	renderer->bindFrameBufferTexture(originalSceneTexture);
	
	Render();
	renderer->unbindFramebuffers();
	
	ShaderBinding* materialBinding;		
	for(int i=0; i < filterShaderMaterial->getNumShaders(); i++) {
		materialBinding = filterShaderMaterial->getShaderBinding(i);
		
		for(int j=0; j < materialBinding->getNumColorTargetBindings(); j++) {
			RenderTargetBinding *colorBinding = materialBinding->getColorTargetBinding(j);
			materialBinding->clearTexture(colorBinding->name);
			materialBinding->addTexture(colorBinding->name, originalSceneTexture);
		}
		
		renderer->applyMaterial(filterShaderMaterial, localShaderOptions[i], i);	
			
		if(i==filterShaderMaterial->getNumShaders()-1) {
			renderer->loadIdentity();
			renderer->drawScreenQuad(renderer->getXRes(), renderer->getYRes());		
		} else {
			for(int j=0; j < materialBinding->getNumOutTargetBindings(); j++) {
				renderer->bindFrameBufferTexture(materialBinding->getOutTargetBinding(j)->texture);
				
				renderer->drawScreenQuad(materialBinding->getOutTargetBinding(j)->width, materialBinding->getOutTargetBinding(j)->height);
				renderer->unbindFramebuffers();
			}						
		}
		renderer->clearShader();
		renderer->loadIdentity();		
		renderer->setOrthoMode();
	}
	
}
示例#3
0
void Camera::drawFilter(Texture *targetTexture, Number targetTextureWidth, Number targetTextureHeight, Texture *targetColorTexture, Texture *targetZTexture) {

	if(!filterShaderMaterial)
		return;
		
	Texture *finalTargetColorTexture;
	Texture *finalTargetZTexture;	
		
	if(targetTexture) {	
		finalTargetColorTexture = targetColorTexture;
		finalTargetZTexture = targetZTexture;		
		CoreServices::getInstance()->getRenderer()->setViewportSize(targetTextureWidth, targetTextureHeight);		
	} else {
		finalTargetColorTexture = originalSceneTexture;
		finalTargetZTexture = zBufferSceneTexture;	
		CoreServices::getInstance()->getRenderer()->setViewportSize(CoreServices::getInstance()->getRenderer()->getXRes(), CoreServices::getInstance()->getRenderer()->getYRes());
	}
	CoreServices::getInstance()->getRenderer()->bindFrameBufferTexture(finalTargetColorTexture);
	CoreServices::getInstance()->getRenderer()->bindFrameBufferTextureDepth(finalTargetZTexture);
	parentScene->Render(this);
	CoreServices::getInstance()->getRenderer()->unbindFramebuffers();


	ShaderBinding* materialBinding;		
	for(int i=0; i < filterShaderMaterial->getNumShaders(); i++) {
		materialBinding = filterShaderMaterial->getShaderBinding(i);
		
		for(int j=0; j < materialBinding->getNumColorTargetBindings(); j++) {
			RenderTargetBinding *colorBinding = materialBinding->getColorTargetBinding(j);
			materialBinding->clearTexture(colorBinding->name);
			materialBinding->addTexture(colorBinding->name, finalTargetColorTexture);
		}

		for(int j=0; j < materialBinding->getNumDepthTargetBindings(); j++) {
			RenderTargetBinding *depthBinding = materialBinding->getDepthTargetBinding(j);
			materialBinding->clearTexture(depthBinding->name);
			materialBinding->addTexture(depthBinding->name, finalTargetZTexture);
		}
		
		CoreServices::getInstance()->getRenderer()->applyMaterial(filterShaderMaterial, localShaderOptions[i], i);		
		if(i==filterShaderMaterial->getNumShaders()-1) {
				if(targetTexture) {
					CoreServices::getInstance()->getRenderer()->setViewportSize(targetTextureWidth, targetTextureHeight);	
					CoreServices::getInstance()->getRenderer()->bindFrameBufferTexture(targetTexture);								
					CoreServices::getInstance()->getRenderer()->clearScreen();
					CoreServices::getInstance()->getRenderer()->loadIdentity();

					CoreServices::getInstance()->getRenderer()->drawScreenQuad(targetTextureWidth, targetTextureHeight);
					CoreServices::getInstance()->getRenderer()->unbindFramebuffers();									
				} else {
					CoreServices::getInstance()->getRenderer()->setViewportSize(CoreServices::getInstance()->getRenderer()->getXRes(), CoreServices::getInstance()->getRenderer()->getYRes());
					CoreServices::getInstance()->getRenderer()->clearScreen();
					CoreServices::getInstance()->getRenderer()->loadIdentity();
					CoreServices::getInstance()->getRenderer()->drawScreenQuad(CoreServices::getInstance()->getRenderer()->getXRes(), CoreServices::getInstance()->getRenderer()->getYRes());
				}
		} else {
			for(int j=0; j < materialBinding->getNumOutTargetBindings(); j++) {
				Texture *bindingTexture = materialBinding->getOutTargetBinding(j)->texture;
				if(bindingTexture) {
					CoreServices::getInstance()->getRenderer()->setViewportSize(bindingTexture->getWidth(), bindingTexture->getHeight());
					CoreServices::getInstance()->getRenderer()->bindFrameBufferTexture(bindingTexture);				
					CoreServices::getInstance()->getRenderer()->drawScreenQuad(bindingTexture->getWidth(), bindingTexture->getHeight());
					CoreServices::getInstance()->getRenderer()->unbindFramebuffers();
				}
			}		
		}
		CoreServices::getInstance()->getRenderer()->clearShader();
		CoreServices::getInstance()->getRenderer()->loadIdentity();
	}
}