It is currently Sat Aug 22, 2020 3:38 am


All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Procedural texturing problems
PostPosted: Sat Nov 07, 2015 4:58 pm 
User avatar

Joined: Sun May 18, 2014 10:52 pm
Posts: 43
So after a day of tinkering I was able to fix an offset texture in the uv mapping of my voxels, but I've come to the conclusion that the only viable way to easily map the textures on all sides of a cube in a cubic mesh volume with any sort of optimization is to use shaders. If not the only way. It pretty much describes the drawbacks in the devdocs.

At this point it's almost worth it to me to switch to horde3D because it provides the deferred rendering that looks so good, and is shader based to begin with. I don't really know the math and science behind it but it seems to me that it would all ultimately make the rendering much quicker for modern machines, considering the amount of texturing in a minecraft-like voxel world.

I already have my game engine using horde3d, I've just not yet familiarized myself with creating custom anything in horde3d. I'm hoping I can use this to get it functional, but this is all new ground to me. Any advice on that anyone?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Procedural texturing problems
PostPosted: Sun Nov 08, 2015 3:26 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
It's definitely worth learning to use shaders - they have been the preferred approach for at least 10 years now! I've no specific experience with Horde3D though.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Procedural texturing problems
PostPosted: Sun Nov 08, 2015 5:48 pm 
User avatar

Joined: Sun May 18, 2014 10:52 pm
Posts: 43
Shaders already implemented, read a bit, trying to reapply the texture based on your example on the wiki. No luck so far with basic irrlicht shaders (apparently it does have them). I'm really suprised it's taken me this long to mess with shaders. At this point I'm pretty confident it'll reveal a solution AND perhaps be reusable with horde3d. Might end up killing two birds with a single stone here. :ugeek:


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Procedural texturing problems
PostPosted: Mon Nov 09, 2015 8:02 am 
User avatar

Joined: Sun May 18, 2014 10:52 pm
Posts: 43
Moving my part of this topic to
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=659


Last edited by Midnight on Tue Nov 10, 2015 5:39 pm, edited 1 time in total.

Top
Offline Profile  
Reply with quote  
 Post subject: Re: Procedural texturing problems
PostPosted: Mon Nov 09, 2015 10:05 pm 

Joined: Thu Apr 10, 2014 9:55 am
Posts: 7
Hi together,

@Midnight: Thirst of all sorry for my late Answer...
Thanks for the flowers, as we say in german. :D. For what i was able to learn from you was unfortnately nothing concrete, except one little thing: that PolyVox has a dramatic performance difference between debug and release, more than other libraries.

This mainly had the reason that i only saw one thread where you were asking questions, and i didnt really understood what kind of problem you had there initially, so i went on further. At some point later, when i remember correctly you solved it, the reason was you did not delete an irrlicht mesh or meshbuffer)...

For the UV-mapping, perhaps i have useful thing to share. I used it a while ago for a different set of rationales (not Voxel related, but for voronoi fractured objects where i want to texture the shards on the inside faces, so that one doesn't see it's fractured). It is also not really mature and complete, so it's an 80 % solution because you can still see some uv coords which are wrongly set. For cubic voxels it could although be robust enough.

I am only posting the relevant excerpts here, since the code is too tied with bullet physics. I hope it's enough to get the idea...

The trick is get the normal of a triangle which represents it's surface direction and then to get the Angle of it in the 3D-Space.
Code:
float getZAngle(float x, float y, float z)
{
    float theta = atan2(x, z);
    return theta * (180 / 3.141592653589793238);
}

float getYAngle(float x, float y, float z)
{
    float theta = atan2(sqrt(pow(z, 2) + pow(x, 2)), y);
    return theta * (180 / 3.141592653589793238);
}


Code:
...

core::plane3df triangle(pMeshBuffer->getPosition(idx[i]), pMeshBuffer->getPosition(idx[i + 1]), pMeshBuffer->getPosition(idx[i + 2]));
            triangle.Normal.X = fabsf(triangle.Normal.X);
            triangle.Normal.Y = fabsf(triangle.Normal.Y);
            triangle.Normal.Z = fabsf(triangle.Normal.Z);
           
            btVector3 nrm = btVector3(triangle.Normal.X, triangle.Normal.Y, triangle.Normal.Z).normalized();
            int yAngle = getYAngle(nrm.getX(), nrm.getY(), nrm.getZ());
            int zAngle = getZAngle(nrm.getX(), nrm.getY(), nrm.getZ());
           
            if (triangle.Normal.X > triangle.Normal.Y && triangle.Normal.X > triangle.Normal.Z) {
                for (uint32_t j = 0; j != 3; ++j) {
                    const uint32_t index = idx[i + j];
                    pMeshBuffer->getTCoords(index).X = pMeshBuffer->getPosition(index).Z;
                    pMeshBuffer->getTCoords(index).Y = pMeshBuffer->getPosition(index).Y;
                }
            } else if ((triangle.Normal.Y > triangle.Normal.X && triangle.Normal.Y > triangle.Normal.Z))  {
                for (uint32_t j = 0; j != 3; ++j) {
                    const uint32_t index = idx[i + j];
                    pMeshBuffer->getTCoords(index).X = pMeshBuffer->getPosition(index).X;
                    pMeshBuffer->getTCoords(index).Y = pMeshBuffer->getPosition(index).Z;
                }
            } else {
                for (uint32_t j = 0; j != 3; ++j) {
                    const uint32_t index = idx[i + j];
                    pMeshBuffer->getTCoords(index).X = pMeshBuffer->getPosition(index).X;
                    pMeshBuffer->getTCoords(index).Y = pMeshBuffer->getPosition(index).Y;
                }
            }
...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Procedural texturing problems
PostPosted: Tue Nov 10, 2015 5:36 pm 
User avatar

Joined: Sun May 18, 2014 10:52 pm
Posts: 43
Sinsemilla wrote:
Hi together,

@Midnight: Thirst of all sorry for my late Answer...

For the UV-mapping, perhaps i have useful thing to share.

I am only posting the relevant excerpts here, since the code is too tied with bullet physics. I hope it's enough to get the idea...

The trick is get the normal of a triangle which represents it's surface direction and then to get the Angle of it in the 3D-Space.


It's ok, I've found a simpler way of abstracting the normals, or at least someone else did and I'm using their shaders :D

Your code seems overly complex but it probably calculates it more properly. And with least impact in large application???

Anyway if you follow that link in my last comment you'll understand.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Procedural texturing problems
PostPosted: Thu Nov 12, 2015 9:37 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Sinsemilla wrote:
... PolyVox has a dramatic performance difference between debug and release, more than other libraries.


Yes, there is a big difference in speed here. Actually I haven't really looked into it, but PolyVox does perform some assert()s when ever you access a voxel. This happens a lot and the asserts are only active in debug mode, so that may be part of it.

Also, I have found this trick to be useful: Visual C++ Debug Builds–”Fast Checks” Cause 5x Slowdowns


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net