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 / Ambient light with mapscape maps

Author
Message
Hell_666
17
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 8th Aug 2012 17:05
Hi, if I use the mapscape lightmap shader on my map created with mapscape, DBPRO lights seem to not work. So I can't use the "set ambient light" command and I really need to change the ambien light level in real time.

Is someone has a solution please ?

Thanks a lot.

Eternal suffering ...

I'm french
Brendy boy
21
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 8th Aug 2012 23:07
you need to code that inside a shader

Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 8th Aug 2012 23:07
Once you apply a shader to an object, the DBPro lighting system will no longer apply as the shader will be expected to handle everything regarding how the object is rendered, so you will have to add whatever light handling you need into that shader. At a basic level, you could simply add a new 'float3' vector (red, green, blue) to the shader called 'AmbientLight' or similar and then edit the pixel shader section to multiply the final result by that. Then, in DBPro, you can adjust that 3d vector to set the ambient lighting to whatever colour and intensity you want. If you need any more help then just say. Assuming you have permission to show the shader code, I can adapt it for you if you want.


Previously TEH_CODERER.
Hell_666
17
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 9th Aug 2012 00:23 Edited at: 9th Aug 2012 00:23
Erf, I don't know the HLSL (and any other shader language in fact ).

Quote: "If you need any more help then just say. Assuming you have permission to show the shader code, I can adapt it for you if you want."


Thanks, I need your help, and I don't think it disturbs Evolved that I post the shader code.



Eternal suffering ...

I'm french
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 9th Aug 2012 02:33
Quote: "Thanks, I need your help, and I don't think it disturbs Evolved that I post the shader code."

Sorry, I hadn't made the connection when you mentioned mapscape that it would be Evolved's shader. I'll no doubt already have it on my machine as a result so there is no problem there.

I'm afraid I'm not familiar with how that shader is used and without knowing which technique in it you're using I wasn't sure of the best place to add the ambient lighting so I went with what seemed most logical; I applied it to the existing light in the vertex shader. This should also be faster rather than doing the extra calculation per-pixel.



This line is the key line: 'float3 AmbientLight = { 1.0, 0.4, 0.0 };'. By default this should now add a red/orange shade to anything you render with it. You could set these all to the same value to simply lighten or darken...they're just RGB values applied to the entire object. I'm afraid I don't have any media to test it with to hand but I checked it compiled correctly in Dark Shader so hopefully it will be good to go. If it doesn't work or you have any other questions then let me know and I'll try and help tomorrow (00:30 now and I always get to the office by 07:00 so I need some sleep ).


Previously TEH_CODERER.
Hell_666
17
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 10th Aug 2012 00:58
Thanks a lot, I'll work on it

Eternal suffering ...

I'm french
Hell_666
17
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 13th Aug 2012 14:12 Edited at: 13th Aug 2012 14:12
I have an other problem now, I try to change the color in my code but there is no color whit this way



This code doesn't render an orange shade, the light is neutral.

Eternal suffering ...

I'm french
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 13th Aug 2012 16:18
It may be that I messed up something in my edit of the shader...
[Excuses] it was pretty late and I didn't have anything to test it with [/Excuses]


Until I have a moment to look into it, please can you try it with a vector4 instead of vector3 and just set the last value to 1.0? I believe you have to use vector4 with shaders even when working with a float3 in the shader.


Previously TEH_CODERER.
Hell_666
17
Years of Service
User Offline
Joined: 11th Jul 2009
Location: France
Posted: 13th Aug 2012 20:51 Edited at: 13th Aug 2012 20:54
You don't have any excuses to do

Ok, I'll try with vector4


EDIT : It works, thanks a lot

Eternal suffering ...

I'm french
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 13th Aug 2012 22:32
Awesome! Glad you've got it working, and no problem.


Previously TEH_CODERER.

Login to post a reply

Server time is: 2026-07-21 20:35:20
Your offset time is: 2026-07-21 20:35:20