Jump to content
  • Advertisement
Sign in to follow this  
L. Spiro

Using a 2D Texture for Point-Light Shadows

This topic is 1239 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I’m about to shift our pipeline over to using a single 2D texture instead of a cube texture for point-light shadows.

The only area worth noting is manually sampling the texture given 3D coordinates.

 

Since I know this has been explored plenty of times there is no reason for me to try to reinvent the wheel, but I absolutely cannot find any mention of this in any papers, tutorials, etc.

 

Anyone have any references for this?

 

 

L. Spiro

Share this post


Link to post
Share on other sites
Advertisement

Those will be useful for creating my own solution from scratch if it comes to that.  For whatever reason, I wasn’t getting anything like this via my own searches.

 

 

L. Spiro

Share this post


Link to post
Share on other sites

Is it one large 2d texture and then you split it into 6 parts and render depth to each one of them? It sounds strictly better than cubemapping, is there any cons to it?

Share this post


Link to post
Share on other sites
Is it one large 2d texture and then you split it into 6 parts and render depth to each one of them? It sounds strictly better than cubemapping, is there any cons to it?"

I'm assuming what hes doing is still rendering the scene 6 times and 6 views, just changing the glViewport to write to a different portion of the texture.

 

What you (Johan) have suggested can't be done, if you are implying that you render the scene once and just have it all map to several parts of a texture. The problem you have is if you have 6 squares randomly packed into a single 2D texture, when you generate the vertex coordinates, any given triangle if only rendered once, can obviously span multiple "squares". There is no way to get one part of the triangle to go to square1 and another part to go to square 2. If you could write in the pixel shader the exact pixel location you want a fragment to end up at, then it would work. But the pixel shader runs after a triangle has been made in screen space and chosen which pixels locations need to be run on the pixel shader.

 

My question to the original post is, whether you render 6 times to a cube map or render 6 times to a single texture acting as a cube-map, why not just use the cubemap. Not to mention that cube maps are hardware supported and when you want to sample on the edge of two of the images, it will sample them properly. In order to do bi-linear filtering across your "faces", you would have to waste pixel shader time to resample the texture instead of letting the hardware do it.

 

Of course there is dual parabaloid maps.

Edited by dpadam450

Share this post


Link to post
Share on other sites

why not just use the cubemap.

Bi-linear filtering should not be used on shadow textures, so being able to automatically sample neighbor textures is not really a benefit.

Instead, the benefits are that you can apply all the same soft-shadow techniques, such as PCF, to your point lights rather than just to your spot lights and directional lights.


L. Spiro

Share this post


Link to post
Share on other sites

The benefits are that you can apply all the same soft-shadow techniques, such as PCF, to your point lights rather than just to your spot lights and directional lights.L. Spiro

You can't use PCF/comparison-sanpling on cube-maps? Is that a restriction on certain platforms?

What you (Johan) have suggested can't be done, if you are implying that you render the scene once and just have it all map to several parts of a texture. The problem you have is if you have 6 squares randomly packed into a single 2D texture, when you generate the vertex coordinates, any given triangle if only rendered once, can obviously span multiple "squares". There is no way to get one part of the triangle to go to square1 and another part to go to square 2.

You can do this on modern hardware (with either manually packed 2d target, or a cube-target) by binding 6 viewport and using a geometry shader to duplicate triangles and output them to specific viewports.

Share this post


Link to post
Share on other sites

You can't use PCF/comparison-sanpling on cube-maps? Is that a restriction on certain platforms?

[EDIT]Do PlayStation 4 and Xbox One have hardware support for more than PCF1 (not really PCF but we just call it that) on cube textures?[/EDIT]

Texture atlases for shadow-mapping is the norm in major studios these days for several of the other benefits they bring, but right now I need to move my desk to the 19th floor.


L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites

You can do this on modern hardware (with either manually packed 2d target, or a cube-target) by binding 6 viewport and using a geometry shader to duplicate triangles and output them to specific viewports.

 

links to this technique?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!