• Content count

  • Joined

  • Last visited

Community Reputation

430 Neutral

1 Follower

About Endemoniada

  • Rank
    Advanced Member

Personal Information

  • Interests
  1. Hi guys, I am setting up instanced drawing (non-indexed) like this: struct d3d_vertex { float x, y, z; float nx, ny, nz; float u, v, w; }; struct d3d_instance { float x, y, z; }; D3D11_INPUT_ELEMENT_DESC layout[4]; layout[0] = { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }; layout[1] = { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }; layout[2] = { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }; layout[3] = { "TEXCOORD", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 36, D3D11_INPUT_PER_VERTEX_DATA, 0 }; ... UINT buffer_strides[2]; buffer_strides[0] = sizeof(d3d_vertex); buffer_strides[1] = sizeof(d3d_instance); d3d_context->IASetVertexBuffers(0, 2, bufferPointers, buffer_strides, buffer_offsets); ... d3d_context->DrawInstanced(tree_model.buffer_size, 1, 0, 0); I am getting this error: ID3D11DeviceContext::DrawInstanced: Input vertex slot 0 has stride 36 which is less than the minimum stride logically expected from the current Input Layout (48 bytes). What am I missing ? Thanks. **** solved part: layout[0] = { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }; layout[1] = { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }; layout[2] = { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }; layout[3] = { "TEXCOORD", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 };
  2. Hi Nypyren, That seems to be exactly what's happening. Once I added another file or two I noticed it, it seemed out of the ordinary so I thought something was wrong. Thanks a lot.
  3. Hi guys, This is really annoying. When I clean and rebuild VS does something like this: 1>------ Rebuild All started: Project: Castle, Configuration: Debug Win32 ------ 1> StdAfx.cpp 1> Vector.cpp ... ... 1> Generating Code... 1> Compiling... 1> Bitmap.cpp 1> Generating Code... 1> Castle.vcxproj -> C:\Code\Projects\Castle\Debug\Castle.exe Notice how it compiles, then generates code, then compiles (usually one or two) more files, then generates code again. Why is it doing that ? In other projects is doesn't and I can't see any difference between them, I've tried a lot of things. Thanks.
  4. 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).
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. HLSL Bilinear Filtering ?

    Thanks a lot everyone, especially Matt, for taking the time to explain it to me.
  10. 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.  
  11. 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.  
  12. 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 ?
  13. 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--;  
  14. 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.  
  15. 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.