public JobHandle SampleIncludeMask(VegetationInstanceData instanceData, Rect spawnRect, TextureMaskType textureMaskType, TextureMaskRule textureMaskRule, JobHandle dependsOn) { if (!spawnRect.Overlaps(TextureRect)) { return(dependsOn); } if (MaskTexture == null) { return(dependsOn); } switch (textureMaskType) { case TextureMaskType.RGBAChannel: if (!_rgbaNativeArray.IsCreated) { _rgbaNativeArray = MaskTexture.GetRawTextureData <RGBABytes>(); } bool inverse = textureMaskRule.GetBooleanPropertyValue("Inverse"); int selectedChannel = textureMaskRule.GetIntPropertyValue("ChannelSelector"); if (MaskTexture.format == TextureFormat.RGBA32) { selectedChannel--; if (selectedChannel == -1) { selectedChannel = 3; } } SampleRgbaChannelIncludeMaskJob sampleRgbaChannelIncludeMaskJob = new SampleRgbaChannelIncludeMaskJob(); sampleRgbaChannelIncludeMaskJob.Width = MaskTexture.width; sampleRgbaChannelIncludeMaskJob.Height = MaskTexture.height; sampleRgbaChannelIncludeMaskJob.Excluded = instanceData.Excluded.ToDeferredJobArray(); sampleRgbaChannelIncludeMaskJob.Position = instanceData.Position.ToDeferredJobArray(); sampleRgbaChannelIncludeMaskJob.TextureMaskData = instanceData.TextureMaskData.ToDeferredJobArray(); sampleRgbaChannelIncludeMaskJob.RgbaNativeArray = _rgbaNativeArray; sampleRgbaChannelIncludeMaskJob.SelectedChannel = selectedChannel; sampleRgbaChannelIncludeMaskJob.Inverse = inverse; sampleRgbaChannelIncludeMaskJob.TextureRect = TextureRect; sampleRgbaChannelIncludeMaskJob.MinValue = textureMaskRule.MinDensity; sampleRgbaChannelIncludeMaskJob.MaxValue = textureMaskRule.MaxDensity; return(sampleRgbaChannelIncludeMaskJob.Schedule(instanceData.Excluded, 32, dependsOn)); } return(dependsOn); }
public TextureMaskGroup(TextureMaskType textureMaskType) { TextureMaskType = textureMaskType; TextureMaskName = "New texture mask"; TextureMaskGroupID = Guid.NewGuid().ToString(); Settings = new TextureMaskSettings(); switch (textureMaskType) { case TextureMaskType.RGBAChannel: Settings.AddRgbaSelectorProperty("ChannelSelector", "Select channel", "", 0); Settings.AddBooleanProperty("Inverse", "Inverse", "", false); RequiredTextureFormatList.Add(TextureFormat.RGBA32); RequiredTextureFormatList.Add(TextureFormat.ARGB32); break; //case TextureMaskType.Grayscale: // Settings.AddBooleanProperty("Inverse", "Inverse", "", false); // RequiredTextureFormatList.Add(TextureFormat.RGBA32); // RequiredTextureFormatList.Add(TextureFormat.ARGB32); // break; } }