Skip to content

Commit

Permalink
add first/either (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman authored Aug 21, 2024
1 parent a1bae88 commit 68563b6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions webgpu/lessons/ja/webgpu-inter-stage-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ WebGPUでは、この「補間」をどうやるかについて、設定項目
* `center`: 補間に際して「ピクセルの中心」をサンプリングする(**default**)
* `centroid`: 補間に際して「プリミティブ(三角形などの基本図形)」単位でサンプリングする。プリミティブ内の全ピクセルで同じ値となる
* `sample`: 補間を「サンプル」単位で行なう。フラグメントシェーダは各サンプルについて実行される
* `first`: Used only with type = `flat`. (default) The value comes from the first vertex of the primitive being drawn
* `either`: Used only with type = `flat`. The value comes from either the first or the last vertex of the primitive being drawn.
補間の設定は、inter-stage変数の属性として記述します。たとえばこんな風に書きます。
Expand Down
2 changes: 2 additions & 0 deletions webgpu/lessons/ko/webgpu-inter-stage-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ select = (a, b, condition) => condition ? b : a;
* `center`: 보간이 픽셀의 중앙에서 수행됨 (**기본값**)
* `centroid`: 현재 프리미티브(primitive)가 차지하는 모든 프래그먼트의 모든 샘플 내에 존재하는 점에 대해 보간이 수행됨. 값은 프래그먼트 내의 모든 샘플에 대해 같은 값임
* `sample`: 샘플 별로 보간이 수행됨. 이 값이 적용되는 경우 프래그먼트 셰이더는 모든 샘플별로 한 번씩 실행됨
* `first`: Used only with type = `flat`. (default) The value comes from the first vertex of the primitive being drawn
* `either`: Used only with type = `flat`. The value comes from either the first or the last vertex of the primitive being drawn.
이러한 속성은 다음과 같이 명시됩니다.
Expand Down
2 changes: 2 additions & 0 deletions webgpu/lessons/ru/webgpu-inter-stage-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ select = (a, b, condition) => condition ? b : a;
* `center`: Интерполяция выполняется от центра пикселя (**по умолчанию**)
* `centroid`: Интерполяция выполняется в точке, лежащей внутри всех выборок, охватываемых фрагментом внутри текущего примитива. Это значение одинаково для всех выборок в примитиве.
* `sample`: Интерполяция выполняется для каждой выборки. Fragment shader вызывается один раз для каждой выборки при применении этого атрибута.
* `first`: Used only with type = `flat`. (default) The value comes from the first vertex of the primitive being drawn
* `either`: Used only with type = `flat`. The value comes from either the first or the last vertex of the primitive being drawn.
Вы указываете эти аттрибуты. Для примера
Expand Down
2 changes: 2 additions & 0 deletions webgpu/lessons/uk/webgpu-inter-stage-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ select = (a, b, condition) => condition ? b : a;
* `center`: Інтерполяція виконується в центрі пікселя (**стандартне значення**)
* `centroid`: Інтерполяція виконується в точці, яка лежить у межах усіх вибірок, охоплених фрагментом у поточному примітиві. Це значення однакове для всіх зразків у примітиві.
* `sample`: Інтерполяція виконується для вибірки. Фрагментний шейдер викликається один раз на вибірку, коли застосовано цей атрибут.
* `first`: Used only with type = `flat`. (default) The value comes from the first vertex of the primitive being drawn
* `either`: Used only with type = `flat`. The value comes from either the first or the last vertex of the primitive being drawn.
Ви зазначаєте їх, як атрибути. Наприклад
Expand Down
7 changes: 5 additions & 2 deletions webgpu/lessons/webgpu-inter-stage-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ Interpolation sampling:
* `center`: Interpolation is performed at the center of the pixel. (**default**)
* `centroid`: Interpolation is performed at a point that lies within all the samples covered by the fragment within the current primitive. This value is the same for all samples in the primitive.
* `sample`: Interpolation is performed per sample. The fragment shader is invoked once per sample when this attribute is applied.
* `first`: Used only with type = `flat`. (default) The value comes from the first vertex of the primitive being drawn
* `either`: Used only with type = `flat`. The value comes from either the first or the last vertex of the primitive being drawn.
You specify these as attributes, for example:
Expand All @@ -359,8 +361,9 @@ You specify these as attributes, for example:
Note that if the inter-stage variable is an integer type then you must set its
interpolation to `flat`.
If you set the interpolation type to `flat`, the value passed to the fragment shader
is the value of the inter-stage variable for the first vertex in that triangle.
If you set the interpolation type to `flat`, by default, the value passed to the fragment shader
is the value of the inter-stage variable for the first vertex in that triangle. For most
`flat` use cases you should pick `either`. We'll cover why in [another article](webgpu-compatibility-mode.html).
In the [next article we'll cover uniforms](webgpu-uniforms.html) as another way to
pass data into shaders.
2 changes: 2 additions & 0 deletions webgpu/lessons/zh_cn/webgpu-inter-stage-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ select = (a, b, condition) => (condition ? b : a);
- `center`: 插值在像素中心进行 (**默认**)
- `centroid`: 插值是在当前基元中片段所覆盖的所有样本内的某一点上进行的。该值对基元中的所有样本都是相同的。
- `sample`: 每次采样时执行插值。应用此属性时,每次采样都会调用一次片段着色器.
- `first`: Used only with type = `flat`. (default) The value comes from the first vertex of the primitive being drawn
- `either`: Used only with type = `flat`. The value comes from either the first or the last vertex of the primitive being drawn.
您可以将其指定为属性。例如:
Expand Down

0 comments on commit 68563b6

Please sign in to comment.