Jump to content
  • Advertisement
Sign in to follow this  
MattSmith_79985

DX11 Simple Vertex Grid (not working)

This topic is 2593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im still a beginner.....but anyways I've been trying to make a 100x100 Grid (no textures, this is eventually going to be used for a heightmap) However Im stuck somewhere, I found the Algorithm to get the vertices and Indices and i've replaced everything but nothing comes up on the screen. I've went back over it 100 times by now and can't find anything wrong. (although im sure it's obvious). If anyone could help me out i'd be super greatful.

I thought about setting a Rasterize state......but I can't get ANYTHING to appear on the screen. Code is below.
shaders.hlsl


struct VOut
{
float4 position : SV_POSITION;
float4 color : COLOR;
};

VOut VShader(float4 position : POSITION, float4 color : COLOR)
{
VOut output;

output.position = position;
output.color = color;
output.color.r = 1.0f; // maximize the red in each vertex

return output;
}


float4 PShader(float4 position : SV_POSITION, float4 color : COLOR) : SV_TARGET
{
return color;
}


main.cpp


#include "vars.h"

// the WindowProc function prototype
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);


// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hWnd;
WNDCLASSEX wc;

ZeroMemory(&wc, sizeof(WNDCLASSEX));

wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = L"WindowClass";

RegisterClassEx(&wc);

RECT wr = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);

hWnd = CreateWindowEx(NULL,
L"WindowClass",
L"Our First Direct3D Program",
WS_OVERLAPPEDWINDOW,
300,
300,
wr.right - wr.left,
wr.bottom - wr.top,
NULL,
NULL,
hInstance,
NULL);

ShowWindow(hWnd, nCmdShow);

// set up and initialize Direct3D
InitD3D(hWnd);

// enter the main loop:

MSG msg;

while(TRUE)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);

if(msg.message == WM_QUIT)
break;
}

RenderFrame();
}

// clean up DirectX and COM
CleanD3D();

return msg.wParam;
}


// this is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
} break;
}

return DefWindowProc (hWnd, message, wParam, lParam);
}


// this function initializes and prepares Direct3D for use
void InitD3D(HWND hWnd)
{
// create a struct to hold information about the swap chain
DXGI_SWAP_CHAIN_DESC scd;

// clear out the struct for use
ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));

// fill the swap chain description struct
scd.BufferCount = 1; // one back buffer
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color
scd.BufferDesc.Width = SCREEN_WIDTH; // set the back buffer width
scd.BufferDesc.Height = SCREEN_HEIGHT; // set the back buffer height
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used
scd.OutputWindow = hWnd; // the window to be used
scd.SampleDesc.Count = 4; // how many multisamples
scd.Windowed = TRUE; // windowed/full-screen mode
scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; // allow full-screen switching

// create a device, device context and swap chain using the information in the scd struct
D3D11CreateDeviceAndSwapChain(NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
NULL,
NULL,
NULL,
D3D11_SDK_VERSION,
&scd,
&swapchain,
&dev,
NULL,
&devcon);


// create the depth buffer texture
D3D11_TEXTURE2D_DESC texd;
ZeroMemory(&texd, sizeof(texd));

texd.Width = SCREEN_WIDTH;
texd.Height = SCREEN_HEIGHT;
texd.ArraySize = 1;
texd.MipLevels = 1;
texd.SampleDesc.Count = 4;
texd.Format = DXGI_FORMAT_D32_FLOAT;
texd.BindFlags = D3D11_BIND_DEPTH_STENCIL;

ID3D11Texture2D *pDepthBuffer;
dev->CreateTexture2D(&texd, NULL, &pDepthBuffer);

// create the depth buffer
D3D11_DEPTH_STENCIL_VIEW_DESC dsvd;
ZeroMemory(&dsvd, sizeof(dsvd));

dsvd.Format = DXGI_FORMAT_D32_FLOAT;
dsvd.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;

dev->CreateDepthStencilView(pDepthBuffer, &dsvd, &zbuffer);
pDepthBuffer->Release();

// get the address of the back buffer
ID3D11Texture2D *pBackBuffer;
swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);

// use the back buffer address to create the render target
dev->CreateRenderTargetView(pBackBuffer, NULL, &backbuffer);
pBackBuffer->Release();

// set the render target as the back buffer
devcon->OMSetRenderTargets(1, &backbuffer, zbuffer);


// Set the viewport
D3D11_VIEWPORT viewport;
ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT));

viewport.TopLeftX = 0; // set the left to 0
viewport.TopLeftY = 0; // set the top to 0
viewport.Width = SCREEN_WIDTH; // set the width to the window's width
viewport.Height = SCREEN_HEIGHT; // set the height to the window's height
viewport.MinDepth = 0; // the closest an object can be on the depth buffer is 0.0
viewport.MaxDepth = 1; // the farthest an object can be on the depth buffer is 1.0

devcon->RSSetViewports(1, &viewport);

InitPipeline();
InitGraphics();
}


// this is the function used to render a single frame
void RenderFrame(void)
{


D3DXMATRIX matRotate, matView, matProjection;
D3DXMATRIX matFinal;

static float Time = 0.0f; Time += 0.0003f;

// create a world matrices
D3DXMatrixRotationY(&matRotate, Time);

// create a view matrix
D3DXMatrixLookAtLH(&matView,
&D3DXVECTOR3(0.0f, 7.0f, 5.0f), // the camera position
&D3DXVECTOR3(0.0f, 0.0f, 0.0f), // the look-at position
&D3DXVECTOR3(0.0f, 1.0f, 0.0f)); // the up direction

// create a projection matrix
D3DXMatrixPerspectiveFovLH(&matProjection,
(FLOAT)D3DXToRadian(45), // field of view
(FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT, // aspect ratio
1.0f, // near view-plane
1000.0f); // far view-plane

// load the matrices into the constant buffer
matFinal = matRotate * matView * matProjection;


// clear the back buffer to a deep blue
devcon->ClearRenderTargetView(backbuffer, D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f));

// clear the depth buffer
devcon->ClearDepthStencilView(zbuffer, D3D11_CLEAR_DEPTH, 1.0f, 0);

// select which vertex buffer to display
UINT stride = sizeof(VertexType);
UINT offset = 0;
devcon->IASetVertexBuffers(0, 1, &pVBuffer, &stride, &offset);
devcon->IASetIndexBuffer(pIBuffer, DXGI_FORMAT_R32_UINT, 0);

// select which primtive type we are using
devcon->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_LINELIST);

//Draw
devcon->DrawIndexed(m_indexCount, 0, 0);

// switch the back buffer and the front buffer
swapchain->Present(0, 0);
}


// this is the function that cleans up Direct3D and COM
void CleanD3D(void)
{
swapchain->SetFullscreenState(FALSE, NULL); // switch to windowed mode

// close and release all existing COM objects
zbuffer->Release();
pLayout->Release();
pVS->Release();
pPS->Release();
pVBuffer->Release();
pIBuffer->Release();
swapchain->Release();
backbuffer->Release();
dev->Release();
devcon->Release();
}


// this is the function that creates the shape to render
void InitGraphics()
{
VertexType* vertices;
unsigned long* indices;
int i, j, index;
float positionX, positionZ;

// Calculate the number of vertices in the terrain mesh.
m_vertexCount = (m_terrainWidth - 1) * (m_terrainHeight - 1) * 8;

// Set the index count to the same as the vertex count.
m_indexCount = m_vertexCount;

vertices = new VertexType[m_vertexCount];
indices = new unsigned long[m_indexCount];

// Initialize the index to the vertex buffer.
index = 0;

// Load the vertex and index array with the terrain data.
for(j=0; j<(m_terrainHeight-1); j++)
{
for(i=0; i<(m_terrainWidth-1); i++)
{
// LINE 1
// Upper left.
positionX = (float)i;
positionZ = (float)(j+1);

vertices[index].position = D3DXVECTOR3(positionX, 0.0f, positionZ);
vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
indices[index] = index;
index++;

// Upper right.
positionX = (float)(i+1);
positionZ = (float)(j+1);

vertices[index].position = D3DXVECTOR3(positionX, 0.0f, positionZ);
vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
indices[index] = index;
index++;

// LINE 2
// Upper right.
positionX = (float)(i+1);
positionZ = (float)(j+1);

vertices[index].position = D3DXVECTOR3(positionX, 0.0f, positionZ);
vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
indices[index] = index;
index++;

// Bottom right.
positionX = (float)(i+1);
positionZ = (float)j;

vertices[index].position = D3DXVECTOR3(positionX, 0.0f, positionZ);
vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
indices[index] = index;
index++;

// LINE 3
// Bottom right.
positionX = (float)(i+1);
positionZ = (float)j;

vertices[index].position = D3DXVECTOR3(positionX, 0.0f, positionZ);
vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
indices[index] = index;
index++;

// Bottom left.
positionX = (float)i;
positionZ = (float)j;

vertices[index].position = D3DXVECTOR3(positionX, 0.0f, positionZ);
vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
indices[index] = index;
index++;

// LINE 4
// Bottom left.
positionX = (float)i;
positionZ = (float)j;

vertices[index].position = D3DXVECTOR3(positionX, 0.0f, positionZ);
vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
indices[index] = index;
index++;

// Upper left.
positionX = (float)i;
positionZ = (float)(j+1);

vertices[index].position = D3DXVECTOR3(positionX, 0.0f, positionZ);
vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
indices[index] = index;
index++;
}
}

// create the vertex buffer
D3D11_BUFFER_DESC bd;
ZeroMemory(&bd, sizeof(bd));

bd.Usage = D3D11_USAGE_DYNAMIC;
bd.ByteWidth = sizeof(VertexType) * m_vertexCount;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;

dev->CreateBuffer(&bd, NULL, &pVBuffer);

// copy the vertices into the buffer
D3D11_MAPPED_SUBRESOURCE ms;
devcon->Map(pVBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer
memcpy(ms.pData, vertices, sizeof(vertices)); // copy the data
devcon->Unmap(pVBuffer, NULL);

// create the index buffer
bd.Usage = D3D11_USAGE_DYNAMIC;
bd.ByteWidth = sizeof(unsigned long) * m_indexCount;
bd.BindFlags = D3D11_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
bd.MiscFlags = 0;

dev->CreateBuffer(&bd, NULL, &pIBuffer);

devcon->Map(pIBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer
memcpy(ms.pData, indices, sizeof(indices)); // copy the data
devcon->Unmap(pIBuffer, NULL);
/*
D3DX11CreateShaderResourceViewFromFile(dev, // the Direct3D device
L"Wood.png", // load Wood.png in the local folder
NULL, // no additional information
NULL, // no multithreading
&pTexture, // address of the shader-resource-view
NULL); // no multithreading
*/


delete [] vertices;
vertices = 0;

delete [] indices;
indices = 0;
}




// this function loads and prepares the shaders
void InitPipeline()
{
// compile the shaders
ID3D10Blob *VS, *PS;
D3DX11CompileFromFile(L"shaders.hlsl", 0, 0, "VShader", "vs_5_0", 0, 0, 0, &VS, 0, 0);
D3DX11CompileFromFile(L"shaders.hlsl", 0, 0, "PShader", "ps_5_0", 0, 0, 0, &PS, 0, 0);

// create the shader objects
dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &pVS);
dev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), NULL, &pPS);

// set the shader objects
devcon->VSSetShader(pVS, 0, 0);
devcon->PSSetShader(pPS, 0, 0);

// create the input element object
D3D11_INPUT_ELEMENT_DESC ied[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D10_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
};

// use the input element descriptions to create the input layout
dev->CreateInputLayout(ied, 3, VS->GetBufferPointer(), VS->GetBufferSize(), &pLayout);
devcon->IASetInputLayout(pLayout);


}


vars.h


// include the basic windows header files and the Direct3D header files
#include <windows.h>
#include <windowsx.h>
#include <d3d11.h>
#include <d3dx11.h>
#include <d3dx10.h>

// include the Direct3D Library file
#pragma comment (lib, "d3d11.lib")
#pragma comment (lib, "d3dx11.lib")
#pragma comment (lib, "d3dx10.lib")

// define the screen resolution
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600

int m_vertexCount, m_indexCount;
int m_terrainWidth=100, m_terrainHeight=100;

// global declarations
IDXGISwapChain *swapchain; // the pointer to the swap chain interface
ID3D11Device *dev; // the pointer to our Direct3D device interface
ID3D11DeviceContext *devcon; // the pointer to our Direct3D device context
ID3D11RenderTargetView *backbuffer; // the pointer to our back buffer
ID3D11DepthStencilView *zbuffer; // the pointer to our depth buffer
ID3D11InputLayout *pLayout; // the pointer to the input layout
ID3D11VertexShader *pVS; // the pointer to the vertex shader
ID3D11PixelShader *pPS; // the pointer to the pixel shader
ID3D11Buffer *pVBuffer; // the pointer to the vertex buffer
ID3D11Buffer *pIBuffer; // the pointer to the index buffer


// a struct to define a single vertex
struct VertexType
{
D3DXVECTOR3 position;
D3DXVECTOR4 color;
};


// function prototypes
void InitD3D(HWND hWnd); // sets up and initializes Direct3D
void RenderFrame(void); // renders a single frame
void CleanD3D(void); // closes Direct3D and releases memory
void InitGraphics(void); // creates the shape to render
void InitPipeline(void); // loads and prepares the shaders




I've rechecked the shader and everything. you don't have to IN depth scan my code but I feel like if I can figure out whats wrong I can understand everything else better. but right now Im stumped.

Also in my debugging mode when I close the program (i still get a black background) I get a arrow pointing to pLayout->Release(); (im guessing this is what was going to be executed next)......but I don't see whats wrong with my layout.

Share this post


Link to post
Share on other sites
Advertisement
VOut VShader(float4 position : POSITION, float4 color : COLOR)
{
VOut output;

output.position = position;
output.color = color;
output.color.r = 1.0f; // maximize the red in each vertex

return output;
}


First of all, where is your world-view-projection-transform? output.position = position will always draw the vertices like they weren't transformed and there was no camera
nor a projection set. I didn't read through all of your code, just try out to multiply the position with the worldviewprojection-matrix.

Share this post


Link to post
Share on other sites
I noticed on the Terrain tutorial site they used this:


////////////////////////////////////////////////////////////////////////////////
// Filename: color.fx
////////////////////////////////////////////////////////////////////////////////


/////////////
// GLOBALS //
/////////////
matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;


//////////////
// TYPEDEFS //
//////////////
struct VertexInputType
{
float4 position : POSITION;
float4 color : COLOR;
};

struct PixelInputType
{
float4 position : SV_POSITION;
float4 color : COLOR0;
};


////////////////////////////////////////////////////////////////////////////////
// Vertex Shader
////////////////////////////////////////////////////////////////////////////////
PixelInputType ColorVertexShader(VertexInputType input)
{
PixelInputType output;


// Change the position vector to be 4 units for proper matrix calculations.
input.position.w = 1.0f;

// Calculate the position of the vertex against the world, view, and projection matrices.
output.position = mul(input.position, worldMatrix);
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);

// Store the input color for the pixel shader to use.
output.color = input.color;

return output;
}


////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////
float4 ColorPixelShader(PixelInputType input) : SV_Target
{
return input.color;
}


////////////////////////////////////////////////////////////////////////////////
// Technique
////////////////////////////////////////////////////////////////////////////////
technique10 ColorTechnique
{
pass pass0
{
SetVertexShader(CompileShader(vs_4_0, ColorVertexShader()));
SetPixelShader(CompileShader(ps_4_0, ColorPixelShader()));
SetGeometryShader(NULL);
}
}



For their shader HLSL.
but what confused me about that is......I wasn't sure what I do with those matrix globals, and im really not sure what the "Technique" thing is.... but is that sort of what your talking about?


edit:
ok i changed mine to this: (more closer to the code I was doing)
...still failing though same thing...hmmm


cbuffer ConstantBuffer
{
float4x4 matFinal;
}

struct VOut
{
float4 position : SV_POSITION;
float4 color : COLOR;
};

VOut VShader(float4 position : POSITION, float4 color : COLOR)
{
VOut output;

output.position = mul(matFinal, position);
output.color = color;

return output;
}


float4 PShader(float4 position : SV_POSITION, float4 color : COLOR) : SV_TARGET
{
return color;
}

Share this post


Link to post
Share on other sites
I wasn't sure what I do with those matrix globals, and im really not sure what the "Technique" thing is.... but is that sort of what your talking about? [/quote]

You mean you were not sure how to asign the matrix or what they do? Because in latter case I would advice you to take a step back and learn the basics about 3d programming before starting to get into action. Will make your life a lot easier. If you know what world view and projection does, nevermind.

ok i changed mine to this: (more closer to the code I was doing)
...still failing though same thing...hmmm[/quote]

Are you asigning your matrix correctly? Also, you do your multiplication wrong:

output.position = mul(position, matFinal);


Order is important for matrix multiplications. a * b =/ b*a.

Share this post


Link to post
Share on other sites
Ok changed the out.position. still the same thing. However now it won't even go into the DirectX black screen window, it just crashes.....(when I changed it to what you said that is, although it still compiles)

and Im pretty sure im assigning the matrix correctly, it's taken directly from Raserteks tutorials (which i've ran before and they work, but he has TONS of other camera/font/etc code with it so I wanted to start simple)

I mean if anything I should at least get SOMETHING on the window (even if the verticies aren't right)

Share this post


Link to post
Share on other sites
Ok changed the out.position. still the same thing. However now it won't even go into the DirectX black screen window, it just crashes.....(when I changed it to what you said that is, although it still compiles)[/quote]

Probably some tiping mistake in the shader. You don't know how often this happend to me, until I started using the nvidia fx composer for writing & testing shaders. I'd recommend you to use such a program, or at least a pre-runtime shader compiler to test for errors. You'll probably have to use the effect framework, but thats not a bad thing either, it makes your life a lot easier.

I mean if anything I should at least get SOMETHING on the window (even if the verticies aren't right) [/quote]

Wrong. If your transform is even a little bit wrong, you are most likely going to see absolutely nothing. Imagine this: Place nothing but a cube right in front of your camera in a directx app. Now turn your camera 180°. What do you see? Nothing. Thats what happens if you don't do transforms properly. The vertices might be placed somewhere outside your cameras range, the projection might be totally screwed up, and the camera is facing god knows where. And thats a logical approach to that topic. Summation: matrix calculation failures will give you nothing but a black screen 99% of the cases.

Share this post


Link to post
Share on other sites
I mean.....My transforms are pretty simple. I set the camera like 7 units above and looking down at the origin....so I don't think that is it. [/quote]

I'm not talking about your transform in general. I'm talking about applying every transform (translate, rotate, scalation) to the world matrix, camera states (position, look target, up-axis), and projection, and finally multiplying these to a world-view-projection-matrix and submit it to the shader. Do you do that properly? At the beginning, I thought I'm doing everything right too, but nothing showed up at all. It took me a few hours to figure out what I did wrong about with my world matrix. Even today, I still have issues like this. If I submit the whole multiplied world-view-projection-matrix to the shader, everthing is fine. But if I multiply every component of that matrix in the shader, I get a black screen. You can never tell whats going on. I'd suggest you try out PIX from the directx sdk, it can tell you the values in your shader. If your matrix is identity or has some strange values like -4*e^10 or so, then your matrices aren't submitted properly to the shader.

Share this post


Link to post
Share on other sites
I guess since Im a beginner I don't really know what I should be looking for, im working off samples and such that i've learned from......So im not sure which part is right.....and which is wrong.

It's very frustrating because theirs not really any Terrain Code for DX11, just DX10 stuff......ugh.

and the DX10 stuff use large classes which makes it extremely confusing to learn. I mean I understand the Tutorials on drawing a box and such, so Drawing a grid shouldn't be much different but somehow it is........I mean if anyone can find the time to see if my Grids are wrong...lemme know because I feel like im SOOO sooo close .

Share this post


Link to post
Share on other sites

I wasn't sure what I do with those matrix globals, and im really not sure what the "Technique" thing is.... but is that sort of what your talking about?


You mean you were not sure how to asign the matrix or what they do? Because in latter case I would advice you to take a step back and learn the basics about 3d programming before starting to get into action. Will make your life a lot easier. If you know what world view and projection does, nevermind.

ok i changed mine to this: (more closer to the code I was doing)
...still failing though same thing...hmmm[/quote]

Are you asigning your matrix correctly? Also, you do your multiplication wrong:

output.position = mul(position, matFinal);


Order is important for matrix multiplications. a * b =/ b*a.
[/quote]
It doesn't matter which way round you write it as the HLSL compiler can figure out what you mean in the case of a row vector * matrix or matrix * column vector. HLSL interprets your vector either as row or column depending on where it is in the mul statement. So the only thing you need to care about is consistency and order when doing matrix * matrix operations as that wil result in errors more info.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!