mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-24 03:21:19 +00:00
wtf
This commit is contained in:
parent
d1ed0a00dd
commit
89c2187f7f
@ -2,6 +2,7 @@
|
||||
uniform vec3 lDirection;
|
||||
uniform bool isSky;
|
||||
uniform bool isPhong;
|
||||
uniform bool isPickerColor;
|
||||
uniform sampler2D tex;
|
||||
uniform float skyMult;
|
||||
|
||||
@ -16,7 +17,10 @@ void
|
||||
main()
|
||||
{
|
||||
vec4 texColor = texture(tex, texCoords);
|
||||
if(isSky) {
|
||||
|
||||
if(isPickerColor){
|
||||
fColor = ifColor;
|
||||
} else if(isSky) {
|
||||
fColor = skyMult * normalize(texColor*texColor*texColor*2/1.41)*2;
|
||||
} else if(isPhong) {
|
||||
// Get lighting vectors
|
||||
|
||||
@ -8,6 +8,7 @@ uniform vec4 color;
|
||||
|
||||
uniform bool isSky;
|
||||
uniform bool isPhong;
|
||||
uniform bool isPickerColor;
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec3 vNormal;
|
||||
@ -30,7 +31,7 @@ main()
|
||||
|
||||
ifColor = color;
|
||||
|
||||
if(!isPhong && !isSky) {
|
||||
if(!isPickerColor && !isPhong && !isSky) {
|
||||
// Get lighting vectors
|
||||
vec3 LightDirection = normalize(lDirection);
|
||||
vec3 nfNormal = normalize(fNormal);
|
||||
@ -50,5 +51,6 @@ main()
|
||||
ifColor = vec4(color * (0.1 + diffuse + specular), 1);
|
||||
//ifColor = vec4(fNormal, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
#version 400 core
|
||||
|
||||
uniform mat4 mvMatrix;
|
||||
uniform mat4 projMatrix;
|
||||
out vec2 texCoords;
|
||||
in vec2 vUv;
|
||||
in vec4 vPosition;
|
||||
|
||||
void
|
||||
main()
|
||||
{
|
||||
gl_Position = projMatrix * mvMatrix * vPosition;
|
||||
texCoords = vUv;
|
||||
}
|
||||
|
||||
@ -305,6 +305,9 @@ void Viewer::initShaders()
|
||||
if ((m_skyMultLoc = m_program->uniformLocation("skyMult")) < 0)
|
||||
qDebug() << "Unable to find m_shader location for" << "skyMult";
|
||||
|
||||
if ((m_pickerColor = m_program->uniformLocation("isPickerColor")) < 0)
|
||||
qDebug() << "Unable to find m_shader location for" << "isPickerColor";
|
||||
|
||||
|
||||
/*
|
||||
* Adding Texture Shader
|
||||
@ -480,6 +483,7 @@ void Viewer::visit(Cube &s)
|
||||
glBindVertexArray(m_VAOs[VAO_Cube]);
|
||||
m_program->setUniformValue(m_isSkyLoc, false);
|
||||
m_program->setUniformValue(m_isPhongLoc, true);
|
||||
m_program->setUniformValue(m_pickerColor, true);
|
||||
m_program->setUniformValue(m_mvMatrixLocation, modelViewMatrix);
|
||||
m_program->setUniformValue(m_normalMatrixLoc, modelViewMatrix.normalMatrix());
|
||||
m_program->setUniformValue(m_colorLocation, s.getColor());
|
||||
@ -532,9 +536,8 @@ Shape* Viewer::pickGeom(int x, int y){
|
||||
* Right now it's fine because we have simple Minecraft rules
|
||||
* but could be important in the future
|
||||
*/
|
||||
QOpenGLShaderProgram *lastshader = m_program;
|
||||
|
||||
//colorPickerShaderProgram->bind();
|
||||
m_program->setUniformValue(m_pickerColor, true);
|
||||
|
||||
std::cout << "Iterating through " << root.getChildren()->size() << "items"<<endl;
|
||||
|
||||
@ -559,6 +562,7 @@ Shape* Viewer::pickGeom(int x, int y){
|
||||
}
|
||||
}
|
||||
|
||||
root.accept(*this);
|
||||
update();
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
@ -582,8 +586,5 @@ Shape* Viewer::pickGeom(int x, int y){
|
||||
std::cout << "Picked Color: " << pickedColor->red() << " " << pickedColor->green() << " " << pickedColor->blue() << " " << pickedColor->alpha() << endl;
|
||||
std::cout << "Picked Shape: " << pickedShape << endl;
|
||||
|
||||
|
||||
|
||||
//lastshader->bind();
|
||||
return pickedShape;
|
||||
}
|
||||
|
||||
@ -98,6 +98,7 @@ private:
|
||||
int m_isSkyLoc;
|
||||
int m_lDirLoc;
|
||||
int m_skyMultLoc;
|
||||
bool m_pickerColor;
|
||||
|
||||
float angle_mult;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user