Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 01 Jul 2003
Offline Last Active Aug 08 2016 10:44 AM

Posts I've Made

In Topic: HLSL Bilinear Filtering ?

18 January 2016 - 09:49 PM

Thanks a lot everyone, especially Matt, for taking the time to explain it to me.

In Topic: Passing Variables to Pixel Shader using Shader class

02 January 2016 - 08:03 PM



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;
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;
d3d_context->UpdateSubresource(d3d_const_buffer, 0, nullptr, &light_shader.const_buffer, 0, 0);

Is that what you mean ?

In Topic: Enable MSAA in DirectX 11

27 December 2015 - 11:38 AM



Here are two different ways I set my quality, they may not be the best ways to do it:

UINT msaa_quality;
// method 1
// 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);

In Topic: Off Center Projection ?

07 December 2015 - 05:49 PM

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.

In Topic: Disable MSAA for Rendering Depth and Normals ?

25 September 2015 - 10:51 AM

Thanks for clearing that up for me Hodgman.


PS - that site you linked has some great stuff