diff --git a/src/refresh/vkpt/color.h b/src/refresh/vkpt/color.h new file mode 100644 index 000000000..0a914366c --- /dev/null +++ b/src/refresh/vkpt/color.h @@ -0,0 +1,44 @@ +/* +Copyright (C) 2019, NVIDIA CORPORATION. All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef COLOR_H_ +#define COLOR_H_ + +static inline float decode_srgb(byte pix) +{ + float x = (float)pix / 255.f; + + if (x < 0.04045f) + return x / 12.92f; + + return powf((x + 0.055f) / 1.055f, 2.4f); +} + +static inline byte encode_srgb(float x) +{ + if (x <= 0.0031308f) + x *= 12.92f; + else + x = 1.055f * powf(x, 1.f / 2.4f) - 0.055f; + + x = max(0.f, min(1.f, x)); + + return (byte)roundf(x * 255.f); +} + +#endif // COLOR_H_ diff --git a/src/refresh/vkpt/shader/global_ubo.h b/src/refresh/vkpt/shader/global_ubo.h index c85cc600b..bf9365d21 100644 --- a/src/refresh/vkpt/shader/global_ubo.h +++ b/src/refresh/vkpt/shader/global_ubo.h @@ -89,7 +89,8 @@ with this program; if not, write to the Free Software Foundation, Inc., UBO_CVAR_DO(pt_metallic_override, -1) /* overrides metallic parameter of all materials if non-negative, [0..1] */ \ UBO_CVAR_DO(pt_ndf_trim, 0.9) /* trim factor for GGX NDF sampling (0..1] */ \ UBO_CVAR_DO(pt_num_bounce_rays, 1) /* number of bounce rays, valid values are 0 (disabled), 0.5 (half-res diffuse), 1 (full-res diffuse + specular), 2 (two bounces) */ \ - UBO_CVAR_DO(pt_particle_softness, 1.0) /* particle softness */ \ + UBO_CVAR_DO(pt_particle_softness, 0.7) /* particle softness */ \ + UBO_CVAR_DO(pt_particle_brightness, 100) /* particle brightness */ \ UBO_CVAR_DO(pt_reflect_refract, 2) /* number of reflection or refraction bounces: 0, 1 or 2 */ \ UBO_CVAR_DO(pt_roughness_override, -1) /* overrides roughness of all materials if non-negative, [0..1] */ \ UBO_CVAR_DO(pt_specular_anti_flicker, 2) /* fade factor for rough reflections of surfaces far away, [0..inf) */ \ diff --git a/src/refresh/vkpt/shader/path_tracer_hit_shaders.h b/src/refresh/vkpt/shader/path_tracer_hit_shaders.h index b544866d7..4aaa9978b 100644 --- a/src/refresh/vkpt/shader/path_tracer_hit_shaders.h +++ b/src/refresh/vkpt/shader/path_tracer_hit_shaders.h @@ -95,7 +95,7 @@ vec4 pt_logic_particle(int primitiveID, vec2 bary) color.a *= factor; color.rgb *= color.a; - color.rgb *= global_ubo.prev_adapted_luminance * 500; + color.rgb *= global_ubo.prev_adapted_luminance * global_ubo.pt_particle_brightness; return color; } diff --git a/src/refresh/vkpt/textures.c b/src/refresh/vkpt/textures.c index 5f589ca52..73bd38810 100644 --- a/src/refresh/vkpt/textures.c +++ b/src/refresh/vkpt/textures.c @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include +#include "color.h" #include "material.h" #include "../stb/stb_image.h" #include "../stb/stb_image_resize.h" @@ -518,28 +519,6 @@ IMG_Load ================ */ -static inline float decode_srgb(byte pix) -{ - float x = (float)pix / 255.f; - - if (x < 0.04045f) - return x / 12.92f; - - return powf((x + 0.055f) / 1.055f, 2.4f); -} - -static inline byte encode_srgb(float x) -{ - if (x <= 0.0031308f) - x *= 12.92f; - else - x = 1.055f * powf(x, 1.f / 2.4f) - 0.055f; - - x = max(0.f, min(1.f, x)); - - return (byte)roundf(x * 255.f); -} - struct filterscratch_s { int num_comps; diff --git a/src/refresh/vkpt/transparency.c b/src/refresh/vkpt/transparency.c index cdf9b61bc..dfd7b8e9d 100644 --- a/src/refresh/vkpt/transparency.c +++ b/src/refresh/vkpt/transparency.c @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "shared/shared.h" #include "vkpt.h" #include "vk_util.h" +#include "color.h" #include "conversion.h" #define TR_PARTICLE_MAX_NUM MAX_PARTICLES @@ -99,12 +100,12 @@ void cast_u32_to_f32_color(int color_index, const color_t* pcolor, float* color_ color.u32 = d_8to24table[color_index & 0xff]; for (int i = 0; i < 3; i++) - color_f32[i] = hdr_factor * ((float)color.u8[i] / 255.0); + color_f32[i] = hdr_factor * decode_srgb(color.u8[i]); } bool initialize_transparency() { - cvar_pt_particle_size = Cvar_Get("pt_particle_size", "0.35", 0); + cvar_pt_particle_size = Cvar_Get("pt_particle_size", "0.5", 0); cvar_pt_beam_width = Cvar_Get("pt_beam_width", "1.0", 0); cvar_pt_beam_lights = Cvar_Get("pt_beam_lights", "1.0", 0);