diff --git a/bin/resources/bloom_bright.nzsl b/bin/resources/bloom_bright.nzsl index 278ea186c..63aaea8d8 100644 --- a/bin/resources/bloom_bright.nzsl +++ b/bin/resources/bloom_bright.nzsl @@ -1,44 +1,44 @@ [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [set(0), binding(1)] colorTexture: sampler2D, + [set(0), binding(0)] viewerData: uniform[ViewerData], + [set(0), binding(1)] colorTexture: sampler2D[f32], } struct FragIn { - [builtin(fragcoord)] fragcoord: vec4, - [location(0)] uv: vec2 + [builtin(fragcoord)] fragcoord: vec4[f32], + [location(0)] uv: vec2[f32] } struct FragOut { - [location(0)] color: vec4 + [location(0)] color: vec4[f32] } struct VertIn { - [location(0)] pos: vec2, - [location(1)] uv: vec2 + [location(0)] pos: vec2[f32], + [location(1)] uv: vec2[f32] } struct VertOut { - [builtin(position)] position: vec4, - [location(0)] uv: vec2 + [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(1.0, 1.0, 1.0) + (color / (BrightThreshold*BrightThreshold)); - color -= vec3(0.5, 0.5, 0.5); - color /= vec3(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(max(color, vec3(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(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(color, 1.0); + output.color = vec4[f32](color, 1.0); else - output.color = vec4(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(input.pos, 0.0, 1.0); + output.position = vec4[f32](input.pos, 0.0, 1.0); output.uv = input.uv; return output; diff --git a/bin/resources/bloom_final.nzsl b/bin/resources/bloom_final.nzsl index 544b5e14f..3b8da880c 100644 --- a/bin/resources/bloom_final.nzsl +++ b/bin/resources/bloom_final.nzsl @@ -1,44 +1,44 @@ [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - //[set(0), binding(1)] colorTexture: sampler2D, - [set(0), binding(2)] bloomTexture: sampler2D, + [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 + [location(0)] uv: vec2[f32] } struct FragOut { - [location(0)] color: vec4 + [location(0)] color: vec4[f32] } struct VertIn { - [location(0)] pos: vec2, - [location(1)] uv: vec2, + [location(0)] pos: vec2[f32], + [location(1)] uv: vec2[f32], } struct VertOut { - [location(0)] uv: vec2, - [builtin(position)] position: vec4 + [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(input.pos, 0.0, 1.0); + output.position = vec4[f32](input.pos, 0.0, 1.0); output.uv = input.uv; return output; diff --git a/bin/resources/deferred_frag.nzsl b/bin/resources/deferred_frag.nzsl index cc4b2f578..7a4e6b554 100644 --- a/bin/resources/deferred_frag.nzsl +++ b/bin/resources/deferred_frag.nzsl @@ -6,52 +6,52 @@ option AlphaTest: bool = false; struct BasicSettings { AlphaThreshold: f32, - DiffuseColor: vec4 + DiffuseColor: vec4[f32] } [layout(std140)] struct InstanceData { - worldMatrix: mat4, - invWorldMatrix: mat4 + worldMatrix: mat4[f32], + invWorldMatrix: mat4[f32] } [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [binding(1)] MaterialDiffuseMap: sampler2D, - [binding(2)] MaterialAlphaMap: sampler2D, - [binding(3)] TextureOverlay: sampler2D, - [binding(4)] instanceData: uniform, - [binding(5)] viewerData: uniform, + [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, - [location(1)] uv: vec2, - [location(2)] pos: vec3 + [location(0)] normal: vec3[f32], + [location(1)] uv: vec2[f32], + [location(2)] pos: vec3[f32] } struct OutputData { - [location(0)] diffuseMap: vec4, - [location(1)] normalMap: vec4, - [location(2)] positionMap: vec4 + [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((vec3(1.0, 1.0, 1.0) + input.normal) * 0.5, 1.0); - output.positionMap = vec4(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; } diff --git a/bin/resources/deferred_vert.nzsl b/bin/resources/deferred_vert.nzsl index a5abeee63..5d61da5fb 100644 --- a/bin/resources/deferred_vert.nzsl +++ b/bin/resources/deferred_vert.nzsl @@ -2,61 +2,61 @@ struct BasicSettings { AlphaThreshold: f32, - DiffuseColor: vec4 + DiffuseColor: vec4[f32] } [layout(std140)] struct InstanceData { - worldMatrix: mat4, - invWorldMatrix: mat4 + worldMatrix: mat4[f32], + invWorldMatrix: mat4[f32] } [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [binding(4)] instanceData: uniform, - [binding(5)] viewerData: uniform, + [binding(0)] settings: uniform[BasicSettings], + [binding(4)] instanceData: uniform[InstanceData], + [binding(5)] viewerData: uniform[ViewerData], } struct InputData { - [location(0)] pos: vec3, - [location(1)] normal: vec3, - [location(2)] uv: vec2 + [location(0)] pos: vec3[f32], + [location(1)] normal: vec3[f32], + [location(2)] uv: vec2[f32] } struct OutputData { - [location(0)] normal: vec3, - [location(1)] uv: vec2, - [location(2)] pos: vec3, - [builtin(position)] position: vec4 + [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(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(input.pos, 1.0); + output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](input.pos, 1.0); return output; } diff --git a/bin/resources/gamma.nzsl b/bin/resources/gamma.nzsl index 7db7e075b..ee34a66af 100644 --- a/bin/resources/gamma.nzsl +++ b/bin/resources/gamma.nzsl @@ -1,28 +1,28 @@ external { - [binding(0)] colorTexture: sampler2D + [binding(0)] colorTexture: sampler2D[f32] } struct FragIn { - [location(0)] uv: vec2 + [location(0)] uv: vec2[f32] } struct FragOut { - [location(0)] color: vec4 + [location(0)] color: vec4[f32] } struct VertIn { - [location(0)] pos: vec2, - [location(1)] uv: vec2 + [location(0)] pos: vec2[f32], + [location(1)] uv: vec2[f32] } struct VertOut { - [location(0)] vertUV: vec2, - [builtin(position)] position: vec4 + [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(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(input.pos, 0.0, 1.0); + output.position = vec4[f32](input.pos, 0.0, 1.0); output.vertUV = input.uv; return output; } diff --git a/bin/resources/gaussian_blur.nzsl b/bin/resources/gaussian_blur.nzsl index 506249a01..4f8323cb5 100644 --- a/bin/resources/gaussian_blur.nzsl +++ b/bin/resources/gaussian_blur.nzsl @@ -1,51 +1,51 @@ [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, + direction: vec2[f32], sizeFactor: f32 } external { - [set(0), binding(0)] viewerData: uniform, - [set(0), binding(1)] colorTexture: sampler2D, - [set(0), binding(2)] blurData: uniform + [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 + [location(0)] uv: vec2[f32] } struct FragOut { - [location(0)] color: vec4 + [location(0)] color: vec4[f32] } struct VertIn { - [location(0)] pos: vec2, - [location(1)] uv: vec2, + [location(0)] pos: vec2[f32], + [location(1)] uv: vec2[f32], } struct VertOut { - [location(0)] uv: vec2, - [builtin(position)] position: vec4 + [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(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(input.pos, 0.0, 1.0); + output.position = vec4[f32](input.pos, 0.0, 1.0); output.uv = input.uv; return output; diff --git a/bin/resources/god_rays.nzsl b/bin/resources/god_rays.nzsl index 9ec039bd2..8a88f4fcd 100644 --- a/bin/resources/god_rays.nzsl +++ b/bin/resources/god_rays.nzsl @@ -1,15 +1,15 @@ [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, //< TODO: Switch to world position + lightPosition: vec2[f32], //< TODO: Switch to world position } const SampleCount: i32 = 200; external { - [set(0), binding(0)] viewerData: uniform, - [set(0), binding(1)] settings: uniform, - [set(0), binding(2)] occluderTexture: sampler2D + [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 + [location(0)] uv: vec2[f32] } struct FragOut { - [location(0)] color: vec4 + [location(0)] color: vec4[f32] } struct VertIn { - [location(0)] pos: vec2, - [location(1)] uv: vec2 + [location(0)] pos: vec2[f32], + [location(1)] uv: vec2[f32] } struct VertOut { - [builtin(position)] position: vec4, - [location(0)] uv: vec2 + [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(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(input.pos, 0.0, 1.0); + output.position = vec4[f32](input.pos, 0.0, 1.0); output.uv = input.uv; return output; diff --git a/bin/resources/lighting.nzsl b/bin/resources/lighting.nzsl index 74ee4da40..71c1c819d 100644 --- a/bin/resources/lighting.nzsl +++ b/bin/resources/lighting.nzsl @@ -1,8 +1,8 @@ [layout(std140)] struct PointLight { - color: vec3, - position: vec3, + color: vec3[f32], + position: vec3[f32], radius: f32, invRadius: f32, @@ -11,11 +11,11 @@ struct PointLight [layout(std140)] struct SpotLight { - transformMatrix: mat4, + transformMatrix: mat4[f32], - color: vec3, - position: vec3, - direction: vec3, + 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, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [binding(1)] colorTexture: sampler2D, - [binding(2)] normalTexture: sampler2D, - [binding(3)] positionTexture: sampler2D, + [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, + [binding(0)] lightParameters: uniform[SpotLight], } struct FragIn { - [builtin(fragcoord)] fragcoord: vec4 + [builtin(fragcoord)] fragcoord: vec4[f32] } struct FragOut { - [location(0)] color: vec4 + [location(0)] color: vec4[f32] } struct VertIn { - [location(0)] pos: vec3 + [location(0)] pos: vec3[f32] } struct VertOut { - [builtin(position)] position: vec4 + [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(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(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(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, normal: vec3) -> f32 +fn compute_attenuation(worldPos: vec3[f32], normal: vec3[f32]) -> f32 { let distance = length(lightParameters.position - worldPos); diff --git a/bin/resources/skybox.nzsl b/bin/resources/skybox.nzsl index 93dc98872..72acb51d0 100644 --- a/bin/resources/skybox.nzsl +++ b/bin/resources/skybox.nzsl @@ -1,32 +1,32 @@ [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [binding(1)] skybox: samplerCube + [binding(0)] viewerData: uniform[ViewerData], + [binding(1)] skybox: samplerCube[f32] } struct VertOut { - [location(0)] uvw: vec3, - [builtin(position)] position: vec4 + [location(0)] uvw: vec3[f32], + [builtin(position)] position: vec4[f32] } struct FragOut { - [location(0)] color: vec4, + [location(0)] color: vec4[f32], [builtin(fragdepth)] depth: f32 } @@ -43,7 +43,7 @@ fn main(input: VertOut) -> FragOut struct VertIn { - [location(0)] position: vec3 + [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(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(input.position, 1.0); + output.position = viewerData.projectionMatrix * rotationMat * vec4[f32](input.position, 1.0); output.uvw = input.position.xyz; return output; diff --git a/bin/resources/tone_mapping.nzsl b/bin/resources/tone_mapping.nzsl index ccb35c0fe..6f9aac1d1 100644 --- a/bin/resources/tone_mapping.nzsl +++ b/bin/resources/tone_mapping.nzsl @@ -1,43 +1,43 @@ [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [set(0), binding(1)] inputTexture: sampler2D + [set(0), binding(0)] viewerData: uniform[ViewerData], + [set(0), binding(1)] inputTexture: sampler2D[f32] } struct FragIn { - [location(0)] uv: vec2, + [location(0)] uv: vec2[f32], } struct FragOut { - [location(0)] color: vec4 + [location(0)] color: vec4[f32] } struct VertIn { - [location(0)] pos: vec2, - [location(1)] uv: vec2, + [location(0)] pos: vec2[f32], + [location(1)] uv: vec2[f32], } struct VertOut { - [location(0)] uv: vec2, - [builtin(position)] position: vec4 + [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(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(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(input.pos, 0.0, 1.0); + output.position = vec4[f32](input.pos, 0.0, 1.0); output.uv = input.uv; return output; diff --git a/examples/DeferredShading/main.cpp b/examples/DeferredShading/main.cpp index e64af4b0d..8185568ab 100644 --- a/examples/DeferredShading/main.cpp +++ b/examples/DeferredShading/main.cpp @@ -17,8 +17,8 @@ constexpr std::size_t BloomSubdivisionCount = 5; [layout(std140)] struct PointLight { - color: vec3, - position: vec3, + color: vec3[f32], + position: vec3[f32], constant: f32, linear: f32, @@ -28,9 +28,9 @@ struct PointLight [layout(std140)] struct SpotLight { - color: vec3, - position: vec3, - direction: vec3, + 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, - position: vec3, - direction: vec3, + color: vec3[f32], + position: vec3[f32], + direction: vec3[f32], constant: f32, linear: f32, diff --git a/examples/RenderTest/main.cpp b/examples/RenderTest/main.cpp index 8f3873bd5..594455d36 100644 --- a/examples/RenderTest/main.cpp +++ b/examples/RenderTest/main.cpp @@ -17,50 +17,50 @@ option red: bool = false; [layout(std140)] struct Data { - projectionMatrix: mat4, - worldMatrix: mat4, - viewMatrix: mat4 + projectionMatrix: mat4[f32], + worldMatrix: mat4[f32], + viewMatrix: mat4[f32] } [set(0)] external { - [binding(0)] viewerData: uniform, + [binding(0)] viewerData: uniform[Data], } [set(1)] external { - [binding(0)] tex: sampler2D + [binding(0)] tex: sampler2D[f32] } struct VertIn { - [location(0)] position: vec3, - [location(1)] normal: vec3, - [location(2)] uv: vec2 + [location(0)] position: vec3[f32], + [location(1)] normal: vec3[f32], + [location(2)] uv: vec2[f32] } struct VertOut { - [builtin(position)] position: vec4, - [location(0)] normal: vec3, - [location(1)] uv: vec2 + [builtin(position)] position: vec4[f32], + [location(0)] normal: vec3[f32], + [location(1)] uv: vec2[f32] } struct FragOut { - [location(0)] color: vec4 + [location(0)] color: vec4[f32] } [entry(frag)] fn main(fragIn: VertOut) -> FragOut { - let lightDir = vec3(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(1.0, 0.0, 0.0, 1.0), vec4(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(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; diff --git a/include/Nazara/Shader/ShaderLangParser.hpp b/include/Nazara/Shader/ShaderLangParser.hpp index 0133967bc..c69c505fa 100644 --- a/include/Nazara/Shader/ShaderLangParser.hpp +++ b/include/Nazara/Shader/ShaderLangParser.hpp @@ -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(); diff --git a/src/Nazara/Graphics/Resources/Shaders/basic_material.nzsl b/src/Nazara/Graphics/Resources/Shaders/basic_material.nzsl index 114956a74..a26d2358a 100644 --- a/src/Nazara/Graphics/Resources/Shaders/basic_material.nzsl +++ b/src/Nazara/Graphics/Resources/Shaders/basic_material.nzsl @@ -21,50 +21,50 @@ const HasUV = (UvLocation >= 0); struct MaterialSettings { AlphaThreshold: f32, - DiffuseColor: vec4 + DiffuseColor: vec4[f32] } [layout(std140)] struct InstanceData { - worldMatrix: mat4, - invWorldMatrix: mat4 + worldMatrix: mat4[f32], + invWorldMatrix: mat4[f32] } [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [binding(1)] MaterialDiffuseMap: sampler2D, - [binding(2)] MaterialAlphaMap: sampler2D, - [binding(3)] TextureOverlay: sampler2D, - [binding(4)] instanceData: uniform, - [binding(5)] viewerData: uniform, + [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, - [location(1), cond(HasColor)] color: vec4 + [location(0), cond(HasUV)] uv: vec2[f32], + [location(1), cond(HasColor)] color: vec4[f32] } struct FragOut { - [location(0)] RenderTarget0: vec4 + [location(0)] RenderTarget0: vec4[f32] } [entry(frag)] @@ -99,29 +99,29 @@ fn main(input: FragIn) -> FragOut struct VertIn { [location(PosLocation)] - pos: vec3, + pos: vec3[f32], [cond(HasVertexColor), location(ColorLocation)] - color: vec4, + color: vec4[f32], [cond(HasUV), location(UvLocation)] - uv: vec2, + uv: vec2[f32], [cond(Billboard), location(BillboardCenterLocation)] - billboardCenter: vec3, + billboardCenter: vec3[f32], [cond(Billboard), location(BillboardSizeRotLocation)] - billboardSizeRot: vec4, //< width,height,sin,cos + billboardSizeRot: vec4[f32], //< width,height,sin,cos [cond(Billboard), location(BillboardColorLocation)] - billboardColor: vec4 + billboardColor: vec4[f32] } struct VertOut { - [location(0), cond(HasUV)] uv: vec2, - [location(1), cond(HasColor)] color: vec4, - [builtin(position)] position: vec4 + [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( + 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(viewerData.viewMatrix[0][0], viewerData.viewMatrix[1][0], viewerData.viewMatrix[2][0]); - let cameraUp = vec3(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(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(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(input.pos, 1.0); + output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](input.pos, 1.0); const if (HasColor) output.color = input.color; diff --git a/src/Nazara/Graphics/Resources/Shaders/blit.nzsl b/src/Nazara/Graphics/Resources/Shaders/blit.nzsl index 4b14dbd9d..c934a5728 100644 --- a/src/Nazara/Graphics/Resources/Shaders/blit.nzsl +++ b/src/Nazara/Graphics/Resources/Shaders/blit.nzsl @@ -1,25 +1,25 @@ external { - [binding(0)] texture: sampler2D + [binding(0)] texture: sampler2D[f32] } struct VertIn { - [location(0)] position: vec2, - [location(1)] uv: vec2 + [location(0)] position: vec2[f32], + [location(1)] uv: vec2[f32] } struct VertOut { - [builtin(position)] position: vec4, - [location(0)] uv: vec2 + [builtin(position)] position: vec4[f32], + [location(0)] uv: vec2[f32] } [entry(vert)] fn main(vertIn: VertIn) -> VertOut { let output: VertOut; - output.position = vec4(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 + [location(0)] color: vec4[f32] } [entry(frag)] diff --git a/src/Nazara/Graphics/Resources/Shaders/depth_material.nzsl b/src/Nazara/Graphics/Resources/Shaders/depth_material.nzsl index 9d2ed0a30..7cbb80bef 100644 --- a/src/Nazara/Graphics/Resources/Shaders/depth_material.nzsl +++ b/src/Nazara/Graphics/Resources/Shaders/depth_material.nzsl @@ -8,44 +8,44 @@ const HasUV = AlphaTest && (HasDiffuseTexture || HasAlphaTexture); struct BasicSettings { AlphaThreshold: f32, - DiffuseColor: vec4 + DiffuseColor: vec4[f32] } [layout(std140)] struct InstanceData { - worldMatrix: mat4, - invWorldMatrix: mat4 + worldMatrix: mat4[f32], + invWorldMatrix: mat4[f32] } [layout(std140)] struct ViewerData { - projectionMatrix: mat4, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [binding(1)] MaterialDiffuseMap: sampler2D, - [binding(2)] MaterialAlphaMap: sampler2D, - [binding(3)] TextureOverlay: sampler2D, - [binding(4)] instanceData: uniform, - [binding(5)] viewerData: uniform, + [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 + [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, - [location(1), cond(HasUV)] uv: vec2 + [location(0)] pos: vec3[f32], + [location(1), cond(HasUV)] uv: vec2[f32] } struct VertOut { - [location(0), cond(HasUV)] uv: vec2, - [builtin(position)] position: vec4 + [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(input.pos, 1.0); + output.position = viewerData.viewProjMatrix * instanceData.worldMatrix * vec4[f32](input.pos, 1.0); const if (HasUV) output.uv = input.uv; diff --git a/src/Nazara/Graphics/Resources/Shaders/phong_material.nzsl b/src/Nazara/Graphics/Resources/Shaders/phong_material.nzsl index 6328ec0f9..ce623ab78 100644 --- a/src/Nazara/Graphics/Resources/Shaders/phong_material.nzsl +++ b/src/Nazara/Graphics/Resources/Shaders/phong_material.nzsl @@ -36,19 +36,19 @@ struct MaterialSettings { // BasicSettings AlphaThreshold: f32, - DiffuseColor: vec4, + DiffuseColor: vec4[f32], // PhongSettings - AmbientColor: vec3, - SpecularColor: vec3, + AmbientColor: vec3[f32], + SpecularColor: vec3[f32], Shininess: f32, } [layout(std140)] struct InstanceData { - worldMatrix: mat4, - invWorldMatrix: mat4 + worldMatrix: mat4[f32], + invWorldMatrix: mat4[f32] } // TODO: Add enums @@ -60,64 +60,64 @@ const SpotLight = 2; struct Light { type: i32, - color: vec4, - factor: vec2, - parameter1: vec4, - parameter2: vec4, - parameter3: vec4, - 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, - invProjectionMatrix: mat4, - viewMatrix: mat4, - invViewMatrix: mat4, - viewProjMatrix: mat4, - invViewProjMatrix: mat4, - renderTargetSize: vec2, - invRenderTargetSize: vec2, - eyePosition: vec3 + 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, - [binding(1)] MaterialDiffuseMap: sampler2D, - [binding(2)] MaterialAlphaMap: sampler2D, - [binding(3)] TextureOverlay: sampler2D, - [binding(4)] instanceData: uniform, - [binding(5)] viewerData: uniform, - [binding(6)] lightData: uniform, - [binding(7)] MaterialEmissiveMap: sampler2D, - [binding(8)] MaterialHeightMap: sampler2D, - [binding(9)] MaterialNormalMap: sampler2D, - [binding(10)] MaterialSpecularMap: sampler2D, + [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, - [location(1), cond(HasUV)] uv: vec2, - [location(2), cond(HasColor)] color: vec4, - [location(3), cond(HasNormal)] normal: vec3, - [location(4), cond(HasNormalMapping)] tbnMatrix: mat3, - [builtin(position)] position: vec4, + [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 + [location(0)] RenderTarget0: vec4[f32] } [entry(frag)] @@ -145,15 +145,15 @@ fn main(input: VertToFrag) -> FragOut const if (HasNormal) { - let lightAmbient = vec3(0.0, 0.0, 0.0); - let lightDiffuse = vec3(0.0, 0.0, 0.0); - let lightSpecular = vec3(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; + let normal: vec3[f32]; const if (HasNormalMapping) - normal = normalize(input.tbnMatrix * (MaterialNormalMap.Sample(input.uv).xyz * 2.0 - vec3(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(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, + pos: vec3[f32], [cond(HasVertexColor), location(ColorLocation)] - color: vec4, + color: vec4[f32], [cond(HasUV), location(UvLocation)] - uv: vec2, + uv: vec2[f32], [cond(HasNormal), location(NormalLocation)] - normal: vec3, + normal: vec3[f32], [cond(HasTangent), location(TangentLocation)] - tangent: vec3, + tangent: vec3[f32], [cond(Billboard), location(BillboardCenterLocation)] - billboardCenter: vec3, + billboardCenter: vec3[f32], [cond(Billboard), location(BillboardSizeRotLocation)] - billboardSizeRot: vec4, //< width,height,sin,cos + billboardSizeRot: vec4[f32], //< width,height,sin,cos [cond(Billboard), location(BillboardColorLocation)] - billboardColor: vec4 + 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( + 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(viewerData.viewMatrix[0][0], viewerData.viewMatrix[1][0], viewerData.viewMatrix[2][0]); - let cameraUp = vec3(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(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(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(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(instanceData.worldMatrix); + let rotationMatrix = mat3[f32](instanceData.worldMatrix); const if (HasColor) output.color = input.color; diff --git a/src/Nazara/Shader/Ast/SanitizeVisitor.cpp b/src/Nazara/Shader/Ast/SanitizeVisitor.cpp index 448075fb5..c4dd366f7 100644 --- a/src/Nazara/Shader/Ast/SanitizeVisitor.cpp +++ b/src/Nazara/Shader/Ast/SanitizeVisitor.cpp @@ -431,7 +431,7 @@ namespace Nz::ShaderAst vectorComponentCount = std::get(GetExpressionType(*vectorExpr)).componentCount; } - // cast expression (turn fromMatrix[i] to vec3(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 expressions" }; + throw AstError{ "CrossProduct only works with vec3[f32] expressions" }; node.cachedExpressionType = type; break; diff --git a/src/Nazara/Shader/LangWriter.cpp b/src/Nazara/Shader/LangWriter.cpp index 65cb60bd5..4646bc6ad 100644 --- a/src/Nazara/Shader/LangWriter.cpp +++ b/src/Nazara/Shader/LangWriter.cpp @@ -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 || std::is_same_v || std::is_same_v) Append(std::to_string(arg)); else if constexpr (std::is_same_v) - Append("vec2(" + 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) Append("vec2(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ")"); else if constexpr (std::is_same_v) - Append("vec3(" + 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) Append("vec3(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ")"); else if constexpr (std::is_same_v) - Append("vec4(" + 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) Append("vec4(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ", " + std::to_string(arg.w) + ")"); else diff --git a/src/Nazara/Shader/ShaderLangParser.cpp b/src/Nazara/Shader/ShaderLangParser.cpp index f08ad1ca4..d73865aa0 100644 --- a/src/Nazara/Shader/ShaderLangParser.cpp +++ b/src/Nazara/Shader/ShaderLangParser.cpp @@ -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(); + 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(); - 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(identifierToken.data); diff --git a/tests/Engine/Shader/AccessMemberTest.cpp b/tests/Engine/Shader/AccessMemberTest.cpp index f53823db1..ac389c868 100644 --- a/tests/Engine/Shader/AccessMemberTest.cpp +++ b/tests/Engine/Shader/AccessMemberTest.cpp @@ -13,7 +13,7 @@ TEST_CASE("structure member access", "[Shader]") std::string_view nzslSource = R"( struct innerStruct { - field: vec3 + field: vec3[f32] } struct outerStruct @@ -23,7 +23,7 @@ struct outerStruct external { - [set(0), binding(0)] ubo: uniform + [set(0), binding(0)] ubo: uniform[outerStruct] } )"; diff --git a/tests/Engine/Shader/Branch.cpp b/tests/Engine/Shader/Branch.cpp index 85044c8c3..cab7aa33e 100644 --- a/tests/Engine/Shader/Branch.cpp +++ b/tests/Engine/Shader/Branch.cpp @@ -18,7 +18,7 @@ struct inputStruct external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[inputStruct] } [entry(frag)] @@ -97,7 +97,7 @@ struct inputStruct external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[inputStruct] } [entry(frag)] @@ -161,7 +161,7 @@ struct inputStruct external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[inputStruct] } [entry(frag)] diff --git a/tests/Engine/Shader/Const.cpp b/tests/Engine/Shader/Const.cpp index 7bb3634cf..4bee938d3 100644 --- a/tests/Engine/Shader/Const.cpp +++ b/tests/Engine/Shader/Const.cpp @@ -37,7 +37,7 @@ struct inputStruct external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[inputStruct] } [entry(frag)] @@ -73,7 +73,7 @@ struct inputStruct external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[inputStruct] } [entry(frag)] @@ -97,7 +97,7 @@ struct inputStruct external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[inputStruct] } [entry(frag)] @@ -118,18 +118,18 @@ const LightCount = 3; [layout(std140)] struct Light { - color: vec4 + color: vec4[f32] } [layout(std140)] struct LightData { - lights: [Light; LightCount] + lights: array[Light, LightCount] } external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[LightData] } [entry(frag)] @@ -152,7 +152,7 @@ fn main() [entry(frag)] fn main() { - let color: vec4 = (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 + color: vec4[f32] } [layout(std140)] struct LightData { - lights: [Light; LightCount] + lights: array[Light, LightCount] } external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[LightData] } [entry(frag)] @@ -209,7 +209,7 @@ fn main() [entry(frag)] fn main() { - let color: vec4 = (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]; diff --git a/tests/Engine/Shader/Loops.cpp b/tests/Engine/Shader/Loops.cpp index 182e21873..dbab1022f 100644 --- a/tests/Engine/Shader/Loops.cpp +++ b/tests/Engine/Shader/Loops.cpp @@ -18,7 +18,7 @@ struct inputStruct external { - [set(0), binding(0)] data: uniform + [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 + [set(0), binding(0)] data: uniform[inputStruct] } [entry(frag)] diff --git a/tests/Engine/Shader/Optimizations.cpp b/tests/Engine/Shader/Optimizations.cpp index e23d1484f..edf34e8d5 100644 --- a/tests/Engine/Shader/Optimizations.cpp +++ b/tests/Engine/Shader/Optimizations.cpp @@ -42,13 +42,13 @@ fn main() [entry(frag)] fn main() { - let output = vec4(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 = vec4(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(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 = vec4(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(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 = vec4(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(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 = vec4(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(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 = vec4(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 + value: vec4[f32] } external { - [set(0), binding(0)] data: uniform + [set(0), binding(0)] data: uniform[inputStruct] } [entry(frag)] @@ -250,7 +250,7 @@ fn main() [entry(frag)] fn main() { - let value: vec4 = data.value.zzzz; + let value: vec4[f32] = data.value.zzzz; } )"); } diff --git a/tests/Engine/Shader/Sanitizations.cpp b/tests/Engine/Shader/Sanitizations.cpp index 76025fee9..e0e565500 100644 --- a/tests/Engine/Shader/Sanitizations.cpp +++ b/tests/Engine/Shader/Sanitizations.cpp @@ -19,7 +19,7 @@ struct inputStruct external { - [set(0), binding(0)] data: uniform + [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 + [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) -> mat2 +fn testMat2ToMat2(input: mat2[f32]) -> mat2[f32] { - return mat2(input); + return mat2[f32](input); } -fn testMat2ToMat3(input: mat2) -> mat3 +fn testMat2ToMat3(input: mat2[f32]) -> mat3[f32] { - return mat3(input); + return mat3[f32](input); } -fn testMat2ToMat4(input: mat2) -> mat4 +fn testMat2ToMat4(input: mat2[f32]) -> mat4[f32] { - return mat4(input); + return mat4[f32](input); } -fn testMat3ToMat2(input: mat3) -> mat2 +fn testMat3ToMat2(input: mat3[f32]) -> mat2[f32] { - return mat2(input); + return mat2[f32](input); } -fn testMat3ToMat3(input: mat3) -> mat3 +fn testMat3ToMat3(input: mat3[f32]) -> mat3[f32] { - return mat3(input); + return mat3[f32](input); } -fn testMat3ToMat4(input: mat3) -> mat4 +fn testMat3ToMat4(input: mat3[f32]) -> mat4[f32] { - return mat4(input); + return mat4[f32](input); } -fn testMat4ToMat2(input: mat4) -> mat2 +fn testMat4ToMat2(input: mat4[f32]) -> mat2[f32] { - return mat2(input); + return mat2[f32](input); } -fn testMat4ToMat3(input: mat4) -> mat3 +fn testMat4ToMat3(input: mat4[f32]) -> mat3[f32] { - return mat3(input); + return mat3[f32](input); } -fn testMat4ToMat4(input: mat4) -> mat4 +fn testMat4ToMat4(input: mat4[f32]) -> mat4[f32] { - return mat4(input); + return mat4[f32](input); } )"; @@ -185,71 +185,71 @@ fn testMat4ToMat4(input: mat4) -> mat4 REQUIRE_NOTHROW(shader = Nz::ShaderAst::Sanitize(*shader, options)); ExpectNZSL(*shader, R"( -fn testMat2ToMat2(input: mat2) -> mat2 +fn testMat2ToMat2(input: mat2[f32]) -> mat2[f32] { return input; } -fn testMat2ToMat3(input: mat2) -> mat3 +fn testMat2ToMat3(input: mat2[f32]) -> mat3[f32] { - let temp: mat3; - temp[0] = vec3(input[0], 0.000000); - temp[1] = vec3(input[1], 0.000000); - temp[2] = vec3(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) -> mat4 +fn testMat2ToMat4(input: mat2[f32]) -> mat4[f32] { - let temp: mat4; - temp[0] = vec4(input[0], 0.000000, 0.000000); - temp[1] = vec4(input[1], 0.000000, 0.000000); - temp[2] = vec4(input[2], 1.000000, 0.000000); - temp[3] = vec4(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) -> mat2 +fn testMat3ToMat2(input: mat3[f32]) -> mat2[f32] { - let temp: mat2; + let temp: mat2[f32]; temp[0] = input[0].xy; temp[1] = input[1].xy; return temp; } -fn testMat3ToMat3(input: mat3) -> mat3 +fn testMat3ToMat3(input: mat3[f32]) -> mat3[f32] { return input; } -fn testMat3ToMat4(input: mat3) -> mat4 +fn testMat3ToMat4(input: mat3[f32]) -> mat4[f32] { - let temp: mat4; - temp[0] = vec4(input[0], 0.000000); - temp[1] = vec4(input[1], 0.000000); - temp[2] = vec4(input[2], 0.000000); - temp[3] = vec4(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) -> mat2 +fn testMat4ToMat2(input: mat4[f32]) -> mat2[f32] { - let temp: mat2; + let temp: mat2[f32]; temp[0] = input[0].xy; temp[1] = input[1].xy; return temp; } -fn testMat4ToMat3(input: mat4) -> mat3 +fn testMat4ToMat3(input: mat4[f32]) -> mat3[f32] { - let temp: mat3; + 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) -> mat4 +fn testMat4ToMat4(input: mat4[f32]) -> mat4[f32] { return input; } diff --git a/tests/Engine/Shader/Swizzle.cpp b/tests/Engine/Shader/Swizzle.cpp index e5d4bf22a..9ffeac2ab 100644 --- a/tests/Engine/Shader/Swizzle.cpp +++ b/tests/Engine/Shader/Swizzle.cpp @@ -16,7 +16,7 @@ TEST_CASE("swizzle", "[Shader]") [entry(frag)] fn main() { - let vec = vec4(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 = vec4(0.000000, 1.000000, 2.000000, 3.000000); - let value: vec3 = 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(0.0, 0.0, 0.0, 0.0); - vec.yzw = vec3(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 = vec4(0.000000, 0.000000, 0.000000, 0.000000); - vec.yzw = vec3(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 = value.xxx; + let vec: vec3[f32] = value.xxx; } )"); @@ -171,8 +171,8 @@ void main() [entry(frag)] fn main() { - let vec: vec3 = (max(2.000000, 1.000000)).xxx; - let vec2: vec3 = (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(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 = vec4(0.000000, 1.000000, 2.000000, 3.000000); - let value: vec4 = 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(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(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 = vec4(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(1.000000, 0.000000); + vec.zyxw.wx.xy.yx = vec2[f32](1.000000, 0.000000); } )");