feature request: new mesh buffer and vertices

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

feature request: new mesh buffer and vertices

Post by REDDemon »

I hope irrlicht will implement soon these features:

MeshBuffers and vertices that supports more than 2 textures and each textures with its own separate textures coordinates. (not really a flexible vertex format)

(if using less than or exactly 4 textures I think this will be always compatible with old hardware)

Thanks.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
fmx

Post by fmx »

Like I said in my other post, it can be done with Tangent vertices:

Code: Select all

Pos = vertex Pos X,Y,Z
Normal = vertex Normal X,Y,Z
UV 1 = vertex UV X,Y
UV 2 = vertex Binormal X,Y
UV 3 = vertex Tangent X,Y
UV 4 = vertex Binormal Z, vertex Tangent Z
You can control these in a shader and map them to the correct texture-slot there too;
remember each material can have up to 4 textures assigned to it.

On older hardware, you can emulate the same setup in software although it wont be as fast or efficient.

The meshbuffer can also be recast to use Tangent vertices, see the iMeshBuffer implementation

It isn't worth adding a new vertex format and meshbuffer just because you need it for one specific project;
I am sure that is what the devs will say to you...
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Post by REDDemon »

I 'm trying now to do that but seems i'm not very good with shaders thanks a lot
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

Maybe you are a bit confused because of the data flow.

You need to setup your meshes first outside the shaders. That is a somewhat simple step, you apply the mapping coordinates you need in the order you need, after, what i do is to access the data in the vertex shader as the vectors they are suposed to be, but i translate them into float2 mapping coordinates and treat them like that in the Pixel shader

Watch this:

This is the input of the vertex shader:

Code: Select all

struct{
float4 position:POSITION0;
float3 normal:NORMAL0;
float3 tangent:TEXCOORD1;
float3 binormal:TEXCOORD2;
float2 texCoord0:TEXCOORD0;
float4 color:COLOR0
};VS_INPUT
That is the layout of the current S3DVertexTangent. Yep, tangent and binormals aren't placed where they should. Maybe this is why it is failing. And indeed, it is not documented. I found out this watching the normal mapping algorithm included in the engine. I think it should either be written somewhere, or even better, that the BINORMAL and TANGENT semantics were actually used.

this is the output of the vertex shader:

Code: Select all

struct{
float4 position:POSITION0;
float2 texCoord0:TEXCOORD0;
float3 normal:TEXCOORD1;
float2 texCoord1:TEXCOORD2;
float2 texCoord2:TEXCOORD3;
float2 texCoord3:TEXCOORD4;
float4 color:TEXCOORD5
};PS_INPUT
In the Vertex shader, for instance i do this....

Code: Select all

PS_INPUT vs_main(VS_INPUT IN){

PS_INPUT OUT;

OUT.Position... (whatever you want to put in the position...)
OUT.normal... (whatever you want to put in the normal...)

OUT.texCoord0 = IN.texCoord0;
OUT.texCoord1 = IN.tangent.xy;
OUT.texCoord2 = float2(IN.tangent.z,IN.binormal.x);
OUT.texCoord3 = IN.binormal.yz;

OUT.color = IN.color;

return OUT;
}
And that way you can have multiple texture coordinates in your shaders. I think this could be used as a small snippet :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Post by REDDemon »

sure that's great. the thing i don't understand in shaders are infact output and input. the meshes were all correctly set up but shaders wasn't work. thanks a lot. :) this will be usefull also as tutorial about how to write shaders.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Post Reply