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 / Trying to do Shadow Mapping...

Author
Message
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 23rd May 2010 08:02 Edited at: 23rd May 2010 09:56
Hi all,

I'm finally trying to work with Shadow Mapping.

I got an example from here:

http://www.evolved-software.com/shaders/Shaders_Shadowing.html

I downloaded the top one called "Cubic Shadow Mapping". It looks fantastic and decide to try implementing it to a simple scene that "I" created.

Here is my code first of all:



I first built my simple scene before trying to implement parts of the Shadow Mapping code. However, when this line is placed in:



The FPS rate goes down to 0 - 5.

Also, there are no shadows in the scene. I know it has something to do with the code above because when I took that out of the Shadow Mapping code, the shadows in it disappear.

I'm obviously missing something because well... this is my first time trying to not only implement shadows, but working with Shaders.

Also, the following lines of code doesn't seem to highlight:

Apply Cube Map To Object
Render Dynamic Cube Map

Where can I get the keywords for this so I can read what they actually do.

Can anyone help me with trying to successfully implement the shadow mapping to my scene? And remember I'm new to Shaders =/

Thanks

EDIT: Just attached the platform file.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 23rd May 2010 12:34
Well, this line:


should be:


and this line:


should be:


That should raise your framerate. Did this help?

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 23rd May 2010 12:58
Thanks The Slayer. Ok...

Adding:

set effect technique 1,"DepthMap"

Raised my frame rate to normal rate. So that's good but I don't get why. I read "set effect technique" and the "DepthMap" is suppose to be a string that refers to an FX? But DepthMap isn't found anywhere else in the code.

Adding:

sync mask 2^0

Didn't change anything except that it moved my camera lower. I read what it did, but don't know how DBPro can decide which cameras are not needed.

In the end however, there are still no shadows. I still can't figure it out =/
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 23rd May 2010 13:13
Quote: "I read "set effect technique" and the "DepthMap" is suppose to be a string that refers to an FX? But DepthMap isn't found anywhere else in the code."

Yep, it refers to code written in the FX file.

Quote: "Didn't change anything except that it moved my camera lower. I read what it did, but don't know how DBPro can decide which cameras are not needed."

Well, the actual camera that is rendering your scene, is not camera 1 that you made at the beginning of your code, but it still is camera 0. Try this: add the command 'POSITION CAMERA 0, 20, -10' in your main loop. Then you'll see that the active camera is 0.

I also noticed that you're not texturing the stages of your objects.

Quote: "In the end however, there are still no shadows. I still can't figure it out "

I'll see if I can make it work, or make some other example later today.

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 23rd May 2010 13:35 Edited at: 23rd May 2010 13:35
Oh so the word "DepthMap" is not in the code, but is inside the FX file? Interesting.

I placed this inside the DO LOOP:

POSITION CAMERA 0, 50, -50

And the camera is where it's at (though not point at 0,0,0). I tried taking out Camera 1 and just using Camera 0, but my code won't run. Don't worry though, this is just my computer not liking DBPro. I'll test more on this at school.

As for the textures, do they really need to be textured for shadows to work? I can always just give them the same wood texture that I gave to the "Player" and the "Ground". However despite the fact that the Player and the Ground are textured the same, the ground is visible but the player is completely dark =S
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 23rd May 2010 14:45
Quote: "I tried taking out Camera 1 and just using Camera 0"

Well, you don't need to take camera 1 out, because you need him to get the effect working. What I meant is that camera 0 is the active camera which allows you to move through your scene. If you move camera 0, then your scene will be rendered from another point of view.

Quote: "Oh so the word "DepthMap" is not in the code, but is inside the FX file?"

'Depthmap' is a directx technique which gives the impression to objects that they have depth.
The 'Shadowmapping' technique renders the shadows.

Quote: "As for the textures, do they really need to be textured for shadows to work? I can always just give them the same wood texture that I gave to the "Player" and the "Ground". However despite the fact that the Player and the Ground are textured the same, the ground is visible but the player is completely dark "

Your player is completely dark because you didn't texture him. The command for texturing objects is 'TEXTURE OBJECT Object Number, Stage Number, Image Number'.
You can give the illusion of depth (and other beautifull things) to your objects by applying a texture and a 'normalmap' to them. These different textures are then applied to the 'stages' of your objects.

Cheers

Slayer rules!!! Yeaaah, man!
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 23rd May 2010 15:49
Here's that example. It's the same example by EVOLVED, so credits go to him. I just changed a bit to suit your needs, I hope?
If there are some things you don't understand, then just ask, and I'll try to answer as good as I can.



Did this help you?

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 23rd May 2010 16:09
I understand the camera thing now...

I sort of understand the directx technique thing now...

And I thought I did texture the player hahaha my bad. I must have took that line out by accident.

Well now that the player is textured, I can see him. Odd thing is, aside the shadow still isn't there, when you move the player left and right, the "ground" becomes lighted around the edge at certain positions. Don't know why that is happening.

Anyway, I'm still trying to figure out why there are no shadows. If you (or anyone else reading this thread) find anything, do tell ^^

Thanks.
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 23rd May 2010 16:13
Yeah that sort of helped.

It's exactly what I'm looking for but the thing is, I'm trying to implement the shadow mapping to an existing game I have. This is why I started from scratch to make sure I only put things which are relevant to shadow mapping.

I'm not saying you did it in vain though, I got more of an idea of the situation but still having difficulty pin-pointing which lines of code makes the shadow appear.
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 23rd May 2010 16:36
OK, I decided to insert the following lines of code into mine...

At the end of the lines of code that made my light:

vec=MAKE VECTOR4(1)

Inside the DO LOOP:

SET VECTOR4 1, OBJECT POSITION X(20), OBJECT POSITION Y(20), OBJECT POSITION Z(20), 0
SET EFFECT CONSTANT VECTOR 1, "LightPosition", 1

Now I can see the light and shadows moving when the light source moves. BUT... The ground is still dark and there is still no shadows. At least I'm getting close though.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 23rd May 2010 18:05
This is the same example, but stripped down to the bare minimum to have shadows. Maybe you could work further from here on?



Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 24th May 2010 05:22 Edited at: 24th May 2010 05:39
I got it!!!

I stripped both yours and mine to its BARE minimum. taking out lines of code 1 at a time.

Apparently, the objects requires both the diffuse texture and the normal_map texture for the shadows to appear.

So it requires that VECTOR4 thing and the NormalMaps for the shadows to work.

Although my shadows and lights are very pixelated though... I think it's because the objects are small, which can serve a problem since my game is small.

This is my code thus far...



But at least I got the shadows working!!!

Thanks for your help The Slayer

EDIT: Yeah actually... with shaders, do objects in the scene have to be large? Because the biggest object in my game is the platform that I attached in my previous posts, which is 60 DBPro units in diameter.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th May 2010 12:49
Quote: "with shaders, do objects in the scene have to be large?"


No.

One problem with shadow mapping is that if you get too close to the shadow without adjusting the shadow depth map camera then your shadows will look blocky with jagged edges. The reason is that each pixel of the shadow map is covering too much of the scene on screen. You can improve things a bit by increasing the shadow map resolution or by using more filtering in the shader - but both of those options will reduce performance.

A better solution is make sure the shadow map is not "wasted" - i.e. try to set the shadow map camera so that as much of the shadow map as possible corresponds to what is actually visible on screen. For example, if your shadow map camera is set so the shadow map corresponds to a whole room and your main camera is focussing on a book in the character's hand then only a few pixels of the shadow map will affect the screen and you'll just see very blocky jagged shadows. It isn't easy to correct this properly - but is worth thinking about when using shadow maps in case you can see a simple fix that improves things without affecting performance. You can't easily get it right for all situations - such as when the visible scene contains a mixture of near and far objects.
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 24th May 2010 13:13 Edited at: 24th May 2010 13:15
Hmmm... I sort of get what you mean. Although I probably have to keep reading your explanation until it hits me...

But uh, in terms of camera. I noticed that the camera has something to do with the shadows. Like in my scene, if I moved the position of the camera in the DO LOOP, the position of the light source changes.

That got me thinking... where "is" the light source coming from? Because in the code that I got from EVOLVED, you don't actually move the light, you move the PLAIN object (Object 20).

So... it seems that the "lightsource" comes from "a camera" in the scene.

Is that right? If so... then can I treat that camera the same as a normal camera? Because in my game, the camera follows the player.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th May 2010 13:35
Quote: "So... it seems that the "lightsource" comes from "a camera" in the scene."


Yes - that's how shadow mapping works. The idea behind shadow mapping is that you place the shadow mapping camera at the light's position - i.e. from that position everything the camera can see must be lit and, conversely, everything the camera can't see can't be lit. The next step is to make the shadow map camera render the distance or depth of each pixel from the camera so the shadow map itself is often greyscale depending on the format used for encoding depth. The fun starts when you try to line up what the shadow map camera sees with what the main camera sees.

Quote: "Is that right? If so... then can I treat that camera the same as a normal camera? Because in my game, the camera follows the player."


Not sure what you mean. If the player corresponds to the main camera and you place the shadow map camera at the main camera's position you won't see any shadows. However, if your game has the main player in the centre of the screen with the main light following the player, then, yes, the shadow map camera should also follow the player. You just need to make sure that the shadow map camera is facing the right way. Shadow mapping is designed for positional lights - but you can mimic a directional light by placing the shadow map camera a long way away with a narrow field of view and long range. I believe someone on the forum got shadow mapping working with a directional light but I'm not sure we've seen the code yet.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 24th May 2010 14:36
@DB_Newbie:

I just had a play with the CubicShadowMapping.FX file in DarkShader. I've adjusted it, so now the shadows should be less pixelized for your scene. Try it out and tell me if it works, okay? Just replace the previous FX file with the one I adjusted and change your code accordingly.

Quote: "Thanks for your help The Slayer"

No problem. Glad to help.

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 24th May 2010 16:11
@ Green Gandalf

Ok that "sort of" makes sense to me in terms of the relationship between shadow mapping and a camera.

To be more detailed... my player in the scene has a glowing object following him around. The only light source in the game is in that object (so think of it as a lantern)

So... all I have to do is make sure that the camera where the "light" is coming from is always positioned at that object's position right?

@The Slayer

WOW! You are awesome! Yeah, the shadow got less pixelated. Much better on the eyes hahahaha.

May I ask what you changed in the .fx code? Just so I can understand it a little more? Thanks.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 25th May 2010 20:09 Edited at: 25th May 2010 21:14
Quote: "WOW! You are awesome! Yeah, the shadow got less pixelated. Much better on the eyes hahahaha."

Well, I'm no expert on the matter (that would be our friend Green Gandalf), but thanks anyways!

Quote: "May I ask what you changed in the .fx code? Just so I can understand it a little more?"

I lowered the values in the shader that render the shadowmaps. The shader renders 9 shadowmaps of each object in the scene. Each shadowmap is a bit larger than the one nearest to the object and gets more transparent on the exterior shadowmaps (see screenie) to give softer edges to the shadows. So, in order to get the shader working for your scene, I lowered the size of those shadowmaps.



Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 26th May 2010 06:53
Hmm... so before it rendered 9 shadowmaps and so you changed it so that it only rendered out like 3 shadowmaps? Is that right?

Also, I forgot to ask this several posts ago... but how do you change the "brightness" of the lights?

I can't seem to figure it out in the code itself. So I assume it's in the .fx file?

Because before, the only way I could dim the light in the scene was to move the light source further away, but I want my light source to be near an object and emit a rather dim light.

If it is indeed in the .fx file, is there a way I can achieve an affect where the light dims and brightens at random intervals? You know, like how candles never emit the same brightness... instead their brightness brightens, then dims, then brightens, then dims.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 26th May 2010 18:33
@DB_Newbie
Just make the colour of the light darker.

The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 26th May 2010 22:52
Quote: "Hmm... so before it rendered 9 shadowmaps and so you changed it so that it only rendered out like 3 shadowmaps? Is that right?"

No, it isn't. It still renders 9 shadowmaps. But I lowered the values to make them smaller for your scene. You probably got those pixelized shadows before, because the camera (from the shader) that renders the shadows is close to your objects.

Quote: "but how do you change the "brightness" of the lights?
I can't seem to figure it out in the code itself. So I assume it's in the .fx file?"

Yep, you've got that right.

Quote: "If it is indeed in the .fx file, is there a way I can achieve an affect where the light dims and brightens at random intervals?"

Yes, there is a way to manipulate the light (and lots of other values in the shader), so I had another play with the shader effect, and adjusted your code so you can manipulate the following things in the shader with DBPro:

- the lightrange of the light
- the ambience of the light (Red,Green,Blue)
- the color of the light (Red,Green,Blue)
- the range of the fog
- the color of the fog (Red,Green,Blue)

Here's the code:


And, here's the adjusted shader FX. Don't forget to replace your previous effect with the new one, okay?

Enjoy!

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 27th May 2010 04:48 Edited at: 27th May 2010 04:51
Thanks again The Slayer. I played around with the new variables and stuff and I got the hang of it.

You know... I was reading the code and the .fx code and I just noticed something.

In the .fx code is a section called "Tweaks" and under that are Float numbers and their corresponding functions like LightColor and the like.

These also correspond to the ones in the code itself. So... if I understand this correctly...

To tweak one of the functions you first call it in using:

null = MAKE VECTOR4(3) - With the number in the brackets indicating which function in the .fx

Then you adjust it accordingly using:

SET VECTOR4 1,1.0,0.0,0.0,0

Then the following tells the code which function that the numbers from SET VECTOR4 is adjusting:

set effect constant vector 1, "LightColor", 1

And I assume that the following closes it or confirms the changes?

null = DELETE VECTOR4(3)

Is that right?

Man I'm so excited for some reason, but also afraid when the time comes to put all this into my existing game. I really hope all goes well with that.

Also, I feel really bad asking again, but with lightmapping, can you also add like a "visual" representation of the light's range? Like you know those cartoons or story books where a person is holding a candle and you can see a circle of light around the candle? Rather than a smooth transition from light to darkness?

With the .fx file, I'm trying to adjust the settings so that instead of the light having a long gradual transition from light to dark, that transition becomes much shorter so on the screen, you can see a visible circle of light around the light source.

Because when you play the game, I want that circle of light to be always on the light source and clearly visible to the player (like those you see in children's story books). Like I can make the light right now create a definitive circle on the ground. But that's only on the ground. Too bad I can't seem to find an example on the net =/
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 28th May 2010 20:30
Quote: "Like I can make the light right now create a definitive circle on the ground. But that's only on the ground. Too bad I can't seem to find an example on the net"

Do you mean like this (screenie)?


Quote: "To tweak one of the functions you first call it in using:
null = MAKE VECTOR4(3) - With the number in the brackets indicating which function in the .fx"

Quote: "Is that right?"

No. The numbre in the brackets doesn't indicate which function in the .fx file. You can give each vector the same numbre (in the brackets), IF you delete that same vector AFTER using it, like this:



But your other assumptions were right, though.

Quote: "Also, I feel really bad asking again, but with lightmapping, can you also add like a "visual" representation of the light's range? Like you know those cartoons or story books where a person is holding a candle and you can see a circle of light around the candle? Rather than a smooth transition from light to darkness?"

Well, you could check each loop the position of the shaderlight, and position a ghosted image (like a torchlike glow) at the same position, and even animate it?

Cheers

Slayer rules!!! Yeaaah, man!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th May 2010 17:44
There is no need to delete and recreate the vector after each set effect constant vector command - just re-use it. Also, you seem to be confused between vectors 1 and 2. I think you meant something like this:

DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 31st May 2010 11:48
Yeah, that's what I meant with the circle on the ground. How did you make the circle that sharp? Although, why is the teapot's shadow "noisy"?

Ah ok, I think I got the VECTOR thing now.

So basically with the circle of light, every time it renders out the shadow, at the same time you render a ghost version of that shadow in front of the camera?

I'm reading the latest .fx file now and is it something to do with the sections called Vertex Shader and Pixel Shader? Because under Pixel Shader, it looks like it has x,y,z co-ordinates:

float shadowmap=1-(texCUBE(DepthMap,IN.ShadowMap+float3(-0.2f,-0.2f,0.2f)) < Depth ? 0.111f:0.0f);
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 31st May 2010 13:42
Quote: "How did you make the circle that sharp? Although, why is the teapot's shadow "noisy"?"

Actually, it's from another shader by EVOLVED. I'll have a look later on to see which shader it was and some code if you need?
It allows you to render an image (like a flashlight or like the projection of colored glass...) to any location possible (floor, wall, etc...). The shadow is kinda filtered through another image to make it look softer or less edgy. But you don't have to if you don't like it.

Quote: "float shadowmap=1-(texCUBE(DepthMap,IN.ShadowMap+float3(-0.2f,-0.2f,0.2f)) < Depth ? 0.111f:0.0f); "

Yep, those are the values that I changed to get the shader work for your scene.

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 31st May 2010 14:00
Another shader by Evolved? Don't worry about it then. I'm already hands full trying to fully understand this one =P

For now, the way the light is shone on the ground is fine. I'm just trying to get a visual representation of the light's range (because there is an enemy I have that attacks the player when it is hit by light and I need to show the player how far the light reaches out.

Ok, so I got the right lines of codes to look at, but how do I exactly get it to render a ghost version of itself in front of the camera?

Because the only line of code that has to do with positioning something is this:

SET EFFECT TECHNIQUE 1, "DepthMap"
Render Dynamic Cube Map 1, 1, OBJECT POSITION X(20), OBJECT POSITION Y(20), OBJECT POSITION Z(20)

But this is a Technique written inside the .fx code and it is positioning the lightsource. I'm trying to play more with the code but having trouble trying to get it to render a circle of light in front of the camera.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 31st May 2010 14:31
Quote: "I'm just trying to get a visual representation of the light's range"

Well, with the shader that you're using right now, I'm afraid you can't achieve that effect. Or, you would have to change the .fx code to make it work. The rendering of the lightcircle is done from within the shader by projecting an image (a black image with a white circle in the center) to the objects in the scene and to the floor.

Quote: "Ok, so I got the right lines of codes to look at, but how do I exactly get it to render a ghost version of itself in front of the camera?"

Quote: "float shadowmap=1-(texCUBE(DepthMap,IN.ShadowMap+float3(-0.2f,-0.2f,0.2f)) < Depth ? 0.111f:0.0f); "

These lines only take care of rendering the shadows.

Cheers

Slayer rules!!! Yeaaah, man!
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 31st May 2010 14:46
Quote: "There is no need to delete and recreate the vector after each set effect constant vector command - just re-use it. Also, you seem to be confused between vectors 1 and 2. I think you meant something like this:"

Thanks for pointing that out, Green Gandalf!
I thought it was best to delete the vector each time.

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 31st May 2010 15:22
Oh ok,

Damn... hmm... I guess I'll have to go to my back up plan.

But the light itself and all its effects are exactly what I wanted. Although I think I'll have to play around with the fog a bit more.

By the way, if I wanted to make 2 lights using Lightmapping, do I have to basically duplicate all the necessary and required lines of code for the 2nd light?

I'm kinda thinking that, but considering how Lightmapping works, 2 light sources would only just conflict with one another right?
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 31st May 2010 16:09
Quote: "I'm kinda thinking that, but considering how Lightmapping works, 2 light sources would only just conflict with one another right?"

If the shader you're using is set up for it, then you could have more than one light at the same time. But the one you are using now, doesn't allow that. Evolved has some shaders that uses up to 7 (or 8?) lights at once, though.
I'm gonna try to make the shader that you're using now, to render the circle of light too. I'm not promising it'll work, but I'll give it a go.

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 1st Jun 2010 10:00 Edited at: 1st Jun 2010 10:36
Yeah that'll be great. Good luck with it and hope you succeed. No pressure though, I have a plan B on how to achieve a circle of light for the player to see. Though it's probably a long and complex process.

I'm playing around and trying to understand Evolved's Multipass Lighting right now because the first code is what I'm looking for in terms of more than 1 lights.

EDIT: Oh and I assume that if I use Light Mapping, the DBPro's own lights won't appear on screen right? Because I tried making a light on screen and I couldn't see it despite me colouring it in.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 2nd Jun 2010 00:06 Edited at: 2nd Jun 2010 08:59
Well, here's some effect I did today. I used some of Evolved's code, so I hope he doesn't mind? This shader renders shadows and gives objects a metallic kind of shine to them. As you can see, it renders more shadows too. What do you think? Nice, hey?



Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 2nd Jun 2010 08:02
Oooooo shiny....

That looks awesome The Slayer ^^ very nice.

Been looking at Evolved's Multipass Lighting and it seems to be a more complicated process considering it uses a 2nd BDPro file (the one where it uses the command "#include".

Was it a case of keeping things simple when he made two DBPro files? I mean, the functions found in "Lighting Functions" can be simply put in the same file as the original scene right?

And yeah, does DBPro's lights become obsolete when using Shaders?
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 2nd Jun 2010 22:16
I found that the Multipass Lighting shader takes a large bite of my fps when you add more complex objects for it to light. What I found is good is to lightmap a level and then use blendmapping for a normal mapping effect.

If it hasn't exploded yet, I haven't touched it.
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 3rd Jun 2010 09:40
I guess I really won't be using Multipass then since I need a light for a game that is filled with objects.

What exactly is blendmapping and is it easy to implement?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jun 2010 12:23
There are some simple examples a few posts down on this thread:

set blend mapping on - how does it work?
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 3rd Jun 2010 12:38
Hmm... so blend mapping is simply combining two maps together to occupy one "slot"?

Well anyway, I bookmarked that link and I'll come back to it if I have to cross that bridge. For now, I'll stick with light mapping ^^
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jun 2010 23:18
Yes - but you can do it up to 8 times in many different ways which gives plenty of scope for many different effects.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 3rd Jun 2010 23:43
@Green Gandalf:

Or, writing a shader which has all those features in it? Then it would only be a matter of using the different techniques unto objects with only one shader. Or wouldn't that be possible?
Blend mapping is probably faster in some occasions, but shaders give far more flexibility and the quality is better too, right?
Of course, writing shaders is much more difficult than using the blend mapping commands.

Cheers

Slayer rules!!! Yeaaah, man!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jun 2010 00:35
Yes.
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 4th Jun 2010 12:01
Well my game doesn't involve flashy visuals or effects. It's more concentrated on the story and game mechanics / game play.

But I'll probably look into it later once I'm finished with this.

Man I really want to implement the light mapping now, but I can't until I fix a couple more of the world's rules and physics and until I can get the character asset in.

Hopefully by then, when I DO implement the light mapping, I can still use this thread so I don't have to make another ^^

I don't want to sound annoying and persistent, but can someone answer my previous question about using DBPro lights with light mapping. I tried it with the current one, placing a light above the scene and its "light" doesn't appear. But I could be missing something. I just need a confirmation on this.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 5th Jun 2010 12:47
Quote: "Man I really want to implement the light mapping now, but I can't until I fix a couple more of the world's rules and physics and until I can get the character asset in."

Do you mean the shadowmapping shader, or the multiple lighting shader? And, what do you need to fix?

Quote: "I don't want to sound annoying and persistent, but can someone answer my previous question about using DBPro lights with light mapping. I tried it with the current one, placing a light above the scene and its "light" doesn't appear."

Is this the issue that you mentioned earlier that needs to be fixed? Because, I don't think you can add lights with the DBPro commands while you're using a shader to manipulate the lights in your scene. I could be wrong, though. I guess that the lights that the shader uses, are the same lights that DBPro uses. But, the shader has probably a higher priority, so when using a shader, the light commands are dissabled. But, as I said before, I could be wrong.
Maybe someone else can shed a light upon this?

Cheers

Slayer rules!!! Yeaaah, man!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 6th Jun 2010 17:13
Oh I meant the Cubic Shadow Mapping by Evolved.

As for the things need fixing, they're nothing big. Just making sure my game is consistent. Like I need to make the speed of my gravity fall the same as my jump's fall (the gravity just moves the player downwards with a constant speed of 0.3 whereas my jump's fall is more fluid because when the player jumps, his speed begins at 1.0 and is constantly lowered by 0.2 so he starts fast, slows down and when he falls, he continuously gains speed until he falls off the map)

As for the DBPro lights, no that isn't one of the things that needs fixing. I have yet to implement the Shadow Mapping into my game because I'm waiting for my character asset to come in.

Anyways, yeah, I'm not surprised if DBPro's lights become "obsolete" when using shaders. I just needed a confirmation. For now, I'll play it save and just assume they don't appear.

Thanks.

Login to post a reply

Server time is: 2026-07-25 16:21:19
Your offset time is: 2026-07-25 16:21:19