Правка по гамма-коррекции материалов
This commit is contained in:
		
							parent
							
								
									87afe6a629
								
							
						
					
					
						commit
						3b773f1eaa
					
				| @ -115,6 +115,9 @@ Scene loadOBJtoScene(const char* filename, const char* mtl_directory, const char | |||||||
| 
 | 
 | ||||||
|     std::string err; |     std::string err; | ||||||
| 
 | 
 | ||||||
|  |     // Значение гамма-коррекции
 | ||||||
|  |     extern float inv_gamma; | ||||||
|  | 
 | ||||||
|     // Если в процессе загрузки возникли ошибки - выдадим исключение
 |     // Если в процессе загрузки возникли ошибки - выдадим исключение
 | ||||||
|     if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &err, filename, mtl_directory)) |     if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &err, filename, mtl_directory)) | ||||||
|         throw std::runtime_error(err); |         throw std::runtime_error(err); | ||||||
| @ -214,8 +217,8 @@ Scene loadOBJtoScene(const char* filename, const char* mtl_directory, const char | |||||||
|         s->set_texture(specular); |         s->set_texture(specular); | ||||||
| 
 | 
 | ||||||
|         // Материал
 |         // Материал
 | ||||||
|         s->material.ka = glm::vec3(materials[materials_ids[i]].ambient[0],  materials[materials_ids[i]].ambient[1],  materials[materials_ids[i]].ambient[2]); |         s->material.ka = pow(glm::vec3(materials[materials_ids[i]].ambient[0],  materials[materials_ids[i]].ambient[1],  materials[materials_ids[i]].ambient[2]), glm::vec3(1/inv_gamma)); | ||||||
|         s->material.kd = glm::vec3(materials[materials_ids[i]].diffuse[0],  materials[materials_ids[i]].diffuse[1],  materials[materials_ids[i]].diffuse[2]); |         s->material.kd = pow(glm::vec3(materials[materials_ids[i]].diffuse[0],  materials[materials_ids[i]].diffuse[1],  materials[materials_ids[i]].diffuse[2]), glm::vec3(1/inv_gamma)); | ||||||
|         s->material.ks = glm::vec3(materials[materials_ids[i]].specular[0], materials[materials_ids[i]].specular[1], materials[materials_ids[i]].specular[2]); |         s->material.ks = glm::vec3(materials[materials_ids[i]].specular[0], materials[materials_ids[i]].specular[1], materials[materials_ids[i]].specular[2]); | ||||||
|         s->material.p  = (materials[materials_ids[i]].shininess > 0.0f) ? 1000.0f / materials[materials_ids[i]].shininess : 1000.0f; |         s->material.p  = (materials[materials_ids[i]].shininess > 0.0f) ? 1000.0f / materials[materials_ids[i]].shininess : 1000.0f; | ||||||
|     }     |     }     | ||||||
|  | |||||||
| @ -14,6 +14,9 @@ | |||||||
| #define WINDOW_HEIGHT 600 | #define WINDOW_HEIGHT 600 | ||||||
| #define WINDOW_CAPTION "OPENGL notes on rekovalev.site" | #define WINDOW_CAPTION "OPENGL notes on rekovalev.site" | ||||||
| 
 | 
 | ||||||
|  | // Значение гамма-коррекции
 | ||||||
|  | float inv_gamma = 1/2.2; | ||||||
|  | 
 | ||||||
| // Функция-callback для изменения размеров буфера кадра в случае изменения размеров поверхности окна
 | // Функция-callback для изменения размеров буфера кадра в случае изменения размеров поверхности окна
 | ||||||
| void framebuffer_size_callback(GLFWwindow* window, int width, int height) | void framebuffer_size_callback(GLFWwindow* window, int width, int height) | ||||||
| { | { | ||||||
| @ -382,7 +385,6 @@ int main(void) | |||||||
|     skyboxShader.bindTextures(skybox_shader_names, sizeof(skybox_shader_names)/sizeof(const char*)); |     skyboxShader.bindTextures(skybox_shader_names, sizeof(skybox_shader_names)/sizeof(const char*)); | ||||||
|      |      | ||||||
|     // Значение гамма-коррекции
 |     // Значение гамма-коррекции
 | ||||||
|     float inv_gamma = 1/2.2; |  | ||||||
|     UBO gamma(&inv_gamma, sizeof(inv_gamma), 4); |     UBO gamma(&inv_gamma, sizeof(inv_gamma), 4); | ||||||
| 
 | 
 | ||||||
|     // Пока не произойдет событие запроса закрытия окна
 |     // Пока не произойдет событие запроса закрытия окна
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user