Hardware Problems-Custom Effect

rated by 0 users
This post has 3 Replies | 2 Followers

Top 150 Contributor
Posts 15
SunBurn_Community_Licensee
SunBurn_Pro_Licensee
Brian Thorpe Posted: 03-12-2010 7:50 PM

I am working on a custom effect which uses a texture to displace  vertices for terrain.  The effect is largely based on the deferred custom effect wobble, except I am using a tex2dlod to access a single format texture for the terrain height values.

The effect works on a Geforce 9400m  and a Geforce 260, however I get a weird result if I try the same with a Geforce 7900.  The problem seems to be related to the depth information being generated. 

The scene in the images below is the Custom Deferred example with an added terrain.  The terrain is the bright ugly textured thing not the terrain model from the example.

http://thordev.releasereality.com/assets/135/original/TerrainProblem.png

This demonstrates the problem.  The image should show the box being covered by the bump of terrain in front of it.

http://thordev.releasereality.com/assets/136/original/TerrainProblem2.png

This image shows the same problem but with a bit more artifacts.  Objects which are not terrain have the weird blended effect, and terrain which covers itself is lacking enough depth information so the terrain behind is showing.

The best I can guess as to what is going on here is that the Depth is not being set right for some reason on a Geforce 7900, but everything else is being calculated correctly so I end up with a kind of weird blending in the final pass.  

For reference here is what it looks like on the other hardware.  

http://thordev.releasereality.com/assets/137/original/TerrainCorrect.PNG

Let me know if you have any ideas so I could fix this for the 7900.  I seemed to remember something about weird issues with single formats for this particular card.  I believe I had to set some value to be a half single value but I do not remember.

Top 10 Contributor
Posts 4,546
Employee
SunBurn_Studio_Licensee

Hi Brian,

SunBurn automatically accounts for hardware supported render targets and initializes the deferred buffers with the correct matching targets.  To test if this is working correctly, try running a fresh copy of the Custom Effect and Power Station examples.

If the problem is not visible in the examples it's likely related to custom code / shaders.  There are several ways to test for code that is behaving oddly in DirectX / XNA or on certain hardware.  Two quick tests, which catch a large portion of problems, are:

  • Compile the project in release mode - in debug mode the DirectX / XNA shader compiler disables a lot of error and warning checks, switching to release mode will display any additional errors or warnings.  A good example of this is when a shader uses too many shader-constants, in debug this compiles fine though the shader behaves poorly, compiling in release mode lets you know why, throwing an error due to too many constants.
  • Turn on DirectX debugging - this will throw exceptions in any graphics code that DirectX does not recommend, this usually means code that runs fine in most circumstances, but can act odd at times.

If those fail to find anything you can also send over a test case and we'll take a look at it.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 150 Contributor
Posts 15
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

John,

Sorry it has taken me awhile to follow up on your advice, I had to keep working on new features to deliver midterm demos for classes on time.  Now that midterms are over I figured I would try to tackle this problem once more.

I ran some tests with the direct x debug and release modes, but had no additional information provided.

Both the custom effects and power station samples work well as far as I can tell.

I tried using a more recent version of my project and checked for additional errors with no problems.

I then tested the more recent project and surprisingly the terrain doesn't have this problem any more.  It has a new problem which I believe is related.  I do not believe this is in any way a Sunburn issue.

The terrain generated from three textures which are sampled in the vertex shader, one is a height texture in a single format, one is a morphed height texture in a single format, and one is a normal map in a color format.

The new problem is that the sampling performed on the normal map results in 0,0,0,0 values.

The only thing I can think of is that there is some weird issue occuring during the sampling in the vertex shader that prevents some techniques from sampling all of the textures all of the time.

In the previous post it was apparent to me that the height was sampled correctly during atleast one pass, but not the depth pass resulting in the weird effects.  This is quite puzzling to me.

Anyways, I will probably have to put this problem on the shelf for now and worry about it later if need be.  I just wanted to give you an update.

Also, in case you were wondering since most of my posts have been regarding terrain and how to get terrain working, I do have some initial results which I am very pleased with.

The pictures show a terrain which is 128x128 vertexes across.  I have tested upto 1024x1024 terrain which works great as well.

These are from the hardware without the issues (geforce 260).

http://thordev.releasereality.com/assets/155/original/Game1.png
http://thordev.releasereality.com/assets/156/original/game2.png
http://thordev.releasereality.com/assets/157/original/Game3.png
http://thordev.releasereality.com/assets/158/original/game4.png

Thanks for the help.  Let me know if you have any additional questions, comments, or if you would like me to post my terrain results more formally for others to see.

Top 10 Contributor
Posts 4,546
Employee
SunBurn_Studio_Licensee

Hi Brian,

Looks cool!

Brian Thorpe:
The terrain generated from three textures which are sampled in the vertex shader, one is a height texture in a single format, one is a morphed height texture in a single format, and one is a normal map in a color format.

The new problem is that the sampling performed on the normal map results in 0,0,0,0 values.

Make sure the sampler state for the texture is set to point sampling - I believe vertex textures are limited to point sampling and also support a smaller subset of the overall texture formats.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Page 1 of 1 (4 items) | RSS