Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Theora + Pixel Shader: Possible? What am I doing wrong?  (Read 1233 times)

atsakir

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
    • View Profile
Theora + Pixel Shader: Possible? What am I doing wrong?
« on: February 18, 2007, 06:56:11 AM »

I already posted this in the Ogre forums but I didn't get any responce so I repost it here if anyone can help.

We are trying to apply a simple alpha blur (antialiasing) shader on each frame of the video texture so that we can smooth out the edges that are clearly visible in the screenshot below  (this is for a ChromaKey renderer for video to RGBA).

Screenshot: The cubes are displayed from video where originally the background has the colour (255,0,255)
No antialiasing:

and these are three antialiasing techniques applied as a second pass during the video frame generation process:
3x1 blur:

cross blur (5-point sample)

3x3 blur:


the MovieLogic class of the Theora videoplugin uses a material like so:

Code: [Select]

mVideoControl->setInputName( movieName );
//Start paused so we can have audio
mVideoControl->setPlayMode( TextureEffectPause );
//! Used for attaching texture to Technique, State, and texture unit layer
mVideoControl->setTextureTecPassStateLevel( 0, 0, 0 );
//Set to true to allow for seeking - highly experimental though ;)
// mVideoControl->setSeekEnabled( false );
//This is mainly for OpenAL - but applies to other audio libs which
//use pooling instead of callbacks for updating...
//Let TheoraMovieClip update the audioclip.
mVideoControl->setAutoAudioUpdate( true );

mVideoControl->setRenderFx((Ogre::TextureSpecialRenderFX)2);
//mVideoControl->setRenderFx((Ogre::TextureSpecialRenderFX)0);
// Grab Our material, then add a new texture unit
MaterialPtr material = MaterialManager::getSingleton().getByName("Example/TheoraVideoPlayer/Play");

//Create the material the first time through this method
if( material.isNull() )
material = MaterialManager::getSingleton().create("Example/TheoraVideoPlayer/Play", "General");

material->getTechnique(0)->getPass(0)->createTextureUnitState();
LogManager::getSingleton().logMessage(material->getTechnique(0)->getPass(0)->getFragmentProgramName());
mVideoControl->setRenderFx(textureFX);
mVideoControl->createDefinedTexture( "Example/TheoraVideoPlayer/Play", "General" );
mClip = mVideoControl->getMaterialNameClip( "Example/TheoraVideoPlayer/Play" );


We have a material file where Example/TheoraVideoPlayer/Play is defined like so:

Code: [Select]

material Example/TheoraVideoPlayer/Play
{
technique
{
pass
{
scene_blend alpha_blend

fragment_program_ref Examples/BlurEdgesFP
{
}
}
}
}


Apparently, the texture unit is generated inside the video rendering code above. The problem is that the shader is not applied to the texture although
Code: [Select]
LogManager::getSingleton().logMessage(material->getTechnique(0)->getPass(0)->getFragmentProgramName());

prints out the correct fragment program.

Any ideas on how to apply a shader to a video frame texture once it has been generated from the video and before it is converted to a CEGUI texture to show on screen?

It appears that creating the texture in code is not the problem. I changed the code so that the texture is declared inside the material script but still the shader is not applied to the texture. The revised material script is as follows:
Code: [Select]

material Media\Videos\introTitles.ogg
{
technique
{
pass
{
fragment_program_ref Examples/BlurEdgesFP
{
}
texture_unit
{
texture_source ogg_video
{
filename Media\Videos\introTitles.ogg
}
}
}
}
}


Applying an antialias pass during rendering is slashing the framerate to half so doing it through the pixel shader is a must for this. I have also come across a Chromakey shader in cg that could further speed up the process but if I can't apply any shader to an ExternalTextureSource I can not use it.

in this post http://www.ogre3d.org/phpBB2/viewtopic.php?t=6465&highlight=external+texture+shader

tuan curanes says:
Quote
videoplugin is in ogreaddons cvs.
here's a topic on it :
http://www.ogre3d.org/phpBB2/viewtopic.php?t=2991&start=150&postdays=0&postorder=asc&highlight=
and some demos at the author website :
http://www.wreckedgames.com/

What you need it to check "external texture source" mechanism in Ogre.
(You'll even be able to add some shader filters on the results.)


So far I haven't been able to apply one. Any ideas?
pjcast or tuan curanes, please if you see this you might be able to help.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2653
    • View Profile
    • http://www.wreckedgames.com
Theora + Pixel Shader: Possible? What am I doing wrong?
« Reply #1 on: February 18, 2007, 07:36:56 PM »

I'm sorry, but I don't really have any experience using shaders. However, it should work. As, all the plugin does is write to the texture unit. Perhaps it has something to do with the pixel format the plugin creates. I'm not really sure, I can't be of much help until I get a better graphics card which supports shaders, so I can start playing around with them finally :D
Logged