Jump to content

  • Log In with Google      Sign In   
  • Create Account

Krzysztof Narkowicz

Member Since 13 Aug 2010
Offline Last Active Today, 04:48 AM

Posts I've Made

In Topic: Question about Epic's course notes about Physically based rendering.

21 September 2016 - 01:55 PM



It's impractical to use SH for high freq IBL, as you need a crazy amount of terms. Additionally, Brian's split sum approximation splits the radiance integral into two parts - one which can be stored in a cube map and second which can be stored in a small 2D texture (this is why there is no L(i) term in the second equation). Anyway, I'm not sure what are you trying to calculate here, as your equations look quite strange - e.g. f(l,v) term is missing.

In Topic: Some HDR, tonemapping and bloom questions

29 August 2016 - 02:31 PM

Right now I use DXGI_FORMAT_R16G16B16A16_UNORM for my "light accumulation" or HDR-buffer. I guess then I should use DXGI_FORMAT_R16G16B16A16_FLOAT instead?


You could use RGB16_UNORM by manually scaling shader outputs and inputs, but RGB16_Float render target is more convenient and precise (you want a lot of precision for the low values and not too much for the very high ones).


Right now I perform my gamma-correction by simply doing a fullscreen pass and rendering the DXGI_FORMAT_R16G16B16A16_UNORM texture into the DXGI_FORMAT_R8G8B8A8_UNORM_SRGB backbuffer texel-by-texel. I guess this works fine since both are in the [0, 1] range. Do these tonemapping alghorithms (like Reinhard) also bring the values > 1.0 into the [0,1] range or is it "just about averaging/smoothing the light intensity"? i.e will I possibly end up with > 1.0 values after tonemapping?  :)


Tonemapping is about reducing color range for the final display, so yes a common tonemapper (one designed for LDR displays) will bring image to the [0;1] range.


EDIT: also, what happens when you write > 1.0 valus into a UNORM texture? I assume they jsut get clamped to 1.0?


Yes. Output values will be clamped to [0;1] range.


EDIT2: another question, I suppose FXAA is to be applied AFTER tonemapping? and bloom BEFORE tonemapping?


Yes. You want bloom before tonemapping (so it works with linear HDR values) and FXAA after tonemapping (so edge blending works "correcly"). 

In Topic: Anyone Know how to achieve XCOM's style of Fog of War?

03 August 2016 - 02:58 PM

Just create a render target with fog of war, where 1 pixel represents one tile and it's value represents if it's visible or not. Update this render target when camera moves, by rendering a circle. This way new tiles around the current camera position will be marked as visible. Finally, render fog of war, by reading mentioned render target, filtering it (maybe using some higher order filter) and apply some kind of cool effect in pixels where fog of war is marked as visible.

In Topic: Diffuse IBL - Importance Sampling vs Spherical Harmonics

09 February 2016 - 03:56 PM

Most often HDR sky textures don't contain sun, as it's a separate analytic light source and you don't want to apply it twice to the scene. Therefore you usually don't have to deal with such extreme values and ~32-64 samples are enough for diffuse pre-integration using importance sampling. It's also pretty cheap, as 6x8x8 destination pixels are enough for low frequency data like diffuse. This of course doesn't yield perfect results, but errors are hard to notice in a real scene with textures.


If you are interested in diffuse pre-integration using SH, then check out this great post by Sébastien Lagarde (it also contains an example application with source code):


In Topic: [DX12] Constant Buffer Packing

07 February 2016 - 03:35 AM

Arrays in HLSL constant buffers are stored without any packing and every element is stored as float4. This way there in no extra overhead for array indexing in shader. If you want to pack arrayd more tightly then simply pass them as float4[] and cast to float2[] in shader.