Jump to content
  • Advertisement
Sign in to follow this  
MrCodeSushi

Buffer<uint> reading wrong values

This topic is 1800 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently trying to get a basic Forward+ renderer working. I've managed to get the first two steps which is the z-prepass, and the lighting stage working. In the lighting stage i have an RWBuffer<uint> that has the format of R8_UINT that stores the tile light indices. That R8_UINT buffer is then passed on to the forward shading stage as an Buffer<uint>. My problem is that when it reads the value of the Buffer<uint>, it always returns 0 even if the buffer contains a different value.

 

I have verified that i am binding the buffer correctly and its value after the lighting stage(compute shader) through the VS Graphics Debugger. Currently, i'm setting my scene so that there are no lights and the light indices buffer are all filled with the max lights value of 256. When it gets to my forward shader though, when it reads the light indices buffer it is always 0. I have checked the buffer bound to my light indices buffer and the xbyte values are all 0xff which should give me 255(uint) but all i get when i read the buffer are all 0. Do i need to do something with the buffer after the compute shader but just before it gets to my forward shader?

 

My implementation is an adoption from MJP's IndexedDeferred demo.

Share this post


Link to post
Share on other sites
Advertisement

It sounds like you're doing everything correctly, so I'm not sure what the problem is. You shouldn't need to do anything to the buffer after the compute shader is done writing to it, you should be able to just read from it in your pixel shader assuming that the UAV and SRV were set up correctly. If you didn't set up the UAV or SRV correctly the debug layer will usually output a warning to let you know that you did something wrong, assuming that you enabled the debug layer when creating the device.

Share this post


Link to post
Share on other sites

sigh... it would have saved me a lot of time if I simply looked at my output window. It turned out i wasn't clearing the bound UAV so when i render the geometry, DX was forcing the SRV to null. Thanks for your amazing help to the community, MJP!

 

Also if you don't mind me asking, i just pretty much copy-pasted the entire lighting equation and i simply don't have any idea on how do some parts of these equation work. I'm guessing that this is a part of the Physically Based BRDFs thing? I've been meaning to learn more about Physically Based Rendering but most of the resources ive seen seem to assume that you already have prior knowledge about these stuff already which just confuses me more. I was wondering if you could provide maybe some articles or a book i could read that talks more in-depth about these topics?

Share this post


Link to post
Share on other sites

Also, prior to the new lighting equation, the phong lighting model was a lot brighter. Now it looks very dark! lol

Edited by BrentChua

Share this post


Link to post
Share on other sites

Yeah the debug layer output can be a lifesaver sometimes! If you want, you can actually set it up to break into the debugger when a warning or error occurs. I usually do this so that I know right away that something is wrong, and also so that I know exactly where it's coming from.  It's really easy to do:

 

ID3D11InfoQueue* infoQueue = NULL;
device->QueryInterface(__uuidof(ID3D11InfoQueue), reinterpret_cast<void**>(&infoQueue));
infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, TRUE);
infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, TRUE);
infoQueue->Release();

 

As for the BRDF, it's basically an energy-conserving Blinn-Phong BRDF paired with a Fresnel term. The energy-conserving Blinn-Phong model does indeed come from the "Physically Based Shading"  side of things. If you're not familiar with the basics, I'd recommend reading through Real-Time Rendering 3rd Edition. It's a fantastic book all-around, but it has a great chapter that describe the physics of lighting and reflectance, as well another chapter that gives a comprehensive overview of BRDF's and the basics of physically based shading models. I'd also recommend reading through Naty Hoffman's presentations and course notes from SIGGRAPH. The slides from this year's course can be found here, but his course notes aren't up yet. You can also find last year's material here.

Share this post


Link to post
Share on other sites

That would definitely help me a lot; I'll include it in my code. I actually have the Real-Time Rendering Book. I've only read the first few chapters before i laid it off because of work and just totally forgot to get back reading into it. Thanks again for all your help. I really appreciate it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!