Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About AireSpringfield

  • Rank

Personal Information

  • Interests


  • Github

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. AireSpringfield

    [D3D11]Access Depth Buffer using SV_Depth

    Thank you very much!
  2. AireSpringfield

    [D3D11]Access Depth Buffer using SV_Depth

    Thanks for your help!
  3. AireSpringfield

    [D3D11]Access Depth Buffer using SV_Depth

    So by my understanding, SV_Depth is useful only when writing custom depth values, but CANNOT be used to achieve custom reading. When writing to SV_Depth, the pipeline discard to write to depth buffer with z/w in SV_Position, which is the default. Am I right?
  4. Hi, We know that it is possible to modify the pixel's depth value using "System Value" semantic SV_Depth in this way: struct PixelOut { float4 color : SV_Target; float depth : SV_Depth; }; PixelOut PS(VertexOut pin) { PixelOut pout; // … usual pixel work pout.Color = float4(litColor, alpha); // set pixel depth in normalized [0, 1] range pout.depth = pin.PosH.z - 0.05f; return pout; } As many post-effect requires the depth value of current pixel (such as fog, screen space reflection), we need to acquire it in the PS. A common way to do that is to render the depth value to a separate texture and sample it in the PS. But I found this method a bit clumsy because we already have depth value stored in the depth-stencil buffer, so I wonder whether it is possible to access from NATIVE depth buffer instead of ANOTHER depth texture. I found this on MSDN: https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/dx-graphics-hlsl-semantics that mentions READ depth data in shader. I tried this in Unity: half4 frag (Vert2Frag v2f, float depth : SV_Depth) : SV_Target { return half4(depth, depth, depth, 1); } However it turns out to be a pure white image, which means this depth values in all pixels are 1. So is that MSDN wrong? Is it possible to sampling a NATIVE depth buffer? Thanks!
  5. AireSpringfield

    Parameters of physically based Material in UE4?

    Thanks so much!By the way, Where can I find some references, like the corresponding hlsl codes?
  6. Hi, I'm currently studying physically based shading in UE4 described in Real Shading in Unreal Engine 4. In the notes, the Material has 4 basic properties: BaseColor, Metallic, Roughness and Cavity. Here is their BRDF model in use: The use of roughness is clearly clarified, and I guess BaseColor is referred as \(c_{diff}\)c_diff in the diffuse component. Then anyone knows how Metallic and Cavity is implemented in UE4? Exact fragments in the source code of the engine would be the best. Thanks a lot!!
  7. So calling XMVector3TransformNormal() doesn't mean to transform a "surface normal" by multiplying inverse transpose of M, "normal" is for ignoring translation, is it?
  8. Hi, When reading Frank Luna's book Introduction to 3D Game Programming with DX11, chapter 10 stenciling, the author made a demo to achieve mirror reflection effect. He made tranformation matrix and transform directional lights as following: // Build reflection matrix to reflect the skull. XMVECTOR mirrorPlane = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f); // xy plane XMMATRIX R = XMMatrixReflect(mirrorPlane); XMMATRIX world = XMLoadFloat4x4(&mSkullWorld) * R; …/ / Reflect the light source as well. // Cache the old light directions, and reflect the light directions. XMFLOAT3 oldLightDirections[3]; for(int i = 0; i < 3; ++i) { oldLightDirections = mDirLights.Direction; XMVECTOR lightDir = XMLoadFloat3(&mDirLights.Direction); XMVECTOR reflectedLightDir = XMVector3TransformNormal(lightDir, R); XMStoreFloat3(&mDirLights.Direction, reflectedLightDir); } But I think the direction of a light source is no more than a vector, not a normal. Why did the author use XMVector3TransformNormal to flip the lights? Thanks!
  9. AireSpringfield

    Member function as callback

    OK, I'd say that I prefer the author's method... Thanks for your help!
  10. Hi, I started reading Introduction to 3D Game Programming with Direct3D 11.0 and have a little question about callback function. In author's example code d3dApp.cpp, he managed to assign a member function to WNDCLASS::lpfnWndProc namespace { // This is just used to forward Windows messages from a global window // procedure to our member function window procedure because we cannot // assign a member function to WNDCLASS::lpfnWndProc. D3DApp* gd3dApp = 0; } LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { // Forward hwnd on because we can get messages (e.g., WM_CREATE) // before CreateWindow returns, and thus before mhMainWnd is valid. return gd3dApp->MsgProc(hwnd, msg, wParam, lParam); } in constructor D3DApp::D3DApp() gd3dApp = this; and in bool D3DApp::InitMainWindow() wc.lpfnWndProc = MainWndProc; Notice that D3DApp::MsgProc is a virtual function. As far as I'm concerned, I would find it convenient to declare MsgProc member function as static. However, a static member can't be virtual. Is there any solution so that I can overcome the contradiction except author's method?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!