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 / Normal Mapping using a Lightmap

Author
Message
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Nov 2014 01:45 Edited at: 13th Nov 2014 01:47
Cause I'm working with 2d I'm creating frame buffers which get combined at the end, pretty much the same as Deferred shading. The current technique is simply lights (texture lights) being draw to a frame buffer then all the buffers (Diffuse, Illumination, Normal and etc) get combined in the final. What it looks like now:


(2000 fake lights is overkill but looks cool)

But I want to know if there's a way to add normal mapping based off the lightmap. I know Direction lightmaps work in this way but having no real time lights. But before I get into that, I just want a stab a simple normal mapping.

I figure the same thing needs to occur at the light frame buffer stage, expect that I sample the norm frame buffer. But this is where I'm stuck, cause I have no clue how all the different lighting techniques Point, Spot, Direction and etc correspond to a flat 2d surface. If anyone could shed some light on this that would be great.

"Get in the Van!" - Van B
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 13th Nov 2014 01:59
Nice graphics

Since I assume you're just using a colour map as your light map then no, normal mapping require the light direction to be known. If you can bake this information into another light map it should be possible though.

Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Nov 2014 02:29 Edited at: 13th Nov 2014 02:30
Quote: "Since I assume you're just using a colour map as your light map then no, normal mapping require the light direction to be known. If you can bake this information into another light map it should be possible though."


Okay, I will look into this...

At the mo, I'm struggling to work out how to combine render targets without a mesh. Is there a way to get the output of a shader which I could then pass into the next without having to texture it on something?

"Get in the Van!" - Van B
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 14th Nov 2014 15:11
Quote: "Is there a way to get the output of a shader which I could then pass into the next without having to texture it on something?"

Using DirectX 10 / 11 you could use a compute shader which has read / write access to a texture resource.
With DirectX 9 you have multipass shaders, but these only allow you to blend the output of several different shader passes in a predetermined way to the final output texture, so you won't be able to access the output from pass 1 in pass 2 etc. Internally this works by issuing multiple draw calls on the same mesh with different associated shaders. Therefore no, I don't believe this to be possible using DX9. The standard way of doing it is, as you say, to use a screen quad to render to in multiple passes, you then use the old render target as the texture in the next pass and so on.

Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 24th Nov 2014 05:25
Quote: "Using DirectX 10 / 11 you could use a compute shader which has read / write access to a texture resource."


Let's hope for this in the next DBP natively, though we can't discredit your amazing work you're doing at the mo with the DX11 plugin, that's some major feat right

I finally remember about how render targets work in ImageKit. Via IK we can eliminate the need for screen quads and just apply the shader to the image. The output can be pasted onto the next render target (or screen) and so on. Though I haven't done Normal Mapping yet. I wanted to see how this works and combining effects and so far the result works well:



I especially like the look of the over distortion at the end.

"Get in the Van!" - Van B
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Nov 2014 16:21 Edited at: 28th Nov 2014 16:22

Combining fullscreen shaders is fun...

Not a bump, just thought it looked interesting: Lighting + High Contrast + Greyscale + Pixelation to a Cube

"Get in the Van!" - Van B

Attachments

Login to view attachments
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 29th Nov 2014 09:16
Sasuke, this is great, absolutely loving your work! Here's some inspiration for ya



Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 29th Nov 2014 15:39
Burning Feet Man, cheers and man that looks cool. Could even create that in 2d, have to do animated texturing and some loose key frame animation with string fluctuating particles... I will look into this

"Get in the Van!" - Van B
ShellfishGames
11
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 2nd Dec 2014 00:45
I've used ImageKit for 2D normal mapping for quite a while now, works really well. I usually render all the normal maps to one screen sized render target (rendering them just as the rest of the scene, so according to camera position/rotation/zoom), then render all lights twice - once to the light render target that's simply used to illuminate the scene (which seems to be what you do in your video), and the other time with another shader to apply the normal mapping effect right on top of the scene.

Video of the effect

That shader takes the relative position of the rendered light's source via two float variables, which allows things such as flashlights.

Also, drawing decals on the ground without them having their own normalmap is pretty fancy as the light will show they don't affect the structure of whatever is beneath them and yeah, that just looks kind of cool.





Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Dec 2014 01:34
It's funny you say this cause it's because of your vids and demos that I started to play with 2d (I mean just 2d cause I've done 2.5 stuff for awhile using meshes which well when it comes to shaders make life easier, well thats what I thought at first). I was used to a more 3d environment especially with shaders but with 2d I got stuck for a bit but I finally got the hang of it as you can probably tell and finally just got normal mapping working. I'll put up a vid soon of it but the effect you produced in your games was great and inspired me to do the same

"Get in the Van!" - Van B
ShellfishGames
11
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 3rd Dec 2014 11:54
Hey, now that's pretty cool. Glad I could provide some inspiration and look forward to your next video.

Login to post a reply

Server time is: 2024-04-16 11:51:19
Your offset time is: 2024-04-16 11:51:19