Skip to content

Commit

Permalink
Add emission output to pbr
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Dec 11, 2023
1 parent ca5d61f commit 1b6faad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion data/standard-render-pbr.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
#include "pbr-common.glsl"

PbrMaterial material;
layout (location = 1) out vec3 f_emission;
uniform int material_id;
uniform sampler2D albedo_tex;
uniform sampler2D metal_rough_occlusion_tex;
uniform sampler2D normal_tex;
uniform sampler2D emission_tex;
uniform sampler2D brdf_lut;
uniform samplerCube irradiance_map;
uniform samplerCube environment_map;
vec3 view_dir, F0;
vec3 view_dir, F0, emission;
vec4 albedo;
float metalness, roughness, occlusion;

Expand All @@ -21,6 +23,7 @@ void standard_init(){
maybe_call_next_method();
material = materials[material_id];
normal = normal_map(normal_tex, world_position-camera_position, uv, normal);
emission = texture(emission_tex, uv).xyz * material.emission_factor;
view_dir = normalize(camera_position - world_position);
albedo = texture(albedo_tex, uv);
albedo.xyz = pow(albedo.xyz,vec3(gamma));
Expand Down Expand Up @@ -82,6 +85,7 @@ vec4 standard_shade(in StandardLight light){
}

void standard_finish(){
f_emission = emission;
color.w = albedo.w;
if(color.w < material.alpha_cutoff)
discard;
Expand Down
1 change: 1 addition & 0 deletions package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@
#:emission-texture
#:normal-texture
#:pbr-render-pass
#:emission
#:environment-light
#:irradiance-map
#:environment-map)
Expand Down
3 changes: 2 additions & 1 deletion renderer/pbr.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
(setf (alpha-cutoff target) (alpha-cutoff material)))

(define-shader-pass pbr-render-pass (standard-shadows-pass light-cache-render-pass)
((environment :initform NIL :accessor environment))
((environment :initform NIL :accessor environment)
(emission :port-type output :texspec (:internal-format :rgb16f) :attachment :color-attachment2 :reader emission))
(:shader-file (trial "standard-render-pbr.glsl")))

(defmethod render-with ((pass pbr-render-pass) (material pbr-material) program)
Expand Down

0 comments on commit 1b6faad

Please sign in to comment.