Jump to content

Clouds Effect Power Option


Recommended Posts

Hello,

I am trying to create a plugin to automate the fire tutorial but am having trouble with the clouds effect. Firstly, in the clouds dialog box there are three items: Scale, Roughness and Blend Mode. However, when calling the effect there is, instead of Roughness, a property called Power and whenever I try to set this item's value it throws an exeption.

Also, whenever I call the clouds effect from my plugin the result looks like the image below:

cloudserrordd5.png

Thanks in advance

KaHuc.png
Link to comment
Share on other sites

Hi,

I don't see for power...

For the image, this is due to the multi-thread stuff...

Try this code for codelab to illustrate the problem (for coders):

// Count one by one and color in scale per channel the pixels in the usual x,y loops.
// You could think you will create a gradient, but surprise!

//Set the steps per channel
int Amount1=2;  //[-100,100]Red Step
int Amount2=2;  //[-100,100]Green Step
int Amount3=2;  //[-100,100]Blue Step

// Define the counter to be unique regardless the (multi)threads
[ThreadStatic]
public static int threadCount = 0;

void Render(Surface dst, Surface src, Rectangle rect)
{
 // Count + 1
 ++threadCount;

 ColorBgra CurrentPixel;
 for(int y = rect.Top; y < rect.Bottom; y++)
 {
   for (int x = rect.Left; x < rect.Right; x++)
   {
     CurrentPixel = src[x,y];
     CurrentPixel.R = (byte)((threadCount * Amount1) % 255);
     CurrentPixel.G = (byte)((threadCount * Amount2) % 255);
     CurrentPixel.B = (byte)((threadCount * Amount3) % 255);
     dst[x,y] = CurrentPixel;
   }
 }
}

The clouds use a random number sequence, and the sequence is renewed for each rois...

So you result is a pile of slices of rendered clouds...

Good luck!

Link to comment
Share on other sites

Hi,

I don't see for power...

For the image, this is due to the multi-thread stuff...

...

The clouds use a random number sequence, and the sequence is renewed for each rois...

So you result is a pile of slices of rendered clouds...

Good luck!

I think you are trying to use the CloudsEffect inside the loops rect, y, x...

Link to comment
Share on other sites

    protected override void OnRender(Rectangle[] rois, int startIndex, int length)
   {
     //CloudsEffect here: ok (but don't know how exactly)
     for (int i = startIndex; i < startIndex + length; ++i)
     {
       //CloudsEffect here: bad
       Rectangle rect = rois[i];
       RenderRI(DstArgs.Surface, SrcArgs.Surface, rect);
     }
   }
   void RenderRI(Surface dst, Surface src, Rectangle rect)
   {
     PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
     Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
     ColorBgra PrimColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
     ColorBgra Px;
     //CloudsEffect here: bad

Link to comment
Share on other sites

I have commented out the irrelevant code while solving this and still have the problem. This is the Render method.

public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs,
           RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length)
       {
           FrameConfigToken token = (FrameConfigToken)parameters;

           CloudsEffect ce = new CloudsEffect();
           PropertyCollection cp = ce.CreatePropertyCollection();
           PropertyBasedEffectConfigToken pbect = new PropertyBasedEffectConfigToken(cp);

           pbect.SetPropertyValue(CloudsEffect.PropertyNames.Scale, 250);
           pbect.SetPropertyValue(CloudsEffect.PropertyNames.BlendOp, new UserBlendOps.DifferenceBlendOp());
           pbect.SetPropertyValue(CloudsEffect.PropertyNames.Power, 0.5);
           pbect.SetPropertyValue(CloudsEffect.PropertyNames.Seed, 5);

           RenderArgs ra = new RenderArgs(new Surface(dstArgs.Size));

           ce.Render(pbect, dstArgs, srcArgs, rois, startIndex, length);

       }

Thanks for your help so-far.

KaHuc.png
Link to comment
Share on other sites

Not really helpful, but: I would have thought that if you give the same seed you'd render different pieces of the same cloud.. But apparently that is not so?

I would write plugins, if I knew what kind of plugins were needed.. :(

Link to comment
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.

 Share

×
×
  • Create New...