Public Sub LoadTerrain(ByVal meshSize As Size, ByVal tileSpacing As Integer, ByVal texloc As String, _
ByVal texMatrix(,) As Byte, Optional ByVal heightmap(,) As Byte = Nothing, _
Optional ByVal xOffset As Integer = 0, Optional ByVal yOffset As Integer = 0)
Dim xNum As Integer = meshSize.Width
Dim yNum As Integer = meshSize.Height
'<-->'Create VertexBuffer
Dim vbMesh As New VertexBuffer(GetType(CustomVertex.PositionTextured), _
xNum * yNum * 6, D3DDev, 0, CustomVertex.PositionTextured.Format, _
Pool.Managed)
Dim vMesh As CustomVertex.PositionTextured() = CType(vbMesh.Lock(0, 0), CustomVertex.PositionTextured())
'<->'Create tiles (triangle list)
Dim iC As Integer = 0 'tilecounter
For x = 0 To xNum - 1
For y = 0 To yNum - 1
'<-->'Select UV Coordinates
Dim uvList As List(Of Vector2) = GetUVCoords(texMatrix(x, y))
vMesh(iC * 6) = New CustomVertex.PositionTextured(x, y, 0, uvList(0).X, uvList(0).Y)
vMesh(iC * 6 + 1) = New CustomVertex.PositionTextured(x + tileSpacing, y, 0, uvList(1).X, _
uvList(1).Y)
vMesh(iC * 6 + 2) = New CustomVertex.PositionTextured(x + tileSpacing, y + tileSpacing, 0, _
uvList(3).X, uvList(3).Y)
vMesh(iC * 6 + 3) = New CustomVertex.PositionTextured(x, y, 0, uvList(0).X, uvList(0).Y)
vMesh(iC * 6 + 4) = New CustomVertex.PositionTextured(x + tileSpacing, y + tileSpacing, 0, _
uvList(3).X, uvList(3).Y)
vMesh(iC * 6 + 5) = New CustomVertex.PositionTextured(x, y + tileSpacing, 0, _
uvList(2).X, uvList(2).Y)
iC += 1
Next
Next
vbMesh.Unlock()
And a picture of the artifacting:
http://newtons.bit.googlepages.com/Image11-08-08.jpg
Any help?
dx9 & vb.net artifacting
I'm working on a simple engine for tilebased games. Nothing special. I have some weird grid-like artifacting. Is this because my tiles that I'm rendering don't share vertexes?
Here's my sub for creating my tiles:
Hi,
You should post the drawing routine instead. Normally thoses types of artefacts are due to wrong texture sampler states: read on texture CLAMPING.
You should post the drawing routine instead. Normally thoses types of artefacts are due to wrong texture sampler states: read on texture CLAMPING.
Quote:Original post by LowRad
Hi,
You should post the drawing routine instead. Normally thoses types of artefacts are due to wrong texture sampler states: read on texture CLAMPING.
Thanks for the reply LowRad, for setting my texture in the draw routine all I'm doing is
D3DDevice.SetTexture(0,texture,0)
Would that be causing the problem?
Without seeing all the code, i would say this is where the problem lies.
This line of quote only tell the device which texture to use, not how to use it.
Checkout the SamplerState class on MSDN. This property is accessible throught the graphicsDevice.SamplerStates indexer. The SamplerState allows you to control how the device will use that texture. And what i was suggesting you check the Addressing property of the SamplerState you are using..
In your case something similar to:
In any ways, i bet you solution lies somewhere in setting the right configuration on that SamplerState.
Good luck,
Quote:
D3DDevice.SetTexture(0,texture,0)
This line of quote only tell the device which texture to use, not how to use it.
Checkout the SamplerState class on MSDN. This property is accessible throught the graphicsDevice.SamplerStates indexer. The SamplerState allows you to control how the device will use that texture. And what i was suggesting you check the Addressing property of the SamplerState you are using..
In your case something similar to:
D3DDevice.SamplerState[0].AddressU = TextureAddressMode.Clamp;D3DDevice.SamplerState[0].AddressV = TextureAddressMode.Clamp;
In any ways, i bet you solution lies somewhere in setting the right configuration on that SamplerState.
Good luck,
Quote:Original post by LowRad
Without seeing all the code, i would say this is where the problem lies.Quote:
D3DDevice.SetTexture(0,texture,0)
This line of quote only tell the device which texture to use, not how to use it.
Checkout the SamplerState class on MSDN. This property is accessible throught the graphicsDevice.SamplerStates indexer. The SamplerState allows you to control how the device will use that texture. And what i was suggesting you check the Addressing property of the SamplerState you are using..
In your case something similar to:D3DDevice.SamplerState[0].AddressU = TextureAddressMode.Clamp;D3DDevice.SamplerState[0].AddressV = TextureAddressMode.Clamp;
In any ways, i bet you solution lies somewhere in setting the right configuration on that SamplerState.
Good luck,
I think that gives me everything I need to figure this out. Thank you much.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement