Jump to content

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


Recommended Posts

If you look at the public/shaders/effects folder, you'll see how the multipass shader architecture works. It should be pretty easy to hack it so each pass has two optional parameters that define a range where that pass is active.

Link to post
Share on other sites
  • Replies 1,3k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hey everyone, I've been coding some very rough GLSL post-processing tests just to see what they'd look like in 0ad, and thought I might share some results. The following images are in pairs, with the

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

Just wanted to say the rock mountain screenshot above looks fantastic

Posted Images

Ideally, we'd have a "base" shader, and if some criteria are met, we switch to another (more detailed) shader. This way, we could link 1/2/3/4… different shaders for different LOD, and also prevent this switching by options, so that lower configs would only use the base shader or the level 1.

I've already added something like that. The user-defined materialmgr.quality setting in the config determines which materials/shaders are loaded. For example, the player_trans_ao_parallax_spec.xml material has this line:


<alternative material="player_trans_ao_spec.xml" quality="8"/>

that tells it to load an alternative material without parallax if the user/engine set the quality factor to less than 8. Unfortunately, this is determined statically at load time, so we can't use it for LOD during rendering.

Come to think of it, this could still be combined with the new stuff quite elegantly.

Edited by myconid
Link to post
Share on other sites

The celt_struct_1_normal should work with any (over a dozen) celt structure actors that still uses celt_struct_1 for it's base texture.

The other is a test on a unit, it should work for actor:

Uh, I should remind people that the modelmapping stuff is limited to instanced objects, like buildings and ships but not people or animals!

No doubt I'll get around to adding support for that too in a later patch, but for now I've sort of put it on the backburner because it won't make that huge of an impact visually, but would require hacking of SSE assembly on the CPU side to transform the tangents.

On that note, perhaps it would be worth revising the GPU skinning code to transform animated objects on the GPU and it would remove the need for big changes to the engine...

Would it be reasonable to make a distinction between dynamic an static objects. Apply SSAO to the dynamic ones and prerendered AO to the static ones?

It would be possible, but I'm doubtful if it would be desirable. SSAO can add haloing artifacts that are most visible on dynamic objects. If we use SSAO, it would be better applied to terrains, but not models. It's really slow, too.

All the same, I'm planning to make a SSAO filter available once I properly add the "Postproc Manager", and we'll see what tricks we can use from there.

I'm thinking whether the best use of SSAO would be for dynamically "baking" a top-down approximation of the terrain's AO at load time/when modified...

Link to post
Share on other sites

I figure that would be the easiest way to use the SSAO... It could also be used on buildings (modifying their xml to add the baked texture). This would help with modding support, too, as they would not be required to bake the AO themselves.

Link to post
Share on other sites
Uh, I should remind people that the modelmapping stuff is limited to instanced objects, like buildings and ships but not people or animals!

Could it be applied to an unanimated actor just to see what the affect might look like on the unit?

Wijitmaker, tried your Celt normalmap. It may be a bit too subtle (or, I chose the wrong building to test it on).

I'm attaching the black and white elevation map, maybe I didn't convert it correctly - or maybe the brightness and contrast needs to be greater.

Sorry for pestering you so, I'd try it myself but ... well you know that story.

post-3-0-27859000-1341935460_thumb.png

Link to post
Share on other sites

Could it be applied to an unanimated actor just to see what the affect might look like on the unit?

Maybe. I'll have to look into it.

I'm attaching the black and white elevation map, maybe I didn't convert it correctly - or maybe the brightness and contrast needs to be greater.

Ah, ok. Created a new map using a 3x3 Sobel filter, as opposed to the 2x2 filter you used. Using GIMP's normalmap plugin. Still pretty subtle.

http://imgur.com/a/Siwn4

Sorry for pestering you so, I'd try it myself but ... well you know that story.

Don't worry, I don't mind at all. After all, I want to test this as well! :)

In fact, do you have any other elevation maps I can play with?

Link to post
Share on other sites

Myconid, do you believe it would be possible to (at runtime) export an heightmap of the map? I think I could use it in the water shader to start doing some fancy stuff (simulating ray-casting for depth)

Edit: scrap it, it may already be in the game…

Edited by wraitii
Link to post
Share on other sites

Myconid, do you believe it would be possible to (at runtime) export an heightmap of the map? I think I could use it in the water shader to start doing some fancy stuff (simulating ray-casting for depth)

:o Dare I ask what you would use this (water) depth info for?

Link to post
Share on other sites

It's possible, yes. You can access a raw 2D array of vertex heights by using


g_Game->GetWorld()->GetTerrain()->GetHeightMap();

with lineskip being


m_VertsPerSide = g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide();

Values are unsigned 16-bit ints.

What on earth do you need raycasting for??

Link to post
Share on other sites

I could use it for improving murkiness (calculating actual distance of light underwater), some sort of advanced refraction, and probably would be nice to have overall. It could also fix a rare, but possible bug with water being incorrectly transparent (if you look at the far side of a steep enough island).

Edited by wraitii
Link to post
Share on other sites

I could use it for improving murkiness (calculating actual distance of light underwater), some sort of advanced refraction, and probably would be nice to have overall. It could also fix a rare, but possible bug with water being incorrectly transparent (if you look at the far side of a steep enough island).

Cool! I happened upon this page yesterday. They use water depth in a seemingly simple way to do foam (don't know how well it looks, though). Another interesting point they make is about the phenomenon of 'color extinction', which may be related to what you are doing with murkiness.

fig4.jpg

Link to post
Share on other sites

You don't need real raycasting to calculate that. Here's a clever little algorithm I've come across:

  1. First render the terrain.
  2. Get the depth buffer which tells us the distance between the camera and the ground at each fragment.
  3. Pass the depth buffer as a texture into the water shader.
  4. Transform the water plane and calculate the depth value of each vertex, then interpolate with varying.
  5. We now have the depth of each point on the plane and the depth of each point on the terrain exactly behind it.
  6. A - B = the distance light travels through water.

And what's more, when I implement the Postprocessing manager, the depth buffer will always be available as a texture.

Link to post
Share on other sites

Very good then... I'll just wait :)

(and no, I indeed didn't need real raycasting, just some info about the heightmap, or the depthbuffer, though I hadn't thought of that).

Would this (particularly points 4/5) require rendering the water twice?

Edited by wraitii
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.


×
×
  • Create New...