mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 11:06:11 -10:00
Shader packs: a matrix built from one vector takes its components column by column
`mat2(v)` with a vec4 `v` is the matrix with columns v.xy and v.zw in GLSL, as when the
components come as several arguments. naga's GLSL front end made each column the whole
vector, which failed validation ("Composing 0's component type is not expected"):
Bloop's water normals (prepare1) were skipped.
This commit is contained in:
1 parent
19f87e8059
commit
1da773a501
2 files changed
+45
No files matched your search
@@ -151,6 +151,17 @@ fn an_integer_vertex_output_without_flat_travels_flat() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_matrix_built_from_one_vector_takes_its_components_column_by_column() {
|
||||
// Bloop: `mat2(fract(sin(...vec4...)))` in its water noise.
|
||||
assert_terrain_translates(
|
||||
"#version 330\nfloat n2d(vec2 p) {\n vec2 i = floor(p);\n p -= i;\n\
|
||||
return dot(mat2(fract(sin(mod(vec4(0, 1, 113, 114) + dot(i, vec2(1, 113)), 6.2831853)) * 43758.5453)) \
|
||||
* vec2(1. - p.y, p.y), vec2(1. - p.x, p.x));\n}\n\
|
||||
layout(location = 0) out vec4 color;\nvoid main() { color = vec4(n2d(vec2(0.5))); }\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn integer_samplers_read_through_the_float_sampling_functions() {
|
||||
// Mello, Voyager, Exposa, Reverie: `uint mask = texture(colortex3, uv).r` on a usampler2D.
|
||||
|
||||
+34
@@ -352,6 +352,40 @@ impl Frontend {
|
||||
}
|
||||
}
|
||||
}
|
||||
// A vector with a component for each of the matrix's (`mat2(vec4)`) fills it column
|
||||
// by column, as several arguments do (GLSL 4.60, 5.4.2).
|
||||
TypeInner::Vector { size, .. } if size as u32 >= columns as u32 * rows as u32 => {
|
||||
let vector_ty = ctx.module.types.insert(
|
||||
Type {
|
||||
name: None,
|
||||
inner: TypeInner::Vector {
|
||||
size: rows,
|
||||
scalar: element_scalar,
|
||||
},
|
||||
},
|
||||
meta,
|
||||
);
|
||||
for c in 0..columns as u32 {
|
||||
let column = (0..rows as u32)
|
||||
.map(|r| {
|
||||
ctx.add_expression(
|
||||
Expression::AccessIndex {
|
||||
base: value,
|
||||
index: c * rows as u32 + r,
|
||||
},
|
||||
meta,
|
||||
)
|
||||
})
|
||||
.collect::<Result<_>>()?;
|
||||
components.push(ctx.add_expression(
|
||||
Expression::Compose {
|
||||
ty: vector_ty,
|
||||
components: column,
|
||||
},
|
||||
meta,
|
||||
)?);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
components = iter::repeat_n(value, columns as usize).collect();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user