Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMigi0027

Posted 25 June 2013 - 05:35 AM

Hi guys, again...

 

I'm having a problem with multiple render targets, where only the first render target gets filled out (has a value).

 

Setting the render targets:

DeferredRender.ApplyShader(dev, devcon);

DeferredRender.mDepth.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);
DeferredRender.mNormals.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);
DeferredRender.mLighting.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);

ID3D11RenderTargetView *deferredViews[3];

deferredViews[0] = DeferredRender.mDepth.m_renderTargetView;
deferredViews[1] = DeferredRender.mNormals.m_renderTargetView;
deferredViews[2] = DeferredRender.mLighting.m_renderTargetView;

devcon->OMSetRenderTargets(3, deferredViews, zbuffer);

RenderScene(STATE_DEFERRED);

gBuffer_Depth = DeferredRender.mDepth.GetShaderResourceView();
gBuffer_Normals = DeferredRender.mNormals.GetShaderResourceView();
gBuffer_Lighting = DeferredRender.mLighting.GetShaderResourceView();

Pixel Shader: (This is just a testing shader, it isn't complete)

struct POut
{
	float4 Depth    : SV_Target0;
	float4 Normals  : SV_Target1;
	float4 Lighting : SV_Target2;
};

POut PShader(VOut input)
{
	POut output;

	// Initialize
	output.Depth = float4(0,0,0,1);
	output.Normals = float4(0,1,0,1);
	output.Lighting = float4(0,1,0,1);

	// Depth
	float depth = (input.depthPosition.z / input.depthPosition.w);
	output.Depth = float4(depth, depth, depth, 1);
	if (_alphamap == 1)
	{
		output.Depth.a *= t_alphamap.Sample(ss, input.texcoord).a;
	}
	if (_diffusealpha == 1)
	{
		output.Depth.a *= t_dffalpha.Sample(ss, input.texcoord).a;
	}

	// Normals
	float3 viewSpaceNormalizedNormals = 0.5 * normalize (input.normal) + 0.5; //0.5 * normalize (input.normal) + 0.5
	output.Normals = float4(viewSpaceNormalizedNormals, 1);

	return output;
}

But as I said, only the first render target gets set, the others doesn't, and I don't get why. Am I even setting the render targets correctly?

 

THANKS!


#1Migi0027

Posted 25 June 2013 - 05:33 AM

Hi guys, again...

 

I'm having a problem with multiple render targets, where only the first render target gets filled out (has a value).

 

Setting the render targets:

DeferredRender.ApplyShader(dev, devcon);

DeferredRender.mDepth.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);
DeferredRender.mNormals.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);
DeferredRender.mLighting.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);

ID3D11RenderTargetView *deferredViews[3];

deferredViews[0] = DeferredRender.mDepth.m_renderTargetView;
deferredViews[1] = DeferredRender.mNormals.m_renderTargetView;
deferredViews[2] = DeferredRender.mLighting.m_renderTargetView;

devcon->OMSetRenderTargets(3, deferredViews, zbuffer);

RenderScene(STATE_DEFERRED);

gBuffer_Depth = DeferredRender.mDepth.GetShaderResourceView();
gBuffer_Normals = DeferredRender.mNormals.GetShaderResourceView();
gBuffer_Lighting = DeferredRender.mLighting.GetShaderResourceView();

Pixel Shader: (This is just a testing shader, it isn't complete)

struct POut
{
	float4 Depth    : SV_Target0;
	float4 Normals  : SV_Target1;
	float4 Lighting : SV_Target2;
};

POut PShader(VOut input)
{
	POut output;

	// Initialize
	output.Depth = float4(0,0,0,1);
	output.Normals = float4(0,1,0,1);
	output.Lighting = float4(0,1,0,1);

	// Depth
	float depth = (input.depthPosition.z / input.depthPosition.w);
	output.Depth = float4(depth, depth, depth, 1);
	if (_alphamap == 1)
	{
		output.Depth.a *= t_alphamap.Sample(ss, input.texcoord).a;
	}
	if (_diffusealpha == 1)
	{
		output.Depth.a *= t_dffalpha.Sample(ss, input.texcoord).a;
	}

	// Normals
	float3 viewSpaceNormalizedNormals = 0.5 * normalize (input.normal) + 0.5; //0.5 * normalize (input.normal) + 0.5
	output.Normals = float4(viewSpaceNormalizedNormals, 1);

	return output;
}

But as I said, only the first render target gets set, the others doesn't, and I don't get why. Am I even setting the render targets correctly?

 

THANKS!


PARTNERS