I originally posted in the beginners' section, but I guess this is much more advanced than I was hoping it would be...
I want to have a material that uses 2 seperate alpha values for vertices. So I derived from S3DVertex and added a u8 "alpha2". One is for transparency, the other for creating a blend with second texture layer. But I realize it's probably not that simple. The CMeshBuffer<Alpha2Vertex> seem to work alright, but the CVertexBuffers (which I just found out about...) probably don't. Especially the stride can't be right. So, I would like to know what steps are necessary to properly implement a custom vertex-type, including corresponding mesh-buffer (and what not).
Question 2 would be: how do I use this data inside the custom material shader?
Custom Material Renderer using Custom Vertices
Re: Custom Material Renderer using Custom Vertices
You need to create a custom vertex declaration that describe the memory layout of your custom vertex and set it as your custom vertex descriptor
Re: Custom Material Renderer using Custom Vertices
You can check how to define custom vertex type in following example:
http://sourceforge.net/p/irrlicht/code/ ... g/main.cpp
http://sourceforge.net/p/irrlicht/code/ ... g/main.cpp
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Re: Custom Material Renderer using Custom Vertices
Thanks for replies. I will look into it later. It's the first time I am working with shaders and I had no idea what to do yesterday. By now, I have figured out that I can easily use the standard S3DVertex2TCoords, pass the data through the vertex shader and simply interpret the extra texCoords as alpha-values inside the pixel shader. It's not the cleanest thing to do, but good enough for the time being.
It's working the way I wanted now
Texture 2 gets blended on top of texture 1, using texture 2's alpha-channel multiplied with interpolated vertex-alpha (texCoord2[0]). The result can be used as any base-material. So I can still use EMT_TRANSPARENT_VERTEX_ALPHA with the actual vertex-alpha values.
It's working the way I wanted now
Texture 2 gets blended on top of texture 1, using texture 2's alpha-channel multiplied with interpolated vertex-alpha (texCoord2[0]). The result can be used as any base-material. So I can still use EMT_TRANSPARENT_VERTEX_ALPHA with the actual vertex-alpha values.
Re: Custom Material Renderer using Custom Vertices
So, after a year I finally looked into that example, because I'm at a point now, where 2TexCoord-vertices won't do anymore. It's just that the example seems to be outdated. It uses an IVertexDescriptor-class which simply isn't there.Nadro wrote:You can check how to define custom vertex type in following example:
http://sourceforge.net/p/irrlicht/code/ ... g/main.cpp
If anyone could help me out with this, I would really appreciate it. I just want to have additional variables in my vertices, nothing more. All I know is that creating a custom vertex and then a mesh-buffer with that vertex doesn't work. My guess is that I have to do something about the material renderer(?). Don't know how or what though...
Re: Custom Material Renderer using Custom Vertices
That example is from the shader-pipeline, not the official Irrlicht. Are you using that?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Custom Material Renderer using Custom Vertices
I don't even know what it is :/
I think I might once again use a dirty workaround and use the vertex normal-components for other purposes, but in the long run, being able to define my own vertices might be handy.
I think I might once again use a dirty workaround and use the vertex normal-components for other purposes, but in the long run, being able to define my own vertices might be handy.
Re: Custom Material Renderer using Custom Vertices
Shader-pipeline is an Irrlicht branch where developments for the version after the next are tried out. And like the name says it's about making materials all shader based. It also seems to have more flexibler vertex format, but admittably I haven't worked with it yet.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm