Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

Mesh and vertex buffer

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

VincentPix
Posts: 48
Joined: 06 Nov 2014, 15:07

Re: Mesh and vertex buffer

Post by VincentPix » 15 Oct 2015, 17:37

heeeelp
If someone has any hint for me

Code: Select all

vs2ps Out;
	for( uint i = 0;i < 4; i++ )
	{
		PosO = PosO + MyPos[i];
	}
		
	//transform position
	Out.Pos = mul(PosO, tWVP);
    
	//transform texturecoordinates
	Out.TexCd = TexCd;

	return Out;
}

TVM Cracklings
Posts: 33
Joined: 30 Sep 2015, 10:49

Re: Mesh and vertex buffer

Post by TVM Cracklings » 17 Oct 2015, 05:57

Hey Vincent,

could you probably describe in words what you're trying to achieve with this? And what is your MyPos array?

In your previous post, you mentioned homography transformation. You could google "translation matrix", "scaling matrix" and "rotation matrix" for more info in that regard. Do bare in mind though that microsoft uses a left handed coord, while openGL (which is the choice for most academic / research institutes) a right handed one, which basically means that you have to transpose everything for an opengl version of transformation matrix to work in directX.

BR
-C

VincentPix
Posts: 48
Joined: 06 Nov 2014, 15:07

Re: Mesh and vertex buffer

Post by VincentPix » 19 Oct 2015, 13:14

Hi

Thanks for your answer and sorry for the missing datas in my previous post.

I'm trying to draw several simple rectangles (4 vertices) with only one rectangle and a shader in my hierarchy.


MyPos is an array of float4 : coordinates of the different rectangles I wish to draw (the w value = 0)

Only the coordinates of the first object work. (moving the original rectangle). but no other rectangle appear in my scene. I think the problem is the indices (only declared for the 1st object not the others).

Code: Select all

vs2ps VS(
	float4 PosO  : POSITION,
	float2 TexCd : TEXCOORD0)
{
	//declare output struct
	vs2ps Out;
	for( int i = 0;i < 2; i++ )
	{
		PosO = PosO + MyPos[i];
		
		//transform position
		Out.Pos = mul(PosO, tWVP);
    
		//transform texturecoordinates
		Out.TexCd = TexCd;

		return Out;
	}
Thanks

TVM Cracklings
Posts: 33
Joined: 30 Sep 2015, 10:49

Re: Mesh and vertex buffer

Post by TVM Cracklings » 19 Oct 2015, 17:33

Unfortunately, what you're trying to achieve is only possible from dx10 up, by only supplying vertex indices to the vertex shader with no attributes.

Check this out for more precise info.

That, btw., is exactly what lerou was talking about, creating geometries in shaders. As you've probably figured out, we have no access to the index buffer, and we're on dx9c, so no.

TVM Cracklings
Posts: 33
Joined: 30 Sep 2015, 10:49

Re: Mesh and vertex buffer

Post by TVM Cracklings » 19 Oct 2015, 17:47

Oh, should be this link

P.S.,

PosO.w would be 1 if not modified somewhere in the shader.

The idea is to have a nice easy way to translate a 3d vector:

To move r=(x,y,z,1) in the x direction for 1 unit length, you just have to multiply it by

(1,0,0,1)
(0,1,0,0)
(0,0,1,0)
(0,0,0,1).

So you basically treat translation the same as rotation and scaling, and don't have to worry any more, while in 3x3, you have to add (1,0,0) to achieve that, which is pretty ugly when anything else can be merged into a matrix multiplication. (But this also introduces a problem: you have to cast your vectors to 3d before you normalize them. Everything comes at a cost :? )

(There's another usage of 4d vector called quaternion, but that's a way more technical topic, and most programmers won't get their hands on that anyway.)

VincentPix
Posts: 48
Joined: 06 Nov 2014, 15:07

Re: Mesh and vertex buffer

Post by VincentPix » 04 Nov 2015, 16:17

Thank you TVM

And thank you for the transformation matrix tuto.

But my real idea is to spread with math functions simple objects (rectangles, boxes) and may be more complexe (imported 3D mesh), using translation vector (or matrix)

I understand your answer and the limitation of the DX version. but as said by Lerou :
Sure, doing that all the time. Check out some of the Glare plugins in the Store :)
I imagined : if I use an already declared object like a ventuz rectangle (4 vertices + indices + uv), when i'll spread it the vertex shader will re-use those indices for each new object (the way to connect the vertices is the same for every object)

So how can we achieve to do that ? There must be a solution. Glare Tehnologies do that in their awesome plugins !

Thanks

TVM Cracklings
Posts: 33
Joined: 30 Sep 2015, 10:49

Re: Mesh and vertex buffer

Post by TVM Cracklings » 05 Nov 2015, 07:27

Not sure whether I got you right.

If you want to reuse a mesh multiple times, then no, there's no way to do that in a Shader node, since that's not a job of a dx9 Shader. I can imagine though that there's some shady cheats going on in some of the more complicated plugins by GT or 2R. :D

So again, in shader model 3.0, you cannot create vertices out of nowhere.

VincentPix
Posts: 48
Joined: 06 Nov 2014, 15:07

Re: Mesh and vertex buffer

Post by VincentPix » 09 Nov 2015, 12:45

Hello,

OK
Let's try another way.

May be we have to import as one mesh a geometry containing several objects and then we can edit the positions of each sub-object with an array of values.
What do you think about it ?

VT

TVM Cracklings
Posts: 33
Joined: 30 Sep 2015, 10:49

Re: Mesh and vertex buffer

Post by TVM Cracklings » 09 Nov 2015, 16:35

Hi there,

TL;DR: Nope, not this way either.

If you look at the code of the default vertex shader, there is a variable named "Position" with the semantic "POSITION". You can see this as the variables of a function, whereas everything else that comes within this struct (in case of the default shader, nothing at all :shock:) is a function (in mathematical sense) of the Position. Same for the output side. There's a POSITION, and this time it's heading towards the rasterizer, while everything else of the output struct travels with it. Inside the rasterizer, screen space vertices are rasterized into fragments, and if there's no vertex in that fragment previously, it's (mostly linearly) interpolated.

So as you can see, one vertex in, one vertex out. I think it's a morphism but I was never good at algebra so don't trust me on that.

-C

Post Reply