Texturing in GLSLweb.engr.oregonstate.edu/~mjb/cs519/Handouts/Textures.1pp.pdf · mjb – January...

4
mjb – January 13, 2020 1 Computer Graphics Texturing in GLSL Textures.pptx This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License Mike Bailey [email protected]

Transcript of Texturing in GLSLweb.engr.oregonstate.edu/~mjb/cs519/Handouts/Textures.1pp.pdf · mjb – January...

Page 1: Texturing in GLSLweb.engr.oregonstate.edu/~mjb/cs519/Handouts/Textures.1pp.pdf · mjb – January 13, 2020 1 Computer Graphics Texturing in GLSL Textures.pptx This work is licensed

mjb – January 13, 2020

1

Computer Graphics

Texturing in GLSL

Textures.pptx

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License

Mike [email protected]

Page 2: Texturing in GLSLweb.engr.oregonstate.edu/~mjb/cs519/Handouts/Textures.1pp.pdf · mjb – January 13, 2020 1 Computer Graphics Texturing in GLSL Textures.pptx This work is licensed

mjb – January 13, 2020

2

Computer Graphics

#version 330 compatibilityout vec2 vST;

voidmain( ){

vST = gl_MultiTexCoord0.st;gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

}

#version 330 compatibilityin vec2 vST;uniform sampler uTexUnit;

voidmain( ){

vec3 newcolor = texture( uTexUnit, vST ).rgb;gl_FragColor = vec4( newcolor, 1. );

}

Vertex shader:

Fragment shader:

2D Texturing

Texture2D 6 worldtex.bmp. . .Program World \

uBlend <0. 0. 1.> \uFrequency <1. 1. 20.> \uOffsetS <0. 0. 1.> uOffsetT <0. 1. 1.> \uTexUnit 6

Page 3: Texturing in GLSLweb.engr.oregonstate.edu/~mjb/cs519/Handouts/Textures.1pp.pdf · mjb – January 13, 2020 1 Computer Graphics Texturing in GLSL Textures.pptx This work is licensed

mjb – January 13, 2020

3

Computer Graphics

World

Page 4: Texturing in GLSLweb.engr.oregonstate.edu/~mjb/cs519/Handouts/Textures.1pp.pdf · mjb – January 13, 2020 1 Computer Graphics Texturing in GLSL Textures.pptx This work is licensed

mjb – January 13, 2020

4

Computer Graphics

Teapot