PDA

View Full Version : Advice on how to do a mozaic effect on the entire screen?



patrick99e99
11-15-2016, 12:46 PM
I am interested in creating a visual effect similar to the transition in Super Mario World:
https://www.youtube.com/watch?v=1FnPe6tinVs&feature=youtu.be&t=29s

So, basically I want over a 1/2 second period for the resolution to continue to get lower and lower so that the pixels get huge, and then over another 1/2 second period, the resolution goes back up to normal.

Can anyone give me a push in the right direction as far as how I would go about doing this?

Is this something that can be done with a shader applied to the main GLView? Or is there a better way?

Cornix
11-15-2016, 01:23 PM
I dont know if this is the best solution (it possibly isnt) but you could render your entire scene into a texture, then render that texture across the entire screen with a fragment shader that pixelates the output. In the fragment shader you start with rendering texels from the texture to the screen 1 to 1 but as time goes by (perhaps controlled with a uniform updated at Client side) you sample increasingly larger parts of the texture, calculate the medium color across all texels and output that for each fragment within the area. (I hope this makes sense to you)

john_connor
11-15-2016, 01:37 PM
using your own framebuffer object:
-- resize the area in which you are rendering using glViewport(0, 0, w, h)


otherwise if you are using an orthographic projection for you 2D renderer, resize the area

patrick99e99
11-15-2016, 02:19 PM
using your own framebuffer object:
-- resize the area in which you are rendering using glViewport(0, 0, w, h)


otherwise if you are using an orthographic projection for you 2D renderer, resize the area

Sorry, I might not be understanding-- wouldn't what you are suggesting just "zoom in"? I want the all of the pixels on the screen to get bigger (and so neighboring pixels would ultimately start to overlap each other), not for the size of the projection to increase (zoom).

john_connor
11-16-2016, 02:01 AM
what happens when supermario enters a level ?
-- the screen resolution gets lower

what happens when supermario appears in the new level ?
-- the screen resolution gets higher

using a framebuffer object:
-- setup (https://sites.google.com/site/john87connor/home/tutorial-10-1-framebuffer-renderbuffer)
-- resizing the draw area (https://sites.google.com/site/john87connor/advanced-opengl-tutorials/tutorial-04-2-framebuffer-size)
----> use glViewport(...) to resize the area and glBlitFramebuffer(...) to copy the rendered image

if i render everything into a framebuffer which is smaller than the window, and i copy the result into the window, i have to:
-- copy the result into a part of the window (like this (https://sites.google.com/site/john87connor/_/rsrc/1473605749373/home/tutorial-10-1-framebuffer-renderbuffer/framebuffer1.png): the grey area is rendered, the remaining blue area is unused)
-- or i have to resize my result to fit te window size
----> like that (https://sites.google.com/site/john87connor/_/rsrc/1474576618764/advanced-opengl-tutorials/tutorial-04-2-framebuffer-size/pixeled.png) (using filter parameter GL_NEAREST)
----> or this (https://sites.google.com/site/john87connor/_/rsrc/1474577145094/advanced-opengl-tutorials/tutorial-04-2-framebuffer-size/linearfilterframebuffer.png) (using filter parameter GL_LINEAR)


if you are using an orthographic projection (matrix), you can modify / resize the matrix (i think)

Grognard
11-17-2016, 01:25 PM
They might be generating out mipmaps for the whole screen and then choosing/blending progressively smaller ones to cause the pixelation. Maybe someone knows for sure. But john has the right basica idea. You are seeing the screen rendered to a smaller and smaller resolution pic basically.