View Full Version : Sorry, need a new blurring method.
starstutter
02-14-2008, 10:56 AM
I know I just said I needed t blur a cube map, but I decided I would be much better off simply blurring something like a spherical map. Distribution doesn't particularly matter, it just needs to be close enough and preferably blurred in a single pass.
So my question now is, is it possible to create a spherical map in runtime (reguarless of how slow it is because this is pre-computation), and if so, how would I go about doing that?
Reedbeta
02-14-2008, 11:06 AM
Raytracing.
Or you could use a vertex shader that would do the spherical projection, but you'd need to have everything pretty highly tesselated for it to work, and I think it would look bad if different objects were tesselated at different levels.
CheshireCat
02-14-2008, 12:16 PM
Render a cubemap and then just transform the data to what ever map you like.
starstutter
02-14-2008, 02:38 PM
Render a cube map and then just transform the data to what ever map you like.
Yes, rendering a cube map is pretty obvious. Do you have any suggestions of how to actually transfer that data? A cube map has all it's faces flat and visible, a sphere map's vision is extremely obscure and weird, so I'm stumped about how I would make the data transfer over and not look like a wavy blur when it got there.
Reedbeta
02-14-2008, 02:49 PM
Oh, that's a good idea (rendering a cube map and then transforming the data), you wouldn't need to worry about tesselating the scene, as you could just tesselate the cube map.
To transform the data you just need to write a routine that does a spherical projection - that is, it would calculate the latitute-longitude coordinates of a vertex relative to the viewer and map those to x, y coordinates on unit square (-1 to 1). Then just take a highly tesselated cube around the origin that's textured by the cube map, and run each vertex through the spherical projection. Put the resulting data in a vertex buffer and render it, and presto, you should get a sphere map in the frame buffer.
You'll have to be a little careful with cube facets that cross the "international date line", i.e. the seam where the longitude coordinate wraps - probably the simplest thing to do is just duplicate those facets, rendering one copy on each side of the seam.
CheshireCat
02-15-2008, 09:53 AM
Yes, rendering a cube map is pretty obvious. Do you have any suggestions of how to actually transfer that data?
Well, you just render a quad over a spherical map texture and map the uv coordinates (u=[0, 1], v=[0, 1]) in pixel shader like: phi=u*2*pi, theta=v*pi, x=sin(theta)*cos(phi), y=sin(theta)*sin(phi), z=cos(theta) and just use [x,y,z] to fetch the cubemap.
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.