Screen space texture offset based on sphere

Started by
5 comments, last by Thaumaturge 1 year, 4 months ago

I have a sphere rendered to texture. I have an offset in screen coordinates (dx, dy), and I want to move the texture so that it still maps on the sphere. How can I calculate the transformation and transform the texture correctly?

My current idea is to render sphere, project each position to screen space, apply inverse offset and calculate position from which to sample pixel from source texture.

However, I don't know how to calculate the position from which to sample.

Simplified example with (0, dy) movement offset.

Left: Source image, Right: Target image after offset in (0, dy) direction

The sphere is at (0,0,0) rendered with ortho-camera put at (0, 0, offset).

Advertisement

Just to let you know, i'm sure nobody understands what you try to do. There is confusion about what's frame buffer, what's textures. Idk if you render a 3D model of a sphere or a 2D sprite. Idk what's in the texture (multiple images making an animation of a sphere?), and what should end up on the screen in the end.

You need to explain fool proof to somebody who knows nothing about your current work. ; )

I have a deferred rendered. I render sphere to texture. So far so good. Now the user move mouse over the screen and I need to rotate the sphere. I used ArcBall to do this for geometry to calculate transformation matrices. However, I need this effect achieve in the screen space texture, without the geometry. I know, that data not visible in the previous frame wont be visible, but that is not an issue. I just need to rotate the screen space texture as if it was geometry. I can calculate world position from the depth and buffer, use ArcBall in pixel shader… but that is way to much computation, and it would be very slow. So I am looking for some solution directly in screen space texture, how to calculate offset for pixels directly.

I still don't get it. But i can guess…

You draw a sphere directly to the framebuffer, not using any 3D model, maybe in a pixel shader.

The sphere can roll. Maybe like the Marble in Marble Madness, or like the Balls in the Zuma game (which actually an animation of the rolling ball both lit and textured, in the form of a sequence of images).

And your problem maybe is to texture your sphere, so as it rolls, it can display something like a checkerboard texture. But you don't know how to calculate UVs for the texture lookup?

Not exactly. I render the textured sphere, but I want to roll it only based on the image. So the texture will roll, but eventually, the texture will disappear and the sphere will be like a single colour.

I want to use the default, rendered, textured sphere and, from now on, roll only the sphere in the image.

Note: I haven't tested the below. It seems logical to me, but I stand to be corrected!

It seems to me that it's more or less a matter of offsetting the texture-lookup for the sphere. Specifically, the offset would be greater near the axis of motion, would decrease further along the axis perpendicular to the aforementioned axis, and would would be clipped to the radius of the sphere.

The decrease in question would be circular--that is, it would be proportional to the distance from the perpendicular axis to the circumference of the sphere as rendered.

In the case of the example given, of an offset of (0, dy), the axis of motion is (0, 1) or (0, -1), and the perpendicular axis is (1, 0). Points along (0, 1) would read a texture-position of something like (0, -dy * k), where “k” is some appropriate constant, points further to either side would read a texture-position of something like (0, -dy * k * v), where “v” is the distance to the circumference from the perpendicular axis, as mentioned previously.

MWAHAHAHAHAHAHA!!!

My Twitter Account: @EbornIan

This topic is closed to new replies.

Advertisement