/* * 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 #include ShaderResourceGroup ImageSrg : SRG_PerDraw { Texture3D m_texture3D; uint m_sliceCount; float2 m_position; float2 m_size; uint2 m_resolution; } struct VSInput { uint m_vertexIndex :SV_VertexID; uint m_instanceIndex :SV_InstanceID; }; struct VSOutput { float4 m_position : SV_Position; float2 m_uv : UV0; uint slice : SLICE; }; struct PSOutput { float4 m_color : SV_Target0; }; VSOutput MainVS(VSInput vsInput) { VSOutput OUT; float2 uvs[4] = { {0.0, 0.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 1.0} }; uint index = vsInput.m_vertexIndex%4; uint sliceIndex = vsInput.m_instanceIndex; float seam = 0.01; float2 startPosition = ImageSrg::m_position + float2((ImageSrg::m_size.x + seam) * sliceIndex, 0.0); OUT.m_position = float4(startPosition + uvs[index] * ImageSrg::m_size, 0, 1.0); OUT.m_uv = uvs[index]; OUT.slice = 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); float3 texColor = ImageSrg::m_texture3D.Load(int4(width * psInput.m_uv.x, height * psInput.m_uv.y, psInput.slice, 0)).xyz; OUT.m_color = float4(TransformColor(texColor, ColorSpaceId::LinearSRGB, ColorSpaceId::SRGB), 1.0); return OUT; }