Simon Brown Posted April 18, 2008 Share Posted April 18, 2008 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: Thanks in advance Quote Link to comment Share on other sites More sharing options...
MadJik Posted April 18, 2008 Share Posted April 18, 2008 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! Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal Link to comment Share on other sites More sharing options...
Simon Brown Posted April 18, 2008 Author Share Posted April 18, 2008 I don't understand what you mean, that script just renders a few gradients vertically. What I am talking about is that intellisense says that the enumerations of CloudsEffect.PropertyNames are: Scale BlendOp Power Seed Quote Link to comment Share on other sites More sharing options...
MadJik Posted April 18, 2008 Share Posted April 18, 2008 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... Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal Link to comment Share on other sites More sharing options...
Simon Brown Posted April 18, 2008 Author Share Posted April 18, 2008 I'm not. However, I am calling it inside Render(), could that be a problem? Quote Link to comment Share on other sites More sharing options...
MadJik Posted April 18, 2008 Share Posted April 18, 2008 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 Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal Link to comment Share on other sites More sharing options...
Simon Brown Posted April 18, 2008 Author Share Posted April 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
harold Posted April 18, 2008 Share Posted April 18, 2008 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? Quote I would write plugins, if I knew what kind of plugins were needed.. Link to comment Share on other sites More sharing options...
Simon Brown Posted April 18, 2008 Author Share Posted April 18, 2008 I have now realised the problem - the SetRenderInfo() call should be in SetRenderInfo(). Quote 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.