더 이상 올바르게 그려지지 않는 셰이더가 있습니다. XNA에서 작동했지만 DX11 및 SharpDX 용으로 다시 작성해야했으며 이제 셰이더 모델 5를 사용합니다. 예외는 없으며 쉐이더 효과는 관련이없는 (?) 기본 샘플러를 제외하고 장치에서 디버그 레이어 메시지를 컴파일하지 않고 잘 컴파일합니다 - 상태 불만. 가장 간단한 텍스처 블리트를 수행하는 정상적인 풀 스크린 쿼드입니다. 내가 서명 사이에 불일치가 의심SharpDX D3D11 VertexElement 형식이 일치하지 않습니다?
[VertexElement("SV_Position")]
public Vector3 Position;
[VertexElement("TEXCOORD0")]
public Vector2 TextureCoordinate;
을 : 나는 버텍스 쉐이더 VertexPositionTexutre
포함 된 SharpDX 객체를 공급하고
(테스트를위한 랜덤 노이즈 텍스처를 사용). VertexPositionTexture
에는 "SV_Position"에 대해 정의 된 위치 구성 요소 Vector3
이 있습니다.
d3d11 definesfloat4
으로 "SV_Position". 구체적인 기본 유형이있는 System-Value 상수입니다. 나는 쉐이더가 float3의 끝을 넘어서 여분의 float를 먹고 있다는 것을 두려워한다. Vector3
. 이것은 또한 내 UV가 여러 정점에서 깨지는 이유를 설명합니다. 나는 결과에 변화없이 float3
에 float4
에서 VSCopy()
의 입력을 변경하는 것을 시도했다
struct V2P
{
float4 vPosition : SV_Position;
float2 vTexcoord : TEXCOORD0;
};
V2P VSCopy(float4 InPos : SV_Position,
float2 InTex : TEXCOORD0)
{
V2P Out = (V2P)0;
// transform the position to the screen
Out.vPosition = float4(InPos);
Out.vTexcoord = InTex;
return Out;
}
:
이 내 버텍스 쉐이더입니다. SharpDX VertexPositionTexture
을 다시 컴파일하는 것만 큼,이 문제를 해결하는 방법이 보이지 않지만 SharpDX가 DirectX11을 완벽하게 지원하므로 잘못 처리해야합니다.
내 정점을 정의하고 다음을 설정하고 :
//using SharpDX.Toolkit.Graphics
[...]//In the initialization
verts = new VertexPositionTexture[]
{
new VertexPositionTexture(
new Vector3(1.0f,-1.0f,0),
new Vector2(1,1)),
new VertexPositionTexture(
new Vector3(-1.0f,-1.0f,0),
new Vector2(0,1)),
new VertexPositionTexture(
new Vector3(-1.0f,1.0f,0),
new Vector2(0,0)),
new VertexPositionTexture(
new Vector3(1.0f,1.0f,0),
new Vector2(1,0))
}
//vb is a Buffer<VertexPositionTexture>
short[] indeces = new short[] { 0, 1, 2, 2, 3, 0 };
vb = SharpDX.Toolkit.Graphics.Buffer.Vertex.New(Game.Instance.GraphicsDevice, verts, SharpDX.Direct3D11.ResourceUsage.Dynamic);
ib = SharpDX.Toolkit.Graphics.Buffer.Index.New(Game.Instance.GraphicsDevice, indeces, dx11.ResourceUsage.Dynamic);
[...] //In the Render method, called every frame to draw the quad
Game.Instance.GraphicsDevice.SetVertexBuffer<VertexPositionTexture>(vb, 0);
Game.Instance.GraphicsDevice.SetIndexBuffer(ib, false);
Game.Instance.GraphicsDevice.DrawIndexed(PrimitiveType.TriangleList, 6);
어떻게 정점 버퍼와 입력 레이아웃을 만들었습니까? – megadan
버텍스와 인덱스 버퍼가 정확히 설정되는 방법으로 질문을 업데이트했습니다. – selkathguy
'VertexInputLayout'을 만들고'SetVertexInputLayout'도 호출하고 있습니까? – megadan