Sign in to follow this  
Sakana Oji

Plugin development by Sakana Oji

Recommended Posts

On 11/16/2015 at 5:31 AM, MJW said:

The following plugin has an initial blur, followed by a brightness and contrast adjustment

Is there a way to call the brightness and contrast adjustment before applying the blur? I want to add this to my HDR effect, though I already built it without the adjustment and blur as Version 1.0 (I still haven't shared it btw)

 

Edit: (Actually, I just already did - along with my Color Intensifier plugin.)

Edited by Sakana Oji
Already shared it.

Share this post


Link to post
Share on other sites

How do i fix this error message? It appears in the error message box.

Quote

Unhandled Exception at line 0: 
System.InvalidOperationException: SetRenderInfo() was not called, nor was render info available implicitely
   at PaintDotNet.ExceptionUtil.ThrowInvalidOperationException(String message) in D:\src\pdn\src\Base\ExceptionUtil.cs:line 161
   at PaintDotNet.Effects.Effect`1.Render(Rectangle[] renderRects, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 52
   at PaintDotNet.Effects.UserScript.Render(Surface dst, Surface src, Rectangle rect)
   at PaintDotNet.Effects.UserScript.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length)
   at PaintDotNet.Effects.CodeLab.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length)

 

Share this post


Link to post
Share on other sites
4 hours ago, Sakana Oji said:

How do i fix this error message?

 

Show us the script.

Share this post


Link to post
Share on other sites

I seem to have lost it somehow. Basically it's an effect that applies the Frosted Glass effect, followed by the Median effect. But I don't know how to show it to you. I apologize.

Share this post


Link to post
Share on other sites

Well, we can't fix the error if you can't show us the script that is giving you the error.

Share this post


Link to post
Share on other sites

I tried my best to recreate it:

// Name: Gaussian Blur with Brightness and Contrast
// Submenu: Blurs
// Author: MJW
// Title: Gaussian Blur with Brighness and Contrast
// Desc: Gaussian Blur with Brightness and Contrast (test multiple built-in effects)
// Keywords: Gaussian blur contrast brightness test multiple built-in effects
// URL:
// Help:
#region UICode
DoubleSliderControl Amount1 = 3; // [0,5] Pressure
DoubleSliderControl Amount2 = 0; // [0,200] Minimum Scatter Radius
IntSliderControl Amount3 = 2; // [1,8] Quality
IntSliderControl Amount4=1; // [1,200] Radius
IntSliderControl Amount5=10; // [0,100] Percentile
#endregion


// Here is the main render loop function
void Render(Surface dst, Surface src, Rectangle rect)
{
    // Setup for calling the Frosted Glass effect
    FrostedGlassEffect frostedEffect = new FrostedGlassEffect();
    PropertyCollection frostedProps = frostedEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken FrostedParameters = new PropertyBasedEffectConfigToken(frostedProps);
    FrostedParameters.SetPropertyValue(FrostedGlassEffect.PropertyNames.MaxScatterRadius, Amount1);
    FrostedParameters.SetPropertyValue(FrostedGlassEffect.PropertyNames.MinScatterRadius, Amount2);
    FrostedParameters.SetPropertyValue(FrostedGlassEffect.PropertyNames.NumSamples, Amount3);
    frostedEffect.SetRenderInfo(FrostedParameters, new RenderArgs(dst), new RenderArgs(src));
    // Call the Frosted Glass function
    frostedEffect.Render(new Rectangle[1] {rect}, 0, 1);  
    
    // Adjust median.
    MedianEffect medianEffect = new MedianEffect();
    PropertyCollection medianProps = medianEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken medianParameters = new PropertyBasedEffectConfigToken(medianProps);
    medianParameters.SetPropertyValue(MedianEffect.PropertyNames.Radius, Amount4);
    medianParameters.SetPropertyValue(MedianEffect.PropertyNames.Percentile, Amount5);
    medianEffect.SetRenderInfo(medianParameters, new RenderArgs(dst), new RenderArgs(dst));
    // Call the Median function
    medianEffect.Render(new Rectangle[1] {rect}, 0, 1);

    // Now in the main render loop, the dst canvas has a crayon version of the src canvas
    // The dst canvas has the contrast adjusted.
}
Edited by Sakana Oji

Share this post


Link to post
Share on other sites

Weirdly the error seems to have gone, but now it makes the picture look all weird and glitchy - NOT the kind of effect I want.

 

The picture below proves it:

 

crayon-error.png

 

How to fix this, please?

Share this post


Link to post
Share on other sites
4 minutes ago, Sakana Oji said:

How to fix this, please?

 

Here's your problem:

 

medianEffect.SetRenderInfo(medianParameters, new RenderArgs(dst), new RenderArgs(dst));

You can't render the median effect to the same canvas you're rendering from.

 

You should probably read the tutorials on my web site:

 

https://boltbait.com/pdn/CodeLab/help/

 

(specifically part 3 & 7)

Share this post


Link to post
Share on other sites

Okay here's my real actual code that I first worked on (not recreated):

 

// Name: Crayon
// Submenu: Artistic
// Author: Sakana Oji
// Title: Crayon
// Desc: Gives the image a crayon effect
// Keywords: crayon artistic
// URL:
// Help:
#region UICode
DoubleSliderControl Amount1 = 3; // [0,10] Thickness
DoubleSliderControl Amount2 = 0; // [0,200] Minimum Scatter Radius
IntSliderControl Amount3 = 2; // [1,8] Quality
IntSliderControl Amount4=1; // [1,5] Radius
IntSliderControl Amount5=10; // [0,100] Percentile
#endregion


// Here is the main render loop function
void Render(Surface dst, Surface src, Rectangle rect)
{
    // Setup for calling the Frosted Glass effect
    FrostedGlassEffect frostedEffect = new FrostedGlassEffect();
    PropertyCollection frostedProps;
    // Call the Frosted Glass function
    frostedEffect.Render(new Rectangle[1] { rect }, 0, 1); 
    
    // Adjust median
    MedianEffect medianEffect = new MedianEffect();
    PropertyCollection medianProps = medianEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken medianParameters = new PropertyBasedEffectConfigToken(medianProps);
    medianParameters.SetPropertyValue(MedianEffect.PropertyNames.Radius, Amount4);
    medianParameters.SetPropertyValue(MedianEffect.PropertyNames.Percentile, Amount5);
    medianEffect.SetRenderInfo(medianParameters, new RenderArgs(dst), new RenderArgs(dst));
    // Call the Median function
    medianEffect.Render(new Rectangle[1] {rect},0,1);

}

Edited by Sakana Oji

Share this post


Link to post
Share on other sites

@Sakana Oji, I appreciate your youthful enthusiasm and maximalism, but you are violating item 2) of The Rules (I hope the admins and mods will be lenient to you again - we all make mistakes sometimes). 
No offense, but I suggest you create your own topic in the proper thread as it did @xod with its Unfinished plugins.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this