Ejemplo n.º 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.GetProjectorCamera();

            GlobalBrush.Color = avg / (float)pixelsCount;

            PainterCamera.BrushColorProperty.GlobalValue = GlobalBrush.Color;

            PaintRenderTexture(delayedPaintingConfiguration);

            delayedPaintingConfiguration = null;
        }
Ejemplo n.º 2
0
        public void PaintRenderTexture(StrokeVector stroke, ImageMeta 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);


                //Debug.Log("Setting position: "+stroke.posTo);

                PainterCamera.GetProjectorCamera().RenderRightNow(this);
            }
            else
            {
                PaintRenderTexture(new BrushStrokePainterImage(stroke, image, bc, painter));
            }
        }
Ejemplo n.º 3
0
        public override bool Inspect()
        {
            var changed = base.Inspect();

            var dp = DepthProjectorCamera.Instance;

            if (inspectedElement == -1)
            {
                if (!dp)
                {
                    "Depth Projector is needed to update shadows".writeHint();

                    if ("Instantiate Depth Projector Camera".Click().nl())
                    {
                        PainterCamera.GetOrCreateProjectorCamera();
                    }
                }
            }

            if ("Depth Camera ".enter(ref inspectedElement, 10).nl())
            {
                GetAllBakedDepths().write(250);

                var tex = GetAllBakedDepths();

                "Depth Mask".edit(ref tex).nl();

                pegi.nl();

                dp.Nested_Inspect();
            }

            if ("Lights ".enter(ref inspectedElement, 11).nl())
            {
                lights.Nested_Inspect().nl(ref changed);
            }

            return(changed);
        }
Ejemplo n.º 4
0
        public bool BrushConfigPEGI(ref bool overrideBlitMode, BrushConfig br)
        {
            var changed = false;

            var p = InspectedPainter;

            var volTex = p.GetVolumeTexture();

            if (volTex)
            {
                overrideBlitMode = true;

                var id = p.ImgMeta;

                if (BrushConfig.showAdvanced)
                {
                    "Grid".toggle(50, ref _useGrid).nl();
                }

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

                br.showingSize = !_enableRayTracing || cpuBlit;


                if (!cpuBlit)
                {
                    if (BrushConfig.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 (_enableRayTracing && BrushConfig.showAdvanced)
                    {
                        pegi.nl();
                        // "Bounced brightness mltpl".edit(ref arbitraryBrightnessIncrease, 1, 2).changes(ref changed);

                        //"A completely arbitrary value that increases the amount of bounced light. Used to utilize the full 0-1 range of the texture for increased percision"
                        //  .fullWindowDocumentationClick();

                        pegi.nl();
                    }

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

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

                        pegi.nl();
                    }
                }

                if (cpuBlit)
                {
                    /*if (_enableRayTracing)
                     *  icon.Warning.write("CPU Brush is slow for volumes");*/
                }
                else
                {
                    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, BrushTypeSphere.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 != null)
                    {
                        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, 22f).nl(ref changed);
                }

                var tmpSpeed = br._dSpeed.value;
                if (MsgPainter.Speed.GetText().edit(40, ref tmpSpeed, 0.01f, 4.5f).nl(ref changed))
                {
                    br._dSpeed.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();

                /*
                 * if (br.GetBlitMode(cpuBlit).UsingSourceTexture && id.TargetIsRenderTexture())
                 * {
                 *  if (TexMGMTdata.sourceTextures.Count > 0)
                 *  {
                 *      "Copy From:".write(70);
                 *      changed |= pegi.selectOrAdd(ref br.selectedSourceTexture, ref TexMGMTdata.sourceTextures);
                 *  }
                 *  else
                 *      "Add Textures to Render Camera to copy from".nl();
                 * }*/
            }
            if (changed)
            {
                this.SetToDirty_Obj();
            }

            return(changed);
        }
Ejemplo n.º 5
0
        public override bool Inspect()
        {
            var changed = false;

            var rtp = PainterCamera.Inst;

            if ("Modules".enter(ref inspectedItems, 10, false).nl_ifNotEntered() && rtp.ModulsInspect().nl(ref changed))
            {
                rtp.SetToDirty();
            }

            if ("Lists".enter(ref inspectedItems, 11).nl(ref changed))
            {
                InspectLists().changes(ref changed);
            }

            if ("Painter Camera".enter(ref inspectedItems, 14).nl_ifNotEntered())
            {
                PainterCamera.Inst.DependenciesInspect(true);
            }

            if ("Depth Projector Camera".enter(ref inspectedItems, 15).nl())
            {
                if (DepthProjectorCamera.Instance)
                {
                    DepthProjectorCamera.Instance.Nested_Inspect().nl();
                }
                else if ("Instantiate".Click())
                {
                    PainterCamera.GetOrCreateProjectorCamera();
                }
            }

            if ("Inspector & Debug".enter(ref inspectedItems, 16).nl())
            {
                QcUtils.InspectInspector();
            }

            if (inspectedItems == -1)
            {
                if ("Painter Data Encode / Decode Test".Click().nl())
                {
                    this.SaveCfgData();

                    matMetas.Clear();

                    this.LoadCfgData();
                }

                #if UNITY_EDITOR
                if ("Enable PlayTime UI".toggleIcon(ref enablePainterUIonPlay).nl())
                {
                    MeshEditorManager.Inst.StopEditingMesh();
                }

                "Hide documentation".toggleIcon(ref hideDocumentation).changes(ref changed);
                MsgPainter.aboutDisableDocumentation.DocumentationClick();
                pegi.nl();

                "Teaching Notifications".toggleIcon("Will show some notifications on the screen", ref showTeachingNotifications).nl();

                "Where to save content".nl(PEGI_Styles.ListLabel);

                "Textures".edit(60, ref texturesFolderName).nl();

                "Atlases: {0}/".F(texturesFolderName).edit(120, ref atlasFolderName).nl();

                "Materials".edit(60, ref materialsFolderName).nl();

                "Meshes".edit(60, ref meshesFolderName).nl();

                if (icon.Discord.Click("Join Discord", 64))
                {
                    PlaytimePainter.Open_Discord();
                }

                if (icon.Docs.Click("Open Asset Documentation", 64))
                {
                    PlaytimePainter.OpenWWW_Documentation();
                }

                if (icon.Email.Click("Report a bug / send suggestion / ask question.", 64))
                {
                    PlaytimePainter.Open_Email();
                }

                pegi.nl();

                LazyLocalization.LanguageSelection().nl();
                #endif
            }

            base.Inspect().nl(ref changed);

            return(changed);
        }