rendering at lower resolutions using fbo with glsl

category: code [glöplog]
anyone know how to do this trick? i cant seem to be able to do the fbo low res trick with glsl as well
added on the 2012-09-26 02:29:01 by Gargaj Gargaj
have been trying to get a X,Y resolution scene to stretch to 2*X,2*Y resolution... i have read that the only fast way to do this is to render to a renderbuffer object attached to a framebuffer, but none of the online stuff really explains how to do this well.. most of them are aiming at rendering to a texture to display on polygons

my code that i have been working with is here
the main symptom is that most of the things I have tried just makes for a blank screen
does it work in 1:1 res?
added on the 2012-09-26 03:34:01 by Gargaj Gargaj
In your code you don't generate a texture and attach it as a color attachment of the framebuffer. Having no color attachment just means you would be writing to nowhere
added on the 2012-09-26 03:40:46 by Laksen Laksen
@Laksen: I thought maybe there was a way to do this without rendering to a texture and then drawing it on a quad again since that would be kind of redundant in this situation. But I guess I just need to render to a texture again.
SiliconLife - you need the texture, renderbuffers are for data you don't need outside the FBO (e.g. a depthbuffer). FBO->tex is the right way.
added on the 2012-09-26 11:00:22 by hornet hornet
managed to do this in android but have a really bizarre problem...

without rendering to texture:
BB Image

rendering to texture:
BB Image

the pixilation is the effect that i want.. but somehow the shader gets messed up and thinks texcoord -1,-1 is in the middle of the screen.. which is wrong
the weirdest thing is when i try to manually fudge factor this:

" attribute vec4 apos;\n"+
"attribute vec2 atex;\n"+
"varying vec2 vtex;\n"+
"void main() {\n"+
" gl_Position = apos;\n"+
" vtex.x = atex.x+0.25;\n"+
" vtex.y = atex.y+0.25;\n"+

the resulting image doesn't move.. only some pixels get darker.. wtf is going on?
If you want a cheap olddemopictureinpicture effect, why not use a specially coded shader with a normal sized FBO?

Works for me.
added on the 2012-09-27 05:52:16 by mudlord mudlord
Actually the computer is right. The texture is addressed between (0,0) (1,1), where (0,0) is the left top corner of the texture.
The screen is addressed in the range of: (-1,1) (1,-1), where (-1,1) is the top left corner of the screen.
To get texture coordinates from apos, what you should do is:

vtex.xy = atex.xy/atex.w*vec2(0.5,-0.5)+vec2(0.5001,0.5001);
added on the 2012-09-27 10:13:18 by archee archee
@mudlord: that would still mean that XRES*YRES number of shaders would have to run, and for raymarching and fractals, it takes up too many shaders*time on the gpu. If I can render at a lower resolution from the beginning I end up taking up less shaders. Right now, not even a julia set can render at > 1fps on the Nexus 7 I borrowed.
thanks archee, that fixed my problem completely. I just changed my tex coordinates to range from 0,0 to 1,1

BB Image
raymarching on android 60 FPS WOOT!!!
BB Image