Welcome, Guest.
Username: Password: Remember me

TOPIC: Access to previous frames

Access to previous frames 4 years 10 months ago #21

I keep getting an error message when I try using a texture rendered from the previous frame.
... \shader@0x2FBE4448(26,8): error X3507: 'currprevTest': Not all control paths return a value

Here's my code hopefully someone can point out what is wrong with it.
...
texture texColorBuffer : COLOR; // or SV_Target

texture	texCurr1
{
	Width 		= 	BUFFER_WIDTH;
	Height 		= 	BUFFER_HEIGHT;
	Format 		= 	RGBA8; 
};

texture	texPrev1
{
	Width 		= 	BUFFER_WIDTH;
	Height 		= 	BUFFER_HEIGHT;
	Format 		= 	RGBA8; 
};

texture	texPrev
{
	Width 		= 	BUFFER_WIDTH;
	Height 		= 	BUFFER_HEIGHT;
	Format 		= 	RGBA8; 
};

sampler samplerColor
{
	Texture 	= texColorBuffer;
	AddressU 	= CLAMP;
	AddressV 	= CLAMP;
	AddressW 	= CLAMP;

	MinFilter 	= LINEAR;
	MagFilter 	= LINEAR;
	MipFilter 	= LINEAR;

	MipLODBias 	= 0.0f;
	
	MinLOD 		= -1000.0f;
	MaxLOD 		= 1000.0f;
	
	MaxAnisotropy 	= 1;
	
	SRGBTexture 	= FALSE;
};

sampler	samplerCurr1
{
	Texture		= texCurr1;
};

sampler	samplerPrev1
{
	Texture		= texPrev1;
};

sampler	samplerPrev
{
	Texture		= texPrev;
};

float4	currprevTest(in float4 pos : SV_Position, in float2 texcoord : TEXCOORD0, out float4 curr : SV_Target0, out float4 prev : SV_Target1)
{
		curr	=	tex2D(samplerColor, texcoord.xy);
		prev	=	tex2D(samplerPrev, texcoord.xy);
}

float4 	MainPS(in float4 pos : SV_Position, in float2 texcoord : TEXCOORD0, out float4 color : SV_Target0, out float4 prev : SV_Target1)
{
		color		=	tex2D(samplerColor, texcoord.xy);

		// stuff...

		color.w		=	1;
		prev		=	color;
}

technique Effect < enabled = true; >
{

	pass currprevPass
	{
		VertexShader 	= MainVS;
		PixelShader 	= currprevTest;

		RenderTarget0	= texCurr1;
		RenderTarget1	= texPrev1;
	}
	pass finalPass
	{
		VertexShader 	= MainVS;
		PixelShader 	= MainPS;

		RenderTarget0	= texColorBuffer;
		RenderTarget1	= texPrev;
	}

}
The administrator has disabled public write access.

Access to previous frames 4 years 10 months ago #22

Deriest wrote:
float4	currprevTest(in float4 pos : SV_Position, in float2 texcoord : TEXCOORD0, out float4 curr : SV_Target0, out float4 prev : SV_Target1)
{
		curr	=	tex2D(samplerColor, texcoord.xy);
		prev	=	tex2D(samplerPrev, texcoord.xy);
}

float4 	MainPS(in float4 pos : SV_Position, in float2 texcoord : TEXCOORD0, out float4 color : SV_Target0, out float4 prev : SV_Target1)
{
		color		=	tex2D(samplerColor, texcoord.xy);

		// stuff...

		color.w		=	1;
		prev		=	color;
}
You are not returning something here, but those functions are specified in that they return a value. In your case you don't want to return anything here though, because that is already done via the "out" parameters. So just write "void currprevTest" and "void MainPS".
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Deriest

Access to previous frames 4 years 10 months ago #23

Wow, something so simple, I totally forgot to do that. Thanks.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2