Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualOrangeatang

Posted 12 July 2013 - 09:51 AM

Hi there!

 

I'm working on a deferred rendering system for a game I'm building, and am having trouble with the final lighting shader. I have three render targets that I'm passing in to the shader, but it only seems to be sampling from the first.

 

So my lighting shader is set up like this :

Texture2D ColourMap;
SamplerState ColourSampler
{
	Texture 	= (ColourMap);
	AddressU 	= CLAMP;
	AddressV 	= CLAMP;
	MagFilter 	= LINEAR;
	MinFilter 	= LINEAR;
	MipFilter 	= LINEAR;
};

Texture2D NormalMap;
SamplerState NormalSampler
{
	Texture 	= (NormalMap);
	AddressU	= CLAMP;
	AddressV	= CLAMP;
	MagFilter	= POINT;
	MinFilter	= POINT;
	MipFilter	= POINT;
};

Texture2D DepthMap;
SamplerState DepthSampler
{
	Texture 	= (DepthMap);
	AddressU	= CLAMP;
	AddressV	= CLAMP;
	MagFilter	= POINT;
	MinFilter	= POINT;
	MipFilter	= POINT;
};

...

float4 PS( PixelShaderInput anInput ) : SV_TARGET
{
 // lighting bits and pieces
}

And in my pixel shader, returning a sample from the colour target :

return ColourMap.Sample( ColourSampler, anInput.myTexCoords );

Produces the same out put as :

return NormalMap.Sample( NormalSampler, anInput.myTexCoords );

I've been saving the colour and normal targets to screenshots (.dds format) and can confirm that they're different... in fact now I'm just filling my normal render target up with (1.0f, 0.0f, 0.0f) to be safe.

 

This is how I'm setting my sampler states :

ID3D11ShaderResourceView* shaderResources[] = { myColourTarget->myShaderResource, myNormalTarget->myShaderResource, myDepthTarget->myShaderResource };

shader->SetShaderResources( shaderResources, 3 )

...

SetShaderResources( ID3D11ShaderResourceView** someShaderResources, int aShaderResourceCount )
{
 myDeviceContext->PSSetSHaderResources( 0, aShaderResourceCount, someShaderResources );
}

Anything obvious that I'm not spotting here?

 

Thanks for your help!


#3Orangeatang

Posted 12 July 2013 - 09:02 AM

Hi there!

 

I'm working on a deferred rendering system for a game I'm building, and am having trouble with the final lighting shader. I have three render targets that I'm passing in to the shader, but it only seems to be sampling from the first.

 

So my lighting shader is set up like this :

Texture2D ColourMap;
SamplerState ColourSampler
{
	Texture 	= (ColourMap);
	AddressU 	= CLAMP;
	AddressV 	= CLAMP;
	MagFilter 	= LINEAR;
	MinFilter 	= LINEAR;
	MipFilter 	= LINEAR;
};

Texture2D NormalMap;
SamplerState NormalSampler
{
	Texture 	= (NormalMap);
	AddressU	= CLAMP;
	AddressV	= CLAMP;
	MagFilter	= POINT;
	MinFilter	= POINT;
	MipFilter	= POINT;
};

Texture2D DepthMap;
SamplerState DepthSampler
{
	Texture 	= (DepthMap);
	AddressU	= CLAMP;
	AddressV	= CLAMP;
	MagFilter	= POINT;
	MinFilter	= POINT;
	MipFilter	= POINT;
};

...

float4 PS( PixelShaderInput anInput ) : SV_TARGET
{
 // lighting bits and pieces
}

And in my pixel shader, returning a sample from the colour target :

return ColourMap.Sample( ColourSampler, anInput.myTexCoords );

Produces the same out put as :

return NormalMap.Sample( NormalSampler, anInput.myTexCoords );

I've been saving the colour and normal targets to screenshots (.dds format) and can confirm that they're different... in fact now I'm just filling my normal render target up with (1.0f, 0.0f, 0.0f) to be safe.

 

This is how I'm setting my sampler states :

ID3D11ShaderResourceView* shaderResources[] = { myColourTarget->myShaderResource, myNormalTarget->myShaderResource, myDepthTarget->myShaderResource };

shader->SetShaderResources( shaderResources, 3 )

...

SetShaderResources( ID3D11ShaderResourceView** someShaderResources, int aShaderResourceCount )
{
 myDeviceContext->PSSetSHaderResources( 0, aShaderResourceCount, someShaderResources );
}

Anything obvious that I'm not spotting here?

 

Thanks for your help!


#2Orangeatang

Posted 12 July 2013 - 08:59 AM

Hi there!

 

I'm working on a deferred rendering system for a game I'm building, and am having trouble with the final lighting shader. I have three render targets that I'm passing in to the shader, but it only seems to be sampling from the first.

 

So my lighting shader is set up like this :

Texture2D ColourMap;
SamplerState ColourSampler
{
	Texture 	= (ColourMap);
	AddressU 	= CLAMP;
	AddressV 	= CLAMP;
	MagFilter 	= LINEAR;
	MinFilter 	= LINEAR;
	MipFilter 	= LINEAR;
};

Texture2D NormalMap;
SamplerState NormalSampler
{
	Texture 	= (NormalMap);
	AddressU	= CLAMP;
	AddressV	= CLAMP;
	MagFilter	= POINT;
	MinFilter	= POINT;
	MipFilter	= POINT;
};

Texture2D DepthMap;
SamplerState DepthSampler
{
	Texture 	= (DepthMap);
	AddressU	= CLAMP;
	AddressV	= CLAMP;
	MagFilter	= POINT;
	MinFilter	= POINT;
	MipFilter	= POINT;
};

...

float4 PS( PixelShaderInput anInput ) : SV_TARGET
{
 // lighting bits and pieces
}

And in my pixel shader, returning a sample from the colour target :

return ColourMap.Sample( ColourSampler, anInput.myTexCoords );

Produces the same out put as :

return NormalMap.Sample( NormalSampler, anInput.myTexCoords );

I've been saving the colour and normal targets to (.dds format) and can confirm that they're different... in fact now I'm just filling my normal render target up with red to be safe.

 

This is how I'm setting my sampler states :

ID3D11ShaderResourceView* shaderResources[] = { myColourTarget->myShaderResource, myNormalTarget->myShaderResource, myDepthTarget->myShaderResource };

shader->SetShaderResources( shaderResources, 3 )

...

SetShaderResources( ID3D11ShaderResourceView** someShaderResources, int aShaderResourceCount )
{
 myDeviceContext->PSSetSHaderResources( 0, aShaderResourceCount, someShaderResources );
}

Anything obvious that I'm not spotting here?

 

Thanks for your help!


#1Orangeatang

Posted 12 July 2013 - 08:58 AM

Hi there!

 

I'm working on a deferred rendering system for a game I'm building, and am having trouble with the final lighting shader. I have three render targets that I'm passing in to the shader, but it only seems to be sampling from the first.

 

So my lighting shader is set up like this :

Texture2D ColourMap;
SamplerState ColourSampler
{
	Texture 	= (ColourMap);
	AddressU 	= CLAMP;
	AddressV 	= CLAMP;
	MagFilter 	= LINEAR;
	MinFilter 	= LINEAR;
	MipFilter 	= LINEAR;
};

Texture2D NormalMap;
SamplerState NormalSampler
{
	Texture 	= (NormalMap);
	AddressU	= CLAMP;
	AddressV	= CLAMP;
	MagFilter	= POINT;
	MinFilter	= POINT;
	MipFilter	= POINT;
};

Texture2D DepthMap;
SamplerState DepthSampler
{
	Texture 	= (DepthMap);
	AddressU	= CLAMP;
	AddressV	= CLAMP;
	MagFilter	= POINT;
	MinFilter	= POINT;
	MipFilter	= POINT;
};

...

float4 PS( PixelShaderInput anInput ) : SV_TARGET
{
 // lighting bits and pieces
}

And in my pixel shader, returning a sample from the colour target :

return ColourMap.Sample( ColourSampler, anInput.myTexCoords );

Produces the same out put as :

NormalMap.Sample( NormalSampler, anInput.myTexCoords );

I've been saving the colour and normal targets to (.dds format) and can confirm that they're different... in fact now I'm just filling my normal render target up with red to be safe.

 

This is how I'm setting my sampler states :

ID3D11ShaderResourceView* shaderResources[] = { myColourTarget->myShaderResource, myNormalTarget->myShaderResource, myDepthTarget->myShaderResource };

shader->SetShaderResources( shaderResources, 3 )

...

SetShaderResources( ID3D11ShaderResourceView** someShaderResources, int aShaderResourceCount )
{
 myDeviceContext->PSSetSHaderResources( 0, aShaderResourceCount, someShaderResources );
}

Anything obvious that I'm not spotting here?


PARTNERS