xml based postprocessing framework

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
tbw
Posts: 59
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Post by tbw »

the sketch effect should look like this:

Image

maybe the shadercode is not the best. It was my bumbling trial to translate the shader to glsl found on http://www.talula.demon.co.uk/postproce ... ssing.html
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Post by REDDemon »

sorry i mistiped it. It was the Scratched effect that gives me a black screen. Pencil Scetch works correctly.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
tbw
Posts: 59
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Post by tbw »

scratched should look like this
(shader is taken directly from nvidia shader library)

Image
the white lines are moving over the screen

I have no idea whats wrong with it....

EDIT:

I testet it on an ATI card and it seems that the original nvidia shader does not run on an ATI card (surprise, srprise ... )
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Wow! Thanks! That little detail made it work (using prepare before)

Now it work! Here is the invert filter working at last! Now it's integrated in my current project. Thanks! I'll put your name in the credits.

Image

If this is not added to IRRlicht, it should at least goes into IRRext!

Anybody have a hint how to create a post shader that could draw occluded part of a character over the geometry? I will also have to find out when the character is hidden by something. I was thinking of using the depth buffer as a mask...

Here is an example (taken from Left 4 Dead)
Image

I would like to have the same thing in my current project (IRB), when the character is behind something.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: xml based postprocessing framework

Post by Granyte »

i'm getting a wierd issue

1>PostProcessManager.cpp(91): error C2039: 'empty' : is not a member of 'irr::core::string<T>'
1> with
1> [
1> T=wchar_t
1> ]
1>PostProcessMan

when i try to compile the original project

any hint or anything?
tbw
Posts: 59
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Re: xml based postprocessing framework

Post by tbw »

the empty method is not available in the irrlicht 1.7.2 version, but in the svn trunk.

replace

Code: Select all

if (strDummy.emtpty())
with

Code: Select all

if (strDummy == "")
then it should compile with the current 1,7.2 version (the alternative is to compile against the irrlicht development trunk)
hope this will help you
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: xml based postprocessing framework

Post by Granyte »

i switched to the SVN trunk because there were other issues to solve to adapt it to 1.7.2 and while i'm at it it keep my code up to date


but now i have a new issue i tryed to add an aditional test shader but i can't get it to work properly
i added it to Effect.xml and PostProcessManager.h but nothing show up when i try to run it i would at least expect some randoom artifact if my shader code was wrong

do i neet to define aditional RTT in the config file even if the shader should use aux input and ox output?
tbw
Posts: 59
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Re: xml based postprocessing framework

Post by tbw »

Hello Granyte,

if you don't need an additional texture for your shader, there is no need to touch the rtt.xml.
In the effect.xml you must take care that your effect id corresponds to the newly added effect enum.
Please post the effect section of the effect.xml with your new effect. Maybe it helps solving this issue.
Another possibility is that your shader does not compile correctly ...
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: xml based postprocessing framework

Post by Granyte »

Code: Select all

<!-- EPPE_FAKESSAO = 25 -->
  <Effect id="24" name="FakeSSAO">
    <ShaderPostProcess name="Fakessao" vsFile="vertex.fx" vsType="0" psFile="SSAOish v2.fx" psType="4" >
      <PixelShaderConstant name="curve_base" value="-6" />
      <Texture index="0" textureClamp="1" />
      <RenderSource path="auxIn" />
      <RenderTarget path="auxOut" />
    </ShaderPostProcess>
  </Effect>

Code: Select all

        EPPE_DEPTH_OF_FIELD,
        EPPE_VIGNETTE,
        EPPE_FAKESSAO,
        EPPE_COUNT
};
my first atempt was to convert Xeffect's SSAO effecto for use with your frame work but that required a view projection matrix wich it aparently the only matrix your frame work does not provide but i burnt my self trying to edit your code so i found a fake SSAO shader on the web and tryed to edit it

Code: Select all

 
uniform sampler2D SceneBuffer : register(s0);
uniform int curve_base;
 
float4 main( float2 texCoord : TEXCOORD0 ) : COLOR
{
        float4 Color, Mask, Final;
        float lum,dev,curve;
 
        Color = tex2D( SceneBuffer, texCoord );
        
        //calc the luminosity of each pixel, channel independent (gives a grayscale)
        lum = ( Color.r + Color.g + Color.b ) / 3;
 
        //curve the colors (use the lum map)
        lum = 4 - ( lum * ( 1 / pow( lum, 2 ) ) );
        lum = smoothstep(curve_base, 3, lum);
        curve = (0.15 * pow(lum,3)) + 0.85;
        //curve = 1-curve;
        curve += 0.075;
        Color = Color * curve;
 
        return Color;
        //return (255,50,50,255);
}
 
then again might have failed there i'm wuite new to shaders and trying to learn more

the commented return was a desesperate atempt to see some sort of artifact to be sure something was showing up but no avail that to failed
tbw
Posts: 59
Joined: Sat Jan 15, 2011 9:51 am
Location: Germany

Re: xml based postprocessing framework

Post by tbw »

Code: Select all

<!-- EPPE_FAKESSAO = 25 -->
  <Effect id="24" name="FakeSSAO">
    <ShaderPostProcess name="Fakessao" vsFile="vertex.fx" vsType="0" psFile="SSAOish v2.fx" psType="4" >
      <PixelShaderConstant name="curve_base" value="-6" />
      <Texture index="0" textureClamp="1" />
      <RenderSource path="auxIn" />
      <RenderTarget path="auxOut" />
    </ShaderPostProcess>
  </Effect>
here you have to replace

Code: Select all

<Effect id="24" name="FakeSSAO">
with

Code: Select all

  <Effect id="25" name="FakeSSAO">
the right id currently appears only in the xml comment, so with this xml input you overwrite the vignette effect!
regarding shader constants you have the choice:

Code: Select all

enum E_SHADER_CONSTANT
{
        ESC_TIME =  0x1,
        ESC_RANDOM = 0x2,
        ESC_BUFFERWIDTH = 0x4,
        ESC_BUFFERHEIGHT =  0x8,
        ESC_PROJECTION = 0x10,
        ESC_VIEW =  0x20,
        ESC_WORLD = 0x40,
        ESC_WORLDVIEW = 0x80,
        ESC_WORLDVIEWPROJ = 0x100
};
Please take a look into the xml comment of the effect.xml. for example with this line in the effect.xml.

Code: Select all

<ShaderPostProcess name="Fakessao" vsFile="vertex.fx" vsType="0" psFile="SSAOish v2.fx" psType="4" psUseWorldViewProj="1">
and additionally

Code: Select all

uniform float4x4 WorldViewProjMatrix;
in your pixel shader you have access to the world view projection matrix. The view matrix, the projection matrix and the world matrix can be passed in the same manner.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: xml based postprocessing framework

Post by Granyte »

the shader i originaly tryed updating is the one from Xeffect and it really use the viewproj matrix not the world view proj so i tryed passing the view and the proj matrix and combining them but ... fail so i tryed adding the view proj to your code fail to on my side


anyway i now have the fake ssao working and it's a failt to the shader output a white background but that's propably the shader i use i'll get working on it since now it at least work

i can't belive i missed the =24 thanks for that
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: xml based postprocessing framework

Post by christianclavet »

Have somebody tested that on OPEN GL with an ATI/intel cards? I was trying my application my Zino HD HTPC (Use a ATI RADEON HD 5450) (I have a NVidia card in my main computer), and I see compilation failing messages for all the shaders... Are the shaders designed only for NVidia? (Most of the compilation failure come back as syntax errors?!)

EDIT: Tested my card with the GPU CAP VIEWER and it report that the card current driver support OPENGL 4.0 and GLSL 4.0. So it should not be a driver issue with open gl.

Have another question, Is there a way to "fade" the shader effect?
Last edited by christianclavet on Wed Aug 10, 2011 7:41 pm, edited 1 time in total.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: xml based postprocessing framework

Post by Granyte »

is there open gl update like there is for directX?

i have the same issue using open GL (running dual 4850 mobility in cfx) but it does not surprise me amd and open GL on windows have never really been friend
Fury.
Posts: 25
Joined: Mon Dec 20, 2010 2:03 pm

Re: xml based postprocessing framework

Post by Fury. »

sure you just need to send a "blend" constant to a shader wich receives as input the screenshot before "myShader" is applied and after the "myShader" was applied and then just mix the two inputs according to the blend factor.

This is not the best way for fading displacement shader such as the water shader. In that case you should reduce the strenght of the effect gradually and then remove the post-p effect-
CQCex
Posts: 8
Joined: Thu Jul 21, 2011 11:25 pm
Location: Germany

Re: xml based postprocessing framework

Post by CQCex »

I'm not sure whether this has been discussed before, but a problem (=crash) occurs when
trying to render after some nodes, which had previously been added to the depth pass, have been deleted.
This seems to happen because the nodes had been added to DepthPassNodes by addNodeToDepthPass() and do not get removed from it
when the node is being removed.

This small function fixes the error, it should be called before the remove() function of the node:
void CPostProcessManager::removeNodeFromDepthPass(irr::scene::ISceneNode *node)
{
int n=DepthPassNodes.binary_search(node);
if(n!=-1)
DepthPassNodes.erase(n);
};
There might be some faster implementations, though.
Post Reply