• Create Account

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

25 replies to this topic

### #21Yura  Members

263
Like
0Likes
Like

Posted 03 January 2013 - 02:44 AM

Playing with DepthBias render state do not give any results...

I still assume it's a z-fighting problem. And I assume you're already using LessEqual for the ZFunc (this should be the default).

Oh my, I just realized this: Depth Bias (Direct3D 9). The devil's in the details:
The bias is not applied to any line and point primitive. However, this bias needs to be applied to triangles drawn in wireframe mode.

Alternative: Setup your WorldViewProjection to manually create a depth bias, e.g. use WVP * Matrix.Translation(0,0,-0.001f) or something. Edit: For the lines only!

Nice suggestion, but not executable in my case. I draw lines and triangles from 1 buffer and WVP matrix is the same for both. I can't change something only for lines or only for triangles. Changes will affect on all primitives.

### #22Yura  Members

263
Like
0Likes
Like

Posted 03 January 2013 - 02:53 AM

In addition to trying out suggestions from this, like I said before, you should also try to introduce some sampler state in your shader now.

My shader is the same. I didn't change anything.
Your suggestion about using VertexShaderOutput instead PixelShaderInput not approached because of VFACE semantic. It is usable only like an input parameter to PixelShader.  It cannot be defined in VertexShaderOutput struct

### #23NewDisplayName  Members

359
Like
1Likes
Like

Posted 03 January 2013 - 03:19 AM

My shader is the same. I didn't change anything.

That's why I was saying that please change it a bit and use a sampler state with some basic filtering, like LINEAR.

The way I see that area is going white around your lines is most probably because of aliasing. So once aliasing is out of the way a clearer picture should come out.

And my bad that I kept overlooking the VFACE comment of yours. It makes sense now, why to use one kind of input than the other.

### #24Yura  Members

263
Like
0Likes
Like

Posted 03 January 2013 - 04:39 AM

My shader is the same. I didn't change anything.

That's why I was saying that please change it a bit and use a sampler state with some basic filtering, like LINEAR.

The way I see that area is going white around your lines is most probably because of aliasing. So once aliasing is out of the way a clearer picture should come out.

And my bad that I kept overlooking the VFACE comment of yours. It makes sense now, why to use one kind of input than the other.

With sampler state I have some problems. I have no idea how to implement it. I found some basic information about samplers, filters etc, but I didn't get it... Maybe you have some useful links or code samples?

### #25unbird  Members

8297
Like
0Likes
Like

Posted 03 January 2013 - 05:15 AM

I can't change something only for lines or only for triangles. Changes will affect on all primitives.
You have two draw calls, so in-between you can change render states and shader constants:
effect.SetValue("worldViewProj", worldViewProj);
effect.BeginPass(0);

d3dDevice.Indices = triangles;
d3dDevice.SetStreamSource(0, vertices, 0, Marshal.SizeOf(typeof(Vertex)));
d3dDevice.DrawIndexedPrimitive(PrimitiveType.TriangleList, 0, 0, totalPointsCount, 0, totalPointsCount / 2);

d3dDevice.Indices = lines;
effect.SetValue("worldViewProj", slightlyCloserWorldViewProj);
effect.CommitChanges();    // <- needed when changing shader constants during a running pass	!
d3dDevice.DrawIndexedPrimitive(PrimitiveType.LineList, 0, 0, totalPointsCount, 0, totalPointsCount);

effect.EndPass();


### #26Yura  Members

263
Like
0Likes
Like

Posted 03 January 2013 - 06:25 AM

I can't change something only for lines or only for triangles. Changes will affect on all primitives.
You have two draw calls, so in-between you can change render states and shader constants:
effect.SetValue("worldViewProj", worldViewProj);
effect.BeginPass(0);

d3dDevice.Indices = triangles;
d3dDevice.SetStreamSource(0, vertices, 0, Marshal.SizeOf(typeof(Vertex)));
d3dDevice.DrawIndexedPrimitive(PrimitiveType.TriangleList, 0, 0, totalPointsCount, 0, totalPointsCount / 2);

d3dDevice.Indices = lines;
effect.SetValue("worldViewProj", slightlyCloserWorldViewProj);
effect.CommitChanges();    // <- needed when changing shader constants during a running pass	!
d3dDevice.DrawIndexedPrimitive(PrimitiveType.LineList, 0, 0, totalPointsCount, 0, totalPointsCount);

effect.EndPass();


slightlyCloserWorldViewProj is working with formula WVP * Matrix.Translation(0, 0, -0.001f);

Thanks a lot!

But, If I'll change my surface to another one, which has Z values with opposite sign, does it mean that my line grid will become invisible (will be absorbed)?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.