Jump to content

FBO - 2d lighting?


Pryme8
 Share

Recommended Posts

How does one go about doing FBO's with BJS?  I have never used one and am trying to replicate https://github.com/mattdesl/lwjgl-basics/wiki/2D-Pixel-Perfect-Shadows

**EDIT** 
I think if I read up on this https://doc.babylonjs.com/how_to/how_to_use_postprocesses Ill be able to handle it!
  **EDIT AGAIN**
So I have figured out how to create a custom post process using the shaderStore inline and am now looking to how to set up what I need to do the 2d lighting, will hopefully figure this out.

 

Link to comment
Share on other sites

So my theory is when you take a spotlight an flip the direction model - object - viewer position and project in back on a plane in a custom shader you can archive shadows
actually a lot of work https://doc.babylonjs.com/babylon101/lights
and then modify the source code to working for your needs.

You test against meshes in 3d or 2d texture ? I think your Walls all defined by the Alpha Channel, let's see maybe i can t hack a simple Ray Tracer shadow map. ( I currently working maybe in 2 Weeks )

FBO is in Babylonjs a RendertargetTexture i think, otherwise DumptheFramebuffer never fails. For Shadow map you need also the enable Depth Test - some tutorial, forum post easy to find, but you always and in WebGL1 Mode ends up with 3 different shaders, and then still with blocky edges etc.


proof of concept
http://thebookofshaders.com/edit.php?log=171101083737 

 

pointlightshadows.gif
 

Link to comment
Share on other sites


DumpFrameBuffer

http://www.babylonjs-playground.com/#10OY8W#9

Just in case you miss it:
https://doc.babylonjs.com/how_to/how_to_use_depthrenderer_to_get_depth_values
 

found via playground search
https://www.babylonjs-playground.com/#1TDGFQ#6

Those blocky edges you see in 512x512 Tex Resolution are Reptiles of the past. - Nostalgic, but yeah still fun.

 

Link to comment
Share on other sites

Thats pretty cool, now I need to figure out how to take all this information and generate and occlusion map per frame.

Once I get that figured out, I want to pass two more textures to the shader to handle the lights where the first one will have the structure on each pxl of red and green for x:y position of the light and blue for its size/radius and alpha for what 2d "layer" its in.  Then the second texture to where the pxl structure would be red blue green values of the light, and alpha for the intensity with both pxls indexes being the same on each texture.

Then I will iterate through the pxls until all the lights are calculated.

I am hoping with this method I can get the lights to render in a single call.  I do not know how optimized this will be though.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...