Shader: Switch type<subtype> to type[subtype]
This commit is contained in:
parent
29a01e975c
commit
e6951d54a5
|
|
@ -1,44 +1,44 @@
|
|||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform<ViewerData>,
|
||||
[set(0), binding(1)] colorTexture: sampler2D<f32>,
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
[set(0), binding(1)] colorTexture: sampler2D[f32],
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[builtin(fragcoord)] fragcoord: vec4<f32>,
|
||||
[location(0)] uv: vec2<f32>
|
||||
[builtin(fragcoord)] fragcoord: vec4[f32],
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2<f32>,
|
||||
[location(1)] uv: vec2<f32>
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4<f32>,
|
||||
[location(0)] uv: vec2<f32>
|
||||
[builtin(position)] position: vec4[f32],
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -50,19 +50,19 @@ fn main(input: FragIn) -> FragOut
|
|||
|
||||
let color = colorTexture.Sample(input.uv).rgb;
|
||||
color *= BrightMiddleGrey / BrightLuminance;
|
||||
color *= vec3<f32>(1.0, 1.0, 1.0) + (color / (BrightThreshold*BrightThreshold));
|
||||
color -= vec3<f32>(0.5, 0.5, 0.5);
|
||||
color /= vec3<f32>(1.0, 1.0, 1.0) + color;*/
|
||||
color *= vec3[f32](1.0, 1.0, 1.0) + (color / (BrightThreshold*BrightThreshold));
|
||||
color -= vec3[f32](0.5, 0.5, 0.5);
|
||||
color /= vec3[f32](1.0, 1.0, 1.0) + color;*/
|
||||
|
||||
let output: FragOut;
|
||||
//output.color = vec4<f32>(max(color, vec3<f32>(0.0, 0.0, 0.0)), 1.0);
|
||||
//output.color = vec4[f32](max(color, vec3[f32](0.0, 0.0, 0.0)), 1.0);
|
||||
|
||||
let color = colorTexture.Sample(input.uv).rgb;
|
||||
let brightness = dot(color, vec3<f32>(0.2126, 0.7152, 0.0722));
|
||||
let brightness = dot(color, vec3[f32](0.2126, 0.7152, 0.0722));
|
||||
if (brightness > 1.0)
|
||||
output.color = vec4<f32>(color, 1.0);
|
||||
output.color = vec4[f32](color, 1.0);
|
||||
else
|
||||
output.color = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
output.color = vec4[f32](0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ fn main(input: FragIn) -> FragOut
|
|||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4<f32>(input.pos, 0.0, 1.0);
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform<ViewerData>,
|
||||
//[set(0), binding(1)] colorTexture: sampler2D<f32>,
|
||||
[set(0), binding(2)] bloomTexture: sampler2D<f32>,
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
//[set(0), binding(1)] colorTexture: sampler2D[f32],
|
||||
[set(0), binding(2)] bloomTexture: sampler2D[f32],
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2<f32>
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2<f32>,
|
||||
[location(1)] uv: vec2<f32>,
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] uv: vec2<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[location(0)] uv: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -54,7 +54,7 @@ fn main(input: FragIn) -> FragOut
|
|||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4<f32>(input.pos, 0.0, 1.0);
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
|
|
|
|||
|
|
@ -6,52 +6,52 @@ option AlphaTest: bool = false;
|
|||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4<f32>
|
||||
DiffuseColor: vec4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct InstanceData
|
||||
{
|
||||
worldMatrix: mat4<f32>,
|
||||
invWorldMatrix: mat4<f32>
|
||||
worldMatrix: mat4[f32],
|
||||
invWorldMatrix: mat4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform<BasicSettings>,
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D<f32>,
|
||||
[binding(2)] MaterialAlphaMap: sampler2D<f32>,
|
||||
[binding(3)] TextureOverlay: sampler2D<f32>,
|
||||
[binding(4)] instanceData: uniform<InstanceData>,
|
||||
[binding(5)] viewerData: uniform<ViewerData>,
|
||||
[binding(0)] settings: uniform[BasicSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
}
|
||||
|
||||
struct InputData
|
||||
{
|
||||
[location(0)] normal: vec3<f32>,
|
||||
[location(1)] uv: vec2<f32>,
|
||||
[location(2)] pos: vec3<f32>
|
||||
[location(0)] normal: vec3[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
[location(2)] pos: vec3[f32]
|
||||
}
|
||||
|
||||
struct OutputData
|
||||
{
|
||||
[location(0)] diffuseMap: vec4<f32>,
|
||||
[location(1)] normalMap: vec4<f32>,
|
||||
[location(2)] positionMap: vec4<f32>
|
||||
[location(0)] diffuseMap: vec4[f32],
|
||||
[location(1)] normalMap: vec4[f32],
|
||||
[location(2)] positionMap: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -72,7 +72,7 @@ fn main(input: InputData) -> OutputData
|
|||
|
||||
let output: OutputData;
|
||||
output.diffuseMap = diffuseColor;
|
||||
output.normalMap = vec4<f32>((vec3<f32>(1.0, 1.0, 1.0) + input.normal) * 0.5, 1.0);
|
||||
output.positionMap = vec4<f32>(input.pos, 1.0);
|
||||
output.normalMap = vec4[f32]((vec3[f32](1.0, 1.0, 1.0) + input.normal) * 0.5, 1.0);
|
||||
output.positionMap = vec4[f32](input.pos, 1.0);
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,61 +2,61 @@
|
|||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4<f32>
|
||||
DiffuseColor: vec4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct InstanceData
|
||||
{
|
||||
worldMatrix: mat4<f32>,
|
||||
invWorldMatrix: mat4<f32>
|
||||
worldMatrix: mat4[f32],
|
||||
invWorldMatrix: mat4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform<BasicSettings>,
|
||||
[binding(4)] instanceData: uniform<InstanceData>,
|
||||
[binding(5)] viewerData: uniform<ViewerData>,
|
||||
[binding(0)] settings: uniform[BasicSettings],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
}
|
||||
|
||||
struct InputData
|
||||
{
|
||||
[location(0)] pos: vec3<f32>,
|
||||
[location(1)] normal: vec3<f32>,
|
||||
[location(2)] uv: vec2<f32>
|
||||
[location(0)] pos: vec3[f32],
|
||||
[location(1)] normal: vec3[f32],
|
||||
[location(2)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct OutputData
|
||||
{
|
||||
[location(0)] normal: vec3<f32>,
|
||||
[location(1)] uv: vec2<f32>,
|
||||
[location(2)] pos: vec3<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[location(0)] normal: vec3[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
[location(2)] pos: vec3[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: InputData) -> OutputData
|
||||
{
|
||||
let worldPos = instanceData.worldMatrix * vec4<f32>(input.pos, 1.0);
|
||||
let worldPos = instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
||||
|
||||
let output: OutputData;
|
||||
output.uv = input.uv;
|
||||
output.normal = input.normal;
|
||||
output.pos = worldPos.xyz;
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4<f32>(input.pos, 1.0);
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
external
|
||||
{
|
||||
[binding(0)] colorTexture: sampler2D<f32>
|
||||
[binding(0)] colorTexture: sampler2D[f32]
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2<f32>
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2<f32>,
|
||||
[location(1)] uv: vec2<f32>
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] vertUV: vec2<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[location(0)] vertUV: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -32,7 +32,7 @@ fn main(input: FragIn) -> FragOut
|
|||
|
||||
let output: FragOut;
|
||||
output.color = colorTexture.Sample(input.uv);
|
||||
//output.color = pow(colorTexture.Sample(input.uv), vec4<f32>(1.0 / gamma, 1.0 / gamma, 1.0 / gamma, 1.0));
|
||||
//output.color = pow(colorTexture.Sample(input.uv), vec4[f32](1.0 / gamma, 1.0 / gamma, 1.0 / gamma, 1.0));
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ fn main(input: FragIn) -> FragOut
|
|||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4<f32>(input.pos, 0.0, 1.0);
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.vertUV = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct BlurData
|
||||
{
|
||||
direction: vec2<f32>,
|
||||
direction: vec2[f32],
|
||||
sizeFactor: f32
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform<ViewerData>,
|
||||
[set(0), binding(1)] colorTexture: sampler2D<f32>,
|
||||
[set(0), binding(2)] blurData: uniform<BlurData>
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
[set(0), binding(1)] colorTexture: sampler2D[f32],
|
||||
[set(0), binding(2)] blurData: uniform[BlurData]
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2<f32>
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2<f32>,
|
||||
[location(1)] uv: vec2<f32>,
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] uv: vec2<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[location(0)] uv: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -62,7 +62,7 @@ fn main(input: FragIn) -> FragOut
|
|||
color += colorTexture.Sample(input.uv - blurData.direction * 3.2307692308 * invTargetSize).rgb * 0.0702702703;
|
||||
|
||||
let output: FragOut;
|
||||
output.color = vec4<f32>(color, 1.0);
|
||||
output.color = vec4[f32](color, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ fn main(input: FragIn) -> FragOut
|
|||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4<f32>(input.pos, 0.0, 1.0);
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
|
|
@ -19,38 +19,38 @@ struct Settings
|
|||
decay: f32,
|
||||
density: f32,
|
||||
weight: f32,
|
||||
lightPosition: vec2<f32>, //< TODO: Switch to world position
|
||||
lightPosition: vec2[f32], //< TODO: Switch to world position
|
||||
}
|
||||
|
||||
const SampleCount: i32 = 200;
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform<ViewerData>,
|
||||
[set(0), binding(1)] settings: uniform<Settings>,
|
||||
[set(0), binding(2)] occluderTexture: sampler2D<f32>
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
[set(0), binding(1)] settings: uniform[Settings],
|
||||
[set(0), binding(2)] occluderTexture: sampler2D[f32]
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2<f32>
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2<f32>,
|
||||
[location(1)] uv: vec2<f32>
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4<f32>,
|
||||
[location(0)] uv: vec2<f32>
|
||||
[builtin(position)] position: vec4[f32],
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -62,7 +62,7 @@ fn main(input: FragIn) -> FragOut
|
|||
|
||||
let uv = input.uv;
|
||||
|
||||
let outputColor = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
let outputColor = vec4[f32](0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
for i in 0 -> SampleCount
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@ fn main(input: FragIn) -> FragOut
|
|||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4<f32>(input.pos, 0.0, 1.0);
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
[layout(std140)]
|
||||
struct PointLight
|
||||
{
|
||||
color: vec3<f32>,
|
||||
position: vec3<f32>,
|
||||
color: vec3[f32],
|
||||
position: vec3[f32],
|
||||
|
||||
radius: f32,
|
||||
invRadius: f32,
|
||||
|
|
@ -11,11 +11,11 @@ struct PointLight
|
|||
[layout(std140)]
|
||||
struct SpotLight
|
||||
{
|
||||
transformMatrix: mat4<f32>,
|
||||
transformMatrix: mat4[f32],
|
||||
|
||||
color: vec3<f32>,
|
||||
position: vec3<f32>,
|
||||
direction: vec3<f32>,
|
||||
color: vec3[f32],
|
||||
position: vec3[f32],
|
||||
direction: vec3[f32],
|
||||
|
||||
radius: f32,
|
||||
invRadius: f32,
|
||||
|
|
@ -27,63 +27,63 @@ struct SpotLight
|
|||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
[set(0)]
|
||||
external
|
||||
{
|
||||
[binding(0)] viewerData: uniform<ViewerData>,
|
||||
[binding(1)] colorTexture: sampler2D<f32>,
|
||||
[binding(2)] normalTexture: sampler2D<f32>,
|
||||
[binding(3)] positionTexture: sampler2D<f32>,
|
||||
[binding(0)] viewerData: uniform[ViewerData],
|
||||
[binding(1)] colorTexture: sampler2D[f32],
|
||||
[binding(2)] normalTexture: sampler2D[f32],
|
||||
[binding(3)] positionTexture: sampler2D[f32],
|
||||
}
|
||||
|
||||
[set(1)]
|
||||
external
|
||||
{
|
||||
[binding(0)] lightParameters: uniform<SpotLight>,
|
||||
[binding(0)] lightParameters: uniform[SpotLight],
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[builtin(fragcoord)] fragcoord: vec4<f32>
|
||||
[builtin(fragcoord)] fragcoord: vec4[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec3<f32>
|
||||
[location(0)] pos: vec3[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let fragcoord = input.fragcoord.xy * viewerData.invRenderTargetSize;
|
||||
let normal = normalTexture.Sample(fragcoord).xyz * 2.0 - vec3<f32>(1.0, 1.0, 1.0);
|
||||
let normal = normalTexture.Sample(fragcoord).xyz * 2.0 - vec3[f32](1.0, 1.0, 1.0);
|
||||
let position = positionTexture.Sample(fragcoord).xyz;
|
||||
|
||||
let attenuation = compute_attenuation(position, normal);
|
||||
|
||||
let output: FragOut;
|
||||
output.color = vec4<f32>(lightParameters.color, 1.0) * attenuation * colorTexture.Sample(fragcoord);
|
||||
output.color = vec4[f32](lightParameters.color, 1.0) * attenuation * colorTexture.Sample(fragcoord);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -92,12 +92,12 @@ fn main(input: FragIn) -> FragOut
|
|||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = viewerData.projectionMatrix * viewerData.viewMatrix * lightParameters.transformMatrix * vec4<f32>(input.pos, 1.0);
|
||||
output.position = viewerData.projectionMatrix * viewerData.viewMatrix * lightParameters.transformMatrix * vec4[f32](input.pos, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
fn compute_attenuation(worldPos: vec3<f32>, normal: vec3<f32>) -> f32
|
||||
fn compute_attenuation(worldPos: vec3[f32], normal: vec3[f32]) -> f32
|
||||
{
|
||||
let distance = length(lightParameters.position - worldPos);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] viewerData: uniform<ViewerData>,
|
||||
[binding(1)] skybox: samplerCube<f32>
|
||||
[binding(0)] viewerData: uniform[ViewerData],
|
||||
[binding(1)] skybox: samplerCube[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] uvw: vec3<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[location(0)] uvw: vec3[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>,
|
||||
[location(0)] color: vec4[f32],
|
||||
[builtin(fragdepth)] depth: f32
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ fn main(input: VertOut) -> FragOut
|
|||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] position: vec3<f32>
|
||||
[location(0)] position: vec3[f32]
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
|
|
@ -51,10 +51,10 @@ fn main(input: VertIn) -> VertOut
|
|||
{
|
||||
// Set translation part to zero
|
||||
let rotationMat = viewerData.viewMatrix;
|
||||
rotationMat[3].xyz = vec3<f32>(0.0, 0.0, 0.0);
|
||||
rotationMat[3].xyz = vec3[f32](0.0, 0.0, 0.0);
|
||||
|
||||
let output: VertOut;
|
||||
output.position = viewerData.projectionMatrix * rotationMat * vec4<f32>(input.position, 1.0);
|
||||
output.position = viewerData.projectionMatrix * rotationMat * vec4[f32](input.position, 1.0);
|
||||
output.uvw = input.position.xyz;
|
||||
|
||||
return output;
|
||||
|
|
|
|||
|
|
@ -1,43 +1,43 @@
|
|||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] viewerData: uniform<ViewerData>,
|
||||
[set(0), binding(1)] inputTexture: sampler2D<f32>
|
||||
[set(0), binding(0)] viewerData: uniform[ViewerData],
|
||||
[set(0), binding(1)] inputTexture: sampler2D[f32]
|
||||
}
|
||||
|
||||
struct FragIn
|
||||
{
|
||||
[location(0)] uv: vec2<f32>,
|
||||
[location(0)] uv: vec2[f32],
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec2<f32>,
|
||||
[location(1)] uv: vec2<f32>,
|
||||
[location(0)] pos: vec2[f32],
|
||||
[location(1)] uv: vec2[f32],
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0)] uv: vec2<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[location(0)] uv: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -48,10 +48,10 @@ fn main(input: FragIn) -> FragOut
|
|||
let hdrColor = inputTexture.Sample(input.uv).rgb;
|
||||
|
||||
// reinhard tone mapping
|
||||
let mapped = vec3<f32>(1.0, 1.0, 1.0) - exp(-hdrColor * exposure);
|
||||
let mapped = vec3[f32](1.0, 1.0, 1.0) - exp(-hdrColor * exposure);
|
||||
|
||||
let output: FragOut;
|
||||
output.color = vec4<f32>(mapped, 1.0);
|
||||
output.color = vec4[f32](mapped, 1.0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ fn main(input: FragIn) -> FragOut
|
|||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4<f32>(input.pos, 0.0, 1.0);
|
||||
output.position = vec4[f32](input.pos, 0.0, 1.0);
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ constexpr std::size_t BloomSubdivisionCount = 5;
|
|||
[layout(std140)]
|
||||
struct PointLight
|
||||
{
|
||||
color: vec3<f32>,
|
||||
position: vec3<f32>,
|
||||
color: vec3[f32],
|
||||
position: vec3[f32],
|
||||
|
||||
constant: f32,
|
||||
linear: f32,
|
||||
|
|
@ -28,9 +28,9 @@ struct PointLight
|
|||
[layout(std140)]
|
||||
struct SpotLight
|
||||
{
|
||||
color: vec3<f32>,
|
||||
position: vec3<f32>,
|
||||
direction: vec3<f32>,
|
||||
color: vec3[f32],
|
||||
position: vec3[f32],
|
||||
direction: vec3[f32],
|
||||
|
||||
constant: f32,
|
||||
linear: f32,
|
||||
|
|
@ -299,9 +299,9 @@ int main()
|
|||
[layout(std140)]
|
||||
struct SpotLight
|
||||
{
|
||||
color: vec3<f32>,
|
||||
position: vec3<f32>,
|
||||
direction: vec3<f32>,
|
||||
color: vec3[f32],
|
||||
position: vec3[f32],
|
||||
direction: vec3[f32],
|
||||
|
||||
constant: f32,
|
||||
linear: f32,
|
||||
|
|
|
|||
|
|
@ -17,50 +17,50 @@ option red: bool = false;
|
|||
[layout(std140)]
|
||||
struct Data
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
worldMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
worldMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32]
|
||||
}
|
||||
|
||||
[set(0)]
|
||||
external
|
||||
{
|
||||
[binding(0)] viewerData: uniform<Data>,
|
||||
[binding(0)] viewerData: uniform[Data],
|
||||
}
|
||||
|
||||
[set(1)]
|
||||
external
|
||||
{
|
||||
[binding(0)] tex: sampler2D<f32>
|
||||
[binding(0)] tex: sampler2D[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] position: vec3<f32>,
|
||||
[location(1)] normal: vec3<f32>,
|
||||
[location(2)] uv: vec2<f32>
|
||||
[location(0)] position: vec3[f32],
|
||||
[location(1)] normal: vec3[f32],
|
||||
[location(2)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4<f32>,
|
||||
[location(0)] normal: vec3<f32>,
|
||||
[location(1)] uv: vec2<f32>
|
||||
[builtin(position)] position: vec4[f32],
|
||||
[location(0)] normal: vec3[f32],
|
||||
[location(1)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main(fragIn: VertOut) -> FragOut
|
||||
{
|
||||
let lightDir = vec3<f32>(0.0, 0.707, 0.707);
|
||||
let lightDir = vec3[f32](0.0, 0.707, 0.707);
|
||||
let lightFactor = dot(fragIn.normal, lightDir);
|
||||
|
||||
let fragOut: FragOut;
|
||||
fragOut.color = lightFactor * tex.Sample(fragIn.uv) * const_select(red, vec4<f32>(1.0, 0.0, 0.0, 1.0), vec4<f32>(1.0, 1.0, 1.0, 1.0));
|
||||
fragOut.color = lightFactor * tex.Sample(fragIn.uv) * const_select(red, vec4[f32](1.0, 0.0, 0.0, 1.0), vec4[f32](1.0, 1.0, 1.0, 1.0));
|
||||
|
||||
return fragOut;
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ fn main(fragIn: VertOut) -> FragOut
|
|||
fn main(vertIn: VertIn) -> VertOut
|
||||
{
|
||||
let vertOut: VertOut;
|
||||
vertOut.position = viewerData.projectionMatrix * viewerData.viewMatrix * viewerData.worldMatrix * vec4<f32>(vertIn.position, 1.0);
|
||||
vertOut.position = viewerData.projectionMatrix * viewerData.viewMatrix * viewerData.worldMatrix * vec4[f32](vertIn.position, 1.0);
|
||||
vertOut.normal = vertIn.normal;
|
||||
vertOut.uv = vertIn.uv;
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ namespace Nz::ShaderLang
|
|||
ShaderAst::ExpressionPtr ParsePrimaryExpression();
|
||||
ShaderAst::ExpressionPtr ParseVariableAssignation();
|
||||
|
||||
ShaderAst::ExpressionType ParseArrayType();
|
||||
ShaderAst::AttributeType ParseIdentifierAsAttributeType();
|
||||
const std::string& ParseIdentifierAsName();
|
||||
ShaderAst::PrimitiveType ParsePrimitiveType();
|
||||
|
|
|
|||
|
|
@ -21,50 +21,50 @@ const HasUV = (UvLocation >= 0);
|
|||
struct MaterialSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4<f32>
|
||||
DiffuseColor: vec4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct InstanceData
|
||||
{
|
||||
worldMatrix: mat4<f32>,
|
||||
invWorldMatrix: mat4<f32>
|
||||
worldMatrix: mat4[f32],
|
||||
invWorldMatrix: mat4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform<MaterialSettings>,
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D<f32>,
|
||||
[binding(2)] MaterialAlphaMap: sampler2D<f32>,
|
||||
[binding(3)] TextureOverlay: sampler2D<f32>,
|
||||
[binding(4)] instanceData: uniform<InstanceData>,
|
||||
[binding(5)] viewerData: uniform<ViewerData>,
|
||||
[binding(0)] settings: uniform[MaterialSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
}
|
||||
|
||||
// Fragment stage
|
||||
struct FragIn
|
||||
{
|
||||
[location(0), cond(HasUV)] uv: vec2<f32>,
|
||||
[location(1), cond(HasColor)] color: vec4<f32>
|
||||
[location(0), cond(HasUV)] uv: vec2[f32],
|
||||
[location(1), cond(HasColor)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] RenderTarget0: vec4<f32>
|
||||
[location(0)] RenderTarget0: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -99,29 +99,29 @@ fn main(input: FragIn) -> FragOut
|
|||
struct VertIn
|
||||
{
|
||||
[location(PosLocation)]
|
||||
pos: vec3<f32>,
|
||||
pos: vec3[f32],
|
||||
|
||||
[cond(HasVertexColor), location(ColorLocation)]
|
||||
color: vec4<f32>,
|
||||
color: vec4[f32],
|
||||
|
||||
[cond(HasUV), location(UvLocation)]
|
||||
uv: vec2<f32>,
|
||||
uv: vec2[f32],
|
||||
|
||||
[cond(Billboard), location(BillboardCenterLocation)]
|
||||
billboardCenter: vec3<f32>,
|
||||
billboardCenter: vec3[f32],
|
||||
|
||||
[cond(Billboard), location(BillboardSizeRotLocation)]
|
||||
billboardSizeRot: vec4<f32>, //< width,height,sin,cos
|
||||
billboardSizeRot: vec4[f32], //< width,height,sin,cos
|
||||
|
||||
[cond(Billboard), location(BillboardColorLocation)]
|
||||
billboardColor: vec4<f32>
|
||||
billboardColor: vec4[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0), cond(HasUV)] uv: vec2<f32>,
|
||||
[location(1), cond(HasColor)] color: vec4<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[location(0), cond(HasUV)] uv: vec2[f32],
|
||||
[location(1), cond(HasColor)] color: vec4[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(vert), cond(Billboard)]
|
||||
|
|
@ -130,27 +130,27 @@ fn billboardMain(input: VertIn) -> VertOut
|
|||
let size = input.billboardSizeRot.xy;
|
||||
let sinCos = input.billboardSizeRot.zw;
|
||||
|
||||
let rotatedPosition = vec2<f32>(
|
||||
let rotatedPosition = vec2[f32](
|
||||
input.pos.x * sinCos.y - input.pos.y * sinCos.x,
|
||||
input.pos.y * sinCos.y + input.pos.x * sinCos.x
|
||||
);
|
||||
rotatedPosition *= size;
|
||||
|
||||
let cameraRight = vec3<f32>(viewerData.viewMatrix[0][0], viewerData.viewMatrix[1][0], viewerData.viewMatrix[2][0]);
|
||||
let cameraUp = vec3<f32>(viewerData.viewMatrix[0][1], viewerData.viewMatrix[1][1], viewerData.viewMatrix[2][1]);
|
||||
let cameraRight = vec3[f32](viewerData.viewMatrix[0][0], viewerData.viewMatrix[1][0], viewerData.viewMatrix[2][0]);
|
||||
let cameraUp = vec3[f32](viewerData.viewMatrix[0][1], viewerData.viewMatrix[1][1], viewerData.viewMatrix[2][1]);
|
||||
|
||||
let vertexPos = input.billboardCenter;
|
||||
vertexPos += cameraRight * rotatedPosition.x;
|
||||
vertexPos += cameraUp * rotatedPosition.y;
|
||||
|
||||
let output: VertOut;
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4<f32>(vertexPos, 1.0);
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](vertexPos, 1.0);
|
||||
|
||||
const if (HasColor)
|
||||
output.color = input.billboardColor;
|
||||
|
||||
const if (HasUV)
|
||||
output.uv = input.pos.xy + vec2<f32>(0.5, 0.5);
|
||||
output.uv = input.pos.xy + vec2[f32](0.5, 0.5);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ fn billboardMain(input: VertIn) -> VertOut
|
|||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4<f32>(input.pos, 1.0);
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
||||
|
||||
const if (HasColor)
|
||||
output.color = input.color;
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
external
|
||||
{
|
||||
[binding(0)] texture: sampler2D<f32>
|
||||
[binding(0)] texture: sampler2D[f32]
|
||||
}
|
||||
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] position: vec2<f32>,
|
||||
[location(1)] uv: vec2<f32>
|
||||
[location(0)] position: vec2[f32],
|
||||
[location(1)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[builtin(position)] position: vec4<f32>,
|
||||
[location(0)] uv: vec2<f32>
|
||||
[builtin(position)] position: vec4[f32],
|
||||
[location(0)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(vertIn: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = vec4<f32>(vertIn.position, 0.0, 1.0);
|
||||
output.position = vec4[f32](vertIn.position, 0.0, 1.0);
|
||||
output.uv = vertIn.uv;
|
||||
|
||||
return output;
|
||||
|
|
@ -27,7 +27,7 @@ fn main(vertIn: VertIn) -> VertOut
|
|||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4<f32>
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
|
|||
|
|
@ -8,44 +8,44 @@ const HasUV = AlphaTest && (HasDiffuseTexture || HasAlphaTexture);
|
|||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4<f32>
|
||||
DiffuseColor: vec4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct InstanceData
|
||||
{
|
||||
worldMatrix: mat4<f32>,
|
||||
invWorldMatrix: mat4<f32>
|
||||
worldMatrix: mat4[f32],
|
||||
invWorldMatrix: mat4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform<BasicSettings>,
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D<f32>,
|
||||
[binding(2)] MaterialAlphaMap: sampler2D<f32>,
|
||||
[binding(3)] TextureOverlay: sampler2D<f32>,
|
||||
[binding(4)] instanceData: uniform<InstanceData>,
|
||||
[binding(5)] viewerData: uniform<ViewerData>,
|
||||
[binding(0)] settings: uniform[BasicSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
}
|
||||
|
||||
// Fragment stage
|
||||
struct FragIn
|
||||
{
|
||||
[location(0), cond(HasUV)] uv: vec2<f32>
|
||||
[location(0), cond(HasUV)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
[entry(frag), cond(AlphaTest)]
|
||||
|
|
@ -73,21 +73,21 @@ fn main() {}
|
|||
// Vertex stage
|
||||
struct VertIn
|
||||
{
|
||||
[location(0)] pos: vec3<f32>,
|
||||
[location(1), cond(HasUV)] uv: vec2<f32>
|
||||
[location(0)] pos: vec3[f32],
|
||||
[location(1), cond(HasUV)] uv: vec2[f32]
|
||||
}
|
||||
|
||||
struct VertOut
|
||||
{
|
||||
[location(0), cond(HasUV)] uv: vec2<f32>,
|
||||
[builtin(position)] position: vec4<f32>
|
||||
[location(0), cond(HasUV)] uv: vec2[f32],
|
||||
[builtin(position)] position: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(vert)]
|
||||
fn main(input: VertIn) -> VertOut
|
||||
{
|
||||
let output: VertOut;
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4<f32>(input.pos, 1.0);
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
||||
|
||||
const if (HasUV)
|
||||
output.uv = input.uv;
|
||||
|
|
|
|||
|
|
@ -36,19 +36,19 @@ struct MaterialSettings
|
|||
{
|
||||
// BasicSettings
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4<f32>,
|
||||
DiffuseColor: vec4[f32],
|
||||
|
||||
// PhongSettings
|
||||
AmbientColor: vec3<f32>,
|
||||
SpecularColor: vec3<f32>,
|
||||
AmbientColor: vec3[f32],
|
||||
SpecularColor: vec3[f32],
|
||||
Shininess: f32,
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct InstanceData
|
||||
{
|
||||
worldMatrix: mat4<f32>,
|
||||
invWorldMatrix: mat4<f32>
|
||||
worldMatrix: mat4[f32],
|
||||
invWorldMatrix: mat4[f32]
|
||||
}
|
||||
|
||||
// TODO: Add enums
|
||||
|
|
@ -60,64 +60,64 @@ const SpotLight = 2;
|
|||
struct Light
|
||||
{
|
||||
type: i32,
|
||||
color: vec4<f32>,
|
||||
factor: vec2<f32>,
|
||||
parameter1: vec4<f32>,
|
||||
parameter2: vec4<f32>,
|
||||
parameter3: vec4<f32>,
|
||||
hasShadowMapping: bool
|
||||
color: vec4[f32],
|
||||
factor: vec2[f32],
|
||||
parameter1: vec4[f32],
|
||||
parameter2: vec4[f32],
|
||||
parameter3: vec4[f32],
|
||||
hasShadowMapping: u32
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct LightData
|
||||
{
|
||||
lights: [Light; MaxLightCount],
|
||||
lightCount: u32,
|
||||
lights: array[Light, MaxLightCount],
|
||||
lightCount: u32
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct ViewerData
|
||||
{
|
||||
projectionMatrix: mat4<f32>,
|
||||
invProjectionMatrix: mat4<f32>,
|
||||
viewMatrix: mat4<f32>,
|
||||
invViewMatrix: mat4<f32>,
|
||||
viewProjMatrix: mat4<f32>,
|
||||
invViewProjMatrix: mat4<f32>,
|
||||
renderTargetSize: vec2<f32>,
|
||||
invRenderTargetSize: vec2<f32>,
|
||||
eyePosition: vec3<f32>
|
||||
projectionMatrix: mat4[f32],
|
||||
invProjectionMatrix: mat4[f32],
|
||||
viewMatrix: mat4[f32],
|
||||
invViewMatrix: mat4[f32],
|
||||
viewProjMatrix: mat4[f32],
|
||||
invViewProjMatrix: mat4[f32],
|
||||
renderTargetSize: vec2[f32],
|
||||
invRenderTargetSize: vec2[f32],
|
||||
eyePosition: vec3[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform<MaterialSettings>,
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D<f32>,
|
||||
[binding(2)] MaterialAlphaMap: sampler2D<f32>,
|
||||
[binding(3)] TextureOverlay: sampler2D<f32>,
|
||||
[binding(4)] instanceData: uniform<InstanceData>,
|
||||
[binding(5)] viewerData: uniform<ViewerData>,
|
||||
[binding(6)] lightData: uniform<LightData>,
|
||||
[binding(7)] MaterialEmissiveMap: sampler2D<f32>,
|
||||
[binding(8)] MaterialHeightMap: sampler2D<f32>,
|
||||
[binding(9)] MaterialNormalMap: sampler2D<f32>,
|
||||
[binding(10)] MaterialSpecularMap: sampler2D<f32>,
|
||||
[binding(0)] settings: uniform[MaterialSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
[binding(5)] viewerData: uniform[ViewerData],
|
||||
[binding(6)] lightData: uniform[LightData],
|
||||
[binding(7)] MaterialEmissiveMap: sampler2D[f32],
|
||||
[binding(8)] MaterialHeightMap: sampler2D[f32],
|
||||
[binding(9)] MaterialNormalMap: sampler2D[f32],
|
||||
[binding(10)] MaterialSpecularMap: sampler2D[f32],
|
||||
}
|
||||
|
||||
struct VertToFrag
|
||||
{
|
||||
[location(0)] worldPos: vec3<f32>,
|
||||
[location(1), cond(HasUV)] uv: vec2<f32>,
|
||||
[location(2), cond(HasColor)] color: vec4<f32>,
|
||||
[location(3), cond(HasNormal)] normal: vec3<f32>,
|
||||
[location(4), cond(HasNormalMapping)] tbnMatrix: mat3<f32>,
|
||||
[builtin(position)] position: vec4<f32>,
|
||||
[location(0)] worldPos: vec3[f32],
|
||||
[location(1), cond(HasUV)] uv: vec2[f32],
|
||||
[location(2), cond(HasColor)] color: vec4[f32],
|
||||
[location(3), cond(HasNormal)] normal: vec3[f32],
|
||||
[location(4), cond(HasNormalMapping)] tbnMatrix: mat3[f32],
|
||||
[builtin(position)] position: vec4[f32],
|
||||
}
|
||||
|
||||
// Fragment stage
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] RenderTarget0: vec4<f32>
|
||||
[location(0)] RenderTarget0: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -145,15 +145,15 @@ fn main(input: VertToFrag) -> FragOut
|
|||
|
||||
const if (HasNormal)
|
||||
{
|
||||
let lightAmbient = vec3<f32>(0.0, 0.0, 0.0);
|
||||
let lightDiffuse = vec3<f32>(0.0, 0.0, 0.0);
|
||||
let lightSpecular = vec3<f32>(0.0, 0.0, 0.0);
|
||||
let lightAmbient = vec3[f32](0.0, 0.0, 0.0);
|
||||
let lightDiffuse = vec3[f32](0.0, 0.0, 0.0);
|
||||
let lightSpecular = vec3[f32](0.0, 0.0, 0.0);
|
||||
|
||||
let eyeVec = normalize(viewerData.eyePosition - input.worldPos);
|
||||
|
||||
let normal: vec3<f32>;
|
||||
let normal: vec3[f32];
|
||||
const if (HasNormalMapping)
|
||||
normal = normalize(input.tbnMatrix * (MaterialNormalMap.Sample(input.uv).xyz * 2.0 - vec3<f32>(1.0, 1.0, 1.0)));
|
||||
normal = normalize(input.tbnMatrix * (MaterialNormalMap.Sample(input.uv).xyz * 2.0 - vec3[f32](1.0, 1.0, 1.0)));
|
||||
else
|
||||
normal = normalize(input.normal);
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ fn main(input: VertToFrag) -> FragOut
|
|||
let lightColor = lightAmbient + lightDiffuse + lightSpecular;
|
||||
|
||||
let output: FragOut;
|
||||
output.RenderTarget0 = vec4<f32>(lightColor, 1.0) * diffuseColor;
|
||||
output.RenderTarget0 = vec4[f32](lightColor, 1.0) * diffuseColor;
|
||||
return output;
|
||||
}
|
||||
else
|
||||
|
|
@ -259,28 +259,28 @@ fn main(input: VertToFrag) -> FragOut
|
|||
struct VertIn
|
||||
{
|
||||
[location(PosLocation)]
|
||||
pos: vec3<f32>,
|
||||
pos: vec3[f32],
|
||||
|
||||
[cond(HasVertexColor), location(ColorLocation)]
|
||||
color: vec4<f32>,
|
||||
color: vec4[f32],
|
||||
|
||||
[cond(HasUV), location(UvLocation)]
|
||||
uv: vec2<f32>,
|
||||
uv: vec2[f32],
|
||||
|
||||
[cond(HasNormal), location(NormalLocation)]
|
||||
normal: vec3<f32>,
|
||||
normal: vec3[f32],
|
||||
|
||||
[cond(HasTangent), location(TangentLocation)]
|
||||
tangent: vec3<f32>,
|
||||
tangent: vec3[f32],
|
||||
|
||||
[cond(Billboard), location(BillboardCenterLocation)]
|
||||
billboardCenter: vec3<f32>,
|
||||
billboardCenter: vec3[f32],
|
||||
|
||||
[cond(Billboard), location(BillboardSizeRotLocation)]
|
||||
billboardSizeRot: vec4<f32>, //< width,height,sin,cos
|
||||
billboardSizeRot: vec4[f32], //< width,height,sin,cos
|
||||
|
||||
[cond(Billboard), location(BillboardColorLocation)]
|
||||
billboardColor: vec4<f32>
|
||||
billboardColor: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(vert), cond(Billboard)]
|
||||
|
|
@ -289,27 +289,27 @@ fn billboardMain(input: VertIn) -> VertOut
|
|||
let size = input.billboardSizeRot.xy;
|
||||
let sinCos = input.billboardSizeRot.zw;
|
||||
|
||||
let rotatedPosition = vec2<f32>(
|
||||
let rotatedPosition = vec2[f32](
|
||||
input.pos.x * sinCos.y - input.pos.y * sinCos.x,
|
||||
input.pos.y * sinCos.y + input.pos.x * sinCos.x
|
||||
);
|
||||
rotatedPosition *= size;
|
||||
|
||||
let cameraRight = vec3<f32>(viewerData.viewMatrix[0][0], viewerData.viewMatrix[1][0], viewerData.viewMatrix[2][0]);
|
||||
let cameraUp = vec3<f32>(viewerData.viewMatrix[0][1], viewerData.viewMatrix[1][1], viewerData.viewMatrix[2][1]);
|
||||
let cameraRight = vec3[f32](viewerData.viewMatrix[0][0], viewerData.viewMatrix[1][0], viewerData.viewMatrix[2][0]);
|
||||
let cameraUp = vec3[f32](viewerData.viewMatrix[0][1], viewerData.viewMatrix[1][1], viewerData.viewMatrix[2][1]);
|
||||
|
||||
let vertexPos = input.billboardCenter;
|
||||
vertexPos += cameraRight * rotatedPosition.x;
|
||||
vertexPos += cameraUp * rotatedPosition.y;
|
||||
|
||||
let output: VertToFrag;
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4<f32>(vertexPos, 1.0);
|
||||
output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](vertexPos, 1.0);
|
||||
|
||||
const if (HasColor)
|
||||
output.color = input.billboardColor;
|
||||
|
||||
const if (HasUV)
|
||||
output.uv = input.pos.xy + vec2<f32>(0.5, 0.5);
|
||||
output.uv = input.pos.xy + vec2[f32](0.5, 0.5);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -317,13 +317,13 @@ fn billboardMain(input: VertIn) -> VertOut
|
|||
[entry(vert), cond(!Billboard)]
|
||||
fn main(input: VertIn) -> VertToFrag
|
||||
{
|
||||
let worldPosition = instanceData.worldMatrix * vec4<f32>(input.pos, 1.0);
|
||||
let worldPosition = instanceData.worldMatrix * vec4[f32](input.pos, 1.0);
|
||||
|
||||
let output: VertToFrag;
|
||||
output.worldPos = worldPosition.xyz;
|
||||
output.position = viewerData.viewProjMatrix * worldPosition;
|
||||
|
||||
let rotationMatrix = mat3<f32>(instanceData.worldMatrix);
|
||||
let rotationMatrix = mat3[f32](instanceData.worldMatrix);
|
||||
|
||||
const if (HasColor)
|
||||
output.color = input.color;
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ namespace Nz::ShaderAst
|
|||
vectorComponentCount = std::get<VectorType>(GetExpressionType(*vectorExpr)).componentCount;
|
||||
}
|
||||
|
||||
// cast expression (turn fromMatrix[i] to vec3<f32>(fromMatrix[i]))
|
||||
// cast expression (turn fromMatrix[i] to vec3[f32](fromMatrix[i]))
|
||||
ExpressionPtr castExpr;
|
||||
if (vectorComponentCount != targetMatrixType.rowCount)
|
||||
{
|
||||
|
|
@ -1967,7 +1967,7 @@ namespace Nz::ShaderAst
|
|||
{
|
||||
const ExpressionType& type = GetExpressionType(*node.parameters.front());
|
||||
if (type != ExpressionType{ VectorType{ 3, PrimitiveType::Float32 } })
|
||||
throw AstError{ "CrossProduct only works with vec3<f32> expressions" };
|
||||
throw AstError{ "CrossProduct only works with vec3[f32] expressions" };
|
||||
|
||||
node.cachedExpressionType = type;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ namespace Nz
|
|||
|
||||
void LangWriter::Append(const ShaderAst::ArrayType& type)
|
||||
{
|
||||
Append("[", type.containedType->type, "; ");
|
||||
Append("array[", type.containedType->type, ", ");
|
||||
|
||||
if (type.length.IsResultingValue())
|
||||
Append(type.length.GetResultingValue());
|
||||
|
|
@ -164,7 +164,7 @@ namespace Nz
|
|||
Append(matrixType.rowCount);
|
||||
}
|
||||
|
||||
Append("<", matrixType.type, ">");
|
||||
Append("[", matrixType.type, "]");
|
||||
}
|
||||
|
||||
void LangWriter::Append(ShaderAst::PrimitiveType type)
|
||||
|
|
@ -192,7 +192,7 @@ namespace Nz
|
|||
case ImageType::Cubemap: Append("Cube"); break;
|
||||
}
|
||||
|
||||
Append("<", samplerType.sampledType, ">");
|
||||
Append("[", samplerType.sampledType, "]");
|
||||
}
|
||||
|
||||
void LangWriter::Append(const ShaderAst::StructType& structType)
|
||||
|
|
@ -203,17 +203,17 @@ namespace Nz
|
|||
|
||||
void LangWriter::Append(const ShaderAst::UniformType& uniformType)
|
||||
{
|
||||
Append("uniform<");
|
||||
Append("uniform[");
|
||||
std::visit([&](auto&& arg)
|
||||
{
|
||||
Append(arg);
|
||||
}, uniformType.containedType);
|
||||
Append(">");
|
||||
Append("]");
|
||||
}
|
||||
|
||||
void LangWriter::Append(const ShaderAst::VectorType& vecType)
|
||||
{
|
||||
Append("vec", vecType.componentCount, "<", vecType.type, ">");
|
||||
Append("vec", vecType.componentCount, "[", vecType.type, "]");
|
||||
}
|
||||
|
||||
void LangWriter::Append(ShaderAst::NoType)
|
||||
|
|
@ -732,15 +732,15 @@ namespace Nz
|
|||
else if constexpr (std::is_same_v<T, float> || std::is_same_v<T, Int32> || std::is_same_v<T, UInt32>)
|
||||
Append(std::to_string(arg));
|
||||
else if constexpr (std::is_same_v<T, Vector2f>)
|
||||
Append("vec2<f32>(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ")");
|
||||
Append("vec2[f32](" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ")");
|
||||
else if constexpr (std::is_same_v<T, Vector2i32>)
|
||||
Append("vec2<i32>(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ")");
|
||||
else if constexpr (std::is_same_v<T, Vector3f>)
|
||||
Append("vec3<f32>(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ")");
|
||||
Append("vec3[f32](" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ")");
|
||||
else if constexpr (std::is_same_v<T, Vector3i32>)
|
||||
Append("vec3<i32>(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ")");
|
||||
else if constexpr (std::is_same_v<T, Vector4f>)
|
||||
Append("vec4<f32>(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ", " + std::to_string(arg.w) + ")");
|
||||
Append("vec4[f32](" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ", " + std::to_string(arg.w) + ")");
|
||||
else if constexpr (std::is_same_v<T, Vector4i32>)
|
||||
Append("vec4<i32>(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ", " + std::to_string(arg.w) + ")");
|
||||
else
|
||||
|
|
|
|||
|
|
@ -207,7 +207,25 @@ namespace Nz::ShaderLang
|
|||
}
|
||||
|
||||
//FIXME: Handle this better
|
||||
if (identifier == "mat4")
|
||||
if (identifier == "array")
|
||||
{
|
||||
Consume();
|
||||
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
|
||||
ShaderAst::ArrayType arrayType;
|
||||
arrayType.containedType = std::make_unique<ShaderAst::ContainedType>();
|
||||
arrayType.containedType->type = ParseType();
|
||||
|
||||
Expect(Advance(), TokenType::Comma); //< ,
|
||||
|
||||
arrayType.length = ParseExpression();
|
||||
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return arrayType;
|
||||
}
|
||||
else if (identifier == "mat4")
|
||||
{
|
||||
Consume();
|
||||
|
||||
|
|
@ -215,9 +233,9 @@ namespace Nz::ShaderLang
|
|||
matrixType.columnCount = 4;
|
||||
matrixType.rowCount = 4;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
matrixType.type = ParsePrimitiveType();
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return matrixType;
|
||||
}
|
||||
|
|
@ -229,9 +247,9 @@ namespace Nz::ShaderLang
|
|||
matrixType.columnCount = 3;
|
||||
matrixType.rowCount = 3;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
matrixType.type = ParsePrimitiveType();
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return matrixType;
|
||||
}
|
||||
|
|
@ -243,9 +261,9 @@ namespace Nz::ShaderLang
|
|||
matrixType.columnCount = 2;
|
||||
matrixType.rowCount = 2;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
matrixType.type = ParsePrimitiveType();
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return matrixType;
|
||||
}
|
||||
|
|
@ -256,9 +274,9 @@ namespace Nz::ShaderLang
|
|||
ShaderAst::SamplerType samplerType;
|
||||
samplerType.dim = ImageType::E2D;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
samplerType.sampledType = ParsePrimitiveType();
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return samplerType;
|
||||
}
|
||||
|
|
@ -269,9 +287,9 @@ namespace Nz::ShaderLang
|
|||
ShaderAst::SamplerType samplerType;
|
||||
samplerType.dim = ImageType::Cubemap;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
samplerType.sampledType = ParsePrimitiveType();
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return samplerType;
|
||||
}
|
||||
|
|
@ -281,9 +299,9 @@ namespace Nz::ShaderLang
|
|||
|
||||
ShaderAst::UniformType uniformType;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
uniformType.containedType = ShaderAst::IdentifierType{ ParseIdentifierAsName() };
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return uniformType;
|
||||
}
|
||||
|
|
@ -294,9 +312,9 @@ namespace Nz::ShaderLang
|
|||
ShaderAst::VectorType vectorType;
|
||||
vectorType.componentCount = 2;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
vectorType.type = ParsePrimitiveType();
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return vectorType;
|
||||
}
|
||||
|
|
@ -307,9 +325,9 @@ namespace Nz::ShaderLang
|
|||
ShaderAst::VectorType vectorType;
|
||||
vectorType.componentCount = 3;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
vectorType.type = ParsePrimitiveType();
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return vectorType;
|
||||
}
|
||||
|
|
@ -320,9 +338,9 @@ namespace Nz::ShaderLang
|
|||
ShaderAst::VectorType vectorType;
|
||||
vectorType.componentCount = 4;
|
||||
|
||||
Expect(Advance(), TokenType::LessThan); //< '<'
|
||||
Expect(Advance(), TokenType::OpenSquareBracket); //< [
|
||||
vectorType.type = ParsePrimitiveType();
|
||||
Expect(Advance(), TokenType::GreaterThan); //< '>'
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket); //< ]
|
||||
|
||||
return vectorType;
|
||||
}
|
||||
|
|
@ -1337,24 +1355,6 @@ namespace Nz::ShaderLang
|
|||
}
|
||||
}
|
||||
|
||||
ShaderAst::ExpressionType Parser::ParseArrayType()
|
||||
{
|
||||
ShaderAst::ArrayType arrayType;
|
||||
|
||||
Expect(Advance(), TokenType::OpenSquareBracket);
|
||||
|
||||
arrayType.containedType = std::make_unique<ShaderAst::ContainedType>();
|
||||
arrayType.containedType->type = ParseType();
|
||||
|
||||
Expect(Advance(), TokenType::Semicolon);
|
||||
|
||||
arrayType.length = ParseExpression();
|
||||
|
||||
Expect(Advance(), TokenType::ClosingSquareBracket);
|
||||
|
||||
return arrayType;
|
||||
}
|
||||
|
||||
ShaderAst::AttributeType Parser::ParseIdentifierAsAttributeType()
|
||||
{
|
||||
const Token& identifierToken = Expect(Advance(), TokenType::Identifier);
|
||||
|
|
@ -1402,9 +1402,6 @@ namespace Nz::ShaderLang
|
|||
return ShaderAst::NoType{};
|
||||
}
|
||||
|
||||
if (Peek().type == TokenType::OpenSquareBracket)
|
||||
return ParseArrayType();
|
||||
|
||||
const Token& identifierToken = Expect(Peek(), TokenType::Identifier);
|
||||
const std::string& identifier = std::get<std::string>(identifierToken.data);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ TEST_CASE("structure member access", "[Shader]")
|
|||
std::string_view nzslSource = R"(
|
||||
struct innerStruct
|
||||
{
|
||||
field: vec3<f32>
|
||||
field: vec3[f32]
|
||||
}
|
||||
|
||||
struct outerStruct
|
||||
|
|
@ -23,7 +23,7 @@ struct outerStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] ubo: uniform<outerStruct>
|
||||
[set(0), binding(0)] ubo: uniform[outerStruct]
|
||||
}
|
||||
)";
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct inputStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -97,7 +97,7 @@ struct inputStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -161,7 +161,7 @@ struct inputStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ struct inputStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -73,7 +73,7 @@ struct inputStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -97,7 +97,7 @@ struct inputStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -118,18 +118,18 @@ const LightCount = 3;
|
|||
[layout(std140)]
|
||||
struct Light
|
||||
{
|
||||
color: vec4<f32>
|
||||
color: vec4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct LightData
|
||||
{
|
||||
lights: [Light; LightCount]
|
||||
lights: array[Light, LightCount]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<LightData>
|
||||
[set(0), binding(0)] data: uniform[LightData]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -152,7 +152,7 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let color: vec4<f32> = (0.000000).xxxx;
|
||||
let color: vec4[f32] = (0.000000).xxxx;
|
||||
let i: i32 = 0;
|
||||
color += data.lights[i].color;
|
||||
let i: i32 = 2;
|
||||
|
|
@ -175,18 +175,18 @@ const LightCount = 3;
|
|||
[layout(std140)]
|
||||
struct Light
|
||||
{
|
||||
color: vec4<f32>
|
||||
color: vec4[f32]
|
||||
}
|
||||
|
||||
[layout(std140)]
|
||||
struct LightData
|
||||
{
|
||||
lights: [Light; LightCount]
|
||||
lights: array[Light, LightCount]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<LightData>
|
||||
[set(0), binding(0)] data: uniform[LightData]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -209,7 +209,7 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let color: vec4<f32> = (0.000000).xxxx;
|
||||
let color: vec4[f32] = (0.000000).xxxx;
|
||||
let light: Light = data.lights[0];
|
||||
color += light.color;
|
||||
let light: Light = data.lights[1];
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct inputStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -250,12 +250,12 @@ OpFunctionEnd)");
|
|||
std::string_view nzslSource = R"(
|
||||
struct inputStruct
|
||||
{
|
||||
value: [f32; 10]
|
||||
value: array[f32, 10]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
|
|||
|
|
@ -42,13 +42,13 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let output = vec4<f32>(8.0, 2.0, -7.0, 0.0) * (7.0 + 5.0) * 2.0 / 4.0;
|
||||
let output = vec4[f32](8.0, 2.0, -7.0, 0.0) * (7.0 + 5.0) * 2.0 / 4.0;
|
||||
}
|
||||
)", R"(
|
||||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let output: vec4<f32> = vec4<f32>(48.000000, 12.000000, -42.000000, 0.000000);
|
||||
let output: vec4[f32] = vec4[f32](48.000000, 12.000000, -42.000000, 0.000000);
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value = vec3<f32>(3.0, 0.0, 1.0).z;
|
||||
let value = vec3[f32](3.0, 0.0, 1.0).z;
|
||||
}
|
||||
)", R"(
|
||||
[entry(frag)]
|
||||
|
|
@ -172,7 +172,7 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value: vec4<f32> = vec4<f32>(42.000000, 42.000000, 42.000000, 42.000000);
|
||||
let value: vec4[f32] = vec4[f32](42.000000, 42.000000, 42.000000, 42.000000);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
|
@ -183,13 +183,13 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value = vec4<f32>(3.0, 0.0, 1.0, 2.0).yzwx;
|
||||
let value = vec4[f32](3.0, 0.0, 1.0, 2.0).yzwx;
|
||||
}
|
||||
)", R"(
|
||||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value: vec4<f32> = vec4<f32>(0.000000, 1.000000, 2.000000, 3.000000);
|
||||
let value: vec4[f32] = vec4[f32](0.000000, 1.000000, 2.000000, 3.000000);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
|
@ -200,13 +200,13 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value = vec4<f32>(3.0, 0.0, 1.0, 2.0).zzxx;
|
||||
let value = vec4[f32](3.0, 0.0, 1.0, 2.0).zzxx;
|
||||
}
|
||||
)", R"(
|
||||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value: vec4<f32> = vec4<f32>(1.000000, 1.000000, 3.000000, 3.000000);
|
||||
let value: vec4[f32] = vec4[f32](1.000000, 1.000000, 3.000000, 3.000000);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
|
@ -217,13 +217,13 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value = vec4<f32>(0.0, 1.0, 2.0, 3.0).xyz.yz.y.x.xxxx;
|
||||
let value = vec4[f32](0.0, 1.0, 2.0, 3.0).xyz.yz.y.x.xxxx;
|
||||
}
|
||||
)", R"(
|
||||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value: vec4<f32> = vec4<f32>(2.000000, 2.000000, 2.000000, 2.000000);
|
||||
let value: vec4[f32] = vec4[f32](2.000000, 2.000000, 2.000000, 2.000000);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
|
@ -233,12 +233,12 @@ fn main()
|
|||
ExpectOptimization(R"(
|
||||
struct inputStruct
|
||||
{
|
||||
value: vec4<f32>
|
||||
value: vec4[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -250,7 +250,7 @@ fn main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let value: vec4<f32> = data.value.zzzz;
|
||||
let value: vec4[f32] = data.value.zzzz;
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ struct inputStruct
|
|||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -84,12 +84,12 @@ fn main()
|
|||
std::string_view nzslSource = R"(
|
||||
struct inputStruct
|
||||
{
|
||||
value: [f32; 10]
|
||||
value: array[f32, 10]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[set(0), binding(0)] data: uniform<inputStruct>
|
||||
[set(0), binding(0)] data: uniform[inputStruct]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
|
|
@ -131,49 +131,49 @@ fn main()
|
|||
WHEN("removing matrix casts")
|
||||
{
|
||||
std::string_view nzslSource = R"(
|
||||
fn testMat2ToMat2(input: mat2<f32>) -> mat2<f32>
|
||||
fn testMat2ToMat2(input: mat2[f32]) -> mat2[f32]
|
||||
{
|
||||
return mat2<f32>(input);
|
||||
return mat2[f32](input);
|
||||
}
|
||||
|
||||
fn testMat2ToMat3(input: mat2<f32>) -> mat3<f32>
|
||||
fn testMat2ToMat3(input: mat2[f32]) -> mat3[f32]
|
||||
{
|
||||
return mat3<f32>(input);
|
||||
return mat3[f32](input);
|
||||
}
|
||||
|
||||
fn testMat2ToMat4(input: mat2<f32>) -> mat4<f32>
|
||||
fn testMat2ToMat4(input: mat2[f32]) -> mat4[f32]
|
||||
{
|
||||
return mat4<f32>(input);
|
||||
return mat4[f32](input);
|
||||
}
|
||||
|
||||
fn testMat3ToMat2(input: mat3<f32>) -> mat2<f32>
|
||||
fn testMat3ToMat2(input: mat3[f32]) -> mat2[f32]
|
||||
{
|
||||
return mat2<f32>(input);
|
||||
return mat2[f32](input);
|
||||
}
|
||||
|
||||
fn testMat3ToMat3(input: mat3<f32>) -> mat3<f32>
|
||||
fn testMat3ToMat3(input: mat3[f32]) -> mat3[f32]
|
||||
{
|
||||
return mat3<f32>(input);
|
||||
return mat3[f32](input);
|
||||
}
|
||||
|
||||
fn testMat3ToMat4(input: mat3<f32>) -> mat4<f32>
|
||||
fn testMat3ToMat4(input: mat3[f32]) -> mat4[f32]
|
||||
{
|
||||
return mat4<f32>(input);
|
||||
return mat4[f32](input);
|
||||
}
|
||||
|
||||
fn testMat4ToMat2(input: mat4<f32>) -> mat2<f32>
|
||||
fn testMat4ToMat2(input: mat4[f32]) -> mat2[f32]
|
||||
{
|
||||
return mat2<f32>(input);
|
||||
return mat2[f32](input);
|
||||
}
|
||||
|
||||
fn testMat4ToMat3(input: mat4<f32>) -> mat3<f32>
|
||||
fn testMat4ToMat3(input: mat4[f32]) -> mat3[f32]
|
||||
{
|
||||
return mat3<f32>(input);
|
||||
return mat3[f32](input);
|
||||
}
|
||||
|
||||
fn testMat4ToMat4(input: mat4<f32>) -> mat4<f32>
|
||||
fn testMat4ToMat4(input: mat4[f32]) -> mat4[f32]
|
||||
{
|
||||
return mat4<f32>(input);
|
||||
return mat4[f32](input);
|
||||
}
|
||||
)";
|
||||
|
||||
|
|
@ -185,71 +185,71 @@ fn testMat4ToMat4(input: mat4<f32>) -> mat4<f32>
|
|||
REQUIRE_NOTHROW(shader = Nz::ShaderAst::Sanitize(*shader, options));
|
||||
|
||||
ExpectNZSL(*shader, R"(
|
||||
fn testMat2ToMat2(input: mat2<f32>) -> mat2<f32>
|
||||
fn testMat2ToMat2(input: mat2[f32]) -> mat2[f32]
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
fn testMat2ToMat3(input: mat2<f32>) -> mat3<f32>
|
||||
fn testMat2ToMat3(input: mat2[f32]) -> mat3[f32]
|
||||
{
|
||||
let temp: mat3<f32>;
|
||||
temp[0] = vec3<f32>(input[0], 0.000000);
|
||||
temp[1] = vec3<f32>(input[1], 0.000000);
|
||||
temp[2] = vec3<f32>(input[2], 1.000000);
|
||||
let temp: mat3[f32];
|
||||
temp[0] = vec3[f32](input[0], 0.000000);
|
||||
temp[1] = vec3[f32](input[1], 0.000000);
|
||||
temp[2] = vec3[f32](input[2], 1.000000);
|
||||
return temp;
|
||||
}
|
||||
|
||||
fn testMat2ToMat4(input: mat2<f32>) -> mat4<f32>
|
||||
fn testMat2ToMat4(input: mat2[f32]) -> mat4[f32]
|
||||
{
|
||||
let temp: mat4<f32>;
|
||||
temp[0] = vec4<f32>(input[0], 0.000000, 0.000000);
|
||||
temp[1] = vec4<f32>(input[1], 0.000000, 0.000000);
|
||||
temp[2] = vec4<f32>(input[2], 1.000000, 0.000000);
|
||||
temp[3] = vec4<f32>(input[3], 0.000000, 1.000000);
|
||||
let temp: mat4[f32];
|
||||
temp[0] = vec4[f32](input[0], 0.000000, 0.000000);
|
||||
temp[1] = vec4[f32](input[1], 0.000000, 0.000000);
|
||||
temp[2] = vec4[f32](input[2], 1.000000, 0.000000);
|
||||
temp[3] = vec4[f32](input[3], 0.000000, 1.000000);
|
||||
return temp;
|
||||
}
|
||||
|
||||
fn testMat3ToMat2(input: mat3<f32>) -> mat2<f32>
|
||||
fn testMat3ToMat2(input: mat3[f32]) -> mat2[f32]
|
||||
{
|
||||
let temp: mat2<f32>;
|
||||
let temp: mat2[f32];
|
||||
temp[0] = input[0].xy;
|
||||
temp[1] = input[1].xy;
|
||||
return temp;
|
||||
}
|
||||
|
||||
fn testMat3ToMat3(input: mat3<f32>) -> mat3<f32>
|
||||
fn testMat3ToMat3(input: mat3[f32]) -> mat3[f32]
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
fn testMat3ToMat4(input: mat3<f32>) -> mat4<f32>
|
||||
fn testMat3ToMat4(input: mat3[f32]) -> mat4[f32]
|
||||
{
|
||||
let temp: mat4<f32>;
|
||||
temp[0] = vec4<f32>(input[0], 0.000000);
|
||||
temp[1] = vec4<f32>(input[1], 0.000000);
|
||||
temp[2] = vec4<f32>(input[2], 0.000000);
|
||||
temp[3] = vec4<f32>(input[3], 1.000000);
|
||||
let temp: mat4[f32];
|
||||
temp[0] = vec4[f32](input[0], 0.000000);
|
||||
temp[1] = vec4[f32](input[1], 0.000000);
|
||||
temp[2] = vec4[f32](input[2], 0.000000);
|
||||
temp[3] = vec4[f32](input[3], 1.000000);
|
||||
return temp;
|
||||
}
|
||||
|
||||
fn testMat4ToMat2(input: mat4<f32>) -> mat2<f32>
|
||||
fn testMat4ToMat2(input: mat4[f32]) -> mat2[f32]
|
||||
{
|
||||
let temp: mat2<f32>;
|
||||
let temp: mat2[f32];
|
||||
temp[0] = input[0].xy;
|
||||
temp[1] = input[1].xy;
|
||||
return temp;
|
||||
}
|
||||
|
||||
fn testMat4ToMat3(input: mat4<f32>) -> mat3<f32>
|
||||
fn testMat4ToMat3(input: mat4[f32]) -> mat3[f32]
|
||||
{
|
||||
let temp: mat3<f32>;
|
||||
let temp: mat3[f32];
|
||||
temp[0] = input[0].xyz;
|
||||
temp[1] = input[1].xyz;
|
||||
temp[2] = input[2].xyz;
|
||||
return temp;
|
||||
}
|
||||
|
||||
fn testMat4ToMat4(input: mat4<f32>) -> mat4<f32>
|
||||
fn testMat4ToMat4(input: mat4[f32]) -> mat4[f32]
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ TEST_CASE("swizzle", "[Shader]")
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec = vec4<f32>(0.0, 1.0, 2.0, 3.0);
|
||||
let vec = vec4[f32](0.0, 1.0, 2.0, 3.0);
|
||||
let value = vec.xyz;
|
||||
}
|
||||
)";
|
||||
|
|
@ -35,8 +35,8 @@ void main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec: vec4<f32> = vec4<f32>(0.000000, 1.000000, 2.000000, 3.000000);
|
||||
let value: vec3<f32> = vec.xyz;
|
||||
let vec: vec4[f32] = vec4[f32](0.000000, 1.000000, 2.000000, 3.000000);
|
||||
let value: vec3[f32] = vec.xyz;
|
||||
}
|
||||
)");
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ OpFunctionEnd)");
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
vec.yzw = vec3<f32>(1.0, 2.0, 3.0);
|
||||
let vec = vec4[f32](0.0, 0.0, 0.0, 0.0);
|
||||
vec.yzw = vec3[f32](1.0, 2.0, 3.0);
|
||||
}
|
||||
)";
|
||||
|
||||
|
|
@ -79,8 +79,8 @@ void main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec: vec4<f32> = vec4<f32>(0.000000, 0.000000, 0.000000, 0.000000);
|
||||
vec.yzw = vec3<f32>(1.000000, 2.000000, 3.000000);
|
||||
let vec: vec4[f32] = vec4[f32](0.000000, 0.000000, 0.000000, 0.000000);
|
||||
vec.yzw = vec3[f32](1.000000, 2.000000, 3.000000);
|
||||
}
|
||||
)");
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ void main()
|
|||
fn main()
|
||||
{
|
||||
let value: f32 = 42.000000;
|
||||
let vec: vec3<f32> = value.xxx;
|
||||
let vec: vec3[f32] = value.xxx;
|
||||
}
|
||||
)");
|
||||
|
||||
|
|
@ -171,8 +171,8 @@ void main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec: vec3<f32> = (max(2.000000, 1.000000)).xxx;
|
||||
let vec2: vec3<f32> = (min(2.000000, 1.000000)).xxx;
|
||||
let vec: vec3[f32] = (max(2.000000, 1.000000)).xxx;
|
||||
let vec2: vec3[f32] = (min(2.000000, 1.000000)).xxx;
|
||||
}
|
||||
)");
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ OpFunctionEnd)");
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec = vec4<f32>(0.0, 1.0, 2.0, 3.0);
|
||||
let vec = vec4[f32](0.0, 1.0, 2.0, 3.0);
|
||||
let value = vec.xyz.yz.y.x.xxxx;
|
||||
}
|
||||
)";
|
||||
|
|
@ -219,8 +219,8 @@ void main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec: vec4<f32> = vec4<f32>(0.000000, 1.000000, 2.000000, 3.000000);
|
||||
let value: vec4<f32> = vec.xyz.yz.y.x.xxxx;
|
||||
let vec: vec4[f32] = vec4[f32](0.000000, 1.000000, 2.000000, 3.000000);
|
||||
let value: vec4[f32] = vec.xyz.yz.y.x.xxxx;
|
||||
}
|
||||
)");
|
||||
|
||||
|
|
@ -247,9 +247,9 @@ OpFunctionEnd)");
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec = vec4<f32>(0.0, 1.0, 2.0, 3.0);
|
||||
let vec = vec4[f32](0.0, 1.0, 2.0, 3.0);
|
||||
vec.wyxz.bra.ts.x = 0.0;
|
||||
vec.zyxw.ar.xy.yx = vec2<f32>(1.0, 0.0);
|
||||
vec.zyxw.ar.xy.yx = vec2[f32](1.0, 0.0);
|
||||
}
|
||||
)";
|
||||
|
||||
|
|
@ -268,9 +268,9 @@ void main()
|
|||
[entry(frag)]
|
||||
fn main()
|
||||
{
|
||||
let vec: vec4<f32> = vec4<f32>(0.000000, 1.000000, 2.000000, 3.000000);
|
||||
let vec: vec4[f32] = vec4[f32](0.000000, 1.000000, 2.000000, 3.000000);
|
||||
vec.wyxz.zxw.yx.x = 0.000000;
|
||||
vec.zyxw.wx.xy.yx = vec2<f32>(1.000000, 0.000000);
|
||||
vec.zyxw.wx.xy.yx = vec2[f32](1.000000, 0.000000);
|
||||
}
|
||||
)");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue