Page 15 of 18

Re: World of Tanks Map format.

Posted: Mon Feb 08, 2016 10:25 pm
by Coffee
Mr. Mouse,
What is the make of your video Card?

It looks like the shader is not working right or the textures are not found.
The trees and decals have the correct textures so its not a path problem.

Re: World of Tanks Map format.

Posted: Tue Feb 09, 2016 3:56 pm
by SkaceKachna
So I can't do anything right now to fix terra?

Also, do you load lights settings from world of tanks or do you use your own?
I'm interested if there is any way to load original lights from the game to achieve best looks.

Re: World of Tanks Map format.

Posted: Tue Feb 09, 2016 9:42 pm
by Mr.Mouse
Coffee wrote:Mr. Mouse,
What is the make of your video Card?

It looks like the shader is not working right or the textures are not found.
The trees and decals have the correct textures so its not a path problem.
I'm running on a Radeon HD 7800. I'm having the latest WoT installed on HD texture mode.

Re: World of Tanks Map format.

Posted: Wed Feb 10, 2016 2:01 am
by Coffee
I think I found the problem..

In nVidia, it is perfectly legal to pass a matrix from the vertex shader to the fragment shader.
This IS a OpenGL spec. However.. I just tested this using one of AMDs tools and it fails.
I moved the building of the matrix (used for lighting) from the vertex to the fragment.
This means that rather than creating the matrix per vertex, it is now being done per PIXEL.
This will slow things down but on my G-Force 660 Ti, I'm not seeing much.
Maybe because this nVidia card of mine has 1344 CUDA cores.
http://www.geforce.com/hardware/desktop ... ifications

Anyway.. The shaders compile fine now using AMDs analyzer tool.

I have been trying to get the trees closer to the game.
There is something serious I'm missing in the scaling of the leaves.
There are 22 floats in a leaf vertex data set. There are 2 leaf formats.
The 2nd type scale perfectly. There is nothing that has to be done to these types.
The 15th float tells you how to interpret the data.
If it is < 4 than this 15th float is a index (0, 1 , 2 , 0, 2, 3) in to an array that defines each corner of a polygon. (2 triangles)

Code: Select all

        vx()  = {-1.0!, 1.0!, 1.0!, -1.0!}
        vy()  = {1.0!, 1.0!, -1.0!, -1.0!}
If it is 4 or greater, you just use the vertices to build the polygon.
There is scaling information in those 22 floats.. I thought it was the 12 and 13th ones for Y and X. Yes.. they appear to be backwards.
Its not consistent from tree to tree. The leaves might look right on one tree but are too big or small on another.
I tried scaling them by the scale of the entire tree using its matrix.
This works for getting the scale from a float(16) matrix:
sx = Sqrt((m(0) ^ 2) + (m(1) ^ 2) + (m(3) ^ 2))
sy = Sqrt((m(4) ^ 2) + (m(5) ^ 2) + (m(6) ^ 2))
sz = Sqrt((m(8) ^ 2) + (m(9) ^ 2) + (m(10) ^ 2))
This does not fix it either.

I'll upload an update even tho the trees are FUBAR!
Version 24 http://209.159.152.184:8080/terra/

Re: World of Tanks Map format.

Posted: Wed Feb 10, 2016 10:37 am
by SkaceKachna
I too noticed some leaves have wrong scale. For now, I set them to be 3x the specified size ... it looks a bit better, but still, weird. Also somehow the World of Tanks leaves actually have light shading ... how :O

Re: World of Tanks Map format.

Posted: Wed Feb 10, 2016 6:19 pm
by Coffee
I found out I was scaling them wrong and my projection was wrong.
I change the code I posted above.

Anyway...
to scale the trees..
Get the length of rows 0 1 and 2. These are the scales
"^" means power or you can do "(M(0) * m(0))" for example.
sx = Sqrt((m(0) ^ 2) + (m(1) ^ 2) + (m(3) ^ 2))
sy = Sqrt((m(4) ^ 2) + (m(5) ^ 2) + (m(6) ^ 2))
sz = Sqrt((m(8) ^ 2) + (m(9) ^ 2) + (m(10) ^ 2))

And average them.. Multiplying by 1/3 (its faster then division)
tree_scale = (sx + sy + sz) * 0.3333

There are 6 vertices in each leaf. These create 2 triangles.
I look up the corners using the 2 arrays:
Dim vx() As Single = {-0.5!, 0.5!, 0.5!, -0.5!}
Dim vy() As Single = {0.5!, 0.5!, -0.5!, -0.5!}
...
Here is my code. I'm still trying to get the lighting correct.

Code: Select all

        Dim m = Trees.matrix(tree).matrix
        Dim sx = Sqrt((m(0) ^ 2) + (m(1) ^ 2) + (m(3) ^ 2))
        Dim sy = Sqrt((m(4) ^ 2) + (m(5) ^ 2) + (m(6) ^ 2))
        Dim sz = Sqrt((m(8) ^ 2) + (m(9) ^ 2) + (m(10) ^ 2))
        Dim tree_scale As Single = (sx + sy + sz) * 0.3333

        Dim vx() As Single = {-0.5!, 0.5!, 0.5!, -0.5!}
        Dim vy() As Single = {0.5!, 0.5!, -0.5!, -0.5!}


        For i = 0 To tree_data.l_indices.Length - 3
            'struct LeafVertex
            '
 '00 00 Vec3     position;
 '12 03 Vec3     normal;
 '24 06 Single   texCoords(2)
 '32 08 Single   windInfo(2)
 '40 10 Single   rotInfo(2)
 '48 12 Single   geomInfo(2)
 '56 14 Single   extraInfo(3)
 '68 17 Single   pivotInfo(2)
 '76 19 Vec3 Tangent; ' 3 floats

            p.x = -tree_data.l_vert((tree_data.l_indices(i) * 22) + 0)
            p.y = tree_data.l_vert((tree_data.l_indices(i) * 22) + 1)
            p.z = tree_data.l_vert((tree_data.l_indices(i) * 22) + 2)

            norm.x = tree_data.l_vert((tree_data.l_indices(i) * 22) + 3)
            norm.y = tree_data.l_vert((tree_data.l_indices(i) * 22) + 4)
            norm.z = tree_data.l_vert((tree_data.l_indices(i) * 22) + 5)

            uv.x = tree_data.l_vert((tree_data.l_indices(i) * 22) + 6)
            uv.y = tree_data.l_vert((tree_data.l_indices(i) * 22) + 7)

            rot.x = tree_data.l_vert((tree_data.l_indices(i) * 22) + 17)
            rot.y = tree_data.l_vert((tree_data.l_indices(i) * 22) + 18)

            vn = tree_data.l_vert((tree_data.l_indices(i) * 22) + 15) ' corner index
            vn2 = tree_data.l_vert((tree_data.l_indices(i) * 22) + 16)
            If vn2 <> 1.0 Then
                Stop ' has NEVER been hit. It is always 1.0
            End If
            sizey = tree_data.l_vert((tree_data.l_indices(i) * 22) + 12)
            sizex = tree_data.l_vert((tree_data.l_indices(i) * 22) + 13)

            pivot.x = tree_data.l_vert((tree_data.l_indices(i) * 22) + 10)
            pivot.y = tree_data.l_vert((tree_data.l_indices(i) * 22) + 11)

            'not sure 100% sure.. This might also be the BiNormal
            tangent.x = tree_data.l_vert((tree_data.l_indices(i) * 22) + 19)
            tangent.y = tree_data.l_vert((tree_data.l_indices(i) * 22) + 20)
            tangent.z = tree_data.l_vert((tree_data.l_indices(i) * 22) + 21)
            'debug string
            sb.Append(rot.x.ToString("0.000000") + "  " + rot.y.ToString("0.000000") + vbCrLf)

            If vn < 4 Then  'less than 4 means this is the special case
                If cnt > 5 Then
                    cnt = 0
                    'Stop ' debug stop at end of each set of 6
                End If
                idx.x = vx(vn)
                idx.y = vy(vn)
                Dim corner As vect3
                corner.x = vx(vn) '- pivot.x
                corner.y = vy(vn) '+ pivot.y
                corner.x *= tree_scale
                corner.y *= tree_scale
                corner.x *= sizex
                corner.y *= sizex
                Gl.glMultiTexCoord3f(0, -uv.x, uv.y, 0.0)
                Gl.glMultiTexCoord3f(1, corner.x, corner.y, 0.0)
                Gl.glMultiTexCoord3f(2, tangent.x, tangent.y, tangent.z)
                Gl.glNormal3f(norm.x, norm.y, norm.z)
                Gl.glVertex3f(p.x, p.y, p.z)

                 cnt += 1
            Else
                ' just use these directly.
                lx = p.x
                ly = p.y
                lz = p.z
                Gl.glMultiTexCoord3f(0, -uv.x, uv.y, 0.0)
                Gl.glMultiTexCoord3f(1, 0.0, 0.0, 0.0)
                Gl.glMultiTexCoord3f(2, tangent.x, tangent.y, tangent.z)
                Gl.glNormal3f(norm.x, norm.y, norm.z)
                Gl.glVertex3f(p.x, p.y, p.z)
            End If
        Next
I posted this code as part of that zip but this section is updated.
I'm not sure about the pivot... I don't know how to use it.
I send the center point as the vertex and the corner as a UV coordinate.
In my shader program I do this at the start of the vertex stage.

Code: Select all

    texCoord.xy = gl_MultiTexCoord0.st;
    vec4 p =  gl_ModelViewMatrix * gl_Vertex;
    p.xyz += gl_MultiTexCoord1.xyz;
    p           = inverse(gl_ModelViewMatrix) * p;
    gl_Position = gl_ModelViewProjectionMatrix * p;
This gets my corner on the screen at the correct location.

Im not sure it you can add custom shaders to your GL wrapper.
If so.. I might be able to help create one once I get my shader lighting correctly.
I am really not sure about the tangent.. It could be a BiNormal.

Re: World of Tanks Map format.

Posted: Wed Feb 10, 2016 9:25 pm
by Mr.Mouse
Sadly. no textures on the models still.
wotterra024.png

Re: World of Tanks Map format.

Posted: Wed Feb 10, 2016 10:14 pm
by Coffee
I have no idea..
for get what I posted..
I deleted it.

Re: World of Tanks Map format.

Posted: Wed Feb 10, 2016 10:33 pm
by Coffee
I updated to version 25.
I doubt this will fix the textures on the models.

Re: World of Tanks Map format.

Posted: Wed Feb 10, 2016 10:34 pm
by Coffee
If anyone else is checking out Terra, can you please report anything thats not working, OK?

http://209.159.152.184:8080/terra/

version 25

Re: World of Tanks Map format.

Posted: Wed Feb 10, 2016 10:56 pm
by SkaceKachna
It finally tried to load the map, but got following exception:

(The exception was in my native language and I had to translate it to english)

Code: Select all

System.InvalidCastException: Conversion of string -400.0 to Double is incorrect. ---> System.FormatException: Input string is in wrong format
   v Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)
   v Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)
   --- End of tracing of inner exception stack ---
   v Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)
   v Terra.modZlib.get_team_locations(String& name)
   v Terra.modZlib.open_pkg(String name)
   v Terra.frmMain.pb1_MouseDown(Object sender, MouseEventArgs e)
   v System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e)
   v System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   v System.Windows.Forms.Control.WndProc(Message& m)
   v System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   v System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   v System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   v System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I actually know excatly what is the problem: My windows uses my local globalization settings, including number format. In my globalization settings, floating point is ',' not '.'.
I don't remember how to fix it, but I think you can force the globalization settings somehow.

Re: World of Tanks Map format.

Posted: Thu Feb 11, 2016 3:35 am
by Coffee
Yes.. its trying to read a period and it needs a comma because of your localization.

Let me see what I can find out...

And.. How do you think they manage to put decals over EVERYTHING?

Could this be deferred rendering?

Re: World of Tanks Map format.

Posted: Thu Feb 11, 2016 4:38 am
by Coffee
Ok.. I uploaded version 26.

See if this will work with your culture.

I basically try to read a value of "0.1234"
if it fails, I replace all the periods in the .visual after its read.
It should work but will slow it down a little...
No worries though, I have found its still faster than jumping through hoops with the all other code that's needed to make it "Culture aware".

Re: World of Tanks Map format.

Posted: Thu Feb 11, 2016 10:04 am
by SkaceKachna
It still throws excpetion (is it the same?)

Code: Select all

System.InvalidCastException: Převod řetězce -400.0 na typ Double není platný. ---> System.FormatException: Vstupní řetězec nemá správný formát.
   v Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)
   v Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)
   --- Konec trasování zásobníku pro vnitřní výjimku ---
   v Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat)
   v Terra.modZlib.get_team_locations(String& name)
   v Terra.modZlib.open_pkg(String name)
   v Terra.frmMain.pb1_MouseDown(Object sender, MouseEventArgs e)
   v System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e)
   v System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   v System.Windows.Forms.Control.WndProc(Message& m)
   v System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   v System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   v System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   v System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Re: World of Tanks Map format.

Posted: Thu Feb 11, 2016 4:22 pm
by Coffee
yes.. exactly the same.

The first time it tries to read one of the team locations, its expecting a comma for the decimal. -400.0 should be in -400,0 format.
Let me try again :(