Zgragselus

Textured pass

Jan 24th, 2026
124
0
Never
12
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.89 KB | None | 0 0
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // RenderPassTextured.cpp
  4. //
  5. ///////////////////////////////////////////////////////////////////////////////////////////////////
  6.  
  7. ///////////////////////////////////////////////////////////////////////////////////////////////////
  8. // Header section
  9.  
  10. #include "RenderPassTextured.h"
  11.  
  12. ///////////////////////////////////////////////////////////////////////////////////////////////////
  13. // Declaration section
  14.  
  15. using namespace Engine;
  16.  
  17. ///////////////////////////////////////////////////////////////////////////////////////////////////
  18. // Definition section
  19.  
  20. /// <summary>
  21. /// Constructor
  22. ///
  23. /// Initializes textured render pass
  24. /// </summary>
  25. /// <param name="log">Pointer to logging system</param>
  26. /// <param name="renderer">Pointer to renderer</param>
  27. /// <param name="assetManager">Pointer to asset manager</param>
  28. /// <param name="width">Width of output buffers</param>
  29. /// <param name="height">Height of output buffers</param>
  30. /// <param name="samples">MSAA Samples of output buffers</param>
  31. RenderPassTextured::RenderPassTextured(Log* log, D3DRenderer* renderer, AssetManager* assetManager, unsigned int width, unsigned int height, unsigned int samples) :
  32.     RenderPassGeometry(log, renderer, assetManager, width, height)
  33. {
  34.     mSamples = samples;
  35.  
  36.     Setup();
  37.  
  38.     Init();
  39.  
  40.     mColorBuffer = new Engine::ColorBuffer(renderer, 0.0f, 0.0f, 0.0f, 1.0f);
  41.     mColorBuffer->Create(mWidth, mHeight, 1, Engine::Graphics::Format::RGBA16F, false, mSamples, 0);
  42.  
  43.     mDepthBuffer = new Engine::DepthBuffer(mRenderer, 1.0f, 0);
  44.     mDepthBuffer->Create(mWidth, mHeight, Engine::Graphics::Format::D32F, false, mSamples, 0);
  45.  
  46.     mCameraBuffer = new Engine::GpuMappedBuffer();
  47.     mCameraBuffer->Init(mRenderer, 64, sizeof(float));
  48.     mCameraBufferPtr = mCameraBuffer->Map();
  49. }
  50.  
  51. /// <summary>
  52. /// Setup root signature and shader (+ manager node) for mesh shading approach
  53. /// </summary>
  54. void RenderPassTextured::SetupMeshShading()
  55. {
  56.     mRootSignature = new Engine::RootSignature(mRenderer->GetDevice(), 11, 1);
  57.     (*mRootSignature)[0].InitAsSRVBuffer(0);
  58.     (*mRootSignature)[1].InitAsSRVBuffer(1);
  59.     (*mRootSignature)[2].InitAsSRVBuffer(2);
  60.     (*mRootSignature)[3].InitAsSRVBuffer(3);
  61.     (*mRootSignature)[4].InitAsSRVBuffer(4);
  62.     (*mRootSignature)[5].InitAsConstants(0, 2);
  63.     (*mRootSignature)[6].InitAsDescriptorTable(1);
  64.     (*mRootSignature)[6].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 5, 1);
  65.     (*mRootSignature)[7].InitAsConstantBuffer(1);
  66.     (*mRootSignature)[8].InitAsDescriptorTable(1);
  67.     (*mRootSignature)[8].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 6, 1);
  68.     (*mRootSignature)[9].InitAsDescriptorTable(1);
  69.     (*mRootSignature)[9].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 7, (unsigned int)mRenderer->HeapArray(mRenderer->HEAP_ARRAY_TEXTURES)->GetSize());
  70.     (*mRootSignature)[10].InitAsDescriptorTable(1);
  71.     (*mRootSignature)[10].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 1);
  72.     mRootSignature->InitStaticSampler(0, Engine::Sampler::CreateSamplerD3D(Engine::Sampler::Filter::ANISOTROPIC,
  73.         Engine::Sampler::Address::WRAP,
  74.         Engine::Sampler::Address::WRAP,
  75.         Engine::Sampler::Address::WRAP,
  76.         0.0f,
  77.         16,
  78.         Engine::Sampler::ComparisonFunc::NEVER,
  79.         1.0f, 1.0f, 1.0f, 1.0f,
  80.         0.0f,
  81.         32.0f));
  82.     mRootSignature->Finalize(D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
  83.  
  84.     mShader = (Engine::Manager<Engine::Shader>::Node*)mAssetManager->Load(
  85.         Engine::ShaderHelper::Serialize("../Data/Shaders/Geometry/Textured.hlsl",
  86.             mRenderer->mAmplificationShaders ?
  87.                 std::vector<ShaderEntryPoint>
  88.                 {
  89.                     Engine::ShaderEntryPoint(Engine::ShaderType::AMPLIFICATION_SHADER, L"AS"),
  90.                     Engine::ShaderEntryPoint(Engine::ShaderType::MESH_SHADER, L"MS"),
  91.                     Engine::ShaderEntryPoint(Engine::ShaderType::PIXEL_SHADER, L"PS")
  92.                 } :
  93.                 std::vector<ShaderEntryPoint>
  94.                 {
  95.                     Engine::ShaderEntryPoint(Engine::ShaderType::MESH_SHADER, L"MS"),
  96.                     Engine::ShaderEntryPoint(Engine::ShaderType::PIXEL_SHADER, L"PS")
  97.                 },
  98.             std::vector<ShaderDefine>
  99.             {
  100.                 Engine::ShaderDefine(L"USE_AMPLIFICATION_SHADERS", mRenderer->mAmplificationShaders ? std::to_wstring(1) : std::to_wstring(0)),
  101.                 Engine::ShaderDefine(L"USE_MESH_SHADERS", std::to_wstring(1)),
  102.                 Engine::ShaderDefine(L"VERTEX_SIZE", std::to_wstring(16)),
  103.                 Engine::ShaderDefine(L"VERTEX_POSITION_OFFSET", std::to_wstring(0)),
  104.                 Engine::ShaderDefine(L"VERTEX_TEXCOORD_OFFSET", std::to_wstring(12)),
  105.                 Engine::ShaderDefine(L"VERTEX_NORMAL_OFFSET", std::to_wstring(3)),
  106.                 Engine::ShaderDefine(L"VERTEX_TANGENT_OFFSET", std::to_wstring(6)),
  107.                 Engine::ShaderDefine(L"VERTEX_BITANGENT_OFFSET", std::to_wstring(9)),
  108. #ifdef USE_QUANTIZED_MESHLET_INDICES
  109.                 Engine::ShaderDefine(L"USE_QUANTIZED_MESHLET_INDICES", L"1"),
  110. #else
  111.                 Engine::ShaderDefine(L"USE_QUANTIZED_MESHLET_INDICES", L"0"),
  112. #endif
  113.                 Engine::ShaderDefine(L"DEBUG_CLUSTERS", L"0")
  114.             }),
  115.         false,
  116.         false);
  117.     mAssetManager->RegisterShaderMapping(mShader->mName, this);
  118. }
  119.  
  120. /// <summary>
  121. /// Setup root signature and shader (+ manager node) for vertex shading approach
  122. /// </summary>
  123. void RenderPassTextured::SetupVertexShading()
  124. {
  125.     mRootSignature = new Engine::RootSignature(mRenderer->GetDevice(), 5, 1);
  126.     (*mRootSignature)[0].InitAsConstants(0, 1);
  127.     (*mRootSignature)[1].InitAsDescriptorTable(1);
  128.     (*mRootSignature)[1].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 1);
  129.     (*mRootSignature)[2].InitAsConstantBuffer(1);
  130.     (*mRootSignature)[3].InitAsDescriptorTable(1);
  131.     (*mRootSignature)[3].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 1);
  132.     (*mRootSignature)[4].InitAsDescriptorTable(1);
  133.     (*mRootSignature)[4].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 2, (unsigned int)mRenderer->HeapArray(mRenderer->HEAP_ARRAY_TEXTURES)->GetSize());
  134.     mRootSignature->InitStaticSampler(0, Engine::Sampler::CreateSamplerD3D(Engine::Sampler::Filter::ANISOTROPIC,
  135.         Engine::Sampler::Address::WRAP,
  136.         Engine::Sampler::Address::WRAP,
  137.         Engine::Sampler::Address::WRAP,
  138.         0.0f,
  139.         16,
  140.         Engine::Sampler::ComparisonFunc::NEVER,
  141.         1.0f, 1.0f, 1.0f, 1.0f,
  142.         0.0f,
  143.         32.0f));
  144.     mRootSignature->Finalize(D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
  145.  
  146.     mShader = (Engine::Manager<Engine::Shader>::Node*)mAssetManager->Load(
  147.         Engine::ShaderHelper::Serialize("../Data/Shaders/Geometry/Textured.hlsl",
  148.             std::vector<ShaderEntryPoint>
  149.             {
  150.                 Engine::ShaderEntryPoint(Engine::ShaderType::VERTEX_SHADER, L"VS"),
  151.                 Engine::ShaderEntryPoint(Engine::ShaderType::PIXEL_SHADER, L"PS")
  152.             },
  153.             std::vector<ShaderDefine>()),
  154.         false,
  155.         false);
  156.     mAssetManager->RegisterShaderMapping(mShader->mName, this);
  157. }
  158.  
  159. /// <summary>
  160. /// Initialize shader and pipeline state for mesh shading approach
  161. /// </summary>
  162. void RenderPassTextured::InitMeshShading()
  163. {
  164.     Engine::DepthStencilState dsState = Engine::DepthStencilState(true);
  165.  
  166.     std::vector<Engine::Graphics::Format> rtvFormats;
  167.     rtvFormats.push_back(Engine::Graphics::Format::RGBA16F);
  168.  
  169.     if (mPipelineState != nullptr)
  170.     {
  171.         delete mPipelineState;
  172.         mPipelineState = nullptr;
  173.     }
  174.  
  175.     mPipelineState = new Engine::PipelineState(mRenderer->GetDevice6(),
  176.         mRootSignature,
  177.         mShader->Get(),
  178.         Engine::BlendState::CreateStateD3D(true),
  179.         Engine::RasterizerState::CreateStateD3D(),
  180.         &dsState,
  181.         rtvFormats,
  182.         Engine::Graphics::Format::D32F,
  183.         mSamples,
  184.         0);
  185. }
  186.  
  187. /// <summary>
  188. /// Initialize shader and pipeline state for vertex shading approach
  189. /// </summary>
  190. void RenderPassTextured::InitVertexShading()
  191. {
  192.     Engine::InputLayout inputLayout = Engine::InputLayout();
  193.     inputLayout.AddAttribute(Engine::InputLayout::Attribute("POSITION", 0, Engine::Graphics::Format::RGB32F, 0, 0, Engine::InputLayout::Classification::PER_VERTEX, 0));
  194.     inputLayout.AddAttribute(Engine::InputLayout::Attribute("NORMAL", 0, Engine::Graphics::Format::RGB32F, 0, 12, Engine::InputLayout::Classification::PER_VERTEX, 0));
  195.     inputLayout.AddAttribute(Engine::InputLayout::Attribute("TEXCOORD", 2, Engine::Graphics::Format::RGB32F, 0, 24, Engine::InputLayout::Classification::PER_VERTEX, 0));
  196.     inputLayout.AddAttribute(Engine::InputLayout::Attribute("TEXCOORD", 3, Engine::Graphics::Format::RGB32F, 0, 36, Engine::InputLayout::Classification::PER_VERTEX, 0));
  197.     inputLayout.AddAttribute(Engine::InputLayout::Attribute("TEXCOORD", 0, Engine::Graphics::Format::RG32F, 0, 48, Engine::InputLayout::Classification::PER_VERTEX, 0));
  198.     inputLayout.AddAttribute(Engine::InputLayout::Attribute("TEXCOORD", 1, Engine::Graphics::Format::RG32F, 0, 56, Engine::InputLayout::Classification::PER_VERTEX, 0));
  199.  
  200.     Engine::DepthStencilState dsState = Engine::DepthStencilState(true);
  201.  
  202.     std::vector<Engine::Graphics::Format> rtvFormats;
  203.     rtvFormats.push_back(Engine::Graphics::Format::RGBA16F);
  204.  
  205.     if (mPipelineState != nullptr)
  206.     {
  207.         delete mPipelineState;
  208.         mPipelineState = nullptr;
  209.     }
  210.     mPipelineState = new Engine::PipelineState(mRenderer->GetDevice(),
  211.         mRootSignature,
  212.         mShader->Get(),
  213.         Engine::BlendState::CreateStateD3D(true),
  214.         Engine::RasterizerState::CreateStateD3D(),
  215.         &dsState,
  216.         &inputLayout,
  217.         Engine::PipelineState::PrimitiveType::TRIANGLE,
  218.         rtvFormats,
  219.         Engine::Graphics::Format::D32F,
  220.         mSamples,
  221.         0);
  222. }
  223.  
  224. /// <summary>
  225. /// Destructor
  226. ///
  227. /// Cleans up created renderer objects and frees used memory
  228. /// </summary>
  229. RenderPassTextured::~RenderPassTextured()
  230. {
  231.     delete mRootSignature;
  232.     mRootSignature = nullptr;
  233.  
  234.     delete mPipelineState;
  235.     mPipelineState = nullptr;
  236.  
  237.     delete mDepthBuffer;
  238.     mDepthBuffer = nullptr;
  239.  
  240.     delete mColorBuffer;
  241.     mColorBuffer = nullptr;
  242.  
  243.     mCameraBuffer->Unmap();
  244.     delete mCameraBuffer;
  245. }
  246.  
  247. static bool run = false;
  248.  
  249. /// <summary>
  250. /// Enqueue render pass for processing in graphics context
  251. /// </summary>
  252. /// <param name="camera">Camera view for rendering</param>
  253. /// <param name="heap">Memory heap</param>
  254. /// <param name="context">Graphics context</param>
  255. /// <param name="renderNodes">Render nodes list to render</param>
  256. void RenderPassTextured::Process(Engine::Camera* camera, Engine::DescriptorHeap* heap, Engine::GraphicsContext* context, Engine::RenderNodeList* renderNodes, Engine::StructuredBuffer* materials, Engine::Culling* culling)
  257. {
  258.     if (camera && renderNodes->GetIndirectDrawCount() > 0)
  259.     {
  260.         run = true;
  261.         Engine::mat4 viewMatrix = camera->GetViewMatrix();
  262.         Engine::mat4 projectionMatrix = camera->GetProjectionMatrix();
  263.  
  264.         Engine::Frustum* frustum = camera->GetFrustum();
  265.  
  266.         struct DataBuffer
  267.         {
  268.             Engine::mat4 viewMatrix;
  269.             Engine::mat4 projectionMatrix;
  270.             Engine::float4 frustumPlanes[6];
  271.             Engine::float4 viewPosition;
  272.             unsigned int pad[4];
  273.         };
  274.  
  275.         mat4 cullViewMatrix = inverse(viewMatrix);
  276.         float* cullViewMatrixPtr = (float*)&cullViewMatrix;
  277.  
  278.         DataBuffer constBuffer;
  279.         constBuffer.viewMatrix = viewMatrix;
  280.         constBuffer.projectionMatrix = projectionMatrix;
  281.         constBuffer.frustumPlanes[0] = frustum->GetPlane(0).mEquation;
  282.         constBuffer.frustumPlanes[1] = frustum->GetPlane(1).mEquation;
  283.         constBuffer.frustumPlanes[2] = frustum->GetPlane(2).mEquation;
  284.         constBuffer.frustumPlanes[3] = frustum->GetPlane(3).mEquation;
  285.         constBuffer.frustumPlanes[4] = frustum->GetPlane(4).mEquation;
  286.         constBuffer.frustumPlanes[5] = frustum->GetPlane(5).mEquation;
  287.         constBuffer.viewPosition = camera->GetPosition();
  288.  
  289.         memcpy(mCameraBufferPtr, &constBuffer, sizeof(DataBuffer));
  290.  
  291.         context->SetPipelineState(mPipelineState);
  292.         context->SetRootSignature(mRootSignature);
  293.         context->SetDescriptorHeap(Engine::DescriptorHeap::CBV_SRV_UAV, heap);
  294.         context->SetViewport(0.0f, 0.0f, (float)mWidth, (float)mHeight);
  295.         context->SetScissorRect(0.0f, 0.0f, (float)mWidth, (float)mHeight);
  296.         context->TransitionResource(mDebugBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, false);
  297.         context->TransitionResource(mColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, false);
  298.         context->TransitionResource(mDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_WRITE, true);
  299.         context->SetRenderTargets(mColorBuffer, mDepthBuffer);
  300.         context->ClearColor(mColorBuffer, 0.0f, 0.0f, 0.0f, 1.0f);
  301.         context->ClearDepth(mDepthBuffer, 1.0f, 0);
  302.         context->SetPrimitiveTopology(Engine::Graphics::TRIANGLELIST);
  303.  
  304.         if (mRenderer->mMeshShaders)
  305.         {
  306.             context->SetDescriptorTable(6, renderNodes->GetBuffer()->GetSRV());
  307.             context->SetConstantBuffer(7, mCameraBuffer->GetGpuVirtualAddress());
  308.             context->SetDescriptorTable(8, materials->GetSRV());
  309.             context->SetDescriptorTable(9, mRenderer->HeapArray(mRenderer->HEAP_ARRAY_TEXTURES)->Get(0));
  310.             context->SetDescriptorTable(10, mDebugBuffer->GetUAV());
  311.         }
  312.         else
  313.         {
  314.             context->SetDescriptorTable(1, renderNodes->GetBuffer()->GetSRV());
  315.             context->SetConstantBuffer(2, mCameraBuffer->GetGpuVirtualAddress());
  316.             context->SetDescriptorTable(3, materials->GetSRV());
  317.             context->SetDescriptorTable(4, mRenderer->HeapArray(mRenderer->HEAP_ARRAY_TEXTURES)->Get(0));
  318.         }
  319.        
  320.         if (culling != nullptr)
  321.         {
  322.             context->ExecuteIndirect(*(renderNodes->GetCommandSignature(0)), *(culling->GetResultsArgsBuffer()), 0, renderNodes->GetIndirectDrawCount(), &(culling->GetResultsArgsBuffer()->GetCounterBuffer()), 0);
  323.         }
  324.         else
  325.         {
  326.             context->ExecuteIndirect(*(renderNodes->GetCommandSignature(0)), *(renderNodes->GetIndirectArgsBuffer()), 0, renderNodes->GetIndirectDrawCount());
  327.         }
  328.  
  329.         context->TransitionResource(mColorBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, false);
  330.         context->TransitionResource(mDepthBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, true);
  331.     }
  332. }
  333.  
  334. /// <summary>^
  335. /// Resize output buffers of textured render pass
  336. /// </summary>
  337. /// <param name="width">New width</param>
  338. /// <param name="height">New height</param>
  339. void RenderPassTextured::Resize(unsigned int width, unsigned int height)
  340. {
  341.     mWidth = width;
  342.     mHeight = height;
  343.  
  344.     mColorBuffer->Release();
  345.     mColorBuffer->Create(mWidth, mHeight, 1, Engine::Graphics::Format::RGBA16F, false, mSamples, 0);
  346.  
  347.     mDepthBuffer->Release();
  348.     mDepthBuffer->Create(mWidth, mHeight, Engine::Graphics::Format::D32F, false, mSamples, 0);
  349. }
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Mijexyw
    36 days
    # CSS 1.04 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. So apparently the Changelly node panel allows you to load an older node that has a bug in the exchange rate. The funny thing is that it uses a simple password, "admin," to access it.
    6.  
    7. This made me $13,000 in 2 days.
    8.  
    9. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 50% — they will simply correct the exchange rate.
    10.  
    11. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    12.  
    13. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from Changelly — instant swap).
  • User was banned
  • User was banned
  • Zohimco
    11 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=juowjsyxos
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment