Jump to content
Sign in to follow this  
myconid

Post-processing effects test (SSAO/HDR/Bloom)

Recommended Posts

Please do, it's better to have some work in progress, than for someone to disappear and all we have left is pretty screenshots (it happens) :) Also, I made a Trac ticket for advanced texture maps: http://trac.wildfire...com/ticket/1429 which seem to cover some or all of what you're working on. Feel free to take ownership of the ticket and post WIP patches there. Or you can create a new ticket in case that one is not a good fit.

I hear you. Speaking of patches, I shudder to think what horrible things I've done to the whitespace...! ;)

Looks great, I hope my old video card handle it :) If not, maybe a good excuse to get an upgrade ;)

I'm on a 4-Y.O. laptop with an ATI Mobility HD 4670, and the GPU is running on low-power settings. I get about 20 fps with SSAO, HDR, Bloom, normal maps and parallax maps enabled at the same time (and the first three are implemented really inefficiently, allocating/deallocating several large textures every frame).

Anyway, I should mention that I'm taking a slight detour from the plan I posted earlier. Before I delve into the terrain renderer, I'll take a shot at implementing specular and self-illumination maps for models (it ought to be trivial). I'd love to do precomputed AO as well, but that will require more drastic changes to the UV-loading code, so it'll have to wait.

An outstanding (non-)issue with the current tangent-space implementation is that animated objects do not support bump/parallax. This is due to my own laziness, as I'd have to transform the tangents on the CPU...

Share this post


Link to post
Share on other sites

The comparison pic is really good (though of course for a perfect effect, the textures ought to be slightly corrected).

Share this post


Link to post
Share on other sites

http://www.2shared.com/file/xOa3k6FI/bumpydiff.html

This contains the normal and parallax effects, not the screen-space effects.

To test:

Get a clean version of the code, extract the archive, patch the code with

patch -p0 -i bumpy.diff

in the 0ad base directory (that contains "source" and "binaries" directories), copy the four png files to binaries/data/mods/public/art/textures/skins/structural/, update workspaces and compile.

Look at the Roman civil centre and Roman arch models to see examples of the effects. To try adding your own, create or modify an "actor" file to use the player_trans_norm.xml material, and add "normal" and "specular" tags as in the examples (if the maps are not found bad things will happen).

The normal map uses the rgb channels for normal mapping and the alpha channel for a heightmap for parallax. The specular map uses the rgb channels for a specular colour and the alpha channel for the self-illumination factor.

Let me know what the performance is like when fully zoomed in -- that may need some tweaking.

Disclaimer: Not finished by any stretch of the imagination. Only tested on Linux/Ati.

If you do something cool with it, feel free to share! :)

Share this post


Link to post
Share on other sites

Not to sound like a broken record, but... Looks great. Keep up the good work. Think also about building windows for those night scene maps. Reminiscent of that age of empires 3 screenshot that can't be replicated in the released version of the game.

Share this post


Link to post
Share on other sites

Not to sound like a broken record, but... Looks great. Keep up the good work.

Much appreciated. :)

I'd like it if people tried the code and gave me some feedback, if possible. No need for anything fancy, just compile, run Oasis 10 and let me know if anything looks wrong, and how good or bad the performance is.

Think also about building windows for those night scene maps. Reminiscent of that age of empires 3 screenshot that can't be replicated in the released version of the game.

Yup, that's the idea!

In the long-term, there are a number of things I will/might try (sort of a wish list, in no particular order):

  • Post-processing effects done right with a dedicated "manager" component.
  • Generic lightmapping. The ability to load arbitrary textures with a separate UV set, and combine them on the model using a user-specified blending mode. For instance, an AO texture would use "multiply", while an emissive lightsource could use "add" or "lighten".
  • Moving textures. E.g. a waterfall could "translate" one or more texture layers at differing speeds to create the illusion of falling water.
  • Ground and distance fog.
  • Variable water level. Water is currently represented as a flat plane. It could use a low-resolution heightmap to have different heights in different parts of the map.
  • Fading line-of-sight. Fade between changes to the LOS texture, to give the effect of smooth movement (like in HoMM6).
  • Line-of-sight obstructions. Use a limited raycasting method to prevent units from seeing through walls or buildings (this makes the game more challenging).
  • Terrain erosion for map generation. Simulate the effects of water and/or wind erosion to create more realistic terrains and specialised terrain textures in Atlas.

Anyway, I really hope my experiments will not impinge on anyone's territory...! :whistling:

Edited by myconid
  • Like 3

Share this post


Link to post
Share on other sites

I'd like it if people tried the code and gave me some feedback, if possible. No need for anything fancy, just compile, run Oasis 10 and let me know if anything looks wrong, and how good or bad the performance is.

I have the open source radeon drivers


OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD RV770
OpenGL version string: 2.1 Mesa 8.1-devel (git-897af1d oneiric-oibaf-ppa)
OpenGL shading language version string: 1.20

This makes the shader fail completely because it requires shading language 1.4 support.

I can run http://nooshu.com/alteredq-a-webgl-ninja which claims to use displacement mapping, thought it looks slightly glitchy (scattered black pixels). This may not be of any relevance though.

Share this post


Link to post
Share on other sites

I have the open source radeon drivers


OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD RV770
OpenGL version string: 2.1 Mesa 8.1-devel (git-897af1d oneiric-oibaf-ppa)
OpenGL shading language version string: 1.20

This makes the shader fail completely because it requires shading language 1.4 support.

I can run http://nooshu.com/al...q-a-webgl-ninja which claims to use displacement mapping, thought it looks slightly glitchy (scattered black pixels). This may not be of any relevance though.

Sorry, that was a mistake on my part. It doesn't need 1.4 support, it should run with 1.2. The somewhat cleaned up version I put on Trac had that fixed.

Edit: Whoops. In the file model_common_norm.vs in the GLSL shaders directory, change the line


#version 140

to


#version 120

and it should stop complaining.

Edited by myconid

Share this post


Link to post
Share on other sites

Tested the updated patch bumpy2.diff with 140 changed to 120 and added the pngs.

My system: Ubuntu 12.04 + Radeon X1600 + mesa driver from git.

I get this console output, repeated many times (apparently we are asking too much from my old card):


r300: ERROR: FS input generic 20 unassigned, not enough hardware slots (it's not a bug, do not report it).
r300: ERROR: FS input generic 21 unassigned, not enough hardware slots (it's not a bug, do not report it).

and this image:

screenshot0001w.png

EDIT: myconid, which Ati card and driver (fglrx or mesa) are you using?

Edited by fabio

Share this post


Link to post
Share on other sites

I have the open source radeon drivers


OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD RV770
OpenGL version string: 2.1 Mesa 8.1-devel (git-897af1d oneiric-oibaf-ppa)
OpenGL shading language version string: 1.20

I'd suggest to update to precise, btw, I am no longer updating mesa drivers in my PPA on older Ubuntu versions.

Share this post


Link to post
Share on other sites

Also note that on other maps without the roman buildings I don't get the "r300 ERRORs" but the terrain flashes with a darker colour.

Share this post


Link to post
Share on other sites

Thanks for testing, fabio!

I'm using fglrx. I wasn't even aware the OSS driver was capable of 3d yet...

Anyway, looks like there are too many shader "outs", basically. Not a problem, since I left a bunch of stuff in there that isn't needed.

Could you try replacing model_common_norm.vs with this: http://pastebin.com/LxqDEfps

and model_common_norm.fs with this: http://pastebin.com/Zp5XxhFf

(no need to recompile)

You get the flashing terrain problem? Interesting. That bug has something to do with the shadowmap, and it's actually come up once before in this thread. Please ignore for now...

Edited by myconid

Share this post


Link to post
Share on other sites

Thanks, it no longer prints the "r300 ERRORs" and it works a bit better now: there is still the "pixellated" effect but not on the whole building as before:

screenshot0001x.png

Share this post


Link to post
Share on other sites

It is working fine for me now that I have changed 140 to 120. Your auto-generated normal/displacement map is pretty terrible for the roof tiles which makes it hard to see how well the shader is working. I made a rough improvement which I have attached. My screenshot uses this new map. On the roof sloping away from the camera the tiles seem to flatten at the top. It looks like clipping, I'm not sure what the cause would be though.

(I remember trying changing the version number previously and it still failed but that was using your first patch, or I might have done something else stupid. Anyway it works now so i am happy :))

(fabio: I am running Mint and haven't bothered to upgrade yet, thanks for letting me know)

Edit:

Looking at your shader it is clipping because you have float height = 0.5, so the top 50% of my displacement map gets clipped.

I found that these settings were nicer.

float scale = 0.008;

float height = 1.0;

This shows defects in my displacement map though (they are too pointy) I will try and correct it.

post-13166-0-49918800-1338204943_thumb.p

post-13166-0-87771700-1338204984_thumb.p

Share this post


Link to post
Share on other sites

Fabio, we'll have to isolate the problem before we can fix it (to the time machine!).

In the fragment shader (.fs), right before the main function there are four preprocessor switches:


#define USE_PARALLAX 1
#define USE_NORMAL_MAP 1
#define USE_SPECULAR_MAP 1
#define USE_SELF_LIGHT 1

Try setting them to 0 one at a time to check which effect is causing trouble.

quantumstate, thanks for testing (and for the improved map). The clipping is probably caused by the line "float height = 0.5;" in the fragment shader. Try setting it to 1.0 (I can't test it myself right now). You may find the effect is a bit too strong then, so you may need to adjust the brightness/contrast of the heightmap.

Share this post


Link to post
Share on other sites

I tried them all, one at a time while leaving the others to 1:

#define USE_PARALLAX	  0

It works fine with this.

#define USE_NORMAL_MAP	0

Still bugged.

#define USE_SPECULAR_MAP  0

The building disappear and I get this:

ERROR: Failed to compile shader 'shaders/glsl/model_common_norm.fs':
0:196(43): error: `specColour' undeclared
0:196(45): error: type mismatch
0:0(0): error: no matching function for call to `mix(vec3, vec3, )'
0:0(0): error: candidates are: float mix(float, float, float)
0:0(0): error: vec3 mix(vec3, vec3, float)
0:0(0): error: float mix(float, float, float)
0:0(0): error: vec2 mix(vec2, vec2, vec2)
0:0(0): error: vec3 mix(vec3, vec3, vec3)
0:0(0): error: vec4 mix(vec4, vec4, vec4)
0:0(0): error: vec2 mix(vec2, vec2, float)
0:0(0): error: vec3 mix(vec3, vec3, float)
0:0(0): error: vec4 mix(vec4, vec4, float)

#define USE_SELF_LIGHT	0

It works fine also with this.

I also tried setting all to 0 and enabling them one at a time: they all looks good, except on the last one which again gives the same effects of USE_SPECULAR_MAP 0 with the others to 1.

Share this post


Link to post
Share on other sites

Thanks, that was the problem, I ninja edited my post which you probably missed. I have attached an updated screenshot and normal map.

These use

float scale = 0.01;

float height = 1.0;

It looks good, I can't detect any framerate change when switching from no parallax to parallax. One concern is model popping which is very obvious. Putting in scale transition seems to work pretty well for this.


if (dist < 100 && h < 0.99)
{
float scale = 0.01;

if (dist > 65)
{
scale = 0.01 * (100 - dist) / 35.0;
}

float height = 1.0;
float iter;

float s;
vec2 move;
iter = (75 - (dist - 25)) / 3 + 5;
...

Edit: as you can see in the screenshot I also get the shadow bug with glsl. This isn't anything to do with your changes though.

post-13166-0-40147000-1338206679_thumb.p

post-13166-0-63859000-1338206722_thumb.p

Share this post


Link to post
Share on other sites

fabio, it looks like the issue is with the parallax (perhaps I'm misunderstanding). The other error isn't too important (technically, self-light uses input from specular, so nvm).

You seem to have newer hardware than me, and nothing in the parallax code stands out as something that could cause that sort of discolouration (parallax doesn't actually write any pixels out, it just distorts the UVs). I assume both you and quantumstate are using the same Mesa driver and his works fine, so I'm kind of stumped... If you turn everything off except the parallax and move the camera around, do you see the effect, even though it's pixellated, or is it not working at all? Also, can you make sure the textures have been installed correctly?

quantum, yeah I missed your edit. The scale transition is definitely a good idea! Glad it works! :D

Edited by myconid

Share this post


Link to post
Share on other sites

quantum, just tested your new heightmap. Yours looks much better than the one I had! :)

Made some more changes to the map, so the normalmapping is a bit stronger... But how do I upload attachments? Are they disabled for noobs?

Share this post


Link to post
Share on other sites

They shouldn't be, at least not in the development and technical discussion forum where this belongs. I'll move it right away :) (Click the more reply options button next to the post button to see the attachments options :) )

Share this post


Link to post
Share on other sites

Thanks feneur!

Here's a map that uses quantumstate's heightmap with a more pronounced normalmap component. Turn the model and terrain ambient colour right down, set the sun elevation to really low, and move the sun rotation slider to see what happens.

post-14564-0-34461600-1338230188_thumb.p

Share this post


Link to post
Share on other sites

fabio, it looks like the issue is with the parallax (perhaps I'm misunderstanding). The other error isn't too important (technically, self-light uses input from specular, so nvm).

It works fine without parallax OR without self_ligth.

You seem to have newer hardware than me, and nothing in the parallax code stands out as something that could cause that sort of discolouration (parallax doesn't actually write any pixels out, it just distorts the UVs). I assume both you and quantumstate are using the same Mesa driver and his works fine, so I'm kind of stumped...

According to a your previous post you have a ATI Mobility HD 4670 (DX10 era), while I have a much older X1600 (DX9 era). quantumstate (RV770, which is a 48xx like your) and I are both using mesa, but different drivers (r300 on my card (this driver supports up to Radeon X1xxx), r600 on his card (Radeon 2xxx -> 6xxx)).

If you turn everything off except the parallax and move the camera around, do you see the effect, even though it's pixellated, or is it not working at all?

In my previous post I also said what I get when enabling only one effect at a time and that with parallax only it's not pixellated. However I now noticed is very slightly pixellated (you can barely see it in the shot) and I get this:

screenshot0001n.png

Also, can you make sure the textures have been installed correctly?

This is waht I get with svn status, I put them in binaries/data/mods/public/art/textures/skins/structural/ (I also used your later texture in previous post)

$ svn status

? binaries/system/ActorEditor

? binaries/system/pyrogenesis

? binaries/system/test

M binaries/data/config/default.cfg

? binaries/data/mods/public/art/materials/player_trans_norm.xml

? binaries/data/mods/public/art/textures/skins/structural/rome_struct_spec.png

? binaries/data/mods/public/art/textures/skins/structural/rome_struct_norm.png

? binaries/data/mods/public/art/textures/skins/structural/rome_struct_arch_spec.png

? binaries/data/mods/public/art/textures/skins/structural/rome_struct_arch_norm.png

M binaries/data/mods/public/art/actors/structures/romans/civic_centre.xml

M binaries/data/mods/public/art/actors/structures/romans/triumphal_arch.xml

? binaries/data/mods/public/shaders/effects/model_norm.xml

? binaries/data/mods/public/shaders/glsl/model_common_norm.fs

? binaries/data/mods/public/shaders/glsl/model_common_norm.vs

? binaries/data/mods/public/shaders/glsl/model_common_norm.xml

M binaries/data/mods/public/shaders/glsl/terrain_common.fs

M binaries/data/mods/public/shaders/glsl/model_common.fs

? libraries/fcollada/src/output

? build/workspaces/gcc

? build/workspaces/codeblocks

? build/premake/.gccmachine.tmp

? build/premake/.gccver.tmp

? build/premake/premake4/bin/release/premake4

? build/premake/premake4/build/gmake.unix/obj

? source/graphics/mikktspace.cpp

? source/graphics/weldmesh.h

? source/graphics/mikktspace.h

? source/graphics/weldmesh.cpp

M source/graphics/ObjectEntry.cpp

M source/graphics/Material.h

M source/graphics/ObjectEntry.h

M source/graphics/ObjectBase.h

M source/graphics/Material.cpp

M source/graphics/ObjectBase.cpp

? source/renderer/MikktspaceWrap.cpp

? source/renderer/MikktspaceWrap.h

M source/renderer/InstancingModelRenderer.cpp

M source/renderer/RenderModifiers.cpp

M source/renderer/ModelRenderer.h

M source/renderer/RenderModifiers.h

M source/renderer/ModelRenderer.cpp

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...