armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

• 0

## Question

I am learning to write shaders in unity3d and I got the following code(so far following the tutotrial):

At the

am I storing the points of the object? Or am I storing only 1 position, and what is that one position? I know from the definition of vertex that it is a data structure used to describe certain attributes, like the position of a point in 2D or 3D space, but what exactly am I storing there?

## Recommended Posts

• 1

You can use too a float4 (or half4 for optimized code) with colors and consequently lights, but in this case, float4 color is equal to red, green, blue and alpha values. I am working on a bundle with more than 70 filters for Unity. This semantic seems to me really complicated for novice and consequently clever and elaborated. Often, by changing a few parameters, you have a totally different displaying. Now my computer becomes a lab

Please login or register to see this link. on a blue and red cubes, and a green sphere...

##### Share on other sites

• 1

Basically when you use a float4 as a position in a shader code, you define X, Y, Z values in space and another one which is named "the fourth coordinate of the matrix model". It is useful for movement and transformation when you combine some points in space. It represents an affine transformation - a linear transformation together with a translation. Obviously, if a position is static (or reached), this value is equal to 1. When you translate a position, it increases starting at 0. Here you can read an explanation which is not more clear than what I said

Imagine a translation on Y axis :

first position : 0, 0, 0 - 0

second position : 0, 1, 0 - 1

##### Share on other sites
• 1

Is the position of the vertex in local space (model space) ....in extremely basic terms it uses x,y,z and the fourth is used to display a 3d object onto a 2d screen (the fourth component should be 1  for points and it needs to be 0 for directions)

##### Share on other sites
• 0

Thanks for the answers. So the x,y and z positions could also be used for the lighting of the model, for example if the object is static the xyz will be 0, and we calculate the light shining on it, angles and other stuff we need to take in consideration based on these right? The object is moved, the position values increase, and we basically change the way is reflected off the object again by updating the calculations. Sorry if it's a dumb thing I just said, it's literally mind numbing getting into these.

##### Share on other sites
• 0

I got it now, thanks.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.