Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to apply Evolved SSAO correctly?

Author
Message
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 11th Apr 2016 07:26
Hello everybody. I need your help with applying this shader correctly.

I'm trying out Evolved Advanced Lighting shaders.
I'm particularly looking for method to apply SSAO correctly.
When I'm trying to add a new cube into the example scene, the object just appears black.
I tried to apply the shaders to the cube using these functions, but they are not working:



Anybody knew how to apply SSAO to a scene?
It's alright if the other effect is not there. I just wanted the SSAO.

Normally I would try to figure this out for myself, but I'm hard-pressed for time. My vacation only lasted for a few more days, so I probably will run out of time before I figure it out.
If anybody had experience with this shader, please tell me how.
Thanks.
Green Gandalf
VIP Member
14
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Apr 2016 10:49 Edited at: 11th Apr 2016 10:59
Quote: "Normally I would try to figure this out for myself"


You could at least help us to help you in that case.

Which of the Advanced Lighting demos illustrates the shader concerned, and which shader is it?

Edit: I guess you mean shader SSAO.fx? But which demo uses it?


Powered by Free Banners
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 11th Apr 2016 14:33 Edited at: 11th Apr 2016 14:33
Whoops sorry, I could have sworn I put the link there lol. Must have missed it during my shader-induced seizure

Sorry. Here
http://www.evolved-software.com/advancedlighting/advancedlighting

The demo project is titled 'material'.
But I just wanted to get the SSAO only working for now, because there's no more time to study the rest.

I wonder If we can isolate SSAO and get it working.

I tried some things on my own, but can't figure these things out:
- I noticed that the 'tea-kettle' object had many layers of texture (normal, specular), but I wonder which are required for SSAO? I tried using a plain white texture on all the layer, but can's see much SSAO-ness
I also only textured layer 0, but things looks really hacky. Not sure layer which is required. It can't be all layers, right?
- I wonder which light number is required for SSAO? There's like 10 in there.
- Which camera number is required for rendering SSAO?
- Is SSAO tied to other parameters except iSSAO? Is there something like a range that wee need to specify?

Thanks
Green Gandalf
VIP Member
14
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Apr 2016 16:20
There's no simple way to answer this without studying the code carefully and seeing at which point the SSAO shader is applied and rendered and which object and textures are used. A quick look at the shader suggests it uses three textures which I guess are applied to texture stages 0, 1 and 2 of a screen quad object somewhere in the code. Here's the relevant code in the shader:



I haven't had time to study the code carefully () but my impression is that the shader relies on two rendered images of the scene before SSAO is applied to the scene each frame:

- a geometry render pass which stores things like diffuse lighting and normal direction for each visible screen pixel of each object in the scene and this is stored in a camera render target which is then applied as the stage 0 texture (= "GeometryTexture")
- a position render pass which stores the XYZ world coordinates of each visible pixel (= "PositionTexture").

These two textures are then read and processed in some way in the shader to give an overall ambient occlusion effect to the scene. I guess the result of this render is another stored image which stores the amount of occlusion desired at each pixel. The resulting image will then be used as part of the final render of the scene. You'd have to delve into the calling DBPro code to find out exactly what is going on though.


Powered by Free Banners
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 11th Apr 2016 19:59
Thanks for the insight.
Looks like it's going to take some time. I guess I'll have to find another stretch of time to delve into this.

Unrelated to this, but,
Do you know of a way to bloom only a single particular object in a scene of many objects?
For example, I only wanted to bloom the skybox, and not the buildings.

Green Gandalf
VIP Member
14
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Apr 2016 20:19
Depends on how the bloom is done. One way is to prepare a bright blurred version of the scene to a camera render target and then combine it with the final scene at the final render. I guess you could simply hide the other scene objects when doing the bright blur render - or something like that?


Powered by Free Banners
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 11th Apr 2016 22:33
Genius, I'll try it after getting some sleep
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 12th Apr 2016 00:06 Edited at: 12th Apr 2016 00:07
The bone animation demo loads colonel z with ssao.

Take a look at the the colonel z texture maps and how they are applied in that demo.

I believe the ssao map fits on stage 4 for most of the object shaders

You also need to enable ssao in the AL setup command.
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Apr 2016 07:00 Edited at: 12th Apr 2016 07:03
Quote: " I guess you could simply hide the other scene objects when doing the bright blur render - or something like that?"


Hey, I tried that, and it works like a charm. Thanks a lot!

Quote: "I believe the ssao map fits on stage 4 for most of the object shaders"


SSAO has maps? Do you know of how standard SSAO maps looks like?
I took a look at texture that was applied at stage 4, but its colouring doesn't make much sense to me.
Green Gandalf
VIP Member
14
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Apr 2016 13:56
Quote: "Hey, I tried that, and it works like a charm. Thanks a lot!"


Thanks for letting me know.


Powered by Free Banners
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 12th Apr 2016 19:29
For fleshy objects, is usually kind of brown/red fit color portion, and may have a greyscale (alpha channel?) to control intensity.

When looking at textures, it's always important to inspect each rgba channel individually, and see how those channels are accessed in the shader.

With AL you don't need to apply the ssao shader to anything directly, AL handles this, instead you apply an object shader that takes an ssao map on one of its texture stages.
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 14th Apr 2016 14:26 Edited at: 14th Apr 2016 16:12
Thanks for the pointers Ortu.

I tried tinkering with the texturing, and it seems that we also required normal maps (stage 3 in 'Material' demo). And also diffuse at stage 0
If not, the lighting of that particular object will be effed up.
Specular and cube mapping seems to be optional

Another question; it's regarding cube.dds thatw as used for cube mapping.
I noticed all cube mapping texture seems to be rather large (~2Mb). When I tried to edit them, they shrink to a few kilobytes, and cannot be used for cube mapping anymore.
I wanted to remove the ingrained reflection in the texture.
How can we edit the cube-map textures correctly?

Here's the Evolved cube map shader project. The cube map texture is Cube0.dds

Attachments

Login to view attachments
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 15th Apr 2016 13:04 Edited at: 15th Apr 2016 15:02
Thanks everybody, I managed to get SSAO working on top of other effects!

But still, there are 2 questions:

1) Is it possible to make an object fully white, without being affected by shadows? In bare-bone DBPro we can SET OBJECT EMISSIVE with RGB(255,255,255) and SET OBJECT LIGHT to 0 to make it completely white.
Is there a way to do this in Advanced Lighting? I used directional light, and the back of the object is always darker than the front-facing the light

2) I noticed that when I have a high object count, the latter-created objects was not shaded correctly in Advanced Lighting. They just appears black.
It's not related to object numbers either. It was like AL keep track of how many object created, and when they reach certain limit, they are not rendered correctly anymore.
The limit seems to be less than 100, I'm not sure the exact count.
Is there really an object number limit to Advanced Lighting? How to remove it?
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Apr 2016 16:02
Quote: "Another question; it's regarding cube.dds thatw as used for cube mapping.
I noticed all cube mapping texture seems to be rather large (~2Mb). When I tried to edit them, they shrink to a few kilobytes, and cannot be used for cube mapping anymore.
I wanted to remove the ingrained reflection in the texture.
How can we edit the cube-map textures correctly?"


It's likely an issue of formatting. I haven't actually tried to edit a cube map myself, but the directX texture tool that comes with the directX SDK should be able to create and save cube maps with correct formatting. Additionally, I remember seeing code either in one of the AL demo's (palm trees maybe?) or in AL itself that captures series of images and saves them out as a cube map, this should be able to be adapted to let you supply your own edited images and save them out the same way.
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Apr 2016 16:12
Quote: "1) Is it possible to make an object fully white, without being affected by shadows? In bare-bone DBPro we can SET OBJECT EMISSIVE with RGB(255,255,255) and SET OBJECT LIGHT to 0 to make it completely white.
Is there a way to do this in Advanced Lighting? I used directional light, and the back of the object is always darker than the front-facing the light"


Yes, this can be done using a special property of the specular map. Take a look at this thread:

https://forum.thegamecreators.com/thread/215788
Green Gandalf
VIP Member
14
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Apr 2016 16:13
Quote: " I remember seeing code either in one of the AL demo's (palm trees maybe?) or in AL itself that captures series of images and saves them out as a cube map"


I'd like to see that code.


Powered by Free Banners
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Apr 2016 16:28 Edited at: 15th Apr 2016 16:33
Hmm, ok, found the code I was thinking of and it looks like it actually saves out each face as a separate image, then applies them individually via set cube mapping on.

Relevant files are palm tree demo:



and Include/Materials.dba:



may not be quite what you're looking for if you need a single file cube map
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 15th Apr 2016 17:43 Edited at: 15th Apr 2016 18:04
Whoa I never knew method for making cube map texture is so...hidden

Quote: "Yes, this can be done using a special property of the specular map. Take a look at this thread:"

I tried to colour the specular map all green 255 and white (R 255, G255, B 255) but the objects still not diffusely white.
Can you give me an example texture?


Regarding the issue of blackouts objects if a lot of object was generated;
- I can avoid this by cloning or instancing objects, even if cloned objects are large in numbers.
- Objects still become black if they are generated individually in large numbers (MAKE OBJECT BOX)
- So this will prevent us from having variety of objects with different shapes

Anybody has any idea on removing the object limit in Advanced Lighting?
Went thought the .fx and the .dba, but still can't find the limiter.
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Apr 2016 21:25 Edited at: 15th Apr 2016 21:27
Sure, here are diffuse, specular and normal maps 2^2 px is sufficient for this effect. (attached)

Tested with bone animation shader: Advanced Lighting/Shaders/Surface/Animation/Normalmap Clip.fx"

But it should work the same with the static object version here: Advanced Lighting\Shaders\Surface\Object\Normalmap Clip.fx

It does appear to still be applying some ambient shading, as it comes up light grey instead of full white, possibly it is caused by this:



you can play around with leaving this off, and if that doesn't work a lot of the shaders in the Post Processing directory can tweak overall brightness output levels.

Attachments

Login to view attachments
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 16th Apr 2016 06:53 Edited at: 16th Apr 2016 06:57
Hey, thanks, that works!

A curious thing happened.
Textured objects appeared sort of 'flaky'.
The weird thing is, I didn't even put on a normal, specular, cube, or SSAO map.
I only diffusely texture it with a photo at stage 0.
The result is still the same even if I put on normal, specular, cube, or SSAO map though.

Here's the image screenshot. Do you know what's the cause?

Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 16th Apr 2016 22:20
looks like the detail map is being applied
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 22nd Apr 2016 03:40
Looks like that 'grainy' detail map is on stage 4. Changing that texture fixed it.
I thought that stage was for SSAO texture, so I didn't mess with it till now.
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 22nd Apr 2016 08:16 Edited at: 22nd Apr 2016 08:51
Grrr, this is really bad
When the created objects reach a certain count, they turns black. They don't seems to be affected by Advanced Lighting anymore.
The limit seems to be less than 50. I just created 50 simple cubes using this lines to apply the AL, and half of the objects was black.
The object number was not the problem either. It's the created object count.



Anybody had similar experience? I doesn't seems viable to make anything anymore with this limit
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 22nd Apr 2016 17:50
Okay, somehow I solved the blackout object issues.

It seems that for every object created, we need to set
set object effect 1,1
Otherwise, latter-created objects will somehow fail to be rendered correctly.
I don't know why the earlier objects can still be rendered correctly. Doesn't make any sense
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 22nd Apr 2016 19:57
hmm that's odd, I'm sure I've loaded more than 50 objects without having issues, but I'll run some testing to try to reproduce.
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 23rd Apr 2016 02:59 Edited at: 23rd Apr 2016 04:58
Another funky thing happened.

I was using some textures on a floor and some boxes, but they turned up completely different color!
I was using the gray texture for the floor, and orange one for the little boxes.
But see how they turned into black and red?
Anybody knows whats going on?







FIXED: it seems like Effect_SetDetailMapping(1,1) texture must be assigned to detail map, or the color won't show up right. And all object must be assigned to an effect.
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 21st May 2016 02:54 Edited at: 28th May 2016 05:13
Anybody knows how to correctly set alpha mapping/transparency to object that use alpha tranparency texture?

I tried the Palm Trees demo, and tried to transplant the code, but,
The loaded object alpha rendering seems to be lacking depth buffer with its alpha reference.
It's like, you can see the back face through the front faces.
I tried switching textures and everything, but the problem is still there.
Was it meant to be like this?

Here's the pic. You can even see the faces facing away, as if the Z-buffer was not rendered correctly.



SOLVED: I'm dumb. For transparency, we should use 'clip' version of the shaders. For alpha, its well, alpha shading.
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 28th May 2016 05:16 Edited at: 3rd Jun 2016 01:06
I've been trying to adjust the fogs, but what does the parameters means?
Quote: "AdvLighting_SetFog(iRange as float,iPower as float,iRed1 as float,iGreen1 as float,iBlue1 as float,iRed2 as float,iGreen2 as float,iBlue2 as float)"

I mean, why is there 2 sets of color parameters?



Also, how to increase overall scene brightness?
I noticed that if the overall scene brightness exceed certain level, the adaptive bloom shader will reduce the brightness of the screen.
So, if I increase the lights 'whitishness', the screen brightness will be reduced to grayish colour.
How to increase this limit, so that the scene can appears brighter? I took a look at the bloom shader, but can't figure out which parameters to change

This is what happened.
This is the normal brightness. Notice the sky is white, and the gray building is reasonably gray


This is what happened if there are too much 'whiteness' on the screen. The overall brightness got turned down, and even the sky appears grey.



SOLVED: To increase overall brightness, just increase the float3 Brightness={2.0f,2.0f,2.0f} in Final Comp.fx. Brigthness in BrightPass.fx doesn't seems to do anything though.
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 19th Jul 2016 05:59
Hello everybody. Just need some examples regarding textures.

Anybody had some examples of detail maps that could work with AL?
The default texture detail.dds was a blank texture, so I couldn't figure out what it would look like if it's not.
I just wanted to see what a working detail map would look like. The ones from googles seems to have different formats/colouring.

Anybody had some examples of detail maps that can be matched with suitable normal and specular maps?
Kuper
11
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 19th Jul 2016 23:01
there is good default detail texture in Textures\Detail folder in AL
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 23rd Jul 2016 14:34
But, that texture is just a tranparent texture? Googling doesn't answers much either...
Do you have other example textures?
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 23rd Jul 2016 16:54
I've been pulling my hair about this weird artifact...
When I applied specular map, when I exceed certain camera angles, the surface seems to be 'blacked out'
You can see in this picture, the floor grew darker the more the distance is from the camera.
I tired to change the textures, but the dark gradient is still there, even if I used the textures from AL 'Directional Lighting' demo, or enabled the sky, or changing the intensity of directional and ambience light
This doesn't seems to happen in AL 'Directional Lighting' demo though.
Any idea why this happened?

Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 23rd Jul 2016 23:41 Edited at: 23rd Jul 2016 23:45
Quote: "But, that texture is just a tranparent texture? Googling doesn't answers much either...
Do you have other example textures? "


It is not just transparent. Look at the channels individually, all four R, G, B, and A have detail content.

The detail texture is basically just a normal map with an added alpha channel. I am not sure offhand what the alpha channel is controlling in the shader, might be spec, could be strength of the detail. looking at the shader that uses this texture will tell you how the channels are used.



A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.

Attachments

Login to view attachments
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 24th Jul 2016 07:58 Edited at: 24th Jul 2016 07:59
I see, so we have to play the individual channels?
Let's say a specular map Red channel is used for specular power, and I wanted to decrease the specular power, then how would I alter the Red channel?
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 24th Jul 2016 18:39 Edited at: 24th Jul 2016 18:45
Yeah, shaders in general compress a lot of information into the channels of the texture maps.

Working with channels is a bit different depending on if you use gimp or photoshop or something else.

Photoshop is easier, there is a channels tab that let's you work with them directly much the same as regular layers.

Gimp requires you to decompose (color menu) the image into a new image in which each channel becomes a layer. You then recompose back into a single flat image.

Once you have isolated the red channel on the spec map, you can adjust the brightness, contrast, levels, etc to raise or lower the values. You can also paint and edit if you want to more fundamentally alter it.

More red is higher power, more black is lower power. (This is greyscale in gimp after decomposing) In this specular power map It's not really the color that is important here, it is the numerical value 0-255 that the color represents. Using the color channels on a texture image is simply a way of encoding that value to a location on the model. (Diffuse and a few other maps that affect object color do use the actual color of the texture)

So a map can encode 4 pieces of data with values in a range of 0-255 by using the rgba channels.


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.

Login to post a reply

Server time is: 2019-07-23 08:02:09
Your offset time is: 2019-07-23 08:02:09