Serenity79

Members
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

350 Neutral

About Serenity79

  • Rank
    Member

Personal Information

  • Interests
    |programmer|
  1. For DX11 I wrote RAII wrappers like this: class OmBlendState { public:     //blendFactor == nullptr => DX will use{ 1, 1, 1, 1 }     OmBlendState(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11BlendState* blendState, const float* blendFactor = nullptr, unsigned sampleMask = 0xFFFFFFFF);     ~OmBlendState(); private:     const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& m_context; }; OmBlendState::OmBlendState(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11BlendState* blendState, const float* blendFactor /*=nullptr*/, unsigned sampleMask /*=0xFFFFFFFF*/)     : m_context{context} {     context->OMSetBlendState(blendState, blendFactor, sampleMask); } OmBlendState::~OmBlendState() {     m_context->OMSetBlendState(nullptr, nullptr, 0xFFFFFFFF); } Usage: void TranspPass::Render() { ... OmBlendState bs{ m_context, m_omAlphaBlendState.Get() }; ... m_context->DrawIndexedInstanced(iaBuff.GetIndexCount(), static_cast<UINT>(instData.size()), 0, 0, 0); } Wrappers upon other states have different interface, for example RT: class OmRenderTargets { public: //Max RTS - 8 (DX11 && DX12) OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11DepthStencilView* pDepthStencilView); OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11RenderTargetView* rtv0, ID3D11DepthStencilView* pDepthStencilView); OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11RenderTargetView* rtv0, ID3D11RenderTargetView* rtv1, ID3D11DepthStencilView* pDepthStencilView); OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11RenderTargetView* rtv0, ID3D11RenderTargetView* rtv1, ID3D11RenderTargetView* rtv2, ID3D11DepthStencilView* pDepthStencilView); OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11RenderTargetView* rtv0, ID3D11RenderTargetView* rtv1, ID3D11RenderTargetView* rtv2, ID3D11RenderTargetView* rtv3, ID3D11DepthStencilView* pDepthStencilView); OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11RenderTargetView* rtv0, ID3D11RenderTargetView* rtv1, ID3D11RenderTargetView* rtv2, ID3D11RenderTargetView* rtv3, ID3D11RenderTargetView* rtv4, ID3D11DepthStencilView* pDepthStencilView); OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11RenderTargetView* rtv0, ID3D11RenderTargetView* rtv1, ID3D11RenderTargetView* rtv2, ID3D11RenderTargetView* rtv3, ID3D11RenderTargetView* rtv4, ID3D11RenderTargetView* rtv5, ID3D11DepthStencilView* pDepthStencilView); OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11RenderTargetView* rtv0, ID3D11RenderTargetView* rtv1, ID3D11RenderTargetView* rtv2, ID3D11RenderTargetView* rtv3, ID3D11RenderTargetView* rtv4, ID3D11RenderTargetView* rtv5, ID3D11RenderTargetView* rtv6, ID3D11DepthStencilView* pDepthStencilView); OmRenderTargets(const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& context, ID3D11RenderTargetView* rtv0, ID3D11RenderTargetView* rtv1, ID3D11RenderTargetView* rtv2, ID3D11RenderTargetView* rtv3, ID3D11RenderTargetView* rtv4, ID3D11RenderTargetView* rtv5, ID3D11RenderTargetView* rtv6, ID3D11RenderTargetView* rtv7, ID3D11DepthStencilView* pDepthStencilView); ~OmRenderTargets(); private: const Microsoft::WRL::ComPtr<ID3D11DeviceContext>& m_context; }; I do not use RAII wrappers upon Vertex Shader, Pixel Shader, IA, because it will be rewritten on next rendering stage. But for GS/CS I always do. So after each Rendering stage, pipeline is pretty clean and there is no need to reset states I did not touch.   This solution is better than having some "Reset all states" object. As a bonus - Exception safe :)
  2. Text Rendering In D3D11/12

    1. I want to use them simultanious in different modes: none, or 1/2/3, or 1+2/1+3/2+3, or 1+2+3. 2. They will do different jobs and will have different interfaces. 3. Sprite and DW will render at last stage, but 3D will render on gbuffer stage. 4. I don't think extra new()'s, virtual pointers is a good thing here. (I am C++ programmer :wink: )
  3. Text Rendering In D3D11/12

    Good Job! I wish you’ll finish it! :)   I was surprised how many people use HTML/CSS/Java in games.   After a little bit of research, I came to conclusion that I need to implement not one, but 3 text renderers in my engine :): Sprites for Debugging (fast and lo-quality) DirectWrite for score, ammo, dialogs, menus, and other plain high-quality text. 3D meshes for animated text on a scene (like rotated and bouncing score value after something was destroyed) If I'll found out that DirectWrite is very slow, I will start Research-2! :)   Thanks you all for help!
  4. Transpose World Inverse Transpose?

      Hurrah!   Microsoft has updated DirectXMath!  https://blogs.msdn.microsoft.com/chuckw/2016/08/02/directxmath-3-09/   Now it supports SSE4 and AVX.   There are not much changes, but XMVector*Length(), XMVector*NormalizeEst(), XMVector*Dot(), and some other vector functions seems much smaller than SSE2 variants.   It's time for me to collect money for upgrade from Q9400 to i7-6700k! :rolleyes:
  5. Hi community!   I about to start text rendering implementation.   I am going to use it for: 1.    Rendering current player’s health, ammo count, … 2.    In near future - debug information. 3.    In the FAR future – text dialogs, some buttons, settings dialog.   I found 3 ways how it might be accomplished:   1. Create bitmap with Direct2D and draw it on backbuffer. Pros: no 3rd party dependency. Cons: ?Performance? 2. Using 3rd party lib. Pros: no need to create layout management Cons1: Extra dependency with (probably) lower quality than Microsoft’s D2D. Cons2: Big concern about performance Concern: No idea about licensing, and how it might hit me later. 3. Full implementation via sprites composition. Pros: Probably faster that D2D Cons1: Entire layout management Cons2: Have no artist, so I should create sprites by myself.   Also I am not aware what is the best practice in the industry.   What would you recommend?
  6. Transpose World Inverse Transpose?

    Hodgman, could you suggest replacement for DirectXMath? Currently I have own small wrapper upon DirectXMath.   I am looking for: 1. At least 80% functional of DirectXMath (float2/3/4, matrix, Quaternion) 2. Support for SSE4/AVX 3. C++ - friendly. 4. <optional> Not a big, general use, just for computer graphics/physics.
  7. Transpose World Inverse Transpose?

      I do not do "WorldInverseTranspose" for any matrix when I place it to a buffer in my code (and Transpose also).   Transpose is often used for OpenGL matrix-vector order multiplication in hlsl code. There 3 ways to bypass it: 1. transpose matrix on CPU 2. use different order for multiplication (Vec*Mat => Mat*Vec) 3. use row_major pragma
  8. Transpose World Inverse Transpose?

      Actually you may not transpose them on CPU: just change multiplication order in shader code:   Something like this:     OUT.position     = mul(IN.wvp, float4(IN.position, 1));     OUT.normalVS     = mul((float3x3)IN.wv, IN.normal);
  9. Basic level editor

    Thank you, GuyWithBeard! It's much better than paint.net!!! :)   It satisfies me by 80%!!!    I just wonder: is there something even more better? The metaphor for software I am looking for is: "Chess board placement tool"   With some objects (predefined) on a palette, and I just place in right places on some variable-length grid.
  10. Basic level editor

    Hi there!   I am looking for simple EXISTING software. The software may not be actually a level editor, it might be some non-game-related software.   Basic idea: to make it easier to arrange objects on a grid.   Required features: Initialize some kind of palette with different types of objects (cubes as rendering approximation would be fine). Be able to create square floor (1000x1000 units max). Take an object from a palette and place it on a floor. Store (and load) to some format to read it in my game and in the level editor between runs. If the format is binary, it should be documented. Should run on Win10. Optional features: Be able to store size of each object type on the palette (a car and a human have different sizes, so it's better to store it once than changing every object instantiation) Able to rotate object on a grid. Height map. On current phase I don’t have time to write it by myself. In the feature I am going to write it by myself with additional customization.   If someone knows this software, please let me know.
  11. Copy texture in a shader artifact.

    Sorry, I just figured out what is going on! :) This is a precision error due LDR 8-bit channels.   256*(.145098045 - .141176477) = 1.004   I did not observe it on HDR texture because VS made some color adjustments on the texture like auto-levels.
  12. I spent some time on debugging and can’t figure out what am I doing wrong. I have a HDR texture with format DXGI_FORMAT_R16G16B16A16_FLOAT. Also I have LDR texture with format DXGI_FORMAT_R8G8B8A8_UNORM Right now there is no tone mapping algorithm implemented, so I just copy entire texture over full-quad shaders. Pixel shader is very simple: Texture2D<float4> HdrColor : register(t0); float4 main(float4 position : SV_Position) : SV_Target { int3 texCoord = int3(position.xy, 0); //TODO: bug is here: HDR texture stores much better gradient, but after Load(), artifact occurs float4 color = HdrColor.Load(texCoord); return color; } After this code run, a banding artifact occurs: color, that I am receiving on Load() is much different that the color is stored in HDR texture.   Pixel                      HDR texture       LDR backbuffer 1015,488              .143188477          .141176477 1015,489              .143310547          .145098045   Both cursors are on [1015,488] position, and one pixel lower on the right picture there is an artifact. You can see it better if you download the image and magnify it. (the color is a little bit different due VS texture visualization) [attachment=31781:LoadArtifact.png]   There are no objects like Rasterizer/Sampler/… bound to the pipeline. Just VS/PS/IL/SRV/RTV.   Has anyone have any clue what’s going on? =) Thanks in advance.