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 / Adapting EVOLVED's cubic shadowmapping shader for more lights?

Author
Message
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 6th Nov 2013 13:12 Edited at: 10th Nov 2013 17:11
[EDIT]

Got this fixed, check out code + demo here:
http://forum.thegamecreators.com/?m=forum_view&t=208719&b=6&p=0


[/EDIT]




Hello!

OK, I've got this shader from EVOLVED:
(this is the original)


Which does exactly what I want, but I Need more lights (4-6 would be good but when the method is known any number is possible)

I've been playing with it trying to add additional lights by using multiple passes:


However, using this the object is shaded by one light (light 1) while its shadow is made by the other light (light 0), the normal mapping works properly for both lights.

I think it would be better to pass both shadow maps (from light0 and light1) through the vertex shader to the Pixel shader and mix them there instead of doing 2 passes, however, when I make any Change to the 'OUT_NormalMap' structure the shader stops working

Code & media attached.

So, my questions are:
1. Which is the best way to do this?
2. Why can't I add variables to the 'OUT_NormalMap' structure?
3. Does anyone know of a good Editor for shaders (currently I'm using Notepad! lol. )?

Thanks,

Bruce
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 6th Nov 2013 19:55
Turns out I'd been using capitals in the struc Definition and then lowercase in the shaders! That's why I couldn't add variables to the 'OUT_NormalMap' structure!

The shader Looks a bit more like this now:

Which I think is going in the right direction, but I can't mix shadowmap with shadowmap_1 without breaking the shader, is there a way to average shadowmap and shadowmap_1?

Thanks,
Bruce
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 6th Nov 2013 21:49
Still no answers?

Ok I've come a bit further (or at least feel I have):

This now has correct shading/shadows on the teapot object but the floor object has shadows cast from just one of the lights (light_1, the second light).
Does anybody know why?

Thanks,
Bruce
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 6th Nov 2013 22:32
Arrrrgggg...

I feel both stupid and clever at the same time, that last shader works but I forgot to apply the second cubmap to the floor object .
But now it's working!

I'll post back with more lights + code when done!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Nov 2013 22:58
Quote: "I feel both stupid and clever at the same time"


The latter is what we'll remember. Well done.



Powered by Free Banners
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 10th Nov 2013 17:12
Thanks GG!

Check out this link for the result:
http://forum.thegamecreators.com/?m=forum_view&t=208719&b=6&p=0
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Nov 2013 01:28
Looks good. I'll look at the code later when I'm awake. It'll be interesting to see how this differs from what I did a while back.



Powered by Free Banners
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 12th Nov 2013 17:14
Quote: "It'll be interesting to see how this differs from what I did a while back."


What did you do a while back? I'm intriuged...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Nov 2013 18:53
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 12th Nov 2013 19:16 Edited at: 12th Nov 2013 19:19
I recognise that! I experimented with that too!

First I ported EVOLVED's normal mapping to that shader but I found that EVOLVED's ran faster, which is why I Chose to adapt it for more lights.

This is a good example of how such a shader works, I learnt a lot from looking at the code to this one! Thanks for sharing!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Nov 2013 21:12
Quote: "but I found that EVOLVED's ran faster"


I wonder why? I'd expect it to be the other way around since he filtered his cube map and I didn't. Perhaps one day I'll look into that.



Powered by Free Banners
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 14th Nov 2013 18:57
Quote: "I'd expect it to be the other way around since he filtered his cube map and I didn't. "


Now that I know a Little more about the shader so would I, I was using an animated model for the test, although that shouldn't make any difference, should it?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Nov 2013 20:02
No, it shouldn't since neither shader uses the fast bone method of working with an animation. Were the shadow map image sizes the same?

Do you still have the source code for the test? I'd be interested in looking at that.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 20:15:04
Your offset time is: 2026-07-06 20:15:04