#Can someone please explain how to add a new shader to the game?
1 messages · Page 1 of 1 (latest)
I've managed to make some changes to Isometric_World and learned that I need to rebuild to see the changes on the game. Also, broke everything hahah
But I've tried using the same logic that xBR uses in GameScene and got no results. :/
{
invert = new InvertEffect(batcher.GraphicsDevice);
}
invert.Sampler.SetValue(new Texture2D(batcher.GraphicsDevice, Camera.Bounds.Width, Camera.Bounds.Height));
This should work?
Here's the shader, it's pretty simple
float4 mainPS(float2 coords: TEXCOORD0) : COLOR0
{
float4 color = tex2D(s0, coords);
if (!any(color)) return color;
color.rgb = 1 - color.rgb;
return color;
}
technique Technique1
{
pass Pass1
{
PixelShader = compile ps_2_0 mainPS();
}
}```
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace ClassicUO.Renderer
{
public class ExampleEffect : Effect
{
public ExampleEffect(GraphicsDevice graphicsDevice) : base(graphicsDevice, Resources.GetExampleEffect().ToArray())
{`
}
public EffectParameter MatrixTransform { get; }
public EffectParameter TextureSize { get; }
}
}```
What am I doing wrong? 😮
Working! Took time to read a good tutorial: https://gmjosack.github.io/posts/my-first-2d-pixel-shaders-part-1/
You need to set everything up on batcher2d.cs after you create your effect
Now gotta figure out how to apply this just to the viewport