Help with simple example using techniques

share shaders here
Post Reply
  • Author
  • Message
Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Help with simple example using techniques

Hi Boris,
I am trying to understand creating more than one technique in enbeffect.fx I have a simple file shown below with only the essentials, 2 pixel shaders that return red and blue, and 2 techniques. I thought I would be able to switch techniques in the shader window and see either the red or blue color, but I can only see the red shader whether red or blue is selected. Did I misunderstand how this is supposed to work?
Thanks for any help!

Here's my enbeffect.fx file:

Code: Select all

struct VS_OUTPUT_POST
{
	float4 vpos  : POSITION;
	float2 txcoord0 : TEXCOORD0;
};

struct VS_INPUT_POST
{
	float3 pos  : POSITION;
	float2 txcoord0 : TEXCOORD0;
};

VS_OUTPUT_POST VS_Quad(VS_INPUT_POST IN)
{
	VS_OUTPUT_POST OUT;

	OUT.vpos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);

	OUT.txcoord0.xy=IN.txcoord0.xy;

	return OUT;
}

float4 PS_red(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
	return float4(1,0,0,1);
}

float4 PS_blue(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
	return float4(0,0,1,1);
}

technique Shader_red <string UIName="Red";>
{
	pass p0
	{
		VertexShader  = compile vs_3_0 VS_Quad();
		PixelShader  = compile ps_3_0 PS_red();

		ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
		ZEnable=FALSE;
		ZWriteEnable=FALSE;
		CullMode=NONE;
		AlphaTestEnable=FALSE;
		AlphaBlendEnable=FALSE;
		SRGBWRITEENABLE=FALSE;
	}
}

technique Shader_blue<string UIName="Blue";>
{
	pass p0
	{
		VertexShader  = compile vs_3_0 VS_Quad();
		PixelShader  = compile ps_3_0 PS_blue();

		ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
		ZEnable=FALSE;
		ZWriteEnable=FALSE;
		CullMode=NONE;
		AlphaTestEnable=FALSE;
		AlphaBlendEnable=FALSE;
		SRGBWRITEENABLE=FALSE;
	}
}
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

Offline
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

Re: Help with simple example using techniques

Not sure if enbeffect.fx can support multiple techniques... I never got it working, but also, is there any practical use for it...? I would be interested in what you are thinking off. I think most interesting files are bloom, prepass and effect, since well, they allow a lot of fun :)

Drop me a message in what you try and do, perhaps I can help? Not sure. Cheers

Offline
User avatar
*master*
Posts: 119
Joined: 05 Jan 2012, 22:34
Location: France

Re: Help with simple example using techniques

enbeffect.fx is single-pass.
Try your effect in effect.txt, should be fine.

Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: Help with simple example using techniques

Hi,
Thanks for your reply. That's too bad about enbeffect.fx only being single pass. I can't use it on effect.txt because what I hoped to do with it involved the use of the game color correction registers which, AFAIK, are only available in enbeffect.fxc.
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

Offline
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

Re: Help with simple example using techniques

What is wrong with just using if() statements to enable/disable certain parts? my enbeffect.fx file and effect.txt file contain various color correction methods and so on that can be enabled/disabled.

Another way with it is put everything in separate functions and simply enable/disable certain functions, same stuff but cleaner. Have a look at how Skylight ENB is build up using its functions in separated .fxh files. Maybe it will give you some ideas.

If performance is a concern just use directives to ommit certain parts from the shader when its compiled, but those cant be adjusted from GUI without pressing the Apply button after they have been changed.
Post Reply