Advanced Effects

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

DEPTH BLURRED FOG

I tried "Depth Based Blurring" in addition to "Depth Based Fog"..
The problem was:
I needed a Buffer rendered by an "8 Bit Geo Depth Shader"
(8 bit grey rather than 24 bit grey, duh) that would be "Added" in a Buffer Pass
that would "Lerp" the Fog into the render ('before' H and V Depth Based Blurring).
(Fog colour hard coded at (0.5, 0.5 ,0.5) )

But.. This would add "Inter Buffer Renderpasses" which takes time, so I
carefully transplanted the "Fog Calculation" into the
"Horizontal" Depth Based Blur shader.. (original 24 bit Geo Shader used for depth image)

This worked fine, but there were these funny Horizontal or Vertical streaks depending on whether
I injected fog into the H or V Blur..

So I decided to transplant the Fog Calcs into BOTH H and V Blur shaders and scale them each by X..
Crazy Idea but the quality came out quite good..

As an extra spinoff it caused the SSAO parameters to be less critical
in a world as large as this! It also helped a lot with the "Shimmies".
(the visible ones can be helped with good nmodelling)

So now this effect is no longer a set of H and V Depth Based Blur shaders, but rather
a Fog Shader on Streroids that blurs by depth!

But wait.. What was that about 24 bit grey being the same as 8 bit grey?
Er, now I'm not so sure, because 8 bit grey gives these funny stripes near the viewer
(on the water surface) where 24 bit grey alleviates this!

So, There is a choice between 8 and 24 bit because 8 bit can still be acceptable where
textures are not as uniform as water like rocks fo instance..

On the other hand, there might be something about the way the 24 bit Geo Shader outputs
the Red Channel (which I understand to be the Depth as it would be had it been 8 bit)..
(see the shader code)
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Here is only the Horizontal Blurrer..

Code: Select all

 
 
 #version 120
 
 uniform sampler2D Image01; // The render to be blurred..
 uniform sampler2D Image02; // In this case a 24 bit "Packed" Image from a Geo Depth Shader..(Alpha is for Clipping)..
 uniform float     BufferWidth;
 uniform float     GeneralStrength;
 
 // WE CAN "CHOOSE" TO USE HIGH DEF DEPTH..
 // 8-bit grey and 24 bit grey is visually very much the same thing! (oh really?)
 float UnPackDepth_002(vec3 RGBDepth) 
  {return RGBDepth.x + (RGBDepth.y / 255.0) + (RGBDepth.z / 65535.0);
  }
 
 void main()
  {vec4 DepthColour = texture2D(Image02, gl_TexCoord[0].xy);
   float blurSize = DepthColour.x * (1.0 /  BufferWidth)  * GeneralStrength; 
   vec4 finalCol = vec4(0.0);
   // gauss distribution with mean:0 std:2
   float weight[9];
   weight[0] = 0.0295;    weight[1] = 0.0673;
   weight[2] = 0.1235;    weight[3] =   0.1786;
   weight[4] = 0.2022;    weight[5] = 0.1786;
   weight[6] = 0.1235;    weight[7] = 0.0673;
   weight[8] = 0.0295;
   // Blur in x (horizontal)
   // Take samples with distance blurSize between them
   for (int i=0; i<9; i++)
    {finalCol += texture2D(Image01, vec2(gl_TexCoord[0].x+(i - 4)*blurSize, gl_TexCoord[0].y))*weight[i]+0.00;
    }
   // To induce a "Squared Curve" we first need to "invert" the value..
   // float FogLerper = 1.0 - (DepthColour.x * 0.75); // A bit faster but Fog grey domain borders are visible at places..
   float FogLerper = 1.0 - (UnPackDepth_002(DepthColour.xyz) * 0.75); // SIGNIFICANT quality increase..
   FogLerper *= FogLerper;
   FogLerper = 1.0 - FogLerper;
   gl_FragColor =  mix(finalCol.xyzw, vec4(0.5, 0.5, 0.5, DepthColour.w), FogLerper);
   // gl_FragColor.xyz = finalCol.xyz; // Original output..
   // gl_FragColor.w = DepthColour.w; // Keep our clipping intact..
  } 
 
 


Here's some shots..
Last edited by Vectrotek on Thu Dec 08, 2016 5:04 pm, edited 1 time in total.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Without any SSAO, Depth Based Blurring and Fog..
Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

With SSAO, Depth Based Blurring and Fog..
(could be used to simulate heavy weather etc)
Image
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Re: Advanced Effects

Post by Virion »

So far the most realistic graphics I've seen on Irrlicht forum :O :O
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Thanks Virion! I whish I could model like those guys on 3f3dm..
I am working on my own modelling skills though.. :?

Also I just discovered that the last project I posted had an "irrlicht.dll" that I compiled my self
and when I moved to Windows 7 I forgot all about that!
So if anyone tried to run the program and got bogus, just recompile it and use your own dll..

Another thing is that I wanted to post a DEMO with this model.. But it is quite big..
I don't want to post things that people can't run especially if its big..

Also I discovered that Audierre "sometimes" don't play nice with with tracks in "*.mod", "*.xm" etc..
The only format I feel is quite stable with Audierre is "*.it" (Impulse tracker)..
There is alot of options when saveing these things in "ModPlug Tracker" (I got a lot to learn)

I think I should disable the download for that project even if it is the first one I posted with my new
"Inter Buffer Non Linear Effect System"..

What modelling programs do you like to use?
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Oh! The same thing happened to my Audierre DLL which I compiled.
So I do the transition to 64 bit Windows and I forget that all the apps I installed now has fresh LIBS..
(not my compiled libs)
The libraries in the IDE directories didn't survive the transition so even the audierre libraries
may cause problems.. Well now it seems fixed.. I was just about to format everything and reinstall..

Phew..
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Too much wen't wrong..
Formatted my machine and reinstalled everything in 7 hours flat..
O.K.>
IrrDeveloper
Posts: 3
Joined: Fri Jun 17, 2016 10:17 am

Re: Advanced Effects

Post by IrrDeveloper »

Hello Vectorek,

Playing around with adding SSAO to my own Irrlicht project, but it's top down view, hope SSAO is worth it for smallish player characters. BTW your work looks great! Did you really post the demo/project?
Want to have a look at it but can't find any link in your posts above, just the screenshots. Am I missing something?
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

@IrrDeveloper..
Hi! I did post a project but when I changed from 32 to 64 bit a few things went wrong..
The project I posted was a bit dicey, so I decided to kill the link.
I'll post it again as soon as I got a good example in terms of the "data size" which can get quite big.

Anyhow thanks for the comment! :)
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

If I don't convert all my polygons to triangles there seems to be a leak of some sort..
Could this have something to do with Irrlicht's method of turning Quads etc to Tris?
Maybe something deeper on the side of Hardware in GL or DX?
Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

Anyhow, I'm trying to get some kind of "Standard Metrics" for my game worlds
and found that if you design a section of, say a level in such a way that it can be
cloned along an axis at a given distance a lot of grunt work can be avoided..

Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

I base everything in the world around the size of a Character..
The character in Blender (my chosen app) is at 10 x 10 x 20 units..
Then building around this standard size in blender where the height of a standard
building at 4 units.. So When I export I scale to 10.0 then a 10 x 10 x 20 character
fits nicely in a standardized form into the world ..

Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

All the cubes are 1 x 1 unit in while modelling. (here char is (10x10x20) / 10 high = 1 x 1 x 2)..
The cubes are not really cubes but 1 x 1 squares that can be extruded in any direction in the same
way Sauerbratten's cool level editor does it..

Obviously large amounts of these squares are converted to bigger faces and "triangularized"
before export..
Image
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Advanced Effects

Post by Vectrotek »

With STRICT "World Metric Modular Rules" the task of animating a character such
as walking up and down stairs could be a bit easier..
Image
These "cubes" are now at 0.5 x 0.5 x 0.5 which was an accidental subdivide!
(had to start over)
Post Reply