![]() |
Path Tracing
|
#include "texture.hpp"#include "stb_image.h"#include "stb_image_resize2.h"#include <algorithm>#include <functional>
Macros | |
| #define | STB_IMAGE_IMPLEMENTATION |
| #define | STB_IMAGE_RESIZE_IMPLEMENTATION |
Functions | |
| bool | loadEnvMap (const string &path, Renderer &r) |
| Loads an HDRI map and uploads it as a GPU texture. | |
| bool | packTextureArray (const vector< CPUMaterial > &cpu_materials, vector< GPUMaterial > &gpu_materials, GLuint &out_array, GLenum internal_format, const char *label, std::function< const CPUTextureSlot &(const CPUMaterial &)> get_slot, std::function< void(GPUMaterial &, int)> write_index) |
| Packs one texture slot (albedo or normal) across all materials into a single GL_TEXTURE_2D_ARRAY, writing the resolved layer index back to the corresponding GPUMaterial field. | |
| bool | uploadTexture (const vector< CPUMaterial > &cpu_materials, vector< GPUMaterial > &gpu_materials, Renderer &r) |
| Builds the material texture array from the loaded materials. Uploads every material texture into a GPU texture array, and patches each GPUMaterial::tex_index to point at its layer. | |
| #define STB_IMAGE_IMPLEMENTATION |
| #define STB_IMAGE_RESIZE_IMPLEMENTATION |
| bool loadEnvMap | ( | const std::string & | path, |
| Renderer & | r ) |
Loads an HDRI map and uploads it as a GPU texture.
| path | Path to the HDRI file (.hdr, .exr) |
| r | Renderer to pass env map |
| bool packTextureArray | ( | const vector< CPUMaterial > & | cpu_materials, |
| vector< GPUMaterial > & | gpu_materials, | ||
| GLuint & | out_array, | ||
| GLenum | internal_format, | ||
| const char * | label, | ||
| std::function< const CPUTextureSlot &(const CPUMaterial &)> | get_slot, | ||
| std::function< void(GPUMaterial &, int)> | write_index ) |
Packs one texture slot (albedo or normal) across all materials into a single GL_TEXTURE_2D_ARRAY, writing the resolved layer index back to the corresponding GPUMaterial field.
| get_slot | Selects which CPUTextureSlot to read (albedo or normal) |
| write_index | Writes the resolved layer (or -1) into the right GPUMaterial field |
| internal_format | GL_SRGB8_ALPHA8 for color data (albedo); GL_RGBA8 for vector-encoded data (normals) |
| label | Short name used only in log output (ex. "albedo", "normal") |
| bool uploadTexture | ( | const vector< CPUMaterial > & | cpu_materials, |
| vector< GPUMaterial > & | gpu_materials, | ||
| Renderer & | r ) |
Builds the material texture array from the loaded materials. Uploads every material texture into a GPU texture array, and patches each GPUMaterial::tex_index to point at its layer.
| cpu_materials | CPU-sided material data, with texture sources |
| gpu_materials | In-out GPU material |
| renderer | Renderer to pass the resulting array |