Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public virtual bool Equals(Material other)
 {
     if (other == null)
     {
         return(false);
     }
     return(AlphaTest.Equals(other.AlphaTest) &&
            Blending.Equals(other.Blending) &&
            ClipIntersections.Equals(other.ClipIntersections) &&
            ClipShadows.Equals(other.ClipShadows) &&
            ColorWrite.Equals(other.ColorWrite) &&
            DepthTest.Equals(other.DepthTest) &&
            DepthWrite.Equals(other.DepthWrite) &&
            Dithering.Equals(other.Dithering) &&
            FlatShading.Equals(other.FlatShading) &&
            Fog.Equals(other.Fog) &&
            Lights.Equals(other.Lights) &&
            Opacity.Equals(other.Opacity) &&
            Overdraw.Equals(other.Overdraw) &&
            PremultipliedAlpha.Equals(other.PremultipliedAlpha) &&
            Side.Equals(other.Side) &&
            Transparent.Equals(other.Transparent) &&
            VertexColors.Equals(other.VertexColors) &&
            Visible.Equals(other.Visible) &&
            UserData == other.UserData &&
            ClippingPlanes == other.ClippingPlanes &&
            string.Equals(Precision, other.Precision));
 }
Пример #2
0
        public void SortingBlock(ref Rect r)
        {
            ps.StartIgnoreChangeCheck();
            bool prevAutoSort = autoSort;

            GUI.enabled = ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Forward;
            autoSort    = UndoableToggle(r, autoSort, autoSort ? "自动排序..." : "自动排序", "auto sort", null);
            GUI.enabled = true;
            if (autoSort != prevAutoSort && autoSort)
            {
                UpdateAutoSettings();
            }
            ps.EndIgnoreChangeCheck();

            r.xMin += 20;
            r.y    += 20;

            bool prevGUI = GUI.enabled;

            GUI.enabled = !autoSort;
            {
                int  wOrder  = SF_GUI.WidthOf("Order", EditorStyles.miniLabel) + 2;
                int  wPlus   = SF_GUI.WidthOf("+", EditorStyles.miniLabel) + 2;
                int  wOffset = 32;
                int  wEquals = SF_GUI.WidthOf("=", EditorStyles.miniLabel);
                int  wResult = 32;
                int  wField  = Mathf.FloorToInt(r.width - wOrder - wPlus - wEquals - wOffset - wResult);
                Rect tRect   = new Rect(r);
                tRect.width = wOrder;
                GUI.Label(tRect, new GUIContent("排序", "确定此着色器相对于其他渲染的顺序"), EditorStyles.miniLabel);
                SF_GUI.MoveRight(ref tRect, wField);
                //queuePreset = (Queue)EditorGUI.Popup(tRect, (int)queuePreset, strQueue );
                queuePreset = (Queue)UndoableEnumPopupNamed(tRect, queuePreset, strQueue, "render queue order");
                SF_GUI.MoveRight(ref tRect, wPlus);
                GUI.Label(tRect, "+");
                SF_GUI.MoveRight(ref tRect, wOffset);
                queueOffset = UndoableIntField(tRect, queueOffset, "render queue offset");
                SF_GUI.MoveRight(ref tRect, wEquals);
                GUI.Label(tRect, "=");
                SF_GUI.MoveRight(ref tRect, wResult);
                GUI.Label(tRect, (queueNumbers[(int)queuePreset] + queueOffset).ToString());
                r.y += 20;
                //renderType = (RenderType)SF_GUI.LabeledEnumField( r,new GUIContent("Render Type","Defines shader replacement; required for some rendering effects, such as SSAO"), renderType, EditorStyles.miniLabel );
                renderType = (RenderType)UndoableLabeledEnumPopupNamed(r, "渲染类型", renderType, strRenderType, "render type");
                r.y       += 20;
                //depthTest = (DepthTest)SF_GUI.LabeledEnumFieldNamed( r, strDepthTest, new GUIContent( "Depth Test", "Compared to the existing geometry in the scene, \nthis determines when to render this geometry. \u2264 is default, meaning:\n\"If this part is closer or as close to the camera as existing geometry, draw me!\"" ), (int)depthTest, EditorStyles.miniLabel );
                depthTest = (DepthTest)UndoableLabeledEnumPopupNamed(r, "深度测试", depthTest, strDepthTest, "depth test");
                r.y      += 20;
                //ignoreProjector = GUI.Toggle(r, ignoreProjector, "Ignore Projectors" );
                ignoreProjector = UndoableToggle(r, ignoreProjector, "忽略投影器", "ignore projectors", null);
                r.y            += 20;
                //writeDepth = GUI.Toggle( r, writeDepth, "Write to Depth buffer" );
                writeDepth = UndoableToggle(r, writeDepth, "写入深度缓冲区", "depth buffer write", null);
                r.y       += 20;
            }
            GUI.enabled = prevGUI;

            r.xMin -= 20;
        }
Пример #3
0
 public IntermediateFramebuffer(GraphicsState graphics, AssetFactoryState assets, Blend blend,
                                DepthTest depthTest, OutputDescription outputDescription)
 {
     OutputDescription = outputDescription;
     Graphics          = graphics;
     Assets            = assets;
     Blend             = blend;
     DepthTest         = depthTest;
     Validate();
 }
Пример #4
0
 public GraphicsRenderState(ShaderSource[] shaders, PrimitiveType topology, bool depthClamp, bool rasterizerDiscard, CullMode cullMode, DepthTest depthTest, ShaderResourceSetReference[] resourceSets)
 {
     Shaders           = shaders ?? throw new ArgumentNullException(nameof(shaders));
     Topology          = topology;
     DepthClamp        = depthClamp;
     RasterizerDiscard = rasterizerDiscard;
     CullMode          = cullMode;
     DepthTest         = depthTest;
     ResourceSets      = resourceSets ?? throw new ArgumentNullException(nameof(resourceSets));
 }
Пример #5
0
        public GraphicsPipeline(GraphicsState graphics, Blend blend, DepthTest depthTest, bool culling,
                                ShaderSet shaders, OutputDescription output, params IGraphicsResource[] resources)
        {
            Resources = resources.ToImmutableArray();
            var rf = graphics.Device.ResourceFactory;

            Pipeline = rf.CreateGraphicsPipeline(new GraphicsPipelineDescription(
                                                     blend switch
            {
                Blend.Alpha => BlendStateDescription.SingleAlphaBlend,
                Blend.Override => BlendStateDescription.SingleOverrideBlend,
                _ => throw new ArgumentException()
            },
Пример #6
0
        private void ApplyDepthTest(DepthTest depthTest)
        {
            if (_renderState.DepthTest.Enabled != depthTest.Enabled)
            {
                Enable(EnableCap.DepthTest, depthTest.Enabled);
                _renderState.DepthTest.Enabled = depthTest.Enabled;
            }

            if (depthTest.Enabled)
            {
                if (_renderState.DepthTest.Function != depthTest.Function)
                {
                    GL.DepthFunc(TypeConverterGL3x.To(depthTest.Function));
                    _renderState.DepthTest.Function = depthTest.Function;
                }
            }
        }
Пример #7
0
        public XmlElement Save(XmlDocument doc)
        {
            XmlElement me = doc.CreateElement("pass");

            me.SetAttribute("name", Name);
            if (IsSM3.HasValue)
            {
                me.SetAttribute("sm3", IsSM3.Value ? "true" : "false");
            }
            if (IsDesktop.HasValue)
            {
                me.SetAttribute("desktop", IsDesktop.Value ? "true" : "false");
            }
            if (VS != null && VS.Length > 0)
            {
                me.SetAttribute("vs", VS);
            }
            if (PS != null && PS.Length > 0)
            {
                me.SetAttribute("ps", PS);
            }
            if (VSDefines.Count > 0)
            {
                me.SetAttribute("vsdefines", string.Join(" ", VSDefines.ToArray()));
            }
            if (PSDefines.Count > 0)
            {
                me.SetAttribute("psdefines", string.Join(" ", PSDefines.ToArray()));
            }

            me.SetAttribute("lighting", LightMode.ToString().ToLower());
            me.SetAttribute("blend", BlendMode.ToString().ToLower());
            me.SetAttribute("depthtest", DepthTest.ToString().ToLower());
            me.SetAttribute("depthwrite", DepthWrite ? "true" : "false");
            me.SetAttribute("alphamask", AlphaMask ? "true" : "false");

            return(me);
        }
Пример #8
0
 public override int GetHashCode()
 {
     return(DepthTest.GetHashCode() ^ DepthBias.GetHashCode() ^ FrontFace.GetHashCode() ^ CullMode.GetHashCode() ^ BlendMode.GetHashCode() ^ FillMode.GetHashCode() ^ StencilMode.GetHashCode());
 }
Пример #9
0
        public override void Deserialize(string key, string value)
        {
            switch (key)
            {
            case "blpr":     // This is no longer saved, but in old shaders, we have to read it with old enum indices

                //	0 "Opaque",
                //	1 "Alpha Blended",
                //	- "Alpha Blended (Premultiplied)",
                //	2 "Additive",
                //	3 "Screen",
                //	4 "Multiplicative",

                int iVal = int.Parse(value);
                if (iVal > 1)     // Offset due to adding premul
                {
                    iVal++;
                }
                blendModePreset = (BlendModePreset)iVal;
                ConformBlendsToPreset();

                lockSrcDstRead = true;
                break;

            case "bsrc":
                if (lockSrcDstRead)
                {
                    break;
                }
                blendSrc = (BlendMode)int.Parse(value);
                break;

            case "bdst":
                if (lockSrcDstRead)
                {
                    lockSrcDstRead = false;
                    break;
                }
                blendDst = (BlendMode)int.Parse(value);
                ConformPresetToBlend();
                break;

            case "dpts":
                depthTest = (DepthTest)int.Parse(value);
                break;

            case "wrdp":
                writeDepth = bool.Parse(value);
                break;

            case "dith":
                dithering = (Dithering)int.Parse(value);
                break;

            case "atcv":
                alphaToCoverage = bool.Parse(value);
                break;

            case "rfrpo":
                perObjectRefraction = bool.Parse(value);
                break;

            case "rfrpn":
                refractionPassName = value;
                break;

            case "coma":
                colorMask = int.Parse(value);
                break;

            case "ufog":
                useFog = bool.Parse(value);
                break;

            case "aust":
                autoSort = bool.Parse(value);
                break;

            case "igpj":
                ignoreProjector = bool.Parse(value);
                break;

            case "qofs":
                queueOffset = int.Parse(value);
                break;

            case "qpre":
                queuePreset = (Queue)int.Parse(value);
                break;

            case "rntp":
                renderType = (RenderType)int.Parse(value);
                break;

            // Fog booleans
            case "fgom":
                fogOverrideMode = bool.Parse(value);
                break;

            case "fgoc":
                fogOverrideColor = bool.Parse(value);
                break;

            case "fgod":
                fogOverrideDensity = bool.Parse(value);
                break;

            case "fgor":
                fogOverrideRange = bool.Parse(value);
                break;

            // Fog values
            case "fgmd":
                fogMode = (ShaderFogMode)int.Parse(value);
                break;

            case "fgcr":
                fogColor.r = float.Parse(value);
                break;

            case "fgcg":
                fogColor.g = float.Parse(value);
                break;

            case "fgcb":
                fogColor.b = float.Parse(value);
                break;

            case "fgca":
                fogColor.a = float.Parse(value);
                break;

            case "fgde":
                fogDensity = float.Parse(value);
                break;

            case "fgrn":
                fogRange.x = float.Parse(value);
                break;

            case "fgrf":
                fogRange.y = float.Parse(value);
                break;

            // Stencil buffer:
            case "stcl":
                useStencilBuffer = bool.Parse(value);
                break;

            case "atwp":
                allowStencilWriteThroughProperties = bool.Parse(value);
                break;

            case "stva":
                stencilValue = byte.Parse(value);
                break;

            case "stmr":
                stencilMaskRead = byte.Parse(value);
                break;

            case "stmw":
                stencilMaskWrite = byte.Parse(value);
                break;

            case "stcp":
                stencilComparison = (DepthTestStencil)int.Parse(value);
                break;

            case "stps":
                stencilPass = (StencilOp)int.Parse(value);
                break;

            case "stfa":
                stencilFail = (StencilOp)int.Parse(value);
                break;

            case "stfz":
                stencilFailZ = (StencilOp)int.Parse(value);
                break;

            // Offset
            case "ofsf":
                offsetFactor = int.Parse(value);
                break;

            case "ofsu":
                offsetUnits = int.Parse(value);
                break;
            }
        }
Пример #10
0
        private void ApplyDepthTest(DepthTest depthTest)
        {
            if (_renderState.DepthTest.Enabled != depthTest.Enabled)
            {
                Enable(EnableCap.DepthTest, depthTest.Enabled);
                _renderState.DepthTest.Enabled = depthTest.Enabled;
            }

            if (depthTest.Enabled)
            {
                if (_renderState.DepthTest.Function != depthTest.Function)
                {
                    GL.DepthFunc(TypeConverterGL3x.To(depthTest.Function));
                    _renderState.DepthTest.Function = depthTest.Function;
                }
            }
        }
Пример #11
0
 public void SetDepthTest(DepthTest d)
 {
     throw new NotImplementedException();
 }