Hi Leute,
ich bin dabei, eine Minecraft-Renderengine zu programmieren. Leider bekomme ich, wenn ich nach vorne gucke, also sehr viele Blöcke in meinem Sichtfeld habe und 3x10x3 Blöcke rendere, nur so um die 8-10fps. Ich hab es bereits so, dass ich nur mein Sichtfeld rendere (Frustum) und, dass die nicht sichtbaren Vertices zwischen den Blöcken nicht gerendert werden. Trotzdem hab ich so ne schlechte Performance. Habt ihr da Ideen wie ich das verbessern könnte?
Ich benutze OpenTK als Renderer. Mein Code zum Rendern ist der hier:
Spoiler anzeigen
Hoffe ihr könnt mir helfen
LG
Twometer
ich bin dabei, eine Minecraft-Renderengine zu programmieren. Leider bekomme ich, wenn ich nach vorne gucke, also sehr viele Blöcke in meinem Sichtfeld habe und 3x10x3 Blöcke rendere, nur so um die 8-10fps. Ich hab es bereits so, dass ich nur mein Sichtfeld rendere (Frustum) und, dass die nicht sichtbaren Vertices zwischen den Blöcken nicht gerendert werden. Trotzdem hab ich so ne schlechte Performance. Habt ihr da Ideen wie ich das verbessern könnte?
Ich benutze OpenTK als Renderer. Mein Code zum Rendern ist der hier:
VB.NET-Quellcode
- Imports OpenTK
- Imports OpenTK.Graphics.OpenGL
- Imports OpenTK.Input
- Public Class CubeRenderer
- Public Sub RenderCube(name As String, pos As Vector3, Optional top As Boolean = True, Optional bottom As Boolean = True, Optional north As Boolean = True, Optional south As Boolean = True, Optional east As Boolean = True, Optional west As Boolean = True)
- Dim x = pos.X
- Dim y = pos.Y
- Dim z = pos.Z
- Dim x0 As Single = x + 0.0F
- Dim x1 As Single = x + 1.0F
- Dim y0 As Single = y + 0.0F
- Dim y1 As Single = y + 1.0F
- Dim z0 As Single = z + 0.0F
- Dim z1 As Single = z + 1.0F
- 'GL.PushMatrix()
- TheTextureManager.BindTexture(name)
- GL.Begin(PrimitiveType.Quads)
- If top Then
- GL.Normal3(0.0, 0.0, 1.0)
- GL.TexCoord2(0.0, 1.0)
- GLVertex(x0, y0, z1)
- GL.TexCoord2(1.0, 1.0)
- GLVertex(x0, y0, z0)
- GL.TexCoord2(1.0, 0.0)
- GLVertex(x1, y0, z0)
- GL.TexCoord2(0.0, 0.0)
- GLVertex(x1, y0, z1)
- End If
- If bottom Then
- GL.Normal3(0.0, 0.0, -1.0)
- GL.TexCoord2(0.0, 1.0)
- GLVertex(x1, y1, z1)
- GL.TexCoord2(1.0, 1.0)
- GLVertex(x1, y1, z0)
- GL.TexCoord2(1.0, 0.0)
- GLVertex(x0, y1, z0)
- GL.TexCoord2(0.0, 0.0)
- GLVertex(x0, y1, z1)
- End If
- If east Then
- GL.Normal3(4.0, 0.0, 0.0)
- GL.TexCoord2(0.0, 1.0) : GLVertex(x0, y1, z0)
- GL.TexCoord2(1.0, 1.0) : GLVertex(x1, y1, z0)
- GL.TexCoord2(1.0, 0.0) : GLVertex(x1, y0, z0)
- GL.TexCoord2(0.0, 0.0) : GLVertex(x0, y0, z0)
- End If
- If west Then
- GL.Normal3(-1.0, 0.0, 0.0)
- GL.TexCoord2(0.0, 1.0) : GLVertex(x0, y1, z1)
- GL.TexCoord2(0.0, 0.0) : GLVertex(x0, y0, z1)
- GL.TexCoord2(1.0, 0.0) : GLVertex(x1, y0, z1)
- GL.TexCoord2(1.0, 1.0) : GLVertex(x1, y1, z1)
- End If
- If north Then
- GL.Normal3(0.0, 1.0, 0.0)
- GL.TexCoord2(0.0, 1.0) : GLVertex(x0, y1, z1)
- GL.TexCoord2(1.0, 1.0) : GLVertex(x0, y1, z0)
- GL.TexCoord2(1.0, 0.0) : GLVertex(x0, y0, z0)
- GL.TexCoord2(0.0, 0.0) : GLVertex(x0, y0, z1)
- End If
- If south Then
- GL.Normal3(0.0, -1.0, 0.0)
- GL.TexCoord2(0.0, 0.0) : GLVertex(x1, y0, z1)
- GL.TexCoord2(0.0, 1.0) : GLVertex(x1, y0, z0)
- GL.TexCoord2(1.0, 1.0) : GLVertex(x1, y1, z0)
- GL.TexCoord2(1.0, 0.0) : GLVertex(x1, y1, z1)
- End If
- '
- 'GL.PopMatrix()
- GL.End()
- 'GL.EndList()
- 'GL.EndQuery(QueryTarget.SamplesPassed)
- 'Dim ResultReady As UInteger = 0
- 'While ResultReady = 0
- ' GL.GetQueryObject(MyOcclusionQuery, GetQueryObjectParam.QueryResultAvailable, ResultReady)
- 'End While
- 'Dim MyOcclusionQueryResult As UInteger = 0
- 'GL.GetQueryObject(MyOcclusionQuery, GetQueryObjectParam.QueryResult, MyOcclusionQueryResult)
- End Sub
- Public Sub GLVertex(x As Single, y As Single, z As Single)
- GL.Vertex3(x, y, z)
- End Sub
- Private Function getDistance(x1, y1, z1, x2, y2, z2) As Double
- Dim xd = x2 - x1
- Dim yd = y2 - y1
- Dim zd = z2 - z1
- Return (xd ^ 2 + yd ^ 2 + zd ^ 2)
- End Function
- End Class
Hoffe ihr könnt mir helfen
LG
Twometer
An Error 404 occurred while loading signature...
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Twometer“ ()