• Content count

  • Joined

  • Last visited

Community Reputation

430 Neutral

About Endemoniada

  • Rank
    Advanced Member

Personal Information

  • Interests
  1. Hi, Does the background move ? I'm not familiar with Direct2D. You can always just go full D3D and render quads for the 2D stuff, it will certainly be very fast. As for loading models from Blender (or any other program) you'll need a loader. It's not that hard to code an .obj loader yourself, otherwise you can probably find some code. It depends on the format your game engines uses so I would just make it myself if I were you, it basically comes down to parsing a text file (for .obj).
  2. 2D What books should I get next? C++

    What is more important, Windows programming or your roguelike ? I would learn to get a basic skeleton D3D11 program up and running, that shouldn't be too difficult. From there I'd make a simple 2D game, like a grid-based one. After that things will start falling into place. I don't think you need any more books.
  3. Hi guys, Do you think I should render my first-person hand/weapon in world space or view space, is there a preferred method ? I got it to work in view space but now I have to do all the lighting in view space too, that's not much of a problem but I've been doing it in world space. I think I would rather do it in world space unless there is a good reason not too. I haven't been able to get that working though. Any help would be appreciated, especially getting it to work in world space. Thanks.
  4. Hi guys, The only way I can get a CCW winding order to work is to use D3D11_CULL_NONE. Take a look: // ccw triangle on x-z plane a = (-8.0f, 0.0f, -8.0f); b = ( 8.0f, 0.0f, -8.0f); c = ( 8.0f, 0.0f,  8.0f); rasterDesc.CullMode = D3D11_CULL_BACK; rasterDesc.FrontCounterClockwise = TRUE; // that doesn't work // if I swap b with c,  and set FrontCounterClockwise = FALSE it works I am really confused. Thanks.
  5. Hi guys,   I'm still not sure about what variable types to use for buffers and shaders. It's easier to explain with code:   // vertex layout   D3D11_INPUT_ELEMENT_DESC layout[] = {  { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },  { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, };   I use a float3 for the position, should it instead be float4 ? Also, I like to use a float4 for the uv so I can use the .zw components for custom data but what if I only use the .xy components, should it then be float2 ?   The same question applies to the shader itself:   struct VS_INPUT {  float3 position : POSITION;  float4 uv : TEXCOORD0; }; Should these exactly match the layout (like they do here) ?   This has always confused me. Thanks.
  6. HLSL Bilinear Filtering ?

    Thanks a lot everyone, especially Matt, for taking the time to explain it to me.
  7. Hi guys,   Do I need to do anything special to get built-in bilinear filtering ?   Here is what I'm doing:     // sampler   D3D11_SAMPLER_DESC desc; desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; ...   // simple shader   struct VS_INPUT {  float4 position : POSITION;  float2 uv : TEXCOORD0; }; struct VS_OUTPUT {  float4 position : SV_POSITION;  float2 uv : TEXCOORD0; };   VS_OUTPUT vshader(VS_INPUT input) {  VS_OUTPUT output;  output.position = float4(input.position.xyz, 1.0f);  output.uv = input.uv;  return output; }   float4 pshader(VS_OUTPUT input) : SV_TARGET {  return float4(Texture0.Sample(Sampler0, input.uv).xyz, 1.0f); }   It's basically just a copy shader so I use it for both (1/2x) downsampling and (2x) upsampling.   It seems alright but maybe I can get better results another way ?   Also, I may write my own filter and would like to know if I am getting the center of the pixels with the code above, so that a pixel to the right of the pixel shader input would be (input.uv.x + 1.0f / texture_width) ? I am pretty sure that's what SV_POSITION does, however, I want to be certain.   Thank you.  
  8. Hi guys,   I used to use techniques to combine two shaders that do pretty much the same thing, like a two-pass blur shader. Is there a way to do somethng similar in D3D11 ?   I know I can pass a variable via the constant buffer and do a conditional but that's not very satisfying.   Thanks.  
  9. Hi,   Just offhand your class can have either it's own data struct matching the constant buffer or a pointer to a global one, then when you use the shader just call UpdateSubresource().   Something like this:   // generic buffer   struct ConstBuffer { float4 data0; float4 data1; };   // create the d3d11 const buffer   ID3D11Buffer* d3d_const_buffer;   D3D11_BUFFER_DESC desc; ZeroMemory(&bd, sizeof(desc));   desc.Usage = D3D11_USAGE_DEFAULT; desc.ByteWidth = sizeof(ConstBuffer); desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; desc.CPUAccessFlags = 0;   hResult = d3d_device->CreateBuffer(&desc, nullptr, &d3d_const_buffer);   // now make it class-friendy   class Shader { // local buffer ConstBuffer const_buffer;   // easy functions to fill in the local buffer void SetLightPos(float4 v) {const_buffer.data0 = v;} void SetLightColour(float4 v) {const_buffer.data1 = v;} };   // use the shader when rendering   Shader light_shader; light_shader.SetLightPos(vLightPos); light_shader.SetLightColour(vLightColour);   d3d_context->UpdateSubresource(d3d_const_buffer, 0, nullptr, &light_shader.const_buffer, 0, 0);   Is that what you mean ?
  10. DX11 Enable MSAA in DirectX 11

    Hi,   Here are two different ways I set my quality, they may not be the best ways to do it:   UINT msaa_quality;   // method 1   msaa_quality = D3D11_STANDARD_MULTISAMPLE_PATTERN;   // method 2   DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; // or the format you're using UINT msaa_samples = 4; // or 2, 8, etc.   hResult = d3d_device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, msaa_samples, &msaa_quality); msaa_quality--;  
  11. Hi guys,   I am trying to convert to an HDR system but when I use any format other than R8G8B8A8_UNORM my call to ResolveSubresource() fails.   I get this error: ...Source Resource format is (0x2, R32G32B32A32_FLOAT). Resolve Format is (0x1c, R8G8B8A8_UNORM)   I made sure to create the resolve texture with R32G32B32A32_FLOAT.   I also made sure this doesn't fail: CheckMultisampleQualityLevels(DXGI_FORMAT_R32G32B32A32_FLOAT,...)   Now matter how I create the resolve texture it tells me it's format is R8G8B8A8_UNORM.   What can I do ? Thank you.  
  12. Hi guys,   I found only two practical articles on temporal smoothing and they leave a lot out.   I read this:   "To combine them, we simply took previous ssao buffer (so it became effectively accumulation texture), took offset based on motion vectors, read it and after deciding on rejection or acceptance (smooth weight) combined them together with a fixed exponential decay (weight of 0.9 for history accumulation buffer on acceptance, it got down to zero on rejection) and output the AO."   I don't know what motion vectors are, or how to accept/reject data based on them. The article makes it seem so simple.   I can use any info you may think is helpful.   Thanks.  
  13. Hi guys,   What format should I use when rendering and blurring SSAO ? I only need one channel. I've been using DXGI_FORMAT_R8G8B8A8_UNORM but I'm wondering if I'd be better off using DXGI_FORMAT_R32_FLOAT or DXGI_FORMAT_R16_FLOAT or perhaps DXGI_FORMAT_R8_UNORM.   My main concern is compatibility and speed, not so much memory usage.   Thanks.  
  14. Off Center Projection ?

    Hi HappyCoder,   I don't know what you mean by applying a translation *after* the perspective transform.   I pass the WorldViewProjection to the shader and it does the transform:   world = DirectX::XMMatrixIdentity(); view = DirectX::XMMatrixLookAtLH(eye, look, up); projection = DirectX::XMMatrixPerspectiveFovLH(pi / 4.0f, aspect_ratio, near_z, far_z);   // for shader world_view = DirectX::XMMatrixMultiply(world, view); world_view_projection = DirectX::XMMatrixMultiply(world_view, projection);   Thanks for helping.
  15. Hi guys,   Is is possible to make (an unrealistic) projection that appears as if the camera is offset even though it isn't ?   The image on the left is a regular projection, the look at point is the black object. I want it to be like the image on the right which I made by moving the look at point to the right (x+ axis) and then using Photoshop to move the cube back to the center.   Thanks.