Shader language

Doctor Caroline,

 I collected some shader language question. In chapter 4 I found this property in your book:

struct VertexOut {

float4 position [[ position ]];

float point_size [[ point_size ]];

};

And I wanna get more information about [position] and [point_size]

[[position]] and [[point_size]] are vertex function output attributes.

When you pass a VertexOut struct from vertex function to fragment function, the rasteriser needs to know which of the items in the struct is the position. So you mark the position with the [[position]] attribute.

[[point_size]] is for when you are rendering points. You specify how large the point size should be.

In Chapter 4, on page 90 of the pdf, both these attributes are described.

A further resource is Apple’s Metal Shading Language specification: https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf. These attributes are described in section 5.7.

Thank you Doctor Caroline. I am downloading this source of pdf. I am going to study hard

1 Like