#Can someone please explain how to add a new shader to the game?

1 messages · Page 1 of 1 (latest)

fleet arch
#

Hi, I'd like to explore adding more shaders to the client, some pointers would be helpful! Thanks!

fleet arch
#

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?

#

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? 😮

fleet arch
#

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

fleet arch
#

All right, after Jaedan's tips I managed to use render_target to add simple shaders only to the viewport. But at what cost?
Now Zoom doesn't work anymore! :/

#

Does anyone knows how would I be able to restore the zoom while using render_target?