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 someone help me make a flashlight?

Author
Message
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 14th Aug 2011 06:28
I can model a flashlight, but i cant ever get lighting to work. if i add a new light, the whole screen turns green?

onhcet d(-_-)b techno
wickedly kick it
19
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 14th Aug 2011 08:00
http://forum.thegamecreators.com/?m=forum_view&t=60628&b=10

Google it first

Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 14th Aug 2011 08:34
Ive already googled it and found the same link but i cant see the images the user posted and the download links are broken

onhcet d(-_-)b techno
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 14th Aug 2011 17:13
Using a hardware light as a spotlight works okay'ish but you have to have more faces on an object for the effect to work properly.

Warning! May contain Nuts!
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 14th Aug 2011 19:38
Faces on an object is not a problem with me and blender. Could you possibly show me how to make a spot light? Maybe make a simple one then upload it?

onhcet d(-_-)b techno
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 14th Aug 2011 22:47
Hardware spotlight: does need lots of faces to work half decent...



Warning! May contain Nuts!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Aug 2011 23:26
This version of your code is simpler and doesn't need IanM's utilities:

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 14th Aug 2011 23:53
Quote: "Hardware spotlight: does need lots of faces to work half decent..."


Yes...we need to make our levels with most faces posible to make something good .I have done the same but with two lights and looks better. I have tried to make it with shaders but that slow down my PC.





Cheers.

I'm not a grumpy grandpa
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 15th Aug 2011 01:08
it worked and i even got my own models in. I tried yours @chafari and i that is the one im using right now, but i cant find where your variables for a# and all that are located? how did you program it without having to set those variables?

onhcet d(-_-)b techno
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Aug 2011 01:41
@Beyond the Humans Knowledge

Hi there. Those variable cam# , a# are the two variables I use to rotate camera and lights. One light works, but I prefered to add a second light to give the feeling of a cone of light. I'm glad you like it.

Cheers.

I'm not a grumpy grandpa
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 15th Aug 2011 02:27
well i know what they do, but here is what i dont get?

a# = 0

see how i set a# the assigned value of 0.
I cant find where you put the values into the variables? How did you do that?

onhcet d(-_-)b techno
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Aug 2011 03:11 Edited at: 15th Aug 2011 03:18
Sorry but I don't know what you mean...

I have not a#=0 in all my lines of code...Do you refer perhaps ?:



I gave three values to the light rotaion x,y,z (cam#,a#,0)

Is that what you mean ??

Edit- Sorry for my stupidity...now I know what you mean
I asign the value to a# in:


So every move I make with the mosue, will be asign to variables cam#/a# right?



Cheers.

I'm not a grumpy grandpa
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 15th Aug 2011 03:18
yes, thank you. instead of putting an exact value for cam# and a#, you just put them for the x and y. I didnt know you could do that?

onhcet d(-_-)b techno
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Aug 2011 03:21
Yes we can do that....we post at the same time sorry

a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)


with this two lines, we get all mouse moving

Cheers.

I'm not a grumpy grandpa
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 15th Aug 2011 03:27
thanks alot, the mouse moving was KILLING ME!!! i putting

camera angle x() = mousex()

and it was comming with the error

"could not understand command at line **"

replacing ** with what line it was.

onhcet d(-_-)b techno
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Aug 2011 18:43
Camera angle X() returns a value, (You can tell as it has brackets) it doesn't set a value. You want X Rotate Camera.

My signature is NOT a moderator plaything! Stop changing it!
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 18th Aug 2011 07:53
i imported my own walls, but the light doesnt show on them, but the show on the matrix?

onhcet d(-_-)b techno
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Aug 2011 14:25
Quote: "i imported my own walls, but the light doesnt show on them, but the show on the matrix?"



You have to add more faces into your walls. Can you rar your model to check ?


Cheers.

I'm not a grumpy grandpa
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 18th Aug 2011 18:26
well i got this world editor with the dark basic i got, but im going to have to just make some walls in blender and put like maybe 500-1000 faces on it.

onhcet d(-_-)b techno
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Aug 2011 18:35 Edited at: 18th Aug 2011 20:51
I'll make an example for you.

Edited
Download this exmple.Notice that only the interior walls are in high poly but not the wall aut the corridor. Press spacebar to see the object in wireframe. We can make a big map but just the wall we need in high poly need to have more faces.


Cheers.

I'm not a grumpy grandpa
technotdc
15
Years of Service
User Offline
Joined: 13th Apr 2011
Location:
Posted: 19th Aug 2011 03:05
bffffffff..........amazing chafari ¡¡¡
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Aug 2011 03:35
@technotdc
Thanks , I'm glad you like it

cheers.

I'm not a grumpy grandpa
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 19th Aug 2011 09:23
well i got my wall imported with 8000 faces anyways, the other problem now is im starting to learn collision with the camera and all that, but when i use automatic camera collision command, i stop at the object, but if i still hold forward, i will soon go through the object? I dont know how to load all these other collision dll's either, so please dont direct me to them unless you can help me with installing them. (sorry if it sounds rude)

onhcet d(-_-)b techno
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Aug 2011 12:32
Ok , there are better collision, like Sparky's dll but I will show you here in my example other easy collision. Download the example and try loading your level.


Cheers.

I'm not a grumpy grandpa
technotdc
15
Years of Service
User Offline
Joined: 13th Apr 2011
Location:
Posted: 19th Aug 2011 17:18
@ chafari

I'm creating now a level (well..a room) with MapScape,because i want your flashlight/collision system.
(with FPSC level it's impossible to "set ambient light to 0" and the flashlight effect are very ugly (low poly) ))

I hope you help me


Eres un puto crack
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Aug 2011 17:24
Apart from upping the poly count which can be a nightmare, the only other method is possibly using decals. It's something I haven't done yet so I couldn't help much. There's also hardware lights and hardware shadows if your graphics card will support it but using them can reduce frame rates.

Warning! May contain Nuts!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 19th Aug 2011 17:35
http://www.evolved-software.com/shaders/lighting

I'd definitely go with the shader flash light method, it looks great.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Aug 2011 18:56
@technotdc
I have to say that is not the same lights in real time and lightmapping. I you are using Mapscape from Evolved, you could use shaders as indicium suggest. I like all Evolved shaders and Mapscape, but shaders slow down too much my PC. The kind of flash light I have showed above, use a lot of polygons where we need to create this effect, but we mustn't add too many. As WLGfx says, it could be a nightmare . This is not a method competision to see which is more realistic, it is a matter of keeping the most FPS possible. Not many games use flash lights and those that do, use to be commercial games so far. I like the method I use that keep more FPS being not so realistic though .


Cheers.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Aug 2011 20:01 Edited at: 19th Aug 2011 22:33
You could do it with a dark plain with a fade to white centre. Maybe add a cone to it.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Aug 2011 20:45
Pincho has come up with a reasonable idea.

Using a plain directly in front of the camera with a transparent texture on it would give a good effect. You can also use 'Set Object Alpha' to fade it out a tad too so the scene will show through partially.

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Aug 2011 22:27
Quote: "Pincho has come up with a reasonable idea."


Believe me, using a mask is not the best idea since the effect is not the same. The best way is to use real lights, which means we lose FPS or using a shader. I made my onw function that set every mesh to high or low poly ,depending on where you pointed the light using change mesh, and the effects was acceptable, but the worst was the design of the map that was very hard


Cheers.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Aug 2011 22:36
Quote: "Believe me, using a mask is not the best idea since the effect is not the same. The best way is to use real lights, which means we lose FPS or using a shader. I made my onw function that set every mesh to high or low poly ,depending on where you pointed the light using change mesh, and the effects was acceptable, but the worst was the design of the map that was very hard


Cheers."


But you said....

Quote: "This is not a method competision to see which is more realistic, it is a matter of keeping the most FPS possible."


chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Aug 2011 23:00
Sorry Pincho Paxton , I love most of your codes, and I know I said that... is not a competision , but perhaps what I meant, is that more polygons was not so slow as shaders in my PC that's why I mentioned this method. I have used aswell a mask as you said with a plain, but looks different.I apologize if there might be some misunderstanding as we do this for fun, not to create friction between us. For oder friends that could be upset with my comments,
I have nothing against the shaders

Cheers.

I'm not a grumpy grandpa
technotdc
15
Years of Service
User Offline
Joined: 13th Apr 2011
Location:
Posted: 20th Aug 2011 00:30
Quote: "The kind of flash light I have showed above, use a lot of polygons where we need to create this effect, but we mustn't add too many. As WLGfx says, it could be a nightmare ."



ok.....thanks
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 20th Aug 2011 07:29
chafari, your file was great, but i cant read spanish!?

onhcet d(-_-)b techno
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Aug 2011 12:23
Quote: "chafari, your file was great, but i cant read spanish!?"


There are not too much to translate, but here you have




Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Aug 2011 15:41
Swapping objects to where a light is would be awkward too and possibly take a lot of disk/memory space unless you could create a function that subdivides objects after loading.

I'm going to have a look into this problem and see what methods I come up with, if any that are fast enough. The easiest is definitely the plain object, but then that wouldn't work in a multiplayer environment. I've never done shaders yet so I don't know, so it might be time to try them out.

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Aug 2011 17:01 Edited at: 20th Aug 2011 17:02
Quote: "Swapping objects to where a light is would be awkward too and possibly take a lot of disk/memory space "


In my case, I get more than 200 FPS all the time whereas if I use shaders, the FPS drops too much. In my method I load a complete subdivided room with six limb . The trick goes ok whenever we have a light between two rooms or near the junction.


Cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Aug 2011 17:27
If the textures are shared between the objects then yeah... I think I'll have a go at subdividing an object in my next project just for LOD and hardware lighting... This subject has given me something to think about...

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Aug 2011 20:13 Edited at: 20th Aug 2011 20:17
Hi again.

Quote: "If the textures are shared between the objects then yeah"

we can check what texture has every wall to adopt new texture

Heres is an example using a mesh that place where the wall are when we point to them. It needs to be checked but it shows how it works.




cheers.

I'm not a grumpy grandpa
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Aug 2011 20:35
@chafari - excellent stuff and the fps is still high. For more complex objects it would definitely be handy to subdivide them. Your example works brilliantly.

Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Aug 2011 20:52
@WLGfx
Thanks....I think we could use three meshes at a time to cover a complete corner, but as I comented , it is hard to set a complete level .


Cheers

I'm not a grumpy grandpa
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 21st Aug 2011 20:11
my pc specs are

ATI Radeon HD 4800+
AMD Athlon II 64 x2 - 2.2Ghz
4Gb Ram.

im sure my pc can hold the shaders well.

onhcet d(-_-)b techno
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Aug 2011 21:32
Quote: "im sure my pc can hold the shaders well"


Nowadays most PC and laptops soport shaders, but when we make a game , we have to think in the worst conditions to ensure it will work to everybody.

Cheers.

I'm not a grumpy grandpa
cyril
18
Years of Service
User Offline
Joined: 6th Aug 2007
Location: 7 miles away from big ben
Posted: 22nd Aug 2011 14:21
Quote: "Nowadays most PC and laptops soport shaders, but when we make a game , we have to think in the worst conditions to ensure it will work to everybody."


It really depends on who his target audience is.

If you are aiming at the casual gamer then its more important to keep shader effects to a minimum, and push out more on polygons since they render faster than any effect for the lowest setting which is usually for netbooks

If you are aiming for the average gamer then you should try to aim down the middle line so only shader that will greatly bring more life to a game, like basic lighting to be achievable at the lowest settings, which is usually for mid-range computers. Something close to a intel p4 2.6Ghz and a GF 6600 or 6800 and 1 GB, which is normally a minimum spec for this class. avoid heavy effects like HDR, or any offset type mapping beyond normal mapping.

The hardest task to do when building a game is to make sure it runs on your target pc specs, this is made harder if you don't have a pc at the target spec to test the game on. and worst if you have a higher spec pc, since you'll be fooled to thinking that you have lots of headroom when you really don't.

For flash lights I used what Indicium said, it not a fissile choice for a casual gamer's machine, but it comes with a few extras such as up to 6 other real time per-pixel point lights, and a lightmap feature.

The Map must be in .dbo format with the lightmap texture at stage 1** for it to work correctly, I find the using either mapscape or gile[s]*(*with lightmaps at texture layer 1) works, however I unsure about dark lights compatibility. The less real time point lights you uses the faster it will run.

**Diffuse textures are normally at stage 0 by default.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 22nd Aug 2011 15:11
I would honestly suggest using Evolved's flashlight shader, or something similar. It runs efficiently on almost any computer, and is just a modification of his lightmap shader. Basically, it just has a cubemap for the flashlight, and then overlays the cubemap texture based on the current view projection onto the lightmap. So it blends into the level's lightmap, giving a flashlight effect. It's extremely efficient, the only downside is that it will not shine on objects that do not have a lightmap shader applied to them.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Aug 2011 15:55
Quote: "I would honestly suggest using Evolved's flashlight shader"


You are right !! I try long time ago with shaders in my old Pc and I couldn't get more than 10 fps, but I took a look to the link Indicium suggest, and it works great !! 240 fps I like it.


Cheers.

I'm not a grumpy grandpa
cyril
18
Years of Service
User Offline
Joined: 6th Aug 2007
Location: 7 miles away from big ben
Posted: 22nd Aug 2011 16:14
Quote: "the only downside is that it will not shine on objects that do not have a lightmap shader applied to them."


There is another downside, it can't be used on objects with an alpha channel or mask, since the transparency is removed, by the shader.

The best overall workaround is to use the Evolved's flash light shader on objects without alpha or masking, and use a subdivision on objects with transparency and use a hardware spot light at the same position and angle as the shader's flashlight.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 22nd Aug 2011 18:17
Quote: "The best overall workaround is to use the Evolved's flash light shader on objects without alpha or masking, and use a subdivision on objects with transparency and use a hardware spot light at the same position and angle as the shader's flashlight."


That's probably the best bet on a good system. And since the Evolved system applies to the level, you don't need to subdivide the level and use up unnecessary polygons. And any other objects not part of the main level are probably already relatively high-poly, like characters.

Just a note, too, the mapscape shader does support transparency. It's an option in the editor.
However, it actually exports two objects when you select that. The main object, but then a separate file for transparent objects, that use a different shader for some reason. It's a little complicated to load, but shouldn't be too hard.

Login to post a reply

Server time is: 2026-07-10 20:58:02
Your offset time is: 2026-07-10 20:58:02