Open igough opened 10 months ago
I also experienced this issue there's a part in the code where it renders the model one more time with +100 pixels.
In shader "gos_tex_vertex_lighted.vert" replace from p.x = (p.x rhw) vp.z + vp.x + 100.0; to p.x = (p.x rhw) vp.z + vp.x;
this is a workaround, but probably rendering happens two times same position.
Thanks a lot for the workaround. Indeed that resulted in only one model being visible.
this is a workaround, but probably rendering happens two times same position
I agree. Unfortunately, shader coding is not part of my existing skill set, so I will read up on enough info to determine what exactly is happening here to come up with a proper fix.
In mclib/tgl.cpp
, within TG_Shape::MultiTransformShape
, some objects are being put onto 2 separate lists for rendering. Line 2453
mcTextureManager->addTriangle(theShape->listOfTextures[theShape->listOfTypeTriangles[j].localTextureHandle].mcTextureNodeIndex,MC2_DRAWSOLID | addFlags);
puts the object vertex data into
masterTextureNodes[nodeId].vertexData (in mclib/txmmgr.h)
.
Line 2492
mcTextureManager->addRenderShape(theShape->listOfTextures[theShape->listOfTypeTriangles[0].localTextureHandle].mcTextureNodeIndex, MC2_DRAWSOLID | addFlags);
puts the object vertex data into
masterTextureNodes[nodeId].hardwareVertexData.
For Mechs and likely other objects, both addTriangle
and addRenderShape
are being called. The data in vertexData is rendered one way (possibly a non-tex shader?) and the data in hardwareVertexData is rendered using the shader in shaders/gos_tex_vertex_lighted.vert
. Since the shader in gos_tex_vertex_lighted.vert
offsets the render by +100 in the x direction, this causes the model to be rendered in 2 different locations, one by the first mechanism and one by the second. So removing the +100 offset in the shader causes the 2 renders to perfectly overlap each other but is not particularly efficient. Possibly work was being done to change from one rendering mechanism to another and the work was interrupted before being completed.
Also, there looks like a typo bug in addRenderShape
where I suspect that the code:
else if (masterTextureNodes[nodeId].vertexData
should be
else if (masterTextureNodes[nodeId].hardwareVertexData
since that function otherwise deals exclusively with the hardwareVertexData
.
Although graphics code is not my strength, I will keep digging.
Submitted pull request #20 to deal with this issue and other bugs.
Hi guys, double draw is just my debug code to make sure HW accelerated shader based code does same thing as my originally ported one. Second draw pass is not needed at all. Sorry for a late reply, unfortunately I have no time at the moment to work on this project, hopefully things will change soon.
OS: Linux GPU: AMD Radeon RX 6700, resolution 3440x1440
I eventually got the code built and all of the missing assets figured out, but all Mech and Vehicle models are rendered twice with the duplicate being to the right of the actual object as shown below.
In issue 15 you say "They are doubled because I have 2 different draw paths in the code" and "It should be easy to disable it." Without additional info I thought that the issue might be associated with
g_debug_draw_calls
inGameOS/gameos/gameos_graphics_debug.cpp
, but that proved false. If you can give me a clue as to which file I should look in I will attempt to fix it.