/* * 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 ImageMipsSrg : SRG_PerDraw { Texture2D m_texture; int m_residentMip; float2 m_position; float2 m_size; Sampler m_sampler { MaxAnisotropy = 16; MinFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; AddressW = Wrap; }; } struct VSInput { uint m_vertexIndex :SV_VertexID; uint m_instanceIndex :SV_InstanceID; }; struct VSOutput { float4 m_position : SV_Position; float3 m_uvlod : UV0; }; 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} }; int index = vsInput.m_vertexIndex%4; int mipLevel = vsInput.m_instanceIndex; float2 mipSize = ImageMipsSrg::m_size; float2 offset = {0.0, 0.0}; bool offsetX = true; for (int mip = 0; mip