Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
Loading...
Searching...
No Matches
pbr.h
Go to the documentation of this file.
1
10#ifndef PBR_H
11#define PBR_H
12
13#include "gl_common.h"
14
18typedef struct {
19 GLint u_env_map;
21 GLint u_mip;
24 GLint u_max_y;
26
30typedef struct {
33 GLint u_max_y;
35
39typedef struct {
43
49void pbr_get_spec_uniforms(GLuint shader, PBRSpecUniforms* out);
50
56void pbr_get_irr_uniforms(GLuint shader, PBRIrrUniforms* out);
57
63void pbr_get_lum_uniforms(GLuint shader, PBRLumUniforms* out);
64
74GLuint build_prefiltered_specular_map(GLuint shader, GLuint env_hdr_tex,
75 int width, int height, float threshold);
76
83GLuint pbr_prefilter_init(int width, int height);
84
103void pbr_prefilter_mip(GLuint shader, const PBRSpecUniforms* uniforms,
104 GLuint env_hdr_tex, GLuint dest_tex, int width,
105 int height, int level, int total_levels, int slice_index,
106 int total_slices, float threshold);
107
116GLuint build_irradiance_map(GLuint shader, GLuint env_hdr_tex, int size,
117 float threshold);
118
124GLuint pbr_irradiance_init(int size);
125
141void pbr_irradiance_slice_compute(GLuint shader, const PBRIrrUniforms* uniforms,
142 GLuint env_hdr_tex, GLuint dest_tex, int size,
143 int slice_index, int total_slices,
144 float threshold);
145
151GLuint build_brdf_lut_map(int size);
152
164void compute_mean_luminance_gpu_start(GLuint shader_pass1, GLuint shader_pass2,
165 GLuint hdr_tex, int width, int height,
166 GLuint ssbos[2],
167 const PBRLumUniforms* uniforms);
168
177float compute_mean_luminance_gpu_result(GLuint ssbos[2],
178 float clamp_multiplier);
179
180#endif /* PBR_H */
Common OpenGL definitions, RAII helpers, and utilities.
void pbr_get_spec_uniforms(GLuint shader, PBRSpecUniforms *out)
Retrieves uniform locations for the specular prefilter shader.
Definition pbr.c:20
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.
Definition pbr.c:63
GLuint build_irradiance_map(GLuint shader, GLuint env_hdr_tex, int size, float threshold)
Generates an irradiance map (diffuse IBL) in a single pass.
Definition pbr.c:230
void pbr_get_lum_uniforms(GLuint shader, PBRLumUniforms *out)
Retrieves uniform locations for the luminance reduction shader.
Definition pbr.c:43
GLuint build_brdf_lut_map(int size)
Generates the 2D BRDF Integration Look-Up Table.
Definition pbr.c:381
GLuint pbr_prefilter_init(int width, int height)
Initializes a texture for progressive specular pre-filtering.
Definition pbr.c:52
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.
Definition pbr.c:178
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.
Definition pbr.c:142
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 aft...
Definition pbr.c:370
GLuint pbr_irradiance_init(int size)
Initializes a texture for progressive irradiance computation.
Definition pbr.c:168
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 ...
Definition pbr.c:280
void pbr_get_irr_uniforms(GLuint shader, PBRIrrUniforms *out)
Retrieves uniform locations for the irradiance convolution shader.
Definition pbr.c:33
Cached uniform locations for radiance convolution shader.
Definition pbr.h:30
GLint u_max_y
Definition pbr.h:33
GLint u_threshold
Definition pbr.h:31
GLint u_offset_y
Definition pbr.h:32
Cached uniform locations for luminance reduction shader.
Definition pbr.h:39
GLint u_numPixels
Definition pbr.h:41
GLint u_numGroups
Definition pbr.h:40
Cached uniform locations for specular prefiltering shader.
Definition pbr.h:18
GLint u_max_y
Definition pbr.h:24
GLint u_env_map
Definition pbr.h:19
GLint u_mip
Definition pbr.h:21
GLint u_threshold
Definition pbr.h:22
GLint u_roughness
Definition pbr.h:20
GLint u_offset_y
Definition pbr.h:23