Line Rendering Problem

sgt_pinky

Well-known member
Joined
Jan 5, 2005
Messages
80
Location
Melbourne, Australia
Ok, I have had this problem since I started. I am rendering polys, and then lines over the top.

On lower quality gfx cards, which dont support SlopeScaleDepthBias, I have really really crappy lines (see attached image).

Interestingly, I initially had the following line in my code:

Code:
dRender.RenderState.SlopeScaleDepthBias = 0
render lines
dRender.RenderState.SlopeScaleDepthBias = 1
render polys

But on cards that dont support SlopeScaleDepthBias, this was producing horrible effects! (Shouldnt it have no effect?). I changed the lines to:

Code:
If dRender.DeviceCaps.RasterCaps.SupportsSlopeScaleDepthBias = True Then dRender.RenderState.SlopeScaleDepthBias = 0

Solved that problem. Although it puzzles me still.

On cheap gfx cards though, I still cannot get nice lines. Has anyone managed this?

RenderState.DepthBias seems to have absolutely no effect that I have noticed on Radeon 9600 Pro, or GeFORCE4 MX.

Cheers,

Pinky
 
Last edited by a moderator:
How about trying to raise the lines a little higher than the polys? Then maybe it wont interfere. Or, if you have zbuffer (and depth buffer) turned off, then simply render the lines after you render the poly and you wont get a problem :). I know I know, cheap solution but I guess it works.

-TPG
 
Yeah, I am rendering the lines AFTER polys to get it that good! If I do the lines before the polys, they are practically invisible.

I cant raise the lines a bit, because then when you rotate the model, they are hidden behind the polys.

When I initialise the device, I use:

Code:
Device.RenderState.ZBufferEnable = True

I havent set anything for Depth Buffer, so maybe its off by default or something. Will check that as soon as I finish installing .NET IDE again. I hate getting new computers now, hehe, cos I am so sick of having to install Visual Studio and all the MSDN stuff. Takes like 10 hours :X
 
Couldnt find anything. There must be some way to get RenderState.DepthBias to work, else why is it there. SlopeScaleDepthBias works beautifully on decent cards.

The D3D caps show that the worst card supports DepthBias:

SupportsDepthBias: True
SupportsSlopeScaleDepthBias: False

Has me stumped.

**EDIT**

Found the problem. In the DX help file:

The bias is not applied to any line and point primitive.

:(

(Not withstanding that poor english: The bias is not applied to any line OR point primitive.)
 
Last edited by a moderator:
Is there some way that I can blend the lines and the polys together? Since the lines are black, and the polys are always a lighter colour, this would have a pretty good effect.
 
Ok. I read the C++ documentation on Pixel Shaders. Sounds like there might be something there. Only examples I could find on the net though work on textures. Can you give me a tip on how to get it to work on line/triangle primitives?

**EDIT**
Are pixel shaders even supported in managed code? I cant find half of the functions I am reading about in the C++ doc.

eg: where is m_pd3dDevice->CreatePixelShader() ? There is no Device.CreatePixelShader function in managed code.

Also, there is no Direct3D.AssembleShaderFromFile() either as far as I can see.
 
Last edited by a moderator:
Some of the advanced features in unmanaged DirectX didnt make it to Managed DirectX (I heard). Search through MSDN and look for CreatePixelShaderFile() and see if it exists somewhere else
 
Back
Top