Jump to content
  • Advertisement
Sign in to follow this  
phatgreen

Deferred Rendering and Camera Issue - DirectX11

This topic is 1007 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've attempted to implement Deferred Rendering into my engine for the first time using Direct3D11, HLSL, C++ (No XNA, my own math lib)... and I've got some issues that I am struggling to find the solution to.

 

 

A Few things to know:

The camera is treated as the origin. The objects, and the lights have their coordinates converted from being relative to the center of the world to being relative to the cameras position in the world.

The objects being generated are geospheres. 

 

Issues:

1. There are bugs in my lighting (I don't even know if its CPU side or GPU side) that I cannot figure out the problem to.

2. My camera is acting very weird. When I pitch the camera the entire world is pitching, when I turn (yaw) the camera yaws correctly and the world doesn't move like it shouldn't.  When I strafe (move along the camera's Right Vector) it is moving as if the right vector has never changed since the application started, as in, the right vector is always parallel with the world's x-axis. Same with the look vector. This camera issue is very strange to me because I had the camera being the origin in a different project and it works just fine, so I don't think it has to do with incorrect methods regarding movement in my Camera Class.

3. When I switch to fullscreen there is some sort of slicing on the screen (like something you would see if your swap chain presented too early)

4. My framerate in general is poor, I don't understand why. With 1 light it is 108fps, 2 lights 79 fps, 3 lights 63, and so on.

5. The objects themselves are jumpy, they will jump a pixel or two, consistently, and at the same intervals in unison. 

 

My lighting is basically acting weird at the poles (They don't appear to be y-axis poles, but some sort of poles in the object's world space). 

I looked through my method that generates the normals and tangents and I believe the issue might be when the normal vector is (0,1,0) and my tangents get wacky and become (0,0,0). However, even when I hardcode it that (0,1,0) vectors should have (1,0,0) tangent vectors, it doesn't solve the issue.

 

I do not believe the issue has anything to do with the data being correctly transferred over to the GPU because I looked at debugged the GPU and found no issues there.

 

Here are some examples of my lighting issue. The following pictures are lit by a single Directional Light (light hits all the objects from the same direction)

 

Directional Light 1

XxqNQpp.jpg

 

Directional Light 2

ENmmJhb.jpg

 

Directional Light 3

7u6m9Pm.jpg

 

Heres one with a Point Light, similiar issues.

A7hcHhG.jpg

 

So with those pictures in mind I've also like to add these screenshots of the shaders used.

Default Vertex Shader

Yrr0INL.jpg

 

Default Pixel Shader

67IvJv4.jpg

 

Deferred Vertex Shader

rDwAqOv.jpg

 

Deferred Pixel Shader Part 1

21i2guP.jpg

 

Deferred Pixel Shader Part 2

RDTNPNZ.jpg

 

 

If you need more information, more code, let me know.

 

Thank you for reading and helping.

 

 

 

 

 

Share this post


Link to post
Share on other sites
Advertisement
there is some problem in your shaders:
 
getGBufferAttributes does not re-normalize the normal, in this way: normal = (textureNormal.Load(sampleIndices).xyz - 0.5) * 2
 
I think you must set normalTS as float3(0.5,0.5,1.0) it is the flat value for a normal map (or skip it if there is no normal map)
 
Regards,
Antonino
Edited by IorPerry

Share this post


Link to post
Share on other sites

Wow it fixed the lighting! Can't believe it was that simple. I still have the camera issue, bad framerate, and the slicing. I'm going to go over all my matrix stuff and see if I can find anything.

 

As of right now..

1 Light - 110fps

10 Lights - 26fps

 

Are binding the gbuffers as resources to the deferredPS supposed to take a lot of time? Because I lose a bulk of my fps to that as well.

Edited by phatgreen

Share this post


Link to post
Share on other sites

Another advice: think in msec not in FPS, it is more simple.

In your case rendering time is: 9msec for 1 light and 38.4msec for 10 lights. so every light take near 3.5 msec... 

 

In my defered rendering I did a visual profiler (OpenGL):

20110824_stats.jpg

here I use ARB_timer_query because my Engine is OpenGL, here https://mynameismjp.wordpress.com/2011/10/13/profiling-in-dx11-with-queries/ you can found a DirectX version.

 

what you can do is profile, optimize and maybe render only a part of screen for point light.

 

Regards,

Antonino

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!