$darkmode
#include "pbr.h"#include "gl_common.h"#include "perf_timer.h"#include "render_utils.h"#include "shader.h"#include <math.h>#include <stddef.h>#include <stdint.h>Functions | |
| void | pbr_get_spec_uniforms (GLuint shader, PBRSpecUniforms *out) |
| Retrieves uniform locations for the specular prefilter shader. More... | |
| void | pbr_get_irr_uniforms (GLuint shader, PBRIrrUniforms *out) |
| Retrieves uniform locations for the irradiance convolution shader. More... | |
| void | pbr_get_lum_uniforms (GLuint shader, PBRLumUniforms *out) |
| Retrieves uniform locations for the luminance reduction shader. More... | |
| GLuint | pbr_prefilter_init (int width, int height) |
| Initializes a texture for progressive specular pre-filtering. More... | |
| void | pbr_prefilter_mip (GLuint shader, const PBRSpecUniforms *uniforms, GLuint env_hdr_tex, GLuint dest_tex, int width, int height, int level, int total_levels, int slice_index, int total_slices, float threshold) |
| Computes a single slice or mip-level for progressive pre-filtering. More... | |
| GLuint | build_prefiltered_specular_map (GLuint shader, GLuint env_hdr_tex, int width, int height, float threshold) |
| Generates a pre-filtered specular environment map in a single pass. More... | |
| GLuint | pbr_irradiance_init (int size) |
| Initializes a texture for progressive irradiance computation. More... | |
| void | pbr_irradiance_slice_compute (GLuint shader, const PBRIrrUniforms *uniforms, GLuint env_hdr_tex, GLuint dest_tex, int size, int slice_index, int total_slices, float threshold) |
| Computes one face/slice of the irradiance map. More... | |
| GLuint | build_irradiance_map (GLuint shader, GLuint env_hdr_tex, int size, float threshold) |
| Generates an irradiance map (diffuse IBL) in a single pass. More... | |
| void | compute_mean_luminance_gpu_start (GLuint shader_pass1, GLuint shader_pass2, GLuint hdr_tex, int width, int height, GLuint ssbos[2], const PBRLumUniforms *uniforms) |
| Starts the GPU computation for mean luminance (non-blocking). Uses a two-pass parallel reduction via compute shaders and SSBOs. More... | |
| float | compute_mean_luminance_gpu_result (GLuint ssbos[2], float clamp_multiplier) |
| Reads the result of mean luminance computation from the SSBO. This function should be called only after the GPU has finished the computation started by compute_mean_luminance_gpu_start. More... | |
| GLuint | build_brdf_lut_map (int size) |
| Generates the 2D BRDF Integration Look-Up Table. More... | |
Variables | |
| static const uint32_t | COMPUTE_GROUP_SIZE_PBR = 32 |
| static const uint32_t | COMPUTE_GROUP_SIZE_LUM = 16 |
| static const uint32_t | MAX_HDR_RESOLUTION = 4096 |
| static const GLuint | BINDING_ENV_MAP = 0 |
| static const GLuint | BINDING_DEST_TEXTURE = 1 |
| static const GLuint | COMPUTE_DISPATCH_Z_ONCE = 1 |
| GLuint build_brdf_lut_map | ( | int | size | ) |
Generates the 2D BRDF Integration Look-Up Table.
| size | LUT resolution (width and height). |
| GLuint build_irradiance_map | ( | GLuint | shader, |
| GLuint | env_hdr_tex, | ||
| int | size, | ||
| float | threshold | ||
| ) |
Generates an irradiance map (diffuse IBL) in a single pass.
| shader | Irradiance convolution shader. |
| env_hdr_tex | Source HDR map. |
| size | Destination resolution (width/height). |
| threshold | Luminance threshold. |
| GLuint build_prefiltered_specular_map | ( | GLuint | shader, |
| GLuint | env_hdr_tex, | ||
| int | width, | ||
| int | height, | ||
| float | threshold | ||
| ) |
Generates a pre-filtered specular environment map in a single pass.
| shader | Prefiltering compute shader. |
| env_hdr_tex | Source HDR environment map. |
| width | Destination width. |
| height | Destination height. |
| threshold | Luminance threshold for importance sampling. |
| float compute_mean_luminance_gpu_result | ( | GLuint | ssbos[2], |
| float | clamp_multiplier | ||
| ) |
Reads the result of mean luminance computation from the SSBO. This function should be called only after the GPU has finished the computation started by compute_mean_luminance_gpu_start.
| ssbos | The SSBOs used in the computation. |
| clamp_multiplier | Multiplier to apply to the result. |
| void compute_mean_luminance_gpu_start | ( | GLuint | shader_pass1, |
| GLuint | shader_pass2, | ||
| GLuint | hdr_tex, | ||
| int | width, | ||
| int | height, | ||
| GLuint | ssbos[2], | ||
| const PBRLumUniforms * | uniforms | ||
| ) |
Starts the GPU computation for mean luminance (non-blocking). Uses a two-pass parallel reduction via compute shaders and SSBOs.
| shader_pass1 | First reduction pass shader. |
| shader_pass2 | Final reduction pass shader. |
| hdr_tex | Source HDR texture. |
| width | Texture width. |
| height | Texture height. |
| ssbos | Pair of SSBO handles for intermediate and final results. |
| uniforms | Cached uniform locations for pass 2. |
| void pbr_get_irr_uniforms | ( | GLuint | shader, |
| PBRIrrUniforms * | out | ||
| ) |
Retrieves uniform locations for the irradiance convolution shader.
| shader | The shader program. |
| out | Pointer to the struct to populate. |
| void pbr_get_lum_uniforms | ( | GLuint | shader, |
| PBRLumUniforms * | out | ||
| ) |
Retrieves uniform locations for the luminance reduction shader.
| shader | The shader program. |
| out | Pointer to the struct to populate. |
| void pbr_get_spec_uniforms | ( | GLuint | shader, |
| PBRSpecUniforms * | out | ||
| ) |
Retrieves uniform locations for the specular prefilter shader.
| shader | The shader program. |
| out | Pointer to the struct to populate. |
| GLuint pbr_irradiance_init | ( | int | size | ) |
Initializes a texture for progressive irradiance computation.
| size | Destination resolution. |
| void pbr_irradiance_slice_compute | ( | GLuint | shader, |
| const PBRIrrUniforms * | uniforms, | ||
| GLuint | env_hdr_tex, | ||
| GLuint | dest_tex, | ||
| int | size, | ||
| int | slice_index, | ||
| int | total_slices, | ||
| float | threshold | ||
| ) |
Computes one face/slice of the irradiance map.
| shader | Compute shader. |
| uniforms | Cached uniform locations. |
| env_hdr_tex | Source HDR map. |
| dest_tex | Destination cubemap. |
| size | Resolution. |
| slice_index | Current face. |
| total_slices | Total faces. |
| threshold | Luminance threshold. |
| GLuint pbr_prefilter_init | ( | int | width, |
| int | height | ||
| ) |
Initializes a texture for progressive specular pre-filtering.
| width | Base level width. |
| height | Base level height. |
| void pbr_prefilter_mip | ( | GLuint | shader, |
| const PBRSpecUniforms * | uniforms, | ||
| GLuint | env_hdr_tex, | ||
| GLuint | dest_tex, | ||
| int | width, | ||
| int | height, | ||
| int | level, | ||
| int | total_levels, | ||
| int | slice_index, | ||
| int | total_slices, | ||
| float | threshold | ||
| ) |
Computes a single slice or mip-level for progressive pre-filtering.
| shader | Compute shader. |
| uniforms | Cached uniform locations. |
| env_hdr_tex | Source HDR map. |
| dest_tex | Destination cubemap. |
| width | Current level width. |
| height | Current level height. |
| level | Current mip level being processed. |
| total_levels | Total number of mips in the cubemap. |
| slice_index | Current face/slice being processed. |
| total_slices | Total slices (usually 6). |
| threshold | Luminance threshold. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |