-- glslfx version 0.1 // // Copyright 2018 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // -- configuration { "techniques": { "default": { "FullscreenVertex": { "source": [ "Fullscreen.Vertex" ] }, "CompositeFragmentNoDepth": { "source": [ "Composite.FragmentNoDepth" ] }, "CompositeFragmentWithDepth": { "source": [ "Composite.FragmentWithDepth" ] } }, "Metal": { "FullscreenVertex": { "source": [ "Fullscreen.Metal.Common", "Fullscreen.Metal.Vertex" ] }, "CompositeFragmentNoDepth": { "source": [ "Fullscreen.Metal.Common", "Composite.Metal.FragmentNoDepth" ] }, "CompositeFragmentWithDepth": { "source": [ "Fullscreen.Metal.Common", "Composite.Metal.FragmentWithDepth" ] } } } } -- glsl Fullscreen.Vertex #version 450 layout(location = 0) in vec4 position; layout(location = 1) in vec2 uvIn; layout(location = 0) out vec2 uv; void main(void) { gl_Position = position; uv = uvIn; } -- glsl Composite.FragmentNoDepth #version 450 layout(location = 0) in vec2 uv; layout (binding = 0) uniform sampler2D color; void main(void) { gl_FragColor = texture(color, uv); } -- glsl Composite.FragmentWithDepth #version 450 layout(location = 0) in vec2 uv; layout (binding = 0) uniform sampler2D color; layout (binding = 1) uniform sampler2D depth; void main(void) { float depth = texture(depth, uv).r; gl_FragColor = texture(color, uv); gl_FragDepth = depth; } -- glsl Fullscreen.Metal.Common struct Interpolated { float4 position [[position]]; float2 uv; }; -- glsl Fullscreen.Metal.Vertex struct Vertex { float4 position [[attribute(0)]]; float2 uvIn [[attribute(1)]]; }; vertex Interpolated vertexEntryPoint(Vertex v [[stage_in]]) { Interpolated out; out.position = v.position; out.uv = v.uvIn; return out; } -- glsl Composite.Metal.FragmentNoDepth constexpr sampler texSampler(address::clamp_to_edge); fragment half4 fragmentEntryPoint( Interpolated input[[stage_in]], texture2d color[[texture(0)]]) { return color.sample(texSampler, input.uv); } -- glsl Composite.Metal.FragmentWithDepth struct Out { float4 color [[color(0)]]; float depth [[depth(any)]]; }; constexpr sampler texSampler(address::clamp_to_edge); fragment Out fragmentEntryPoint( Interpolated input[[stage_in]], texture2d color[[texture(0)]], depth2d depth[[texture(1)]]) { Out out; out.depth = depth.sample(texSampler, input.uv); out.color = color.sample(texSampler, input.uv); return out; }