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 / DarkBasic Built In Lighting & Shaders

Author
Message
UnrealSWAT
14
Years of Service
User Offline
Joined: 24th May 2012
Location:
Posted: 19th Apr 2013 11:15
Hi Everyone,

I've been trying to search both Evolved's forum and this forum in search of an answer but I couldn't find one anywhere. I've been putting together my own modular based game engine for my own game. Coming together nicely, so I thought I'd make it look prettier by including Normal Mapping (I'm not an artist so I can't say I could get the textures together for a more advanced effect, I just make normal map versions of royalty free textures I find! Not the best practice I know)

So I added some lights, one of which is always at the position of the camera, I set my skybox to not be affected by light. When I'm moving around without the shader on I can see the light is affecting the rest of the map no problem.

I made a routine that goes through the MapScape based map I've made and textures each limb with the default texture at stage 0, normal map at stage 1, normalize texture that's included with the normal map shader at stage 2. Then I use the effect on the limb. Then the map goes dark no matter what I set the light to. I can tell the shader is on and looks like it's working etc. I just can't get the light to hit it properly.

Do the built in lighting commands work with the shader? Or if not since I own Dark Lights do those lighting commands work with the shader?

If not are there any other shaders I need to be made aware of that do work with them?

Can't get my head around this one :/

Thanks in advance for any help!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 19th Apr 2013 15:35
The lighting is calculated in the shader itself (if the shader was written to support it), so no, the built in lights will not affect anything with your shader.

You need to use a shader which supports lights. Usually the lighting data is passed to the shader by using a global variable. For example, if my shader uses the variable lightPosition to calculate lights:



You have to change that variable to the light position in DBP by doing this:



Note that the shader remembers what position you set the lights to last, so if you don't move your lights anymore, you only have to give the positions to the shader once.

Run a forum search for the free shader package and for evolved's shaders. There are definitely normal shaders that support this.

TheComet


Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 22nd Apr 2013 16:52
You can rig your game to position the shaders lights in the same place/orientation as the built-in lights so everything lines up nicely. An issue that crops up is that the shader only supports a set number of lights. So if you have less lights then supported, then the shader is still processing zeroed or empty lights. If you need more lights than the shader supports then you need to work out a method for sorting lights to fit on the shader. An example would be the player walking into new game areas with different lights. It's possible to switch shaders to increase and reduce light counts, but this requires knowing how to rewrite the shader.

Login to post a reply

Server time is: 2026-07-07 10:33:51
Your offset time is: 2026-07-07 10:33:51