mobility commit

This commit is contained in:
Hurlu 2019-06-07 11:16:16 +09:00
parent a9fc5d0cf5
commit fe5a3b2541
4 changed files with 36 additions and 36 deletions

View File

@ -1,29 +1,23 @@
#version 440 #version 440
//layout (location = 0) out vec3 gPosition; layout (location = 0) out vec3 gPosition;
//layout (location = 1) out vec3 gNormal; layout (location = 1) out vec3 gNormal;
//layout (location = 2) out vec4 gAlbedoSpec; layout (location = 2) out vec4 gAlbedoSpec;
in vec2 TexCoords; in vec2 TexCoords;
in vec3 FragPos; in vec3 FragPos;
in vec3 Normal; in vec3 Normal;
in vec3 RawColor;
out vec3 FragColor;
uniform sampler2D tex; uniform sampler2D tex;
void main() void main()
{ {
//gPosition = FragPos; gPosition = FragPos;
//gPosition = normalize(abs(FragPos)); //gPosition = normalize(abs(FragPos));
// gPosition = vec3(1,1,1); //gPosition = vec3(1,1,1);
//
// gNormal = normalize(Normal); gNormal = normalize(Normal);
//
// gAlbedoSpec.rgb = vec3(1,0,1); gAlbedoSpec.rgb = texture(tex, TexCoords).rgb;
// gAlbedoSpec.a = 1; gAlbedoSpec.a = 1;
//gAlbedoSpec.rgb = texture(tex, TexCoords).rgb;
//gAlbedoSpec.a = texture(texture_specular1, TexCoords).r;
FragColor = RawColor;
} }

View File

@ -7,7 +7,6 @@ layout(location=3) in vec2 v_texmap;
out vec2 TexCoords; out vec2 TexCoords;
out vec3 FragPos; out vec3 FragPos;
out vec3 RawColor;
out vec3 Normal; out vec3 Normal;
uniform mat4 mvp; uniform mat4 mvp;
@ -20,5 +19,6 @@ void main(void)
TexCoords = v_texmap; TexCoords = v_texmap;
gl_Position = mvp * vec4(coord3d, 1.0f); gl_Position = mvp * vec4(coord3d, 1.0f);
FragPos = (ModelMatrix * vec4(coord3d, 1.0f)).xyz; FragPos = (ModelMatrix * vec4(coord3d, 1.0f)).xyz;
//FragPos = gl_Position.xyz; //FragPos = coord3.xyz;
//FragPos = gl_Position.xyz;
} }

View File

@ -343,7 +343,7 @@ void Mesh::draw(SceneContext &ctx) {
MeshEntry * m = meshEntries[i]; MeshEntry * m = meshEntries[i];
// Moving the object to his set position // Moving the object to his set position
model.glPushMatrix(); model.glPushMatrix();
effectTransformations(); effectTransformations();
@ -355,10 +355,16 @@ void Mesh::draw(SceneContext &ctx) {
ctx.normalMatrix = glm::mat3(glm::transpose(glm::inverse(ctx.modelViewMatrix))); ctx.normalMatrix = glm::mat3(glm::transpose(glm::inverse(ctx.modelViewMatrix)));
shader.addUniform("mvp", ctx.mvpMatrix); shader.addUniform("mvp", ctx.mvpMatrix);
shader.addUniform("NormalMatrix", ctx.normalMatrix); //shader.addUniform("NormalMatrix", ctx.normalMatrix);
shader.addUniform("ModelMatrix", ctx.modelMatrix); //shader.addUniform("ModelMatrix", ctx.modelMatrix);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures["0"].tex_ref);
meshEntries.at(i)->render(ctx, shader);
glBindTexture(GL_TEXTURE_2D, 0);
meshEntries.at(i)->render(ctx, shader);
model.glPopMatrix(); model.glPopMatrix();
} }
shader.disable(); shader.disable();

View File

@ -140,29 +140,29 @@ void MyGlWindow::setup()
std::srand(18); std::srand(18);
int zob = std::rand(); int zob = std::rand();
for (int i = 0; i < 1; i++) for (int i = 0; i < 100; i++)
{ {
std::string cube_name = "Cube" + std::to_string(i); std::string cube_name = "Cube" + std::to_string(i);
meshes.emplace(cube_name, new Mesh(moddata, "DSGeometryPass.vert", "DSGeometryPass.frag")); meshes.emplace(cube_name, new Mesh(moddata, "DSGeometryPass.vert", "DSGeometryPass.frag"));
meshes[cube_name]->textures["0"] = _scnctx.textures["BrickTex"];
/*meshes[cube_name]->textures["cube_tex"] = Texture("./Models/cube/color_map.png");
float pos_x = std::rand() % 100 + 50; float pos_x = std::rand() % 100 - 50;
float pos_z = std::rand() % 100 + 50; float pos_z = std::rand() % 100 - 50;
meshes[cube_name]->addStartTranslation(glm::vec4(0, 1, 0, 0)); /*meshes[cube_name]->addStartTranslation(glm::vec4(0, 1, 0, 0));
meshes[cube_name]->addStartTranslation(glm::vec4(pos_x, 0, 0, 0)); meshes[cube_name]->addStartTranslation(glm::vec4(pos_x, 0, 0, 0));
meshes[cube_name]->addStartTranslation(glm::vec4(0, 0, pos_z, 0)); meshes[cube_name]->addStartTranslation(glm::vec4(0, 0, pos_z, 0));
meshes[cube_name]->addStartRotation(glm::vec4(1, 0, 0, std::rand() % 360)); meshes[cube_name]->addStartRotation(glm::vec4(1, 0, 0, std::rand() % 360));
meshes[cube_name]->addStartRotation(glm::vec4(0, 1, 0, std::rand() % 360)); meshes[cube_name]->addStartRotation(glm::vec4(0, 1, 0, std::rand() % 360));
meshes[cube_name]->addStartRotation(glm::vec4(0, 0, 1, std::rand() % 360));*/ meshes[cube_name]->addStartRotation(glm::vec4(0, 0, 1, std::rand() % 360));*/
//float light_r = (40 + std::rand() % 60) / 100.f; float light_r = (40 + std::rand() % 60) / 100.f;
//float light_g = (40 + std::rand() % 60) / 100.f; float light_g = (40 + std::rand() % 60) / 100.f;
//float light_b = (40 + std::rand() % 60) / 100.f; float light_b = (40 + std::rand() % 60) / 100.f;
//_scnctx.lights.emplace("RandLight" + i, _scnctx.lights.emplace("RandLight" + i,
// Light(glm::vec3(light_r, light_g, light_b), glm::vec4(pos_x, 2, pos_z, 1))); Light(glm::vec3(light_r, light_g, light_b), glm::vec4(pos_x, 2, pos_z, 1)));
} }
} }
@ -184,12 +184,12 @@ void MyGlWindow::draw()
glViewport(0, 0, _scnctx.width, _scnctx.height); glViewport(0, 0, _scnctx.width, _scnctx.height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//_multipassManager.enableFrameBufferTexture("position_buffer"); _multipassManager.enableFrameBufferTexture("position_buffer");
for (auto it = meshes.begin(); it != meshes.end(); it++) for (auto it = meshes.begin(); it != meshes.end(); it++)
(*it).second->draw(_scnctx); (*it).second->draw(_scnctx);
//_multipassManager.drawResultToScreen(_scnctx); _multipassManager.drawResultToScreen(_scnctx);
} }
void MyGlWindow::resize(int w, int h) void MyGlWindow::resize(int w, int h)