Exemplo n.º 1
0
void pool::update(const float4x4& view_projection, const camera& camera, const point_light& light, GLuint caustics_tex_id, int num_wall) {
    glUseProgram(render_prog_.program);

    setUniform(render_prog_.program, "cameraPosition", camera.get_pos());
    setUniform(render_prog_.program, "viewProjectionMatrix", view_projection);


    setUniform(render_prog_.program, "objectMatrix", object_matrix_[num_wall]);
    setUniform(render_prog_.program, "inversedObjectMatrix", inversed_object_matrix_[num_wall]);

    setUniform(render_prog_.program, "gridSizeX", 256);
    setUniform(render_prog_.program, "gridSizeZ", 256);
    setUniform(render_prog_.program, "sizeX", size_x_[num_wall]);
    setUniform(render_prog_.program, "sizeZ", size_z_[num_wall]);
    light.setup_shader(render_prog_.program);
    material_.setup_shader(render_prog_.program);

    bindTexture(render_prog_.program, CAUSTICS + num_wall, "caustics", caustics_tex_id);
    bindTexture(render_prog_.program, FLOOR_TILT, "floorTilt", floor_tex_->GetColorTexId());

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);

    pool_mesh_->Draw(GL_TRIANGLES);

    glDisable(GL_BLEND);
    glDisable(GL_CULL_FACE);
}
Exemplo n.º 2
0
void water::update(const float4x4& view_projection, const camera& camera, const point_light& light) {
	// count normals
	GLint old_viewport[4];
  glGetIntegerv(GL_VIEWPORT, old_viewport);

  glViewport(0, 0, grid_size_x_, grid_size_z_);
  glDisable(GL_DEPTH_TEST);

	norm_tex_->BeginRenderingToThisTexture();
	glUseProgram(normal_prog_.program);
	setUniform(normal_prog_.program, "objectMatrix", object_matrix_);
	setUniform(normal_prog_.program, "inversedObjectMatrix", inversed_object_matrix_);
	setUniform(normal_prog_.program, "gridSizeX",    grid_size_x_);
  setUniform(normal_prog_.program, "gridSizeZ",   grid_size_z_);
  bindTexture(normal_prog_.program, WATER_POSITIONS, "inPositions", pos_tex_[c_]->GetColorTexId());
	full_screen_quad_->Draw();
	norm_tex_->EndRenderingToThisTexture();
	glEnable(GL_DEPTH_TEST);
  glViewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]);


	// draw water
	glUseProgram(render_prog_.program);
  setUniform(render_prog_.program, "cameraPosition", camera.get_pos());
	setUniform(render_prog_.program, "viewProjectionMatrix", view_projection);
  setUniform(render_prog_.program, "objectMatrix", object_matrix_);

	light.setup_shader(render_prog_.program);
	material_.setup_shader(render_prog_.program); 
	setUniform(render_prog_.program, "gridSizeX", grid_size_x_);
  setUniform(render_prog_.program, "gridSizeZ", grid_size_z_);
  bindTexture(render_prog_.program, WATER_POSITIONS, "inPositions", pos_tex_[c_]->GetColorTexId());
	bindTexture(render_prog_.program, WATER_NORMALS, "inNormals", norm_tex_->GetColorTexId());

	//glEnable(GL_DEPTH_TEST);
  glEnable(GL_BLEND); 
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);	

	water_mesh_->Draw(GL_TRIANGLES);

	glDisable(GL_BLEND); 
}