Mahisorn Wongphati

The best way to make your dreams come true is to wake up!" — Paul Valery

Browsing Posts published in January, 2009

แค่หนาวกะฝนตกไม่มีอะไรมาก

ประจำครับพี่น้อง

เตะๆอยู่ก็อยากชกมวยซะงั้น

http://www.qtsoftware.com/about/licensing

ของดีจาก Manager


Vertex Shader

varying vec2 pos;
void main(void) {
    pos = vec2(gl_Vertex.xy);
    gl_Position = ftransform();
}

Fragment Shader

uniform   sampler2D  image;
uniform   sampler3D  lookup;
uniform   float      imageWidth;
uniform   float      imageHeight;
varying   vec2       pos;

void main(void)
{
    //find the texture coordinate corresponding to this fragment
    vec2 texCoord = vec2(pos.x/imageWidth, pos.y/imageHeight);

    //get the corresponding color
    vec4 colorIn = texture2D(image, texCoord);

    //apply look up tables
    vec4 colorOut;
    colorOut.rgb = texture3D(lookup, colorIn.rgb).rgb;

    //final color
    gl_FragColor = colorOut;
}

Multitexturing

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, imageName);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_3D, lutName);

Set Texture in Shader Program

texLoc = glGetUniformLocation(programObj, "image");
glUniform1i(texLoc, 0); //texture0
texLoc = glGetUniformLocation(programObj, "lookup");
glUniform1i(texLoc, 1); //texture1

Note:

Rss Feed Tweeter button Facebook button Technorati button Reddit button Linkedin button Webonews button Delicious button Digg button Flickr button Stumbleupon button Youtube button