# DX11 Need help implementing NDF-Filtering + LEAN mapping

## Recommended Posts

Hello,

I manged so far to implement NVIDIA's NDF-Filtering at a basic level (the paper can be found here). Here is my code so far:

//...
// project the half vector on the normal (?)
float3 hppWS = halfVector / dot(halfVector, geometricNormal)
float2 hpp = float2(dot(hppWS, wTangent), dot(hppWS, wBitangent));

// compute the pixel footprint
float2x2 dhduv = float2x2(ddx(hpp), ddy(hpp));

// compute the rectangular area of the pixel footprint
float2 rectFp = min((abs(dhduv[0]) + abs(dhduv[1])) * 0.5, 0.3);

// map the area to ggx roughness
float2 covMx = rectFp * rectFp * 2;
roughness = sqrt(roughness * roughness + covMx);
//... 

Now I want combine this with LEAN mapping as state in Chapter 5.5 of the NDF paper.

But I struggle to understand what theses sections actually means in Code:

Quote

To combine this filtering method with our NDF filtering, we do
the following: We first interpret the first-order moments as a regular
tangent frame with it.

I suppose the first-order moments are the B coefficent of the LEAN map, however things like

float3 hppWS = halfVector / dot(halfVector, float3(lean_B, 0));

doesn't bring up anything usefull.

Next theres:

Quote

We then compute a covariance matrix SIGMA
of the estimated Beckmann distribution (Eq. 5 in [OB10]) and interpret
this as another kernel filter  induced by variations of half
vectors caused by the normal map.

This simply means:

// M and B are the coefficents from the LEAN map
float2x2 sigma_mat = float2x2(
M.x - B.x * B.x, M.z - B.x * B.y,
M.z - B.x * B.y, M.y - B.y * B.y);

does it?

Finally:

Quote

Finally, using the convolution formulation of NDF filtering from
Eq. 12, we perform a nested convolution

This is the part confuses me the most: how am I suppose to convolute two matrices? I know the concept of convolution in terms of functions, not matrices. Should I multiple them? That didn't make any usefully output.

I hope someone can help with this maybe too specific question, I'm really despaired to make this work and i've spend too many hours of trial & error...

Cheers,

Julian

Edited by schneckerstein

## Create an account

Register a new account

• 9
• 10
• 12
• 10
• 10
• ### Similar Content

• Hi,

I am working on a project where I'm trying to use Forward Plus Rendering on point lights. I have a simple reflective scene with many point lights moving around it. I am using effects file (.fx) to keep my shaders in one place. I am having a problem with Compute Shader code. I cannot get it to work properly and calculate the tiles and lighting properly.

Is there anyone that is wishing to help me set up my compute shader?
Thank you in advance for any replies and interest!

• Hi, right now building my engine in visual studio involves a shader compiling step to build hlsl 5.0 shaders. I have a separate project which only includes shader sources and the compiler is the visual studio integrated fxc compiler. I like this method because on any PC that has visual studio installed, I can just download the solution from GitHub and everything just builds without additional dependencies and using the latest version of the compiler. I also like it because the shaders are included in the solution explorer and easy to browse, and double-click to open (opening files can be really a pain in the ass in visual studio run in admin mode). Also it's nice that VS displays the build output/errors in the output window.
Anyone with some experience in this?

• Hello!
Have a problem with reflection shader for D3D11:
1>engine_render_d3d11_system.obj : error LNK2001: unresolved external symbol IID_ID3D11ShaderReflection
#include <D3Dcompiler.h>
#include <D3DCompiler.inl>
#pragma comment(lib, "D3DCompiler.lib")
//#pragma comment(lib, "D3DCompiler_47.lib")
As MSDN tells me but still no fortune. I think lot of people did that already, what I missing?
where recommend to use SDK headers and libs before Wind SDK, but I am not using DirectX SDK for this project at all, should I?

• Hi there, this is my first post in what looks to be a very interesting forum.
I am using DirectXTK to put together my 2D game engine but would like to use the GPU depth buffer in order to avoid sorting back-to-front on the CPU and I think I also want to use GPU instancing, so can I do that with SpriteBatch or am I looking at implementing my own sprite rendering?

• I am trying to draw a screen-aligned quad with arbitrary sizes.

currently I just send 4 vertices to the vertex shader like so:
pDevCon->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
pDevCon->Draw(4, 0);

then in the vertex shader I am doing this:
float4 main(uint vI : SV_VERTEXID) : SV_POSITION
{
float2 texcoord = float2(vI & 1, vI >> 1);
return float4((texcoord.x - 0.5f) * 2, -(texcoord.y - 0.5f) * 2, 0, 1);
}
that gets me a screen-sized quad...ok .. what's the correct way to get arbitrary sizes?...I have messed around with various numbers, but I think I don't quite get something in these relationships.
one thing I tried is:

float4 quad = float4((texcoord.x - (xpos/screensizex)) * (width/screensizex), -(texcoord.y - (ypos/screensizey)) * (height/screensizey), 0, 1);

.. where xpos and ypos is number of pixels from upper right corner..width and height is the desired size of the quad in pixels
this gets me somewhat close, but not right.. a bit too small..so I'm missing something ..any ideas?

.