Ego Eram Reputo Posted April 13 Share Posted April 13 11 hours ago, fd2 said: I want to call few plugins in a row. Seen the latest API documentation? https://paintdotnet.github.io/apidocs/api/index.html There are a great many effects you can access and chain together. For example, see https://paintdotnet.github.io/apidocs/api/PaintDotNet.Effects.Gpu.html 1 Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 13 Author Share Posted April 13 16 hours ago, Ego Eram Reputo said: Seen the latest API documentation? https://paintdotnet.github.io/apidocs/api/index.html There are a great many effects you can access and chain together. For example, see https://paintdotnet.github.io/apidocs/api/PaintDotNet.Effects.Gpu.html There are also these effects: https://paintdotnet.github.io/apidocs/api/PaintDotNet.Direct2D1.Effects.html The effects you can chain together are Direct2D effects. You can write a Paint.NET effect (yes the term "effect" is overloaded) that chains them together, but you can't combine Paint.NET effects like that. But that shouldn't matter because all of the bulit-in Paint.NET effects are essentially UI wrappers for the Direct2D effects. The effects whose names begin with "Pdn" are the Direct2D effects that power the built-in Paint.NET effects that you see in the app menus. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Timo Kinnunen Posted 16 hours ago Share Posted 16 hours ago Am I using SampleMapRenderer incorrectly or missing something? I'm getting CyclicGraphExceptions but I don't see what the problem could be. Here's the code: private static IDeviceImage SampleAt(IDeviceContext dc, IDeviceImage src, float offsetX, float offsetY) { IDeviceImage sm = new HlslBinaryOperatorEffect(dc, new ScenePositionEffect(dc, ScenePositionFormat.XY01), HlslBinaryOperator.Add, new Vector4Float(offsetX, offsetY, 0f, 0f)); SampleMapRenderer r = new SampleMapRenderer(dc); r.Properties.Input.Set(src); r.Properties.SampleMaps.SetCount(1); r.Properties.SampleMaps[0].Set(sm); r.Properties.EdgeMode.SetValue(SampleMapEdgeMode.Clamp); r.Properties.SamplingMode.SetValue(SampleMapSamplingMode.Linear); return r; } protected override IDeviceImage OnCreateOutput(IDeviceContext dc) { IDeviceImage src = Environment.SourceImage; //IDeviceImage sX1 = SampleAt(dc, src, -0.25f, 0f), sX2 = SampleAt(dc, src, 0.25f, 0f); return new HlslBinaryOperatorEffect(dc, new HlslBinaryFunctionEffect(dc, HlslBinaryFunction.Dot, sX1, sX1), HlslBinaryOperator.Subtract, new HlslBinaryFunctionEffect(dc, HlslBinaryFunction.Dot, sX2, sX2)); // Doesn't help return new HlslBinaryOperatorEffect(dc, new HlslBinaryFunctionEffect(dc, HlslBinaryFunction.Dot, SampleAt(dc, src, -0.25f, 0f), SampleAt(dc, src, -0.25f, 0f)), HlslBinaryOperator.Subtract, new HlslBinaryFunctionEffect(dc, HlslBinaryFunction.Dot, SampleAt(dc, src, +0.25f, 0f), SampleAt(dc, src, +0.25f, 0f))); } Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted 14 hours ago Author Share Posted 14 hours ago @Timo Kinnunen There's a few things here. First, SampleMapRenderer is a bit picky due to some low-level internal Direct2D particulars. You will need to wrap Environment.SourceImage by using deviceContext.CreateBufferedImage(), and use that image instead of Environment.SourceImage. I've already seen this happen in another situation where it throws an InvalidGraphConfiguration, and I put in a special error message to direct folks to CreateBufferedImage(), but it looks like the effect graph you're creating is resulting in a cyclic graph instead. I'm not entirely sure how/why, but the DynamicImage framework (which SampleMapRenderer is based on) does some really really crazy stuff to achieve what it's doing, and it may be putting Direct2D into a state that just doesn't make sense. Second, SampleMapRenderer is definitely not the right tool to use for what you're doing. SampleMapRenderer is meant for distortion effects, like Effects -> Distort -> Dents, which sample pixels from all over the image. In order to achieve this, it requires a LOT of processing power in the general case (the internal effects have access to a property that helps to massively reduce that). You're only doing a sampling offset of +/- 0.25 pixels, so SMR is horrendously inefficient. Since your sampling is so simple, try using DisplacementMapEffect instead ( PDN docs, MSFT docs ). Outside of CodeLab, this would probably be best done with a custom shader written with ComputeSharp.D2D1. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.