Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Texture3D usable in Fragment Shader

$
0
0

@totetmatt wrote:

Hello all,

I’m fairly new on openframework / opengl world and I’m looking for some guidance on a problem I’m facing.

I would like to build a tool that, with some pictures / video of a timelapse, could perform some operations to render an image or a video like this :

What I was thinking is basically, get all images as a 3DTexture, use some fragment shader (and like that it could not only do simple stripe but more complex transformation, even maybe having a “bonzomatic” style editor ? ) and then just show the fragment shader result … that’s it :smiley:

I currently understand how to load a image as a texture, pass it to my fragment shader and perfom some operation on it.

void ofApp::setup(){
	ofLoadImage(texture[0], "01.JPG"); // ofTexture texture[3];
	ofLoadImage(texture[1], "02.JPG");
	ofLoadImage(texture[2], "03.JPG");
	shader.load("shader.vert", "shader.frag");
}

void ofApp::update(){
	float iTime = ofGetElapsedTimef();
	shader.begin();
	shader.setUniform1f("iTime", iTime);
	shader.setUniformTexture("tex", texture[0], 0);
	shader.end();
}
/// shader.frag
#version 150

out vec4 outputColor;
uniform float iTime;
uniform sampler2DRect tex;

void main() {
    float windowWidth = 1024.0;
    float windowHeight = 768.0;
    float x = gl_FragCoord.x / windowWidth;
    float y =  gl_FragCoord.y / windowHeight;
    vec3 t = texture(tex,vec2(gl_FragCoord.x,windowHeight-gl_FragCoord.y)*5.).rgb;
    t *=sin(iTime)*.5+.5;
    outputColor = vec4(t,1.);
}

But now, I would like to understand how to use the GL_TEXTURE_3D / sampler3D and more exactly how to generate this 3D texture and pass it to the fragment shader. I had some look around the internet and books, but couldn’t find something that help me.

Thanks a lot !

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles