Jump to content
  • Advertisement
Sign in to follow this  
EmptyVoid

Why do my polygons keep droping out?!?!?

This topic is 3701 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 cant understand why my polygons keep droping out I thought it may be a problem with the shader or Z-buffer and I've run like 100 test and I know thats not it. Here is a picture to show whats going on: It's only on the mesh thats going to be water also seems to be radiating in circles away from the camera.

Share this post


Link to post
Share on other sites
Advertisement
Could you explain things in a little more detail? Such as how the scene should look? What kind of renderer are you using? Maybe a wireframe grab so that we can compare what you see with the underlying geometry.

It's very hard to make out whats wrong without knowing what it should look like.
For your own sake you could try rendering out the surface normals using GL_LINE at each vertex or face depending on what you're using.

Andy

Share this post


Link to post
Share on other sites
If I understand correctly, you want to render a mesh representing water.
What you should consider is to render the mesh without any of the water effects (like changing vertices height and so forth) in wireframe mode.
By doing that you can see if the vertices and edges are located where you expect and you may understand the source of the problem.

Share this post


Link to post
Share on other sites
Given that you didn't actually describe your problem, we're reduced to guessing. If you're seeing polys disappear when they go further away from the camera then I'm guessing that you've got your far plane set too close. In OpenGL this is set when you call glPerspective.

Share this post


Link to post
Share on other sites



It's difinately not the Z-buffer whole polygons are droping out.
I had to capture it at the exact moment when it renders the polygons properly.

Also it's in DirectX 9 and it's chucked terrain.

Share this post


Link to post
Share on other sites
Ok so it is water rendering over a ChunkedLOD of terrain. Is it a single solid plane of water, or does it have any LOD'ing on the water? Do you render a water plane per-chunk?

Have you tried reducing the tesselation of the water surface? It looks quite high poly in your wireframe.

Are you using shaders or fixed function? Could you post the draw code for the water plane itself, i.e. where you setup and call the D3DDrawIndexedPrmitive or whatever.

You're terrain appears to be rendering just fine underneath the water (which looks like it's being torn into strips) so have you tried running it with the drawcall/&setup disabled for the terrain. If you still get the problem then you've narrowed it down a bit at least.

Andy

Share this post


Link to post
Share on other sites
Quote:
Original post by NineYearCycle
Ok so it is water rendering over a ChunkedLOD of terrain. Is it a single solid plane of water, or does it have any LOD'ing on the water? Do you render a water plane per-chunk?

Have you tried reducing the tesselation of the water surface? It looks quite high poly in your wireframe.

Are you using shaders or fixed function? Could you post the draw code for the water plane itself, i.e. where you setup and call the D3DDrawIndexedPrmitive or whatever.

You're terrain appears to be rendering just fine underneath the water (which looks like it's being torn into strips) so have you tried running it with the drawcall/&setup disabled for the terrain. If you still get the problem then you've narrowed it down a bit at least.

Andy


Shaders and the draw call is
Chunk->DrawSubset(0);
the terrain and the water are both using the same function to draw. the only thing thats different is the shaders but the water shader is super simple. I'll post it:


float4x4 WorldViewProj : WORLDVIEWPROJ;
float4x4 WorldOffset;

texture Tex0 : DiffuseMap
<
string UIName = "Water Texture";
>;

sampler Base = sampler_state
{
Texture = (Tex0);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};

struct VS_OUTPUT
{
float4 position : POSITION;
float2 tex1 : TEXCOORD0;
};

VS_OUTPUT VS(float3 position : POSITION, float2 tex1 : TEXCOORD0)
{
VS_OUTPUT Out;
Out.position = mul(float4(normalize(mul(float4(position,1),WorldOffset).xyz),1),WorldViewProj);
Out.tex1 = tex1;
return Out;
}

float4 PS(VS_OUTPUT IN ) : COLOR
{
return tex2D( Base, IN.tex1 );
}

technique Default
{
pass P0
{
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}




Also I need to explain what it's doing. It's rotating the Geo-mipmapped plane to the six sides of a cube and normalizeing the vertices. Basicly a procedural planet.

Share this post


Link to post
Share on other sites
Another thing is when I set it to software vertex processing it renders fine...
Oh and when I render 2 things of land they render fine. So the water shader has to be the problem...

Ok now this is clearly not my falt theres something wrong with DirectX or my video card....

I made a copy of my terrain shader and said to not add the offset for the terrain. and it worked then I tried to remove the code that created the noise and I removed some and it worked fine but I cant remove it all or they start to drop out again. Here is how much of a shell I was able to make of my shader and it worked fine for rendering the water:

[source c++]
float4x4 WorldViewProj : WORLDVIEWPROJ;
float4x4 View : ViewInverse;
float4x4 WorldOffset;

int Planet_Seed
<
string UIName = "Seed";
int UIMin = 1;
int UIMax = 65536;
int UIStep = 1;
string UIWidget = "slider";
> = 1;


texture Tex0 : DiffuseMap
<
string UIName = "Base Texture";
>;


sampler Base = sampler_state
{
Texture = (Tex0);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};

struct VS_OUTPUT
{
float4 position : POSITION;
float4 color : COLOR;
float2 tex1 : TEXCOORD0;
};

float Interpolate(float a, float b, float x)
{
float f = 0;
return a*(1-f) + b*f;
}


float Noise(int x, int y, int z)
{
return Planet_Seed;
}


float InterpolatedNoise(float x, float y, float z)
{
float v1 = Noise(0, 0, 0);
float v2 = Noise(0, 0, 0);
float v3 = Noise(0, 0, 0);
float v4 = Noise(0, 0, 0);

float v5 = Noise(0, 0, 0);
float v6 = Noise(0, 0, 0);
float v7 = Noise(0, 0, 0);
float v8 = Noise(0, 0, 0);

float i1 = Interpolate(v1, v2, 0);
float i2 = Interpolate(v3, v4, 0);
float i3 = Interpolate(i1, i2, 0);

float i4 = Interpolate(v5, v6, 0);
float i5 = Interpolate(v7, v8, 0);
float i6 = Interpolate(i4, i5, 0);

return Interpolate(i3, i6, 0);
}

VS_OUTPUT VS(float4 position : POSITION, float2 tex1 : TEXCOORD0)
{
VS_OUTPUT Out;
float3 Cartesian = normalize(mul(position,WorldOffset).xyz);
float Offset=0;
if(Planet_Seed>0)
Offset = InterpolatedNoise(0,0,0);



Out.position = mul(float4(Cartesian+((Cartesian/200)*Offset),1),WorldViewProj);
Out.tex1 = tex1;
Out.color = float4(0,0,0,1);

return Out;
}



float4 PS(VS_OUTPUT IN ) : COLOR
{
return tex2D( Base, IN.tex1 );
}

technique Default
{
pass P0
{
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}



[Edited by - EmptyVoid on April 3, 2008 9:32:07 AM]

Share this post


Link to post
Share on other sites
This might be me being thick but bear with me.

The vertex format for the water shader that you posted was this:

struct VS_OUTPUT
{
    float4 position : POSITION;
    float2 tex1 : TEXCOORD0;
};

and the one from your terrain is:

struct VS_OUTPUT
{
    float4 position : POSITION;
    float4 color : COLOR;
    float2 tex1 : TEXCOORD0;
};

Could it be that you're not changing the vertex declarations for the water? If the terrain works with the terrain shader, and the water works with the terrain shader until you "cut it down" then is that cutting down altering your vertex declaraction?

Andy

Share this post


Link to post
Share on other sites
Oh and since you're using DirectX have you tried using the debug runtimes so that you can get some error output? It'll run slower but it'll also give you a load more info about any internal errors or bad settings.

Andy

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!