• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

430 Neutral

1 Follower

About Endemoniada

  • Rank
    Advanced Member

Personal Information

  • Interests
  1. Hi guys, I am having a hard time understanding projective texture mapping. I understand shadow mapping but just don't get what I'm supposed to do to project a texture (like light coming through a grill.) What do I actually draw, quads with the light textures? Maybe someone can tell me the basics. I'm talking about the projective texture mapping that looks like it's coming from a slide projector. Thanks a lot.

    Thanks MJP, I wasn't sure I was doing it right. For my depth and shadow maps I store the linear view space depth (normalized), I learned that from your posts. If I were using DXGI_FORMAT_R32_FLOAT should I do it the same way or just store the raw depth values ? Thanks again.
  3. Hi guys, I want to visualize textures having the DXGI_FORMAT_D16_UNORM format (like depth, shadow maps, etc.) I'm copying to the clipboard but can't figure out how to get the values. // resource is mapped to subresource for (int i = 0; i < texture_height; i++) { BYTE* src = (BYTE*)(subresource.pData) + (i * subresource.RowPitch); // start of row for (int j = 0; j < texture_width; j++) { grey = *((unsigned short*)(src)); // this isn't right // fill in my rgb values here src += 2; (advance 2 bytes = 16 bits) } } Please help. Thanks.
  4. 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 };
  5. 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.
  6. 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.
  7. 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).
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. HLSL Bilinear Filtering ?

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