Actually completely L07
This commit is contained in:
parent
9768278cf1
commit
60695f80cf
2 changed files with 13 additions and 3 deletions
|
@ -5,11 +5,16 @@ uniform mat4 MV;
|
||||||
attribute vec4 aPos; // In object space
|
attribute vec4 aPos; // In object space
|
||||||
attribute vec3 aNor; // In object space
|
attribute vec3 aNor; // In object space
|
||||||
varying vec3 color;
|
varying vec3 color;
|
||||||
|
uniform float t;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P * MV * aPos;
|
vec4 temp = aPos;
|
||||||
|
temp.z = (cos(20*aPos.x + t) + sin(20*aPos.y + t))/20.0;
|
||||||
|
gl_Position = P * MV * temp;
|
||||||
vec3 l = vec3(0.0, 0.0, 1.0); // In camera space
|
vec3 l = vec3(0.0, 0.0, 1.0); // In camera space
|
||||||
vec4 n = MV * vec4(aNor, 0.0);
|
vec3 tempn = aNor;
|
||||||
|
tempn.z = (cos(20*aPos.x + t) + sin(20*aPos.y + t))/20.0;
|
||||||
|
vec4 n = MV * vec4(tempn, 0.0);
|
||||||
color = vec3((n.x*l.x + n.y*l.y + n.z*l.z), (n.x*l.x + n.y*l.y + n.z*l.z), (n.x*l.x + n.y*l.y + n.z*l.z));
|
color = vec3((n.x*l.x + n.y*l.y + n.z*l.z), (n.x*l.x + n.y*l.y + n.z*l.z), (n.x*l.x + n.y*l.y + n.z*l.z));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ shared_ptr<Camera> camera;
|
||||||
shared_ptr<Program> prog;
|
shared_ptr<Program> prog;
|
||||||
map<string,GLuint> bufIDs;
|
map<string,GLuint> bufIDs;
|
||||||
int indCount;
|
int indCount;
|
||||||
|
float t = glfwGetTime();
|
||||||
|
|
||||||
bool keyToggles[256] = {false}; // only for English keyboards!
|
bool keyToggles[256] = {false}; // only for English keyboards!
|
||||||
|
|
||||||
|
@ -104,6 +105,7 @@ static void init()
|
||||||
prog->addAttribute("aNor");
|
prog->addAttribute("aNor");
|
||||||
prog->addUniform("MV");
|
prog->addUniform("MV");
|
||||||
prog->addUniform("P");
|
prog->addUniform("P");
|
||||||
|
prog->addUniform("t");
|
||||||
|
|
||||||
camera = make_shared<Camera>();
|
camera = make_shared<Camera>();
|
||||||
camera->setInitDistance(2.0f);
|
camera->setInitDistance(2.0f);
|
||||||
|
@ -261,7 +263,9 @@ static void render()
|
||||||
camera->applyProjectionMatrix(P);
|
camera->applyProjectionMatrix(P);
|
||||||
MV->pushMatrix();
|
MV->pushMatrix();
|
||||||
camera->applyViewMatrix(MV);
|
camera->applyViewMatrix(MV);
|
||||||
|
|
||||||
|
t = glfwGetTime();
|
||||||
|
|
||||||
prog->bind();
|
prog->bind();
|
||||||
glUniformMatrix4fv(prog->getUniform("P"), 1, GL_FALSE, value_ptr(P->topMatrix()));
|
glUniformMatrix4fv(prog->getUniform("P"), 1, GL_FALSE, value_ptr(P->topMatrix()));
|
||||||
glEnableVertexAttribArray(prog->getAttribute("aPos"));
|
glEnableVertexAttribArray(prog->getAttribute("aPos"));
|
||||||
|
@ -277,6 +281,7 @@ static void render()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glDisableVertexAttribArray(prog->getAttribute("aNor"));
|
glDisableVertexAttribArray(prog->getAttribute("aNor"));
|
||||||
glDisableVertexAttribArray(prog->getAttribute("aPos"));
|
glDisableVertexAttribArray(prog->getAttribute("aPos"));
|
||||||
|
glUniform1f(prog->getUniform("t"), t);
|
||||||
prog->unbind();
|
prog->unbind();
|
||||||
|
|
||||||
MV->popMatrix();
|
MV->popMatrix();
|
||||||
|
|
Reference in a new issue