Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

1 Follower

About Tubby94

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

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

  1. I get that I can create new world and MVP matrices to separately describe the positions, but it still doesn't solve the problem of how I tell the shader to use MVPA on the cube and MVPB on the pyramid.
  2. The concept makes sense to me, but I still don't understand where to place this transformation in my code.
  3. //Initialization XMFLOAT4X4 mWorld = MathHelper::Identity4x4(); XMFLOAT4X4 mView = MathHelper::Identity4x4(); XMFLOAT4X4 mProj = MathHelper::Identity4x4(); // Build the view matrix. XMVECTOR pos = XMVectorSet(x, y, z, 1.0f); XMVECTOR target = XMVectorZero(); XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); XMMATRIX view = XMMatrixLookAtLH(pos, target, up); XMStoreFloat4x4(&mView, view); XMMATRIX world = XMLoadFloat4x4(&mWorld); XMMATRIX proj = XMLoadFloat4x4(&mProj); XMMATRIX worldViewProj = world*view*proj; // Update the constant buffer with the latest worldViewProj matrix. ObjectConstants objConstants; XMStoreFloat4x4(&objConstants.WorldViewProj, XMMatrixTranspose(worldViewProj)); World matrix is used when converting coordinates from local space to world space. View Matrix is used when converting coordinates from world space to camera space. Projection Matrix is used to map 3D coordinates on a 2D plane. Think I understand these concepts well enough, I'm just not sure how to apply this to only the first 8 or last 5 vertices of the single vertex buffer.
  4. Can anyone at least point me in the right direction?
  5. I'm currently learning how to store multiple objects in a single vertex buffer for efficiency reasons. So far I have a cube and pyramid rendered using ID3D12GraphicsCommandList::DrawIndexedInstanced; but when the screen is drawn, I can't see the pyramid because it is drawn inside the cube. I'm told to "Use the world transformation matrix so that the box and pyramid are disjoint in world space". Can anyone give insight on how this is accomplished? First I init the verts in Local Space std::array<VPosData, 13> vertices = { //Cube VPosData({ XMFLOAT3(-1.0f, -1.0f, -1.0f) }), VPosData({ XMFLOAT3(-1.0f, +1.0f, -1.0f) }), VPosData({ XMFLOAT3(+1.0f, +1.0f, -1.0f) }), VPosData({ XMFLOAT3(+1.0f, -1.0f, -1.0f) }), VPosData({ XMFLOAT3(-1.0f, -1.0f, +1.0f) }), VPosData({ XMFLOAT3(-1.0f, +1.0f, +1.0f) }), VPosData({ XMFLOAT3(+1.0f, +1.0f, +1.0f) }), VPosData({ XMFLOAT3(+1.0f, -1.0f, +1.0f) }), //Pyramid VPosData({ XMFLOAT3(-1.0f, -1.0f, -1.0f) }), VPosData({ XMFLOAT3(-1.0f, -1.0f, +1.0f) }), VPosData({ XMFLOAT3(+1.0f, -1.0f, -1.0f) }), VPosData({ XMFLOAT3(+1.0f, -1.0f, +1.0f) }), VPosData({ XMFLOAT3(0.0f, +1.0f, 0.0f) }) } Then data is stored into a container so sub meshes can be drawn individually SubmeshGeometry submesh; submesh.IndexCount = (UINT)indices.size(); submesh.StartIndexLocation = 0; submesh.BaseVertexLocation = 0; SubmeshGeometry pyramid; pyramid.IndexCount = (UINT)indices.size(); pyramid.StartIndexLocation = 36; pyramid.BaseVertexLocation = 8; mBoxGeo->DrawArgs["box"] = submesh; mBoxGeo->DrawArgs["pyramid"] = pyramid; Objects are drawn mCommandList->DrawIndexedInstanced( mBoxGeo->DrawArgs["box"].IndexCount, 1, 0, 0, 0); mCommandList->DrawIndexedInstanced( mBoxGeo->DrawArgs["pyramid"].IndexCount, 1, 36, 8, 0); Vertex Shader cbuffer cbPerObject : register(b0) { float4x4 gWorldViewProj; }; struct VertexIn { float3 PosL : POSITION; float4 Color : COLOR; }; struct VertexOut { float4 PosH : SV_POSITION; float4 Color : COLOR; }; VertexOut VS(VertexIn vin) { VertexOut vout; // Transform to homogeneous clip space. vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj); // Just pass vertex color into the pixel shader. vout.Color = vin.Color; return vout; } float4 PS(VertexOut pin) : SV_Target { return pin.Color; }
  6. Yeah I figured this out after a lot of trail and error, I had to create another buffer that will hold the color data. Thanks for the reply
  7. EDIT: I have now solved my problem after trail and error Hi All, I'm following Frank Luna's book, Introduction to 3D Game Programming with Directx 12, and have come to the point where there is an exercise to create a cube using 2 Vertex buffers; one for position, and one for color. I'm then supposed to bind these to different Input slots(0 and 1). All is fine except my color data seems to be misinterpreted by the pipeline, no matter what color I specify to the vertices in my buffer, the cube will still be rendered as a predetermined assortment of colors. Am I missing anything important to achieving this goal? these are the steps I took so far: Used Two vertex buffers to feed pipeline with vertices struct VPosData {XMFLOAT3 Pos; }; struct VColorData {XMFLOAT4 Color; }; Changed INPUT_ELEMENT_DESC accordingly mInputLayout = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } }; Bound the two vertex buffers to the input slots mCommandList->IASetVertexBuffers(0, 1, &mBoxGeo->VertexBufferView()); //Input Slot 0 for verts mCommandList->IASetVertexBuffers(1, 1, &mBoxGeo->VertexBufferView()); //Input Slot 1 for Color The Textbook doesn't specify any extra steps to achieve this result, so at this point I'm not sure how to go about debugging this problem. Any feedback would be appreciated.
  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!