# I don't think my shaders are working, looking for help

Using sharpdx(directx 11) developing on UWP.

This is a link to a previous question of not being able to compile the shader files(written in hlsl) How to compile shader files in UWP Later I have found some method to avoid the original exception(unable to open or find shader files) but still the shaders seem not to be working.

My method to "avoid the original exception" is to change the file path to

System.IO.Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "ProjectName")


If the method works, I would surely post it as an answer to the previous question

The current problem is no display on the screen(all black), while I can check the stored data in the vertex buffer using graphic diagnostics tools built in visual studio.

Here is my code for the shaders, problem may be going from here because this is the first shader file I've written. Please have a look and discuss may things go wrong.

struct VertexOut
{
float4 PosH : SV_POSITION;
float4 Color : COLOR;
};

float4 PS(VertexOut pin) : SV_Target
{
return pin.Color;
}


cbuffer dataBuffer : register(b0)
{
matrix ViewProjection;
};

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), ViewProjection);
// Just pass vertex color into the pixel shader.
vout.Color = vin.Color;
return vout;
}


where I compiled them

byte[] vertexShaderByteCode = ShaderBytecode.CompileFromFile(this.path + "\\Transf_VS.fx", "VS", "vs_5_0");
device,
);
device,
);


data structure definition

public struct ScatterVertex
{
SharpDX.Vector3 Position;
SharpDX.Color4 Color;
}


inputlayout initialization

this.inputLayout = new D3D11.InputLayout(
this.device,
inputSignature,
new SharpDX.Direct3D11.InputElement[]
{
new D3D11.InputElement(
"Position",
0,
SharpDX.DXGI.Format.R32G32B32_Float,
0
),
new D3D11.InputElement(
"Color",
0,
SharpDX.DXGI.Format.R32G32B32A32_Float,//I'm not very sure whether or why I should use this option
0
)
}
);


Here's the projection matrix in the camera class, which is later sent to the constant buffer

private Matrix View { get { return Matrix.LookAtLH(this.Eye, this.Target, this.Up); } }
private Matrix Proj { get { return Matrix.PerspectiveFovLH(this.Fov, this.Aspect, this.Near, this.Far); } }
public Matrix WorldViewProject
{
get
{
Matrix wvp = (this.View * this.Proj);
wvp.Transpose();
return wvp;
}
}


If you need anything else to solve this, just let me know and I'll manage to get it. Thank you!

• Unfortunately in graphics programming 'blank screen' can come about for any number of reasons. Where is the code where you update the ViewProjection value in your constant buffer? Nov 10 '16 at 6:09
• It's a bit long, let me check it myself first Nov 10 '16 at 6:56
• I've updated the answer Nov 10 '16 at 7:53

It turns out the problem is not with the shader, but the Draw method. I missed setting the first parameter of draw in my code, which should be the primitives I am intending to draw.