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 some kind soul help with shader code?

Author
Message
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 13th Mar 2013 00:14
The following is the shader I'm using for lights and bump mapping.
I can't seem to figure out how to add evolved's shadow shader to this one, but I'm sure it needs to be added to this code in order to work properly with the lights.

I was using DBP's native set shadow shading on but it's quite slow and somewhat buggy. The reason I liked it though, is nothing extra really needed to be done as it already worked on top of this shader.

Could someone help me combine this with a shadow shader in a manner that works with light 2 (light 1 is set to character ala Dark Souls, light 2 is world light in my game) so that no extra code need be written? I honestly don't even have a preference as to what shadow shader is used, as long as it's relatively fast and works without any extra code just based on light 2 position.

This may be a tall order, so we'll see if I can get any responses.



http://mattsmith.carbonmade.com/
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 14th Mar 2013 10:13
Unfortunately this isn't possible without any extra code. To handle the shadow mapping would require an additional camera per shadow casting light to render a depth map of all objects which should cast shadows which is used for the shadow processing which would then be supplied as an additional texture layer for every object in the scene that should receive shadows.

So you would need extra code to:
- Create the needed cameras and render them to images and texture the objects that will receive shadows with those images
- Handle when to update those cameras as updating them each frame would be too slow
- When it is time to render a depth map, handle hiding any objects that shouldn't cast shadows and setting their shader to a depth map technique and then showing them again for the main camera
- Depending on how you render your depth map (cube or planar), you will also have to manage/optimise the area the camera renders to the depth map by adjusting its range and FOV to isolate the are the camera can see and not waste resolution on non-visible areas

Have you seen Evolved's Advanced Lighting shaders? These already implement this kind of combination. http://www.evolved-software.com/advancedlighting/advancedlighting

Alternatively, you could take a look at Fallout's tutorial (http://forum.thegamecreators.com/?m=forum_view&t=198425&b=1) and try to combine it with this shader. The main issue you may have is command limit depending on what PS/VS versions you're going to use.

Hope this helps a little!


Previously TEH_CODERER.

Login to post a reply

Server time is: 2026-07-07 00:48:25
Your offset time is: 2026-07-07 00:48:25