Utilizing Vertex Layouts

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
MrGuy
Posts: 18
Joined: Mon Oct 29, 2012 11:05 pm

Utilizing Vertex Layouts

Post by MrGuy »

Hey there, guys,
i tumbled across a little problem i got with the engine: The lack of customizable Vertex layouts.
I googled quite a while and of course searched the tuts etc. but i could not help it: There's no real information about this topic but the info that its not supported.

So: Did i miss a hint? I really need custom vertex formats for my project or i have to utilize pretty ugly (and HELLA expensive methods) for my project.
For those interested: The general topic is multiple Materials blended over a MarchingCube generated IsoSurface.


If it really is not implemented/accessible: Is there any way to change that? I guess that would involve recompiling the irrlicht engine after some changes made to the source. Any hint where to start? I dont really dug deap into all that stuff - i takle things head on and start thinking when i bump into problems. :P

If i missed any important information i will add them asap! Sorry in that case.


Warm regards and thanks in advance,
MrGuy
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Utilizing Vertex Layouts

Post by Mel »

there is a version of Irrlicht which has support for flexible vertex formats in the SVN, maybe you want to check it

http://irrlicht.svn.sourceforge.net/vie ... -pipeline/

That is an SVN version, so it is likely to have unsolved bugs.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
MrGuy
Posts: 18
Joined: Mon Oct 29, 2012 11:05 pm

Re: Utilizing Vertex Layouts

Post by MrGuy »

Thanks a lot, mel,
i downloaded, compiled it and stuff. Then i build the docu and am reading into atm.

As it seems MeshBuffers need a VertexLayout as a VertexDescriptor now which i have to implement and pass to it as an argument for the constructor? And of course i got to define the layout in the shader i guess?

If you got any tipps that might help me getting into the topic faster than crawling through sourcecode and descriptions of methods i appreciate it, otherwise i gotta stick with it. ;)




Warm regards,
MrGuy
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Utilizing Vertex Layouts

Post by Nadro »

Hi,

This is a short info about usage FVF in Irrlicht (shader-pipeline branch):
You have to register new vertex layout via "IVideoDriver::addVertexDescriptor" eg. called "MyVertexFormat", at next You have to add an attributes to "MyVertexFormat" descriptor via "IVertexDescriptor::addAttribute" eg. position, normal, texcoord and others. When You will have defined vertex descriptor You must apply it to a vertex buffer (this is part of mesh buffer) via "IVertexBuffer::setVertexDescriptor". Thats all. You'll get an acces to Your vertex values via "attribute" operator in GLSL and semantic in HLSL.

Cheers,
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Utilizing Vertex Layouts

Post by Mel »

And later, if, for instance you load a skinned mesh, how can you apply that vertex layout to the loaded mesh?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
MrGuy
Posts: 18
Joined: Mon Oct 29, 2012 11:05 pm

Re: Utilizing Vertex Layouts

Post by MrGuy »

Most likely load it into a standard layout first and copy it into the extended afterwards...

Since i use runtime generated meshes this shouldnt become that much of a problem. :)
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Utilizing Vertex Layouts

Post by Nadro »

Mel wrote:And later, if, for instance you load a skinned mesh, how can you apply that vertex layout to the loaded mesh?
You have to change a VertexDescriptor (IVertexBuffer::setVertexDescriptor) and convert vertices (IMeshManipulator::convertVertices) to properly format. I think that a good idea will be a param (bool convertVertices = true) in setVertexDescriptor which will be automatically call a convertVertices method when it is set to "true". Now Your skinned mesh will be have other vertex format.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Utilizing Vertex Layouts

Post by Mel »

Thanks for the explanation, I hope this makes it soon to the trunk of the engine :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
MrGuy
Posts: 18
Joined: Mon Oct 29, 2012 11:05 pm

Re: Utilizing Vertex Layouts

Post by MrGuy »

I played around with it a bit and it seems to be not as intuitive as i thought.

I tumbled across the GLSL specifications tho and found, that GLSLs standard vertex layout expects 8 UV coords. I could encode my needed information in that one if - and here comes the part i dislike here - irrlicht would offer a vertex which supported those 8 uvs. :P

So is there by chance a way to implement that? I looked inside the code but its utterly unclear to me how those S3DVertex' and its children are working. I would like guesses, since i find that solution better than the utilizing of vertex layouts which arent in the core release by now.


Regards,
MrGuy
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Utilizing Vertex Layouts

Post by Nadro »

You can use "attribute" in GLSL instead of fixed pipeline solution - UV slots. How to use it I posted in this thread. Of course it's related just for shader-pipeline branch. A current stable release supports only S3DVertex, S3DVertex2Coords and S3DVertexTangents and we will not extend this interface, because in future releases it will be replaced by a system from shader-pipeline.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
MrGuy
Posts: 18
Joined: Mon Oct 29, 2012 11:05 pm

Re: Utilizing Vertex Layouts

Post by MrGuy »

Well then. I went through all the pain of learning how to work with it ( It was quite easy, when i look back... Stupid me did some mistakes at the beginning. )

Now its working! Here we go: Marchingcubes generated isosurfaces with smooth blending between given materials ( Every blending possible )
http://imageshack.us/photo/my-images/202/matblend.png/ For those interested. :)
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Utilizing Vertex Layouts

Post by Nadro »

Nice :) I am glad that FVF was useful for You in this case.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Utilizing Vertex Layouts

Post by Mel »

Let's see how long it takes for it to be included in the engine :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
MrGuy
Posts: 18
Joined: Mon Oct 29, 2012 11:05 pm

Re: Utilizing Vertex Layouts

Post by MrGuy »

Vertex layouts have some neat use cases. :)
I'm working on a vertexcollapse algorithm for now, but i will post a screenshot of my a bit more advanced Terrains. The sphere is abit boring. :P

Could take some time tho. I dont know how fast i will finish the VC-algorithm. I hate to operate on those nasty buffers. :D



Thanks a lot for your help guys. :)
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Utilizing Vertex Layouts

Post by hendu »

Can't see the pic by clicking the link, and the direct (embed) link gives a 404...
http://img202.imageshack.us/img202/9311/matblend.png
Post Reply