Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit d40eb02

Browse files
committed
added texture matrix in Cinder project
1 parent dca2baf commit d40eb02

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Diff for: ports/cinder/Ex_7_2_texpixlight/assets/pixlightvert.glsl

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
uniform mat4 ciModelView;
44
uniform mat4 ciModelViewProjection;
55
uniform mat3 ciNormalMatrix;
6+
uniform mat4 textureMatrix;
67

78
uniform vec4 lightPosition;
89

@@ -24,5 +25,5 @@ void main() {
2425
lightDir = normalize(lightPosition.xyz - ecVertex);
2526
vertColor = ciColor;
2627

27-
vertTexCoord = vec4(ciTexCoord0.x, 1 - ciTexCoord0.y, 0, 1);
28+
vertTexCoord = textureMatrix * vec4(ciTexCoord0, 0, 1);
2829
}

Diff for: ports/cinder/Ex_7_2_texpixlight/src/Ex_7_2_texpixlightApp.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ void Ex_7_2_texpixlightApp::setup() {
3434
auto img = loadImage(loadAsset("lachoy.jpg"));
3535
label = gl::Texture2d::create(img);
3636

37-
pointLight[0] = 0;
38-
pointLight[1] = -getWindowHeight();
39-
pointLight[2] = 0;
37+
pointLight[0] = 0; pointLight[1] = -getWindowHeight(); pointLight[2] = 0;
4038

4139
shader = gl::GlslProg::create(loadAsset("pixlightvert.glsl"), loadAsset("pixlightfrag.glsl"));
4240
shader->uniform("texMap", 0);
@@ -60,6 +58,10 @@ void Ex_7_2_texpixlightApp::draw() {
6058
gl::setMatrices(cam);
6159
gl::ScopedModelMatrix modelScope;
6260

61+
mat4 tm = mat4(1.0);
62+
tm[1][1] = -1; tm[3][1] = 1;
63+
shader->uniform("textureMatrix", tm);
64+
6365
mat4 mv = gl::getModelMatrix();
6466
vec4 lightPos = mv * vec4(pointLight, 1.0f);
6567
shader->uniform("lightPosition", lightPos);

0 commit comments

Comments
 (0)