Jump to content

  • Log In with Google      Sign In   
  • Create Account

Endemoniada

Member Since 01 Jul 2003
Offline Last Active Feb 19 2016 04:13 PM

Topics I've Started

Should I always use float4 ?

19 February 2016 - 04:08 PM

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.


HLSL Bilinear Filtering ?

13 January 2016 - 08:47 PM

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.

 


Shader Technique Alternative for D3D11 ?

02 January 2016 - 08:14 PM

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.

 


ResolveSubresource() Failing for non-R8G8B8A8_UNORM

26 December 2015 - 02:45 PM

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.

 


Temporally Smoothing SSAO ?

16 December 2015 - 12:22 PM

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.

 


PARTNERS