Shader: Switch type<subtype> to type[subtype]
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user