Jump to content

  • Log In with Google      Sign In   
  • Create Account

Problem with rendering to 3D Texture?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Waaayoff   Members   -  Reputation: 783

Like
0Likes
Like

Posted 05 July 2013 - 08:04 AM

I wrote a simple test code that creates a 3D texture and fills it with red pixels. All i get is the same colour i'm setting the render target to. Here's the shader code: (The problem is probably here)

struct GS_OUT_LAYER
{
	float4 posH	: SV_POSITION;
	uint layer	: SV_RenderTargetArrayIndex;
};

float4 VShader(float4 pos : POSITION) : SV_POSITION
{
	return pos;
}

[maxvertexcount(3)]
void GShader(triangle float4 input[3] : POSITION, inout TriangleStream<GS_OUT_LAYER> triStream)
{
	GS_OUT_LAYER output;

	output.posH  = input[0];
	output.layer = 0; 
	triStream.Append(output);
	
	output.posH  = input[1];
	output.layer = 0; 
	triStream.Append(output);
	
	output.posH  = input[2];
	output.layer = 0; 
	triStream.Append(output);
}

float4 PShader(GS_OUT_LAYER input) : SV_TARGET
{
	return float4(1, 0, 0, 1);
}

And this is how i create the texture and render target:

RenderEffect Test3DEffect;
	
	Test3DEffect.pVertexShader = mRenderer->LoadShader(VERTEX_SHADER, "Shaders/Test3D.hlsl", "VShader", "vs_4_0");
	Test3DEffect.pGeometryShader = mRenderer->LoadShader(GEOMETRY_SHADER, "Shaders/Test3D.hlsl", "GShader", "gs_4_0");
	Test3DEffect.pPixelShader = mRenderer->LoadShader(PIXEL_SHADER, "Shaders/Test3D.hlsl", "PShader", "ps_4_0");

	Texture3D* Test3DTexture;
	TConfig3d.Width = 256;
	TConfig3d.Height = 64;
	TConfig3d.Depth = 32;
	TConfig3d.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
	TConfig3d.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
	Test3DTexture = mRenderer->CreateTexture3D(TConfig3d, NULL);

	int TestTarget;
	RTConfig.Format = TConfig3d.Format;
	RTConfig.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
	RTConfig.Texture3D.MipSlice = 0;
	RTConfig.Texture3D.FirstWSlice = 0;
	RTConfig.Texture3D.WSize = 32;
	TestTarget = mRenderer->CreateRenderTargetView(Test3DTexture, &RTConfig);

	mPipeline->SetRenderTargets(1, &TestTarget, &mZBuffer);
	mPipeline->ClearRenderTarget(0, D3DXCOLOR(0.2f, 0.3f, 0.6f, 1.0f));
	mPipeline->ClearDepthStencilView();
	mPipeline->SetViewport(TransmittanceViewport);

	pQuad->SetRenderEffect( &Test3DEffect );
	cmd = pQuad->GetRenderCommand();
	
	mPipeline->Draw(cmd);

	mRenderer->Present();

	mPipeline->SaveTextureToFile(Test3DTexture->GetResource(), D3DX11_IFF_DDS, "Test3D.dds"); 

Edited by Waaayoff, 05 July 2013 - 08:06 AM.

"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

Sponsor:

#2 Waaayoff   Members   -  Reputation: 783

Like
0Likes
Like

Posted 05 July 2013 - 08:51 AM

Well i found the problem; i don't know why but it works when i don't set a depth stencil view. Works for 1st slice anyway since i'm setting it directly to zero in shader.

 

Edit: I forgot to mention that in the geometry shader this:

 

triangle float4 input[3] : POSITION

 

should be changed to this:

 

triangle float4 input[3] : SV_POSITION


Edited by Waaayoff, 05 July 2013 - 09:24 AM.

"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS