# Rectilinear Texture Warping - Building Warp Maps

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

## Recommended Posts

Hi

I have read Paul Rosens white paper on RTW shadow mapping many times but I have a hard time understanding how exactly the warp maps are converted from 1-D blurred importance maps to the 1-D warp maps. The source code is confusing to me aswell.

Key terms: Shadow map, warp maps, super cells, importance map, output frame.

http://www.cspaul.com/wiki/doku.php?id=publications:Rosen.2012.I3D

The paper does not suggest the importance map resolution the demo uses, only that "resolution only needs to be large enough to detect the existence of the smallest features of interest" to shadow properly. It also states that "The warping maps are composed of a set of super-cells at equal or lower resolution than the base texture."

Questions:

Is the importance map in the demo the same or lower resolution than the shadow map?

When collapsing the importance maps to 1-D, does it keep the same width (i.e 512x512 becomes 512)?

What resolution does the warp map have (looks like 28 super cells), does this mean that it is a 32 pixel long 1D texture?

How do you then collapse a 512px importance map down to a 32px warp map?

The warp map is colored red, blue and black. Is the Red channel displacing in the positive direction and blue displacing in the negative direction?

The "GetWarp(k)" formula to produce the 32 super cell values is kinda tricky to get the picture of. It sums upto the k'th super cell and divides by the total importance. Do we do this sum over the 512px importance map? Do we sum every 16 pixels in the 1-D importance map to create a super cell and divide by the total importance? Kinda hard to follow where and what we sum up.

##### Share on other sites

More techniques with  a similar idea, and easier implementation and/or better documentation are Sample Distribution Shadow Maps: http://visual-computing.intel-research.net/art/publications/sdsm/ and "Oblique Shadow Maps" from Crytek: http://www.crytek.com/download/Playing%20with%20Real-Time%20Shadows.pdf go down quite a bit for the Oblique Shadow Maps, Crytek's one covers a lot.

Anyway, hope that helps. SDSM in particular is both a well written presentation, has a code sample, and is an incredibly similar idea to Rectilinear Warping.

Edited by Frenetic Pony

##### Share on other sites

Look for some keywords on here. I remember he posted this on gamedev.net but I recall having an issue with his algorithm at the high level after reading it.

##### Share on other sites

Unfortunatly those articles are not helping. But with some creative use of pen and paper i've cooked up something from what I got out of Rosens paper. I will see if I can implement this. I'm trying to do this on SM3.0 in DX9. All maps will have the same length.

1. First the importance map is collapsed into two 1D maps, the vertical and the horizontal. This is done by setting each corresponding pixel to the maximum value in the row or column.

2. These 1D maps are then blurred.

3. Calculate the sum of all pixels in each blurred map to get the total importance. Perhaps this can be done on the GPU by rendering to a 1x1 texture using a quad. Since the pixel shader is only run once for each 1D map it will sample the entire 1D blurred map and spit out the sum. Which can be read back to the CPU and set as a constant on the GPU. I don't know if there is a faster method to find the total importance.

4. The warping map is constructed by rendering to a 1D texture. The first pixel in the warp map will recieve half the value of the first pixel in the blurred 1D map divided by total importance. The second pixel in the warp map will recieve the full value of the first pixel, plus half the value of the second pixel divided by total importance. The third pixel in the warp map will recieve half the value of the third pixel in the blurred map, plus the sum of the first and second pixel  divided by total importance. The algorithm here is the sum up all the pixels before the current pixel, plus half of the current pixel and divide by total importance. Each pixel in the warp map is a pointer that maps to a new coordinate. This is a list of pixels with values between 0 and 1.

5. Render the shadow map; in the vertex shader transform all vertices to screen space to have a value between -1 and 1 as normal. Then add 1 and divide by 2 to scale it to the range between 0 and 1. We now sample pixels in the warp maps where our value is between. A linear interpolation of the two pixel values gives us a new mapped coordinate in the range 0 to 1. We scale it back to be in the range -1 and 1 and output the result. Perhaps we can fiddle the warp map to have values between -1 and 1 to avoid back and forth scaling.

6. Render the scene to a texture.

7. Render full screen quad using the texture from step 6. In the pixel shader convert UV's to shadow map space and run them through the warp maps, using the new UV's sample the shadow map and do the depth test.

Hope there aren't any flaws in what I just said.

Edited by Tispe

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 9
• 34
• 16
• 11
• 12
• ### Forum Statistics

• Total Topics
634123
• Total Posts
3015649
×