Beispiel #1
0
            public void AfterCameraRender(RenderTexture texture)
            {
                var size = RenderTextureBuffersManager.tinyTextureSize;

                int pixelsCount = size * size;

                var tiny = RenderTextureBuffersManager.GetDownscaleOf(texture,
                                                                      RenderTextureBuffersManager.tinyTextureSize, true);

                var pix = RenderTextureBuffersManager.GetMinSizeTexture().CopyFrom(tiny).GetPixels();

                Color avg = Color.black;

                foreach (var p in pix)
                {
                    avg += p;
                }

                var pcam = PainterCamera.GetOrCreateProjectorCamera();

                GlobalBrush.Color = avg / pixelsCount;

                PainterShaderVariables.BrushColorProperty.GlobalValue = GlobalBrush.Color;

                PaintRenderTextureUvSpace(delayedPaintingConfiguration);

                delayedPaintingConfiguration = null;
            }
Beispiel #2
0
            public void PaintRenderTextureUvSpace(PaintCommand.UV command)
            {
                Stroke      stroke = command.Stroke;
                TextureMeta image  = command.TextureData;
                Brush       bc     = command.Brush;

                var vt = image.GetVolumeTextureData();

                if (!vt)
                {
                    Debug.LogError("Painted volume was not found");
                    return;
                }

                if (_enableRayTracing)
                {
                    rayTraceCameraConfiguration.From(stroke);

                    bc.useAlphaBuffer = false;

                    delayedPaintingConfiguration = new PaintCommand.UV(stroke, image, bc);

                    PainterCamera.GetOrCreateProjectorCamera().RenderRightNow(this);
                }
                else
                {
                    PaintRenderTextureInternal(command); // Maybe wrong
                }
            }
            public void PaintRenderTexture(StrokeVector stroke, TextureMeta image, BrushConfig bc,
                                           PlaytimePainter painter)
            {
                var vt = painter.GetVolumeTexture();

                if (!vt)
                {
                    Debug.LogError("Painted volume was not found");
                    return;
                }

                if (_enableRayTracing)
                {
                    rayTraceCameraConfiguration.From(stroke);

                    bc.useAlphaBuffer = false;

                    delayedPaintingConfiguration = new BrushStrokePainterImage(stroke, image, bc, painter);

                    PainterCamera.GetProjectorCamera().RenderRightNow(this);
                }
                else
                {
                    PaintRenderTexture(new BrushStrokePainterImage(stroke, image, bc, painter));
                }
            }
Beispiel #4
0
        public bool Inspect()
        {
            var changed = false;

            if (_inspectedStuff == -1)
            {
                pegi.toggleDefaultInspector(this);



                "Main Cam".edit(ref _mainCam).nl();
                "Directional Light".edit(ref directional).nl();
                "Sky Renderer".edit(ref skeRenderer).nl();
                "Sky dinamics".edit(ref skyDynamics).nl();

                if (_mainCam)
                {
                    if (_mainCam.clearFlags == CameraClearFlags.Skybox)
                    {
                        "Skybox will hide procedural sky".writeWarning();
                        if ("Set to Black Color".Click())
                        {
                            _mainCam.clearFlags      = CameraClearFlags.Color;
                            _mainCam.backgroundColor = Color.clear;
                        }
                    }
                }
            }


            if ("Weather configurations".enter(ref _inspectedStuff, 0).nl())
            {
                var cam = PainterCamera.GetModule <ColorBleedCameraModule>();
                if (cam != null)
                {
                    cam.Nested_Inspect(ref changed);
                }
            }

            return(changed);
        }
Beispiel #5
0
            public bool BrushConfigPEGI(Brush br)
            {
                var changed = false;

                var p = InspectedPainter;

                var volTex = p.TexMeta.GetVolumeTextureData();

                if (volTex)
                {
                    var tex = volTex.Texture;

                    if (tex)
                    {
                        "Volume is a {0} texture".F(tex.IsColorTexture() ? "Color" : "Non-Color Data").write();

#if UNITY_EDITOR
                        if (tex.IsColorTexture())
                        {
                            pegi.nl();
                            var imp = tex.GetTextureImporter();

                            if ((imp != null) && "FIX texture".Click() && (imp.WasWrongIsColor(false)))
                            {
                                imp.SaveAndReimport();
                            }
                        }
#endif


                        pegi.nl();
                    }
                    else
                    {
                        "Volume has no texture".writeWarning();
                    }

                    var id = p.TexMeta;

                    var cpuBlit = id.TargetIsTexture2D().nl();

                    br.showingSize = !_enableRayTracing || cpuBlit;

                    if (!cpuBlit)
                    {
                        if (Brush.showAdvanced || _enableRayTracing)
                        {
                            "Ray-Tracing".toggleIcon(ref _enableRayTracing, true).changes(ref changed);

                            if (br.useAlphaBuffer)
                            {
                                icon.Warning.write(
                                    "Ray Tracing doesn't use Alpha buffer. Alpha buffer will be automatically disabled");
                            }
                        }

                        if ("Ray Trace Camera".conditional_enter(
                                _enableRayTracing && PainterCamera.depthProjectorCamera,
                                ref _exploreRayTaceCamera).nl_ifFoldedOut())
                        {
                            "Min".edit(40, ref minFov, 60, maxFov - 1).nl(ref changed);

                            "Max".edit(40, ref maxFov, minFov + 1, 170).nl(ref changed);

                            rayTraceCameraConfiguration.Nested_Inspect().nl(ref changed);
                        }

                        if (smoothing > 0 || Brush.showAdvanced)
                        {
                            pegi.nl();
                            "Smoothing".edit(70, ref smoothing, 0, 1).changes(ref changed);
                            pegi.FullWindowService.DocumentationClickOpen("Best used in the end");

                            pegi.nl();
                        }

                        if (!_exploreRayTaceCamera && _enableRayTracing)
                        {
                            var dp = PainterCamera.depthProjectorCamera;

                            if (!dp)
                            {
                                if ("Create Projector Camera".Click().nl())
                                {
                                    PainterCamera.GetOrCreateProjectorCamera();
                                }
                            }
                            else if (dp.pauseAutoUpdates)
                            {
                                pegi.nl();
                                "Light Projectors paused".toggleIcon(ref dp.pauseAutoUpdates).nl(ref changed);
                            }

                            pegi.nl();
                        }
                    }

                    if (!cpuBlit)
                    {
                        pegi.nl();

                        if (!br.GetBrushType(false).IsAWorldSpaceBrush)
                        {
                            "Only World space brush can edit volumes".writeHint();
                            pegi.nl();
                            if ("Change to Sphere brush".Click())
                            {
                                br.SetBrushType(false, BrushTypes.Sphere.Inst);
                            }
                        }
                    }

                    pegi.nl();


                    if (!_exploreRayTaceCamera && PainterCamera.Data.showVolumeDetailsInPainter &&
                        (volTex.name + " " + VolumeEditingExtensions.VolumeSize(id.texture2D, volTex.hSlices))
                        .foldout(ref _exploreVolumeData).nl())
                    {
                        volTex.Nested_Inspect().changes(ref changed);

                        if (volTex.NeedsToManageMaterials)
                        {
                            var painterMaterial = InspectedPainter.Material;
                            if (painterMaterial)
                            {
                                if (!volTex.materials.Contains(painterMaterial))
                                {
                                    if ("Add This Material".Click().nl())
                                    {
                                        volTex.AddIfNew(p);
                                    }
                                }
                            }
                        }
                    }

                    if (!cpuBlit)
                    {
                        MsgPainter.Hardness.GetText()
                        .edit(MsgPainter.Hardness.GetDescription(), 70, ref br.hardness, 1f, 5f).nl(ref changed);
                    }

                    var tmpSpeed = br._dFlow.Value;
                    if (MsgPainter.Flow.GetText().edit(40, ref tmpSpeed, 0.01f, 4.5f).nl(ref changed))
                    {
                        br._dFlow.Value = tmpSpeed;
                    }

                    if (br.showingSize)
                    {
                        var maxScale = volTex.size * volTex.Width * 4;

                        "Scale:".edit(40, ref br.brush3DRadius, 0.001f * maxScale, maxScale * 0.5f)
                        .changes(ref changed);

                        if (cpuBlit && !_brushShaderFroRayTrace && br.brush3DRadius > BrushScaleMaxForCpu(volTex))
                        {
                            icon.Warning.write(
                                "Size will be reduced when panting due to low performance of the CPU brush for volumes");
                        }
                    }

                    pegi.nl();
                }

                return(changed);
            }