Error to build fxaa3_11 on my sahder

hi, I try to compile my fxaa shader but I get this output from the pipeline tool:

FXAA.fx(100,2): error X4532: texlod not supported on this target

#if SM4
#define PS_PROFILE ps_4_0_level_9_1
#define VS_PROFILE vs_4_0
#define COLOR_OUTPUT SV_Target0
#define POSITION_INPUT SV_Position

#define DEFINE_2D_TEXTURE(tex) Texture2D tex##Texture; \
SamplerState tex##Sampler { AddressU = Wrap; AddressV = Wrap; }

#define DEFINE_2D_TEXTURE_RG(tex, regIndex) Texture2D tex##Texture : register(PS_PROFILE,t##regIndex); \
SamplerState tex##Sampler : register(PS_PROFILE,s##regIndex)

#define SAMPLE_TEXTURE_2D(tex, coord) tex##Texture.Sample(tex##Sampler, coord)

#elif SM3

#define PS_PROFILE ps_3_0
#define VS_PROFILE vs_3_0
#define COLOR_OUTPUT COLOR0
#define POSITION_INPUT POSITION

#define DEFINE_2D_TEXTURE(tex) Texture2D tex##Texture; \
sampler tex##Sampler = sampler_state { Texture = ; }

#define DEFINE_2D_TEXTURE_RG(tex, regIndex) sampler tex##Sampler : register(PS_PROFILE,s##regIndex)

#define SAMPLE_TEXTURE_2D(tex, coord) tex2D(tex##Sampler, coord)

#else

#define PS_PROFILE ps_2_0
#define VS_PROFILE ps_2_0
#define COLOR_OUTPUT COLOR0
#define POSITION_INPUT POSITION

#define DEFINE_2D_TEXTURE(tex) Texture2D tex##Texture; \
sampler tex##Sampler = sampler_state { Texture = ; }

#define DEFINE_2D_TEXTURE_RG(tex, regIndex) sampler tex##Sampler : register(PS_PROFILE,s##regIndex)

#define SAMPLE_TEXTURE_2D(tex, coord) tex2D(tex##Sampler, coord)

#endif

#ifdef XBOX
#define FXAA_360 1
#else
#define FXAA_PC 1
#endif
#define FXAA_QUALITY__PRESET 23
#define FXAA_GREEN_AS_LUMA 1
#define FXAA_HLSL_4 1

#include "Fxaa3_11.fxh"

float4x4 World;
float4x4 View;
float4x4 Projection;

Texture2D TheTexture : register(t0);
SamplerState TheSampler : register(s0);

float4 VertexShaderFunction( float4 Position : POSITION0, float4 _Color : COLOR0, float2 _TexCoord : TEXCOORD0) : SV_Position0
{
float4 output;
float4 worldPosition = mul(Position, World);
float4 viewPosition = mul(worldPosition, View);
output = mul(viewPosition, Projection);

return output;
}

float2 InverseViewportSize;
float4 ConsoleSharpness;
float4 ConsoleOpt1;
float4 ConsoleOpt2;
float SubPixelAliasingRemoval;
float EdgeThreshold;
float EdgeThresholdMin;
float ConsoleEdgeSharpness;

float ConsoleEdgeThreshold;
float ConsoleEdgeThresholdMin;
// Must keep this as constant register instead of an immediate
float4 Console360ConstDir = float4(1.0, -1.0, 0.25, -0.25);

float4 PixelShaderFunction_FXAA(float4 _Position : POSITION_INPUT, float4 _Color : COLOR0, float2 _TexCoord : TEXCOORD0 ) : COLOR_OUTPUT
{
#ifdef SM4
FxaaTex theSample = {TheSampler, TheTexture};
#else
float4 theSample = tex2D(TheSampler, _TexCoord); 
#endif

return FxaaPixelShader( 
    _TexCoord,
     float4(0,0,0,0),   // Not used in PC or Xbox 360
    theSample,
    theSample,          
    theSample,          
    InverseViewportSize,    // FXAA Quality only
    ConsoleSharpness,       
    ConsoleOpt1,
    ConsoleOpt2,
    SubPixelAliasingRemoval,
    EdgeThreshold,
    EdgeThresholdMin,
    ConsoleEdgeSharpness,
    ConsoleEdgeThreshold,   
    ConsoleEdgeThresholdMin, 
    Console360ConstDir
    );
}

float4 PixelShaderFunction_Standard(float4 _Position : POSITION_INPUT, float4 _Color : COLOR0, float2 _TexCoord : TEXCOORD0) : COLOR_OUTPUT
{
#ifdef SM4
return TheTexture.SampleLevel( TheSampler, _TexCoord, 0);
#else
return tex2D(TheSampler, _TexCoord);
#endif

}

technique Standard
{
pass Pass1
{
VertexShader = compile VS_PROFILE VertexShaderFunction();
PixelShader = compile PS_PROFILE PixelShaderFunction_Standard();
}
}

technique FXAA
{
pass Pass1
{
VertexShader = compile VS_PROFILE VertexShaderFunction();
PixelShader = compile PS_PROFILE PixelShaderFunction_FXAA();
}
}

please need help

well texlod is not supported on this target. Define a higher shadermodel maybe

hi, thanks for your answers @kosmonautgames, I don’t know how to do that, I know that monogame use shader model 4, I have defined FXAA_HLSL_4 for fxaa file but i don’t if I do something wrong.
ps: sorry for my english.

You can change the profile in

PixelShader = compile PS_PROFILE PixelShaderFunction_FXAA();

e.g.

PixelShader = compile ps_4_0 PixelShaderFunction_FXAA();

Or change

#define PS_PROFILE ps_4_0_level_9_1

at the top of your file to

#define PS_PROFILE ps_4_0

Hi @Jjagg, very thank you, it work fine !!

1 Like

Hello everyone, it’s me again, unfortunately with the same problem, I changed my
#define PS_PROFILE ps_4_0_level_9_1
with
#define PS_PROFILE ps_4_0

content pipeline build fine .fx file, but monogame bug when I try to load this effect.

L’exception SharpDX.SharpDXException n’a pas été gérée
HResult=-2147024809
Message=HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: Paramètre incorrect.

Source=SharpDX
StackTrace:
Ă  SharpDX.Result.CheckError()
Ă  SharpDX.Direct3D11.Device.CreatePixelShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, PixelShader pixelShaderOut)
à SharpDX.Direct3D11.PixelShader…ctor(Device device, Byte shaderBytecode, ClassLinkage linkage)
Ă  Microsoft.Xna.Framework.Graphics.Shader.CreatePixelShader() dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Graphics\Shader\Shader.DirectX.cs:ligne 90
Ă  Microsoft.Xna.Framework.Graphics.Shader.PlatformConstruct(Boolean isVertexShader, Byte shaderBytecode) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Graphics\Shader\Shader.DirectX.cs:ligne 65
à Microsoft.Xna.Framework.Graphics.Shader…ctor(GraphicsDevice device, BinaryReader reader) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Graphics\Shader\Shader.cs:ligne 116
Ă  Microsoft.Xna.Framework.Graphics.Effect.ReadEffect(BinaryReader reader) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Graphics\Effect\Effect.cs:ligne 267
à Microsoft.Xna.Framework.Graphics.Effect…ctor(GraphicsDevice graphicsDevice, Byte effectCode, Int32 index, Int32 count) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Graphics\Effect\Effect.cs:ligne 107
Ă  Microsoft.Xna.Framework.Content.EffectReader.Read(ContentReader input, Effect existingInstance) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Content\ContentReaders\EffectReader.cs:ligne 20
Ă  Microsoft.Xna.Framework.Content.ContentTypeReader1.Read(ContentReader input, Object existingInstance) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Content\ContentTypeReader.cs:ligne 57 Ă  Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Content\ContentReader.cs:ligne 188 Ă  Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]() dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Content\ContentReader.cs:ligne 163 Ă  Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]() dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Content\ContentReader.cs:ligne 72 Ă  Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action1 recordDisposableObject) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Content\ContentManager.cs:ligne 304
Ă  Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Content\ContentManager.cs:ligne 226
Ă  FXAATest.Game1.LoadContent() dans D:\WORK_LEADPROG_TCHEKS\ASTRAL_ENGINE_1.0\MY_ASTRAL\ASTRAL_Port2\FXAATest\FXAATest\Game1.cs:ligne 54
Ă  Microsoft.Xna.Framework.Game.Initialize() dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Game.cs:ligne 543
Ă  FXAATest.Game1.Initialize() dans D:\WORK_LEADPROG_TCHEKS\ASTRAL_ENGINE_1.0\MY_ASTRAL\ASTRAL_Port2\FXAATest\FXAATest\Game1.cs:ligne 40
Ă  Microsoft.Xna.Framework.Game.DoInitialize() dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Game.cs:ligne 679
Ă  Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Game.cs:ligne 384
Ă  Microsoft.Xna.Framework.Game.Run() dans d:\TDJ\GitHub\MonoGame\MonoGame.Framework\Game.cs:ligne 370
Ă  FXAATest.Program.Main() dans D:\WORK_LEADPROG_TCHEKS\ASTRAL_ENGINE_1.0\MY_ASTRAL\ASTRAL_Port2\FXAATest\FXAATest\Program.cs:ligne 18

it seems that monogame does not load when pixel shader effects is compile ps_4_0

I’m sorry I can’t see what the problem is, but some other people have implemented FXAA in Monogame (for example DigitalRune engine, which was open sourced recently, but there are many others if you google). Maybe you can compare and see what they do differently.