/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include ShaderResourceGroup ImageSrg : SRG_PerDraw { Texture3D m_texture3D; uint m_sliceIndex; float2 m_position; float2 m_size; } struct VSInput { uint m_vertexIndex : SV_VertexID; }; struct VSOutput { float4 m_position : SV_Position; float2 m_uv : UV0; uint m_slice : SLICE; }; struct PSOutput { float4 m_color : SV_Target0; }; VSOutput MainVS(VSInput vsInput) { VSOutput OUT; float2 uvs[4] = { {-1.0, -1.0}, {1.0, -1.0}, {-1.0, 1.0}, {1.0, 1.0} }; uint index = vsInput.m_vertexIndex%4; float seam = 0.01; float2 startPosition = ImageSrg::m_position; OUT.m_position = float4(startPosition + uvs[index] * ImageSrg::m_size, 0, 1.0); OUT.m_uv = (uvs[index]+1) * 0.5; OUT.m_slice = ImageSrg::m_sliceIndex; return OUT; } PSOutput MainPS(VSOutput psInput) { PSOutput OUT; // Get the image dimensions uint width; uint height; uint depth; uint numberOfLevels; ImageSrg::m_texture3D.GetDimensions(0, width, height, depth, numberOfLevels); OUT.m_color = ImageSrg::m_texture3D.Load(int4(width * psInput.m_uv.x, height * psInput.m_uv.y, psInput.m_slice, 0)); return OUT; }