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 / Can't get Bond1's bloom to play nice with Evolved's cubic shadow mapping

Author
Message
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 19th Mar 2014 03:14
Here's my code, if it's difficult to read I'll post a working example tomorrow (tired, been coding way too long tonight!)
They both work, but not so well at the same time. Strange artifacts and what not.
Any help would be super duper cool!



New sig coming soon..
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 19th Mar 2014 16:39
Here's a screen shot showing the strange artifacts..

New sig coming soon..

Attachments

Login to view attachments
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 19th Mar 2014 19:59 Edited at: 19th Mar 2014 20:30
Alright, here's a much simpler question that I can't figure out.
How do I change the camera used to render the shadow maps in this code to camera 2 instead of 1? Every time I try it doesn't work right. (shader attached)



New sig coming soon..

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Mar 2014 22:55 Edited at: 20th Mar 2014 00:51
I'm fairly sure you need camera 1 to exist before you can use camera 2 correctly - even if you don't actually use camera 1.

This works in your demo:



Camera 1 doesn't need to be a dummy camera - i.e. you can use it for something else - but it must exist if you want to use camera 2.

Similarly, this works as well:



Actually that last one surprised me - I thought it had to be camera 4, i.e. the one before camera 5, but apparently not.

It's a DBPro bug.

Edit Just noticed that the render dynamic cube map command is using camera 2 in the demo. Not sure how that affects the above comments - so they might be bugged too. I usually use the "-1" option for a temporary camera in that command.

Edit2 Time I retired. The render dynamic cube map command is using camera 1 so the additional cameras I was making are irrelevant.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 19th Mar 2014 23:25
Thanks. I seem to have figured out how to do what I was asking, but I still get glitches when using the cubic shadow shader in combination with the bloom. I would think the shaders would need to be combined, except that one's an object shader and the other a fullscreen shader.

I actually haven't been able to combine use of the cubic shadow shader with ANY bloom shader correctly.

New sig coming soon..
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Mar 2014 23:38
Actually, the shadows in that demo don't look right to me. Perhaps one of the matrices hasn't been set correctly?

There shouldn't be a problem getting the two to work together though.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 20th Mar 2014 00:12
Quote: "Actually, the shadows in that demo don't look right to me."

That only happens when both shaders are used. I don't get it, I have one working example with bloom and one with shadows, but if I combine the code it's messed up.

New sig coming soon..
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 20th Mar 2014 16:30 Edited at: 20th Mar 2014 19:29
I'm just attaching the project folder, Green Gandalf (or anyone else with more of a clue than myself) could you please have a look at it? You can observe both shaders working, but rendering incorrectly.

My guess is I've made a simple error somewhere in the code, but I can't for the life of me figure out where.

EDIT - I think it has something to do with the rendering order...maybe? The shadows on the floor seem to be almost reversed, the shadow area is light and everything else is dark.

EDIT2 - code.txt is with both shaders loaded, code2.txt is shadows only, code3.txt is bloom only.

New sig coming soon..

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Mar 2014 18:51
Quote: "My guess is I've made a simple error somewhere in the code, but I can't for the life of me figure out where."


Possible - but my guess is that one of the shader inputs is wrong or missing. I'd check the "tweakables" in the shadow shader first (not sure that all the relevant ones are labelled as tweakables though). Shadow mapping needs something like a view or view projection matrix calculated from the light's position. Without seeing the code (yet ) that would the the first thing I'd check as I don't recall seeing it in your code. The bloom needs to be applied after rendering the scene with shadows.

Hope to check this tomorrow (out at a meeting this evening ). Perhaps someone else can check?



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 20th Mar 2014 19:27
Quote: "Hope to check this tomorrow (out at a meeting this evening ). Perhaps someone else can check?"

Thanks! Of course I'll take help from anyone in the mean time
I'm not seeing anything relevant in the shader, although I've noticed that even if I switch the shadow rendering to camera 2 (without the bloom running), if I then disable camera 1 the shadows disappear completely, so something must be causing a conflict there..

New sig coming soon..
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2014 00:24
Quote: "I'm not seeing anything relevant in the shader"


There isn't - I forgot it was cubic shadow mapping.

I'll look at it again tomorrow.

Quote: "although I've noticed that even if I switch the shadow rendering to camera 2 (without the bloom running), if I then disable camera 1 the shadows disappear completely, so something must be causing a conflict there.."


I think that's the bug I was talking about earlier when I thought you were already using camera 2 for the shadow render (you weren't ). In other words you must have camera 1 defined if you want to use camera 2.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 21st Mar 2014 00:37
Quote: "I'll look at it again tomorrow."

Thanks, and the hair that I won't be tearing out thanks you.

New sig coming soon..
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2014 18:06
Try the attached demo.

1. I've changed the media to make the texturing more obvious.

2. I've made a number of minor edits to the shader (most of these avoid irrelevant compiler errors in my version of Dark Shader, a few make the shader work a bit better in the distance, etc).

3. I've changed the initial camera position to improve the initial view.

4. I've made the edits necessary to enable you to use camera 2.



Powered by Free Banners

Attachments

Login to view attachments
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 21st Mar 2014 19:01
Thanks, it definitely looks better now, I'm sadly still getting a reverse shadow when I apply the bloom shader though. Should I set the bloom to camera 2 or the shadow mapping shader?

Thanks again for you're help, also. I really appreciate it.

New sig coming soon..
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2014 19:21
Quote: "I'm sadly still getting a reverse shadow when I apply the bloom shader though"


Could you post the code you're currently using? Now that I've got into this I can probably make more progress with the problem.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 21st Mar 2014 20:09
Definitely can, thanks.


Project folder attached, probably shows the problem better.

New sig coming soon..

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2014 21:16
Thanks. Got your demo and I can see some obvious symptoms - no idea yet what the problem is but I'm on the case . Supposed to be cooking supper right now () but I'll report back as soon as I get a chance to study the code.



Powered by Free Banners
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2014 22:44
There seem to be a few oddities in your code - but when I "fix" them the symptoms are still there. A bit baffled at the moment.

For example, the boy character has image id 2 (a normal map) applied to stage 1:



but you also have these:



and



In other words image id 2 is used twice - for two quite different things.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 21st Mar 2014 23:09
Hmm. I knew I had some things messed up in the code, but that's really weird that fixing them doesn't change the problem..
I'm no shader expert, is it possible that these two are flat-out incompatible together?

New sig coming soon..
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2014 23:29 Edited at: 21st Mar 2014 23:30
Quote: "I'm no shader expert, is it possible that these two are flat-out incompatible together?"


I don't think so. I've run out of time tonight but I'll have another look tomorrow when I get the chance.

I have a feeling that conflicting image or camera settings are involved somehow but not sure where. The fact that there seem to be multiple copies of the shadows makes me wonder whether texture scaling is involved somehow - but again I can't see where. Similarly, you have dynamic cube map id 1 and a regular image id 1. That should be OK but makes me wonder whether there's an odd DBPro bug somewhere.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 22nd Mar 2014 00:02
Quote: "I'll have another look tomorrow when I get the chance."

I appreciate it very much.

New sig coming soon..
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Mar 2014 19:14
Well, that was a surprise.

Found what appears to be the cause of the bug - but not sure why at the moment.

I made several changes to the code (mainly for my benefit) but the crucial ones seem to be here (lines marked ***):



Here's the full code I used (I was using FullDesktop project setting):



The remaining issue is that the shadow is not animated - I think you need a bone shader for that (unless I've made another error somewhere...). I've got one somewhere. I'll dig out the demo.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 22nd Mar 2014 19:32 Edited at: 22nd Mar 2014 19:56
I'm actually not seeing any cast shadows now, even with the bloom disabled. 'Tis very strange. Maybe this is the wrong shader to use here, I'm really just looking for cast shadows (animated), normal mapping and bloom. If you find that shader, I'd be interested in trying it out.
Thanks for all your help so far.

EDIT - I think this is the shader you were referencing, but I'm not having any better luck incorporating the bloom shader into this demo:
http://forum.thegamecreators.com/?m=forum_view&t=196819&b=1

New sig coming soon..
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Mar 2014 21:34 Edited at: 22nd Mar 2014 21:36
Quote: "I'm actually not seeing any cast shadows now"


This is what I see when I run that code (and move the camera a bit of course):



Quote: "'Tis very strange."


Indeed. Did you use the whole snippet or just the first fragment? Perhaps one of the other edits was needed as well?

Quote: "I think this is the shader you were referencing"


Looks like it.

Looks like we need a version which is not only TR-proof but also WW-proof. At the moment I've no idea how to do that.



Powered by Free Banners

Attachments

Login to view attachments
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 22nd Mar 2014 21:59 Edited at: 22nd Mar 2014 21:59
Quote: "Looks like we need a version which is not only TR-proof but also WW-proof. At the moment I've no idea how to do that."

I read that on the original thread and had a funny feeling I was going to get served.

Quote: "Did you use the whole snippet or just the first fragment? Perhaps one of the other edits was needed as well?"

I tried both, but I guess I should try it again; or maybe not if the shadow doesn't animate. I'm getting results exactly the same as your screen, except no shadow. Did you update the shader again? Confused. Again.


New sig coming soon..

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Mar 2014 23:37
Quote: "Did you update the shader again?"


Not that I recall.

In any case I've just copied my code into your original project .dba file without any other changes and, yes, the shadow is there.

Quote: "Confused. Again."


Me likewise.

Looks like a possible DX9/GFX card oddity to me. One of my cubic shadowmapping demos works fine on my oldish desktop but breaks down on this newer laptop. No idea what the problem is.

What really baffles me about the full code that I posted is this line:



Why on earth doesn't that conflict with the quite different image 2 used as a normal map for the boy character?

Not sure whether that is a bug or a feature - or just good old fashioned witchcraft.

I don't know what to suggest now - other than a few stiff drinks.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 23rd Mar 2014 00:37 Edited at: 23rd Mar 2014 03:47
Quote: "I don't know what to suggest now - other than a few stiff drinks."

Yeah, I guess I'll start experimenting with all the shadow shaders I can find to see if I can get the bloom working with any of them.
Well thanks for your help, I appreciate it.

EDIT
Still haven't had any luck with any bloom shader + shadow mapping, but Evolved's light scattering shader integrates pretty painlessly.

New sig coming soon..
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Mar 2014 12:18 Edited at: 23rd Mar 2014 12:58
I'm going to have another look at this. I hadn't realised yesterday that without the bloom effect the shadows animate correctly so ignore my comments about a bone shader being needed. If they animate without bloom they should animate with bloom. My guess is that there's a bug in the sync camera 1 command. I'll report back when I've done some tests.

Might just need to use



instead of



Edit No that doesn't work at all. Perhaps we need to avoid the camera effect DS commands altogether and revert to standard DBPro commands using screen quads, set camera to image, etc? Just thinking aloud at the moment. But all this should work together somehow. Or there's something simple I've overlooked in the code.

Edit2 Well, that was unexpected. Just removed the camera effect commands and everything still works the same as before, i.e. bloom, shadows, but no animated shadows. The code does seem a bit simpler though since the quad shader isn't needed so I might go with this.



Powered by Free Banners
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Mar 2014 16:39
Found the problem. Can't believe I didn't notice it before.

You've forgotten to show the scene objects before the cube map render. The reason you get a non-animated shadow is seems to be because the first pass has the shadow map rendered - and with your bloom code the scene objects are hidden when the subsequent shadow maps are rendered.

Anyway, with that fixed I see animated shadows with bloom. Here's the shadow map rendering code which works:





Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 23rd Mar 2014 16:52
Ah man, that's SO awesome! I've been sweating over this for about 7 days now, honestly thanks!
I figured it was a code problem on my end!

New sig coming soon..
BlackFox
FPSC Master
17
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 23rd Mar 2014 17:04
Nice catch, Green Gandalf. I too took a look at the code this morning over coffee and missed the showing of scene objects before cube render. I made a note of this in my book so if I ever have this issue appear, I'll know what to look at first. We coders tend to sometimes overlook the obvious when trying to find the problem.

Now I know who's brain to pick in future.

There's no problem that can't be solved without applying a little scripting.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Mar 2014 17:32
Quote: "Ah man, that's SO awesome!"


Thanks - but I'm rather embarrassed at not checking that particular issue at the outset.

Anyway, at least you can move on now and tweak other things that need it.

The good news is that I've refreshed my memory on how to get these things working together correctly.

Quote: "We coders tend to sometimes overlook the obvious when trying to find the problem."


Painfully true.



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 25th Mar 2014 02:23 Edited at: 25th Mar 2014 02:24
Just wanted to post how nice this is looking with the light scattering shader added. Thanks again GG.



I love my dbpro family!

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Mar 2014 12:13
Looks excellent. Thanks for sharing.

Which light scattering shader did you use?



Powered by Free Banners
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 25th Mar 2014 13:38
Quote: "Which light scattering shader did you use?"

This is the one from Evolved's website. I'd probably add even more shaders but my pc is getting a bit old.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Mar 2014 20:50
Thanks. Sounds like it's time for me to have another look at his shaders.



Powered by Free Banners

Login to post a reply

Server time is: 2025-05-15 03:59:16
Your offset time is: 2025-05-15 03:59:16