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 / Dark Lights wall shading help.

Author
Message
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 14th Nov 2013 04:33 Edited at: 14th Nov 2013 04:38
Hello.

I use Dark Lights to add shadows to my world. My world is made up of tiles.


It shades just fine except on the side of walls, were it shades kind of wrong. I don't know how to describe it so I uploaded a photo. Look at the wall to the right.

I tried fixing it with SET OBJECT LIGHT thinking that maybe the shadows are from the native DBP default light. And it does remove the shadow. But only if I disable Dark Lights. When I turn Dark Lights back on they appear.



Thanks.
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 12:56
Those tiles on the right look identical to me.

Are they instances of one parent tile? If so then they will all have the same UV references to the light map (it's a while since I used Dark Lights but I believe it works by creating a light map combined with creating an extra set of UV data for each object - but that won't work with instances if I've understood correctly).



Powered by Free Banners
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 14th Nov 2013 19:00
They are clones. When they were instances Dark Lights Told me it skipped them.
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 14th Nov 2013 19:15
Are These objects made at runtime by DBP or are they loaded from files?
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 14th Nov 2013 19:40
They are copied from a source object that was loaded into the program via load object
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 19:57
Do you mean they were copied after you created the light map? If so then that's essentially the same problem that I described. If, however, you created and positioned the clones and then created the light map it sounds as if you've hit a bug. What happens if you create new objects rather than clones or instances?



Powered by Free Banners
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 14th Nov 2013 20:07
They are copied before the light map. and loading them like the base object instead of cloning from the base object has the same effect.
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:52
Are you putting them in their correct positions before computing the light maps?



Powered by Free Banners
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 14th Nov 2013 21:06 Edited at: 14th Nov 2013 21:13
yes. lighting the map is the last thing the map loader function does before starting the game.

edit:

oh and yes each object is positioned before I add it into the lighting system.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2013 00:33 Edited at: 15th Nov 2013 01:25
Strange. I'll try to reproduce that tomorrow (when I'm awake and have located my copy of Dark Lights ).

Edit Last thought before I shut down for the night: have you tried swapping the stage 0 and stage 1 textures, i.e. base texture and light map? If these are the wrong way round for some reason then you might get that effect.



Powered by Free Banners
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2013 12:03 Edited at: 15th Nov 2013 15:46
I've just set up a simple scene using a tiled wall and I don't get the problem you're having.

Can you produce a simple trimmed down sample which shows the problem?

Here's the code I used. The "ground" is a single flat plain, the wall on the right is a sequence of identical tiles:



Edit Here's a better version of the same thing. The first time you run it, it creates the lightmaps and saves the objects. The next time it simply loads the previously created objects and lightmaps. Uses clones for illustration - and includes the extra flag when the plains are created (seems to be necessary).





Powered by Free Banners
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 15th Nov 2013 15:40 Edited at: 15th Nov 2013 15:44
Here is the code that starts DL and sets up my sun. I put it way back so the shadows would be constant in length.



The map is built in a "for x = 1 to" style. The grid is 10 by 10.



The code that builds the light map is the same from the demos.




I also included the object and its texture. Be sure to download them.

Thanks for your time bro.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2013 15:48
Ha! I see we posted at the same time.

I'll look at your code as soon as I can (must do some shopping some time this afternoon ).



Powered by Free Banners
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 15th Nov 2013 15:51 Edited at: 15th Nov 2013 15:57
Lol.

K thanks bro.

hey wail I'm at it do you know how to save the light map object? or to bake the shadow textures unto one big object so I can load it up later?
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Nov 2013 15:58
Quote: "LM Add Custom Point Light posX#,posY#,posZ#,500000000000,500000000000,0,1.0,1.0,1.0"


The bolded values are too large to be interpreted as integers / dwords / (reasonable) floats.
You will probably get significant floating point errors with such values; try to set them to something like a million or below, which should still be large enough.
If they are parsed as integers first before being cast to floats the value will also wrap around and would in that case not necessarily reflect the desired value at all. In this case it would become ~1.7 billions, which I guess is still valid for your purpose, but with another value it could end up close to 0 or negative. Just a heads up.


"Why do programmers get Halloween and Christmas mixed up?"
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2013 16:00 Edited at: 15th Nov 2013 16:03
Quick question for now. What's the point of the asterisked line in your snippet?



Edit

Quote: "hey wail I'm at it do you know how to save the light map object? or to bake the shadow textures unto one big object so I can load it up later? "


See my earlier edited post with code doing just that.



Powered by Free Banners
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 15th Nov 2013 16:11 Edited at: 15th Nov 2013 16:24
@ Rudolpho

Good to know. Thanks for the pointer.

@ Green Gandalf

That is the type of world peace it is. Though it does not serve much purposes in the actual game I guess. :\

I was going to use it in the actual game. But the way the code evolved it never really came into play. Guess I should remove it to save memory.


you mean this here?



I though it just saved a bunch of objects. I don't understand how that would save the shadow texture on it and reposition itself in a dynamic matter. (instead of incrementing)
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2013 18:48
Quote: "I though it just saved a bunch of objects."


Yes it does and the .dbo format preserves the texture and lightmap references so when you reload they are all retextured correctly as you can see in my demo. You still need to position and rotate them in the loading code - as in my demo again. So you'd need to store those values as well.

I've just re-read your questions - I was answering the first one really.

I don't really see how your code fits together. What's the value of cliffleftright and what does it represent? Also, what do the "0" and "1" represent in these two lines?



What are these objects? Plains, boxes, cubes? If they are plains then your screenshot shows a sequence of sides and tops (assuming we are looking down at the scene). How do those faces relate to the 0 and 1, etc?

It would help enormously if, instead of providing isolated snippets, you gave one simple piece of runnable code. You can prune a lot of stuff out of it and just leave the bit that's causing trouble. It would save all these questions.



Powered by Free Banners
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 15th Nov 2013 20:53
Quote: "Yes it does and the .dbo format preserves the texture and lightmap references so when you reload they are all retextured correctly as you can see in my demo. You still need to position and rotate them in the loading code - as in my demo again. So you'd need to store those values as well."


ohh I get that. That's cool. I'm sure I can work that in some how.

oh sorry for being a little difficult. I'm going to do what you said and make an executable that will show you whats up and include relevant code. I'll hop on it, But I'm a little busy today. so it might be later.

But for now I'll answer your questions above.

the objects were made in milkshape. they are like cubes, but missing there bottoms.... now that I think about it they were plains that I extruded. I'll try replacing it with a cube of the same proportions. maybe that is whats going on...

I store the data inside an array. cliffleftright is the ID of the cliff tile peace. so basically when it reads a slot in the array is "cliffleftright " it will load a cliff tile there.



the 0 is the object's number used for map maker purposes of removing and replacing it with something else. though it's obsolete in the main game code. The map editor and game loader share the same world loader (for the most part) I should optimize it...

the 1 is what kind of tile is occupying this slot in the array. though like above it's more so for the map editor.

I'll post a new reply here when I finish the EXE. but like I said that might be later.

Thanks for your patience.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2013 22:20
Thanks, but the exe is no good.

I need the code itself. I realise you probably don't want to provide all your code and media, but this problem looks like you only need one object and one texture - with the object cloned or copied many times within the code. So a very brief bit of code should be all that's required to reproduce the fault. Or is that what you meant by "include relevant code". By "runnable" I meant both compilable and runnable.

Thanks for the explanation of the 0 and 1 slots in the array. I'll have another look in the meantime to see if anything occurs to me. You could try Rudolpho's suggestion although I doubt that's the issue here. I could be wrong though.

Don't worry about timing, I'm in the middle of cooking supper myself so no rush.



Powered by Free Banners
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 15th Nov 2013 23:19 Edited at: 15th Nov 2013 23:20
Quote: "You could try Rudolpho's suggestion although I doubt that's the issue here. "


Already tried that. Did nothing.

I guess I did not make it clear that I was going to give you the code in the manner you said. I was just going to include the exe as a fast launch for you so you could see it right away. I mean maybe it was somehow local to me. but it turns out I was onto something.

Quote: "the objects were made in milkshape. they are like cubes, but missing there bottoms.... now that I think about it they were plains that I extruded. I'll try replacing it with a cube of the same proportions. maybe that is whats going on... "


turns out that was it. I made a box and put it to the same proportions as the plain I extruded. and that removed them. The screen shot below shows the new object vs a modification of the original object.



Thanks for the help.

On a side note what are you making? I have not had dinner yet and I'm starving... I want spaghetti so bad.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2013 23:46 Edited at: 15th Nov 2013 23:51
Interesting. I wonder what was throwing things off?

I wonder if it's a similar issue to the one that requires us to add the final flag when creating a DBPro plain?


Turning to more important things:

Quote: "On a side note what are you making?"


I'm glad you asked that.

It doesn't have a name but was originally invented as a means of using up the copious quantities of courgettes that we grew this year. It has since been used as a means of using up surplus things lurking in the fridge or cupboard. Tonight's concoction involved diced potatoes, carrots, courgettes, mushrooms, capsicum, tomatoes, mixed with chopped and fried garlic (two varieties ) and onions (the potatoes and carrots were parboiled first). Then seasoned with a fresh chopped red chilli, coarsely ground black pepper, a few bay leaves and a sprinkling of sea salt. Then approx 120 ml of water was added to the mixture, stirred and the whole lot cooked in the microwave on a high setting and stirred once during cooking. When it was all cooked I melted some goat's cheese on the top and served. For those who are interested in such things, the potatoes, courgettes, onions and garlic were all home and organically grown. Further details available on request.

Edit Forgot to mention the spoonful of tomato puree mixed in before cooking. Don't think I missed anything else.

Now, where were we? Oh yes:

Anyway, glad you got it sorted.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-07 00:09:27
Your offset time is: 2026-07-07 00:09:27