protected UniversalProviderInfo(ProviderInfo providerInfo) : base(providerInfo) {
            try {
                PropertySheet = PropertySheet.Parse(@"@import ""pstab.properties"";", "default");
            } catch (Exception) {

                PropertySheet = new PropertySheet();
            }
            
        }
Пример #2
0
        public BuildScript(string filename)
        {
            _sheet = new PropertySheet(_project);
            _sheet.ParseFile(filename);

            foreach(var target in _sheet.CurrentView.ReplaceableChildren ) {
                target.MapTo(_project.LookupTarget(target),PtkRoutes);
            }

            _sheet.Route(_project.ProjectRoutes());

            // convert #product-info into a dictionary.
            productInformation = _sheet.Metadata.Value.Keys.Where(each => each.StartsWith("product-info")).ToXDictionary(each => each.Substring(12), each => _sheet.Metadata.Value[each]);

            _sheet.CopyToModel();
        }
Пример #3
0
 protected UniversalProviderInfo(ProviderInfo providerInfo)
     : base(providerInfo)
 {
     PropertySheet = PropertySheet.Parse(@"@import ""pstab.properties"";", "default");
 }
Пример #4
0
 public void Dispose()
 {
     _sheet = null;
 }
Пример #5
0
        public void Dispose()
        {
            _sheet = null;
            _nuspec = null;

            if (MsBuildMap._projects.ContainsKey(_props)) {
                MsBuildMap._projects.Remove(_props);
            }

            if(MsBuildMap._projects.ContainsKey(_targets)) {
                MsBuildMap._projects.Remove(_targets);
            }

            if (ProjectCollection.GlobalProjectCollection.LoadedProjects.Contains(_props)) {
                ProjectCollection.GlobalProjectCollection.UnloadProject(_props);
            }
            _props = null;
            if(ProjectCollection.GlobalProjectCollection.LoadedProjects.Contains(_targets)) {
                ProjectCollection.GlobalProjectCollection.UnloadProject(_targets);
            }
            _targets = null;
        }
        public DecalSettingsView(DecalMasterNode node)
        {
            m_Node = node;
            PropertySheet ps = new PropertySheet();

            int indentLevel = 0;

            ps.Add(new PropertyRow(CreateLabel("Affect BaseColor", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.affectsAlbedo.isOn;
                    toggle.RegisterValueChangedCallback(ChangeAffectsAlbedo);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Affects Normal", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.affectsNormal.isOn;
                    toggle.RegisterValueChangedCallback(ChangeAffectsNormal);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Affects Metal", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.affectsMetal.isOn;
                    toggle.RegisterValueChangedCallback(ChangeAffectsMetal);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Affects AO", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.affectsAO.isOn;
                    toggle.RegisterValueChangedCallback(ChangeAffectsAO);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Affects Smoothness", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.affectsSmoothness.isOn;
                    toggle.RegisterValueChangedCallback(ChangeAffectsSmoothness);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Affects Emission", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.affectsEmission.isOn;
                    toggle.RegisterValueChangedCallback(ChangeAffectsEmission);
                });
            });

            Add(ps);
        }
Пример #7
0
        public PackageScript(string filename)
        {
            _nuspec.metadata.id = "Package";
            _nuspec.metadata.version = "1.0.0";
            _nuspec.metadata.authors = "NAME";
            _nuspec.metadata.owners = "NAME";
            _nuspec.metadata.licenseUrl = "http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE";
            _nuspec.metadata.projectUrl = "http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE";
            _nuspec.metadata.iconUrl = "http://ICON_URL_HERE_OR_DELETE_THIS_LINE";
            _nuspec.metadata.requireLicenseAcceptance = "false";
            _nuspec.metadata.description = "Package description";
            _nuspec.metadata.releaseNotes = "Summary of changes made in this release of the package.";
            _nuspec.metadata.copyright = "Copyright 2013";

            _sheet = new PropertySheet(this);

            // get the full path to the .autopkgFile
            var fullPath = filename.GetFullPath();
            autopkgFolder = Directory.GetParent(fullPath).FullName;

            // parse the script
            _sheet.ParseFile(filename);
            _sheet.ImportText(RequiredTemplate, "required");

            // ensure we have at least the package ID
            pkgName = _sheet.View.nuget.nuspec.id;
            if (string.IsNullOrEmpty(pkgName)) {
                throw new ClrPlusException("the Field nuget.nuspec.id can not be null or empty. You must specify an id for a package.");
            }

            // set the package name macro
            _sheet.AddMacro("pkgname", pkgName);

            // generate the relative output paths.
            nuspecPath = Path.Combine(autopkgFolder, "{0}.nuspec".format(pkgName));
            propsPath = Path.Combine(autopkgFolder, "{0}.props".format(pkgName));
            targetsPath = Path.Combine(autopkgFolder, "{0}.targets".format(pkgName));

            // do the property sheet mapping
            var conditions = new XDictionary<string, string>();

            _sheet.Route("nuget.nuspec".MapTo(new object() , MapNuspec().ToArray() ));
            _sheet.Route("nuget.files".MapTo( new object() ,
                "condition".MapTo(conditions, key => Configurations.NormalizeConditionKey(key, _sheet.View.configurations as View)),
                "*".MapTo(conditions, key => Configurations.NormalizeConditionKey(key, _sheet.View.configurations as View))
                ));

            var hasProps = (_sheet.View.nuget.HasChild("props") && _sheet.View.nuget.props.HasChildren );
            var hasTargets = (_sheet.View.nuget.HasChild("targets") && _sheet.View.nuget.targets.HasChildren);

            if (hasProps) {
                _sheet.MapProject("nuget.props", _props);
                _sheet.MapConfigurations("configurations", _props);
            }

            if (hasTargets) {
                _sheet.MapProject("nuget.targets", _targets);
                _sheet.MapConfigurations("configurations", _targets);
            }

            // persist the propertysheet to the msbuild model.
            _sheet.View.CopyToModel();

            // generate automatic rules for lib/bin/include
            var implictRules = _sheet.CurrentView.GetMetadataValue("options.implicit-rules").IsNegative();

            // process files
            ProcessFiles(_sheet.View.nuget.files, autopkgFolder, implictRules, null);
        }
Пример #8
0
 public override void newProperties(PropertySheet ps)
 {
     base.newProperties(ps);
     this.filename = ps.getString("filename");
 }
Пример #9
0
 public abstract void newProperties(PropertySheet ps);
        void HandleMatrix2Property(
            ValueChangedCallback valueChangedCallback,
            PropertySheet propertySheet,
            Matrix4x4 matrix2Property,
            string labelName = "Default")
        {
            var vector2PropertyDrawer = new Vector2PropertyDrawer();

            vector2PropertyDrawer.preValueChangeCallback  = PreValueChangeCallback;
            vector2PropertyDrawer.postValueChangeCallback = PostValueChangeCallback;

            propertySheet.Add(vector2PropertyDrawer.CreateGUI(
                                  newValue =>
            {
                Vector2 row1 = MatrixRowFetchCallback(1);
                valueChangedCallback(new Matrix4x4()
                {
                    m00 = newValue.x,
                    m01 = newValue.y,
                    m02 = 0,
                    m03 = 0,
                    m10 = row1.x,
                    m11 = row1.y,
                    m12 = 0,
                    m13 = 0,
                    m20 = 0,
                    m21 = 0,
                    m22 = 0,
                    m23 = 0,
                    m30 = 0,
                    m31 = 0,
                    m32 = 0,
                    m33 = 0,
                });
            },
                                  matrix2Property.GetRow(0),
                                  labelName,
                                  out var row0Field
                                  ));

            propertySheet.Add(vector2PropertyDrawer.CreateGUI(
                                  newValue =>
            {
                Vector2 row0 = MatrixRowFetchCallback(0);
                valueChangedCallback(new Matrix4x4()
                {
                    m00 = row0.x,
                    m01 = row0.y,
                    m02 = 0,
                    m03 = 0,
                    m10 = newValue.x,
                    m11 = newValue.y,
                    m12 = 0,
                    m13 = 0,
                    m20 = 0,
                    m21 = 0,
                    m22 = 0,
                    m23 = 0,
                    m30 = 0,
                    m31 = 0,
                    m32 = 0,
                    m33 = 0,
                });
            },
                                  matrix2Property.GetRow(1),
                                  "",
                                  out var row1Field
                                  ));
        }
Пример #11
0
        public StackLitSettingsView(StackLitMasterNode node) : base(node)
        {
            m_Node = node;
            PropertySheet ps = new PropertySheet();

            int indentLevel = 0;

            ps.Add(new PropertyRow(CreateLabel("Surface Type", indentLevel)), (row) =>
            {
                row.Add(new EnumField(SurfaceType.Opaque), (field) =>
                {
                    field.value = m_Node.surfaceType;
                    field.RegisterValueChangedCallback(ChangeSurfaceType);
                });
            });

            if (m_Node.surfaceType == SurfaceType.Transparent)
            {
                ++indentLevel;

                // No refraction in StackLit, always show this:
                ps.Add(new PropertyRow(CreateLabel("Blending Mode", indentLevel)), (row) =>
                {
                    row.Add(new EnumField(StackLitMasterNode.AlphaModeLit.Additive), (field) =>
                    {
                        field.value = GetAlphaModeLit(m_Node.alphaMode);
                        field.RegisterValueChangedCallback(ChangeBlendMode);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Blend Preserves Specular", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.blendPreserveSpecular.isOn;
                        toggle.OnToggleChanged(ChangeBlendPreserveSpecular);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Fog", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.transparencyFog.isOn;
                        toggle.OnToggleChanged(ChangeTransparencyFog);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Distortion", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.distortion.isOn;
                        toggle.OnToggleChanged(ChangeDistortion);
                    });
                });

                if (m_Node.distortion.isOn)
                {
                    ++indentLevel;
                    ps.Add(new PropertyRow(CreateLabel("Distortion Blend Mode", indentLevel)), (row) =>
                    {
                        row.Add(new EnumField(DistortionMode.Add), (field) =>
                        {
                            field.value = m_Node.distortionMode;
                            field.RegisterValueChangedCallback(ChangeDistortionMode);
                        });
                    });
                    ps.Add(new PropertyRow(CreateLabel("Distortion Depth Test", indentLevel)), (row) =>
                    {
                        row.Add(new Toggle(), (toggle) =>
                        {
                            toggle.value = m_Node.distortionDepthTest.isOn;
                            toggle.OnToggleChanged(ChangeDistortionDepthTest);
                        });
                    });
                    --indentLevel;
                }

                m_SortPiorityField = new IntegerField();
                ps.Add(new PropertyRow(CreateLabel("Sort Priority", indentLevel)), (row) =>
                {
                    row.Add(m_SortPiorityField, (field) =>
                    {
                        field.value = m_Node.sortPriority;
                        field.RegisterValueChangedCallback(ChangeSortPriority);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Transparent Depth Prepass", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.alphaTestDepthPrepass.isOn;
                        toggle.OnToggleChanged(ChangeAlphaTestPrepass);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Transparent Depth Postpass", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.alphaTestDepthPostpass.isOn;
                        toggle.OnToggleChanged(ChangeAlphaTestPostpass);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Depth Write", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.zWrite.isOn;
                        toggle.OnToggleChanged(ChangeZWrite);
                    });
                });

                if (m_Node.doubleSidedMode == DoubleSidedMode.Disabled)
                {
                    ps.Add(new PropertyRow(CreateLabel("Cull Mode", indentLevel)), (row) =>
                    {
                        row.Add(new EnumField(m_Node.transparentCullMode), (e) =>
                        {
                            e.value = m_Node.transparentCullMode;
                            e.RegisterValueChangedCallback(ChangeTransparentCullMode);
                        });
                    });
                }

                ps.Add(new PropertyRow(CreateLabel("Depth Test", indentLevel)), (row) =>
                {
                    row.Add(new EnumField(m_Node.zTest), (e) =>
                    {
                        e.value = m_Node.zTest;
                        e.RegisterValueChangedCallback(ChangeZTest);
                    });
                });

                --indentLevel;
            }

            ps.Add(new PropertyRow(CreateLabel("Alpha Clipping", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.alphaTest.isOn;
                    toggle.OnToggleChanged(ChangeAlphaTest);
                });
            });

            if (m_Node.alphaTest.isOn)
            {
                ++indentLevel;
                ps.Add(new PropertyRow(CreateLabel("Alpha to Mask", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.alphaToMask.isOn;
                        toggle.OnToggleChanged(ChangeAlphaToMask);
                    });
                });
                --indentLevel;
            }

            ps.Add(new PropertyRow(CreateLabel("Double-Sided", indentLevel)), (row) =>
            {
                row.Add(new EnumField(DoubleSidedMode.Disabled), (field) =>
                {
                    field.value = m_Node.doubleSidedMode;
                    field.RegisterValueChangedCallback(ChangeDoubleSidedMode);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Fragment Normal Space", indentLevel)), (row) =>
            {
                row.Add(new EnumField(NormalDropOffSpace.Tangent), (field) =>
                {
                    field.value = m_Node.normalDropOffSpace;
                    field.RegisterValueChangedCallback(ChangeSpaceOfNormalDropOffMode);
                });
            });

            // Rest of UI looks like this:
            //
            //  baseParametrization
            //    energyConservingSpecular
            //
            //  anisotropy
            //  coat
            //  coatNormal
            //  dualSpecularLobe
            //    dualSpecularLobeParametrization
            //    capHazinessWrtMetallic
            //  iridescence
            //  subsurfaceScattering
            //  transmission
            //
            //  receiveDecals
            //  receiveSSR
            //  addPrecomputedVelocity
            //  geometricSpecularAA
            //  specularOcclusion
            //
            //  anisotropyForAreaLights
            //  recomputeStackPerLight
            //  shadeBaseUsingRefractedAngles

            // Base parametrization:

            ps.Add(new PropertyRow(CreateLabel("Base Color Parametrization", indentLevel)), (row) =>
            {
                row.Add(new EnumField(StackLit.BaseParametrization.BaseMetallic), (field) =>
                {
                    field.value = m_Node.baseParametrization;
                    field.RegisterValueChangedCallback(ChangeBaseParametrization);
                });
            });

            if (m_Node.baseParametrization == StackLit.BaseParametrization.SpecularColor)
            {
                ++indentLevel;
                ps.Add(new PropertyRow(CreateLabel("Energy Conserving Specular", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.energyConservingSpecular.isOn;
                        toggle.OnToggleChanged(ChangeEnergyConservingSpecular);
                    });
                });
                --indentLevel;
            }

            // Material type enables:
            ps.Add(new PropertyRow(CreateLabel("Material Core Features", indentLevel)), (row) => {});
            ++indentLevel;

            ps.Add(new PropertyRow(CreateLabel("Anisotropy", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.anisotropy.isOn;
                    toggle.OnToggleChanged(ChangeAnisotropy);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Coat", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.coat.isOn;
                    toggle.OnToggleChanged(ChangeCoat);
                });
            });

            if (m_Node.coat.isOn)
            {
                ++indentLevel;
                ps.Add(new PropertyRow(CreateLabel("Coat Normal", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.coatNormal.isOn;
                        toggle.OnToggleChanged(ChangeCoatNormal);
                    });
                });
                --indentLevel;
            }

            ps.Add(new PropertyRow(CreateLabel("Dual Specular Lobe", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.dualSpecularLobe.isOn;
                    toggle.OnToggleChanged(ChangeDualSpecularLobe);
                });
            });

            if (m_Node.dualSpecularLobe.isOn)
            {
                ++indentLevel;
                ps.Add(new PropertyRow(CreateLabel("Dual SpecularLobe Parametrization", indentLevel)), (row) =>
                {
                    row.Add(new EnumField(StackLit.DualSpecularLobeParametrization.HazyGloss), (field) =>
                    {
                        field.value = m_Node.dualSpecularLobeParametrization;
                        field.RegisterValueChangedCallback(ChangeDualSpecularLobeParametrization);
                    });
                });
                if ((m_Node.baseParametrization == StackLit.BaseParametrization.BaseMetallic) &&
                    (m_Node.dualSpecularLobeParametrization == StackLit.DualSpecularLobeParametrization.HazyGloss))
                {
                    ps.Add(new PropertyRow(CreateLabel("Cap Haziness For Non Metallic", indentLevel)), (row) =>
                    {
                        row.Add(new Toggle(), (toggle) =>
                        {
                            toggle.value = m_Node.capHazinessWrtMetallic.isOn;
                            toggle.OnToggleChanged(ChangeCapHazinessWrtMetallic);
                        });
                    });
                }
                --indentLevel;
            }

            ps.Add(new PropertyRow(CreateLabel("Iridescence", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.iridescence.isOn;
                    toggle.OnToggleChanged(ChangeIridescence);
                });
            });

            if (m_Node.surfaceType != SurfaceType.Transparent)
            {
                ps.Add(new PropertyRow(CreateLabel("Subsurface Scattering", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.subsurfaceScattering.isOn;
                        toggle.OnToggleChanged(ChangeSubsurfaceScattering);
                    });
                });
            }

            ps.Add(new PropertyRow(CreateLabel("Transmission", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.transmission.isOn;
                    toggle.OnToggleChanged(ChangeTransmission);
                });
            });
            --indentLevel; // ...Material type enables.

            ps.Add(new PropertyRow(CreateLabel("Receive Decals", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.receiveDecals.isOn;
                    toggle.OnToggleChanged(ChangeReceiveDecals);
                });
            });

            ps.Add(new PropertyRow(CreateLabel((m_Node.surfaceType == SurfaceType.Transparent) ? "Receive SSR Transparent" : "Receive SSR", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    if (m_Node.surfaceType == SurfaceType.Transparent)
                    {
                        toggle.value = m_Node.receiveSSRTransparent.isOn;
                        toggle.OnToggleChanged(ChangeReceiveSSRTransparent);
                    }
                    else
                    {
                        toggle.value = m_Node.receiveSSR.isOn;
                        toggle.OnToggleChanged(ChangeReceiveSSR);
                    }
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Add Precomputed Velocity", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.addPrecomputedVelocity.isOn;
                    toggle.OnToggleChanged(ChangeAddPrecomputedVelocity);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Geometric Specular AA", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.geometricSpecularAA.isOn;
                    toggle.OnToggleChanged(ChangeGeometricSpecularAA);
                });
            });

            //ps.Add(new PropertyRow(CreateLabel("Specular Occlusion (main enable)", indentLevel)), (row) =>
            //{
            //    row.Add(new Toggle(), (toggle) =>
            //    {
            //        toggle.value = m_Node.specularOcclusion.isOn;
            //        toggle.OnToggleChanged(ChangeSpecularOcclusion);
            //    });
            //});

            // SpecularOcclusion from SSAO
            if (m_Node.devMode.isOn)
            {
                // Only in dev mode do we show controls for SO fed from SSAO: otherwise, we keep the default which is DirectFromAO
                ps.Add(new PropertyRow(CreateLabel("Specular Occlusion (from SSAO)", indentLevel)), (row) =>
                {
                    row.Add(new EnumField(StackLitMasterNode.SpecularOcclusionBaseMode.DirectFromAO), (field) =>
                    {
                        field.value = m_Node.screenSpaceSpecularOcclusionBaseMode;
                        field.RegisterValueChangedCallback(ChangeScreenSpaceSpecularOcclusionBaseMode);
                    });
                });
                if (StackLitMasterNode.SpecularOcclusionModeUsesVisibilityCone(m_Node.screenSpaceSpecularOcclusionBaseMode))
                {
                    ++indentLevel;
                    ps.Add(new PropertyRow(CreateLabel("Specular Occlusion (SS) AO Cone Weight", indentLevel)), (row) =>
                    {
                        row.Add(new EnumField(StackLitMasterNode.SpecularOcclusionAOConeSize.CosWeightedAO), (field) =>
                        {
                            field.value = m_Node.screenSpaceSpecularOcclusionAOConeSize;
                            field.RegisterValueChangedCallback(ChangeScreenSpaceSpecularOcclusionAOConeSize);
                        });
                    });
                    ps.Add(new PropertyRow(CreateLabel("Specular Occlusion (SS) AO Cone Dir", indentLevel)), (row) =>
                    {
                        row.Add(new EnumField(StackLitMasterNode.SpecularOcclusionAOConeDir.ShadingNormal), (field) =>
                        {
                            field.value = m_Node.screenSpaceSpecularOcclusionAOConeDir;
                            field.RegisterValueChangedCallback(ChangeScreenSpaceSpecularOcclusionAOConeDir);
                        });
                    });
                    --indentLevel;
                }
            }

            // SpecularOcclusion from input AO (baked or data-based SO)
            {
                ps.Add(new PropertyRow(CreateLabel("Specular Occlusion (from input AO)", indentLevel)), (row) =>
                {
                    if (m_Node.devMode.isOn)
                    {
                        row.Add(new EnumField(StackLitMasterNode.SpecularOcclusionBaseMode.DirectFromAO), (field) =>
                        {
                            field.value = m_Node.dataBasedSpecularOcclusionBaseMode;
                            field.RegisterValueChangedCallback(ChangeDataBasedSpecularOcclusionBaseMode);
                        });
                    }
                    else
                    {
                        row.Add(new EnumField(StackLitMasterNode.SpecularOcclusionBaseModeSimple.DirectFromAO), (field) =>
                        {
                            // In non-dev mode, parse any enum value set to a method not shown in the simple UI as SPTD (highest quality) method:
                            StackLitMasterNode.SpecularOcclusionBaseModeSimple simpleUIEnumValue =
                                Enum.TryParse(m_Node.dataBasedSpecularOcclusionBaseMode.ToString(), out StackLitMasterNode.SpecularOcclusionBaseModeSimple parsedValue) ?
                                parsedValue : StackLitMasterNode.SpecularOcclusionBaseModeSimple.SPTDIntegrationOfBentAO;
                            field.value = simpleUIEnumValue;
                            field.RegisterValueChangedCallback(ChangeDataBasedSpecularOcclusionBaseModeSimpleUI);
                        });
                    }
                });
                if (StackLitMasterNode.SpecularOcclusionModeUsesVisibilityCone(m_Node.dataBasedSpecularOcclusionBaseMode))
                {
                    ++indentLevel;
                    ps.Add(new PropertyRow(CreateLabel("Specular Occlusion AO Cone Weight", indentLevel)), (row) =>
                    {
                        row.Add(new EnumField(StackLitMasterNode.SpecularOcclusionAOConeSize.CosWeightedBentCorrectAO), (field) =>
                        {
                            field.value = m_Node.dataBasedSpecularOcclusionAOConeSize;
                            field.RegisterValueChangedCallback(ChangeDataBasedSpecularOcclusionAOConeSize);
                        });
                    });
                    --indentLevel;
                }
            }

            if (m_Node.SpecularOcclusionUsesBentNormal())
            {
                if (m_Node.devMode.isOn)
                {
                    ps.Add(new PropertyRow(CreateLabel("Specular Occlusion Bent Cone Fixup", indentLevel)), (row) =>
                    {
                        row.Add(new EnumField(StackLitMasterNode.SpecularOcclusionConeFixupMethod.Off), (field) =>
                        {
                            field.value = m_Node.specularOcclusionConeFixupMethod;
                            field.RegisterValueChangedCallback(ChangeSpecularOcclusionConeFixupMethod);
                        });
                    });
                }
                else
                {
                    // Just show a simple toggle when not in dev mode
                    ps.Add(new PropertyRow(CreateLabel("Specular Occlusion Bent Cone Fixup", indentLevel)), (row) =>
                    {
                        row.Add(new Toggle(), (toggle) =>
                        {
                            toggle.value = m_Node.specularOcclusionConeFixupMethod != StackLitMasterNode.SpecularOcclusionConeFixupMethod.Off;
                            toggle.OnToggleChanged(ChangeSpecularOcclusionConeFixupMethodSimpleUI);
                        });
                    });
                }
            }

            ps.Add(new PropertyRow(CreateLabel("Support LOD CrossFade", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.supportLodCrossFade.isOn;
                    toggle.OnToggleChanged(ChangeSupportLODCrossFade);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Advanced Options", indentLevel)), (row) => {});
            ++indentLevel;

            ps.Add(new PropertyRow(CreateLabel("Anisotropy For Area Lights", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.anisotropyForAreaLights.isOn;
                    toggle.OnToggleChanged(ChangeAnisotropyForAreaLights);
                });
            });

            // Per Punctual/Directional Lights
            {
                ps.Add(new PropertyRow(CreateLabel("Per Punctual/Directional Lights:", indentLevel)), (row) => { });
                ++indentLevel;

                if (m_Node.coat.isOn)
                {
                    ps.Add(new PropertyRow(CreateLabel("Base Layer Uses Refracted Angles", indentLevel)), (row) =>
                    {
                        row.Add(new Toggle(), (toggle) =>
                        {
                            toggle.value = m_Node.shadeBaseUsingRefractedAngles.isOn;
                            toggle.OnToggleChanged(ChangeShadeBaseUsingRefractedAngles);
                        });
                    });
                }
                if (m_Node.coat.isOn || m_Node.iridescence.isOn)
                {
                    ps.Add(new PropertyRow(CreateLabel("Recompute Stack & Iridescence", indentLevel)), (row) =>
                    {
                        row.Add(new Toggle(), (toggle) =>
                        {
                            toggle.value = m_Node.recomputeStackPerLight.isOn;
                            toggle.OnToggleChanged(ChangeRecomputeStackPerLight);
                        });
                    });
                }
                ps.Add(new PropertyRow(CreateLabel("Honor Per Light Max Smoothness", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.honorPerLightMinRoughness.isOn;
                        toggle.OnToggleChanged(ChangeHonorPerLightMinRoughness);
                    });
                });

                --indentLevel;
            } // Per Punctual/Directional Lights

            // Uncomment to show the dev mode UI:
            //
            //ps.Add(new PropertyRow(CreateLabel("Enable Dev Mode", indentLevel)), (row) =>
            //{
            //    row.Add(new Toggle(), (toggle) =>
            //    {
            //        toggle.value = m_Node.devMode.isOn;
            //        toggle.OnToggleChanged(ChangeDevMode);
            //    });
            //});

            if (m_Node.devMode.isOn)
            {
                ps.Add(new PropertyRow(CreateLabel("Show And Enable StackLit Debugs", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.debug.isOn;
                        toggle.OnToggleChanged(ChangeDebug);
                    });
                });
            }

            ps.Add(new PropertyRow(CreateLabel("Override Baked GI", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.overrideBakedGI.isOn;
                    toggle.OnToggleChanged(ChangeoverrideBakedGI);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Depth Offset", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.depthOffset.isOn;
                    toggle.OnToggleChanged(ChangeDepthOffset);
                });
            });

            --indentLevel; //...Advanced options

            Add(ps);
            Add(GetShaderGUIOverridePropertySheet());
        }
Пример #12
0
        public SGESimpleLitSettingsView(SGESimpleLitMasterNode node)
        {
            m_Node = node;

            PropertySheet ps = new PropertySheet();

            ps.Add(new PropertyRow(new Label("Render Type")), (row) =>
            {
                row.Add(new EnumField(SurfaceMaterialTags.RenderType.Opaque), (field) =>
                {
                    field.value = m_Node.RenderType;
                    field.RegisterValueChangedCallback(ChangeRenderType);
                });
            });

            ps.Add(new PropertyRow(new Label("Render Queue")), (row) =>
            {
                row.Add(new EnumField(SurfaceMaterialTags.RenderQueue.Geometry), (field) =>
                {
                    field.value = m_Node.RenderQueue;
                    field.RegisterValueChangedCallback(ChangeRenderQueue);
                });
            });

            ps.Add(new PropertyRow(new Label("Blend")), (row) =>
            {
                row.Add(new EnumField(BlendMode.Off), (field) =>
                {
                    field.value = m_Node.BlendMode;
                    field.RegisterValueChangedCallback(ChangeBlendMode);
                });
            });

            ps.Add(new PropertyRow(new Label("Cull")), (row) =>
            {
                row.Add(new EnumField(SurfaceMaterialOptions.CullMode.Back), (field) =>
                {
                    field.value = m_Node.CullMode;
                    field.RegisterValueChangedCallback(ChangeCullMode);
                });
            });

            ps.Add(new PropertyRow(new Label("ZWrite")), (row) =>
            {
                row.Add(new EnumField(SurfaceMaterialOptions.ZWrite.On), (field) =>
                {
                    field.value = m_Node.ZWrite;
                    field.RegisterValueChangedCallback(ChangeZWrite);
                });
            });

            ps.Add(new PropertyRow(new Label("ZTest")), (row) =>
            {
                row.Add(new EnumField(SurfaceMaterialOptions.ZTest.LEqual), (field) =>
                {
                    field.value = m_Node.ZTest;
                    field.RegisterValueChangedCallback(ChangeZTest);
                });
            });

            ps.Add(new PropertyRow(new Label("Fragment Normal Space")), (row) =>
            {
                row.Add(new EnumField(NormalDropOffSpace.Tangent), (field) =>
                {
                    field.value = m_Node.normalDropOffSpace;
                    field.RegisterValueChangedCallback(ChangeSpaceOfNormalDropOffMode);
                });
            });


            ps.Add(new PropertyRow(new Label("Custom Editor")), (row) =>
            {
                row.Add(new TextField(String.Empty), (field) =>
                {
                    field.value = m_Node.CustomEditor;
                    field.RegisterValueChangedCallback(ChangeCustomEditor);
                });
            });

            Add(ps);
        }
 public virtual void newProperties(PropertySheet ps)
 {
 }
Пример #14
0
        public override void Render(PostProcessRenderContext context)
        {
            PropertySheet sheet = context.propertySheets.Get(shader);
            CommandBuffer cmd   = context.command;

            Camera cam = context.camera;

            #region Skybox sampling
            //Add the skybox rendering component to any camera rendering Fog
            if (settings.colorSource.value == Fog.FogColorSource.SkyboxColor)
            {
                //Ignore hidden camera's, except scene-view cam
                if (cam.hideFlags != HideFlags.None && cam.name != "SceneCamera")
                {
                    return;
                }

                if (!skyboxCams.ContainsKey(cam))
                {
                    skyboxCams[cam] = cam.gameObject.GetComponent <RenderScreenSpaceSkybox>();

                    if (!skyboxCams[cam])
                    {
                        skyboxCams[cam] = cam.gameObject.AddComponent <RenderScreenSpaceSkybox>();
                    }
                    skyboxCams[cam].manuallyAdded = false; //Don't show warning on component
                }
            }
            #endregion

            //OpenVR.System.GetProjectionMatrix(vrEye, mainCamera.nearClipPlane, mainCamera.farClipPlane, EGraphicsAPIConvention.API_DirectX)

            //Clip-space to world-space camera matrix conversion
            #region Property value composition
            var p = GL.GetGPUProjectionMatrix(cam.projectionMatrix, false);
            p[2, 3] = p[3, 2] = 0.0f;
            p[3, 3] = 1.0f;
            var clipToWorld = Matrix4x4.Inverse(p * cam.worldToCameraMatrix) * Matrix4x4.TRS(new Vector3(0, 0, -p[2, 2]), Quaternion.identity, Vector3.one);
            sheet.properties.SetMatrix("clipToWorld", clipToWorld);

            float FdotC  = cam.transform.position.y - settings.height;
            float paramK = (FdotC <= 0.0f ? 1.0f : 0.0f);
            //Always exclude skybox for skybox color mode
            //Always include when using light scattering to avoid depth discontinuity
            float skyboxInfluence = (settings.lightScattering) ? 1.0f : settings.skyboxInfluence;
            float distanceFog     = (settings.distanceFog) ? 1.0f : 0.0f;
            float heightFog       = (settings.heightFog) ? 1.0f : 0.0f;

            int colorSource  = (settings.useSceneSettings) ? 0 : (int)settings.colorSource.value;
            var sceneMode    = (settings.useSceneSettings) ? RenderSettings.fogMode : settings.fogMode;
            var sceneDensity = (settings.useSceneSettings) ? RenderSettings.fogDensity : settings.globalDensity / 100;
            var sceneStart   = (settings.useSceneSettings) ? RenderSettings.fogStartDistance : settings.fogStartDistance;
            var sceneEnd     = (settings.useSceneSettings) ? RenderSettings.fogEndDistance : settings.fogEndDistance;

            bool  linear  = (sceneMode == FogMode.Linear);
            float diff    = linear ? sceneEnd - sceneStart : 0.0f;
            float invDiff = Mathf.Abs(diff) > 0.0001f ? 1.0f / diff : 0.0f;

            Vector4 sceneParams;
            sceneParams.x = sceneDensity * 1.2011224087f; // density / sqrt(ln(2)), used by Exp2 fog mode
            sceneParams.y = sceneDensity * 1.4426950408f; // density / ln(2), used by Exp fog mode
            sceneParams.z = linear ? -invDiff : 0.0f;
            sceneParams.w = linear ? sceneEnd * invDiff : 0.0f;

            float gradientDistance = (settings.gradientUseFarClipPlane.value) ? settings.gradientDistance : context.camera.farClipPlane;
            #endregion

            #region Property assignment
            if (settings.heightNoiseTex.value)
            {
                sheet.properties.SetTexture("_NoiseTex", settings.heightNoiseTex);
            }
            if (settings.fogColorGradient.value)
            {
                sheet.properties.SetTexture("_ColorGradient", settings.fogColorGradient);
            }
            sheet.properties.SetFloat("_FarClippingPlane", gradientDistance);
            sheet.properties.SetVector("_SceneFogParams", sceneParams);
            sheet.properties.SetVector("_SceneFogMode", new Vector4((int)sceneMode, settings.useRadialDistance ? 1 : 0, colorSource, settings.heightFogNoise ? 1 : 0));
            sheet.properties.SetVector("_NoiseParams", new Vector4(settings.heightNoiseSize * 0.01f, settings.heightNoiseSpeed * 0.01f, settings.heightNoiseStrength, 0));
            sheet.properties.SetVector("_DensityParams", new Vector4(settings.distanceDensity, settings.heightNoiseStrength, settings.skyboxMipLevel, 0));
            sheet.properties.SetVector("_HeightParams", new Vector4(settings.height, FdotC, paramK, settings.heightDensity * 0.5f));
            sheet.properties.SetVector("_DistanceParams", new Vector4(-sceneStart, 0f, distanceFog, heightFog));
            sheet.properties.SetColor("_FogColor", (settings.useSceneSettings) ? RenderSettings.fogColor : settings.fogColor);
            sheet.properties.SetVector("_SkyboxParams", new Vector4(skyboxInfluence, settings.skyboxMipLevel, 0, 0));
            #endregion

            #region Light scattering
            //Repurpose parts of the bloom effect
            bool enableScattering = (settings.lightScattering) ? true : false;

            if (enableScattering)
            {
                int  tw = Mathf.FloorToInt(context.screenWidth / (2f));
                int  th = Mathf.FloorToInt(context.screenHeight / (2f));
                bool singlePassDoubleWide = (context.stereoActive && (context.stereoRenderingMode == PostProcessRenderContext.StereoRenderingMode.SinglePass) && (context.camera.stereoTargetEye == StereoTargetEyeMask.Both));
                int  tw_stereo            = singlePassDoubleWide ? tw * 2 : tw;

                // Determine the iteration count
                int   s           = Mathf.Max(tw, th);
                float logs        = Mathf.Log(s, 2f) + Mathf.Min(settings.scatterDiffusion.value, 10f) - 10f;
                int   logs_i      = Mathf.FloorToInt(logs);
                int   iterations  = Mathf.Clamp(logs_i, 1, k_MaxPyramidSize);
                float sampleScale = 0.5f + logs - logs_i;
                sheet.properties.SetFloat("_SampleScale", sampleScale);

                // Prefiltering parameters
                float lthresh   = Mathf.GammaToLinearSpace(settings.scatterThreshold.value);
                float knee      = lthresh * settings.scatterSoftKnee.value + 1e-5f;
                var   threshold = new Vector4(lthresh, lthresh - knee, knee * 2f, 0.25f / knee);
                sheet.properties.SetVector("_Threshold", threshold);

                // Downsample
                var lastDown = context.source;
                for (int i = 0; i < iterations; i++)
                {
                    int mipDown = m_Pyramid[i].down;
                    int mipUp   = m_Pyramid[i].up;
                    int pass    = i == 0 ? (int)Pass.Prefilter : (int)Pass.Downsample;

                    context.GetScreenSpaceTemporaryRT(cmd, mipDown, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, tw_stereo, th);
                    context.GetScreenSpaceTemporaryRT(cmd, mipUp, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, tw_stereo, th);
                    cmd.BlitFullscreenTriangle(lastDown, mipDown, sheet, pass);

                    lastDown  = mipDown;
                    tw_stereo = (singlePassDoubleWide && ((tw_stereo / 2) % 2 > 0)) ? 1 + tw_stereo / 2 : tw_stereo / 2;
                    tw_stereo = Mathf.Max(tw_stereo, 1);
                    th        = Mathf.Max(th / 2, 1);
                }

                // Upsample
                int lastUp = m_Pyramid[iterations - 1].down;
                for (int i = iterations - 2; i >= 0; i--)
                {
                    int mipDown = m_Pyramid[i].down;
                    int mipUp   = m_Pyramid[i].up;
                    cmd.SetGlobalTexture("_BloomTex", mipDown);
                    cmd.BlitFullscreenTriangle(lastUp, mipUp, sheet, (int)Pass.Upsample);
                    lastUp = mipUp;
                }

                float intensity      = RuntimeUtilities.Exp2(settings.scatterIntensity.value / 10f) - 1f;
                var   shaderSettings = new Vector4(sampleScale, intensity, 0, iterations);
                sheet.properties.SetVector("_ScatteringParams", shaderSettings);

                cmd.SetGlobalTexture("_BloomTex", lastUp);

                // Cleanup
                for (int i = 0; i < iterations; i++)
                {
                    if (m_Pyramid[i].down != lastUp)
                    {
                        cmd.ReleaseTemporaryRT(m_Pyramid[i].down);
                    }
                    if (m_Pyramid[i].up != lastUp)
                    {
                        cmd.ReleaseTemporaryRT(m_Pyramid[i].up);
                    }
                }
            }

            #endregion

            #region shader passes
            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, enableScattering ? (int)Pass.BlendScattering : (int)Pass.Blend);
            #endregion
        }
Пример #15
0
        public void Run(string[] args, PropertySheet sheet)
        {
            var options = args.Switches();
            _propertySheet = sheet;

            FindRules();

            BuildScanMaps();

            // store targets to ignore.
            IgnoredTargets = _scanRule["ignore-targets"].AsStrings();

            // load trace files up front.
            LoadTraceFiles(args.GetParametersForSwitch("load-trace"));
            LoadTraceFiles(_scanRule);

            // create the flat collection
            allProcesses = Traces.process.Traverse(c => c.process);

            // run the auto scan for the current directory unless told not to.
            if (_scanRule["auto-scan"].AsBoolean(true)) {
                ScanSource(Environment.CurrentDirectory);
            }

            // scan all additional source directory trees
            ScanSourceDirectories(_scanRule["auto-scanRule"].AsStrings());

            // figure out what the developer wants to build
            IdentifyTargets();

            // set product info per target
            SetProductInfo();

            // associate any project rules with them
            AssociateProjectRules();

            // In each target, create the source groups
            CreateSourceGroupsInTargets();

            // figure out what files go into each target
            AddSourceFilesToProjects();

            // Assign each file to the groups in each project
            AssignFilesToGroups();

            foreach( var target in Targets ) {
                var fname = Path.Combine(Path.GetDirectoryName(_propertySheet.Filename), Path.GetFileName(target.SpecFile.Link.Output) + ".spec");
                target.SpecFile.Save(fname);

                Console.WriteLine("{0}(1,1): Created Spec file", fname);
            }
        }
Пример #16
0
        public HairSettingsView(HairMasterNode node) : base(node)
        {
            m_Node = node;
            PropertySheet ps = new PropertySheet();

            int indentLevel = 0;

            ps.Add(new PropertyRow(CreateLabel("Surface Type", indentLevel)), (row) =>
            {
                row.Add(new EnumField(SurfaceType.Opaque), (field) =>
                {
                    field.value = m_Node.surfaceType;
                    field.RegisterValueChangedCallback(ChangeSurfaceType);
                });
            });

            if (m_Node.surfaceType == SurfaceType.Transparent)
            {
                ++indentLevel;

                ps.Add(new PropertyRow(CreateLabel("Preserve Specular Lighting", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.blendPreserveSpecular.isOn;
                        toggle.OnToggleChanged(ChangeBlendPreserveSpecular);
                    });
                });

                m_SortPriorityField = new IntegerField();
                ps.Add(new PropertyRow(CreateLabel("Sorting Priority", indentLevel)), (row) =>
                {
                    row.Add(m_SortPriorityField, (field) =>
                    {
                        field.value = m_Node.sortPriority;
                        field.RegisterValueChangedCallback(ChangeSortPriority);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Receive Fog", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.transparencyFog.isOn;
                        toggle.OnToggleChanged(ChangeTransparencyFog);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Back Then Front Rendering", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.backThenFrontRendering.isOn;
                        toggle.OnToggleChanged(ChangeBackThenFrontRendering);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Transparent Depth Prepass", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.alphaTestDepthPrepass.isOn;
                        toggle.OnToggleChanged(ChangeAlphaTestPrepass);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Transparent Depth Postpass", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.alphaTestDepthPostpass.isOn;
                        toggle.OnToggleChanged(ChangeAlphaTestPostpass);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Transparent Writes Motion Vector", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.transparentWritesMotionVec.isOn;
                        toggle.OnToggleChanged(ChangeTransparentWritesMotionVec);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Depth Write", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.zWrite.isOn;
                        toggle.OnToggleChanged(ChangeZWrite);
                    });
                });

                if (m_Node.doubleSidedMode == DoubleSidedMode.Disabled)
                {
                    ps.Add(new PropertyRow(CreateLabel("Cull Mode", indentLevel)), (row) =>
                    {
                        row.Add(new EnumField(m_Node.transparentCullMode), (e) =>
                        {
                            e.value = m_Node.transparentCullMode;
                            e.RegisterValueChangedCallback(ChangeTransparentCullMode);
                        });
                    });
                }

                ps.Add(new PropertyRow(CreateLabel("Depth Test", indentLevel)), (row) =>
                {
                    row.Add(new EnumField(m_Node.zTest), (e) =>
                    {
                        e.value = m_Node.zTest;
                        e.RegisterValueChangedCallback(ChangeZTest);
                    });
                });

                --indentLevel;
            }

            ps.Add(new PropertyRow(CreateLabel("Double-Sided", indentLevel)), (row) =>
            {
                row.Add(new EnumField(DoubleSidedMode.Disabled), (field) =>
                {
                    field.value = m_Node.doubleSidedMode;
                    field.RegisterValueChangedCallback(ChangeDoubleSidedMode);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Alpha Clipping", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.alphaTest.isOn;
                    toggle.OnToggleChanged(ChangeAlphaTest);
                });
            });

            if (m_Node.alphaTest.isOn)
            {
                ++indentLevel;
                ps.Add(new PropertyRow(CreateLabel("Use Shadow Threshold", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.alphaTestShadow.isOn;
                        toggle.OnToggleChanged(ChangeAlphaTestShadow);
                    });
                });

                ps.Add(new PropertyRow(CreateLabel("Alpha to Mask", indentLevel)), (row) =>
                {
                    row.Add(new Toggle(), (toggle) =>
                    {
                        toggle.value = m_Node.alphaToMask.isOn;
                        toggle.OnToggleChanged(ChangeAlphaToMask);
                    });
                });
                --indentLevel;
            }

            ps.Add(new PropertyRow(CreateLabel("Receive Decals", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.receiveDecals.isOn;
                    toggle.OnToggleChanged(ChangeDecal);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Receive SSR", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.receiveSSR.isOn;
                    toggle.OnToggleChanged(ChangeSSR);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Add Precomputed Velocity", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.addPrecomputedVelocity.isOn;
                    toggle.OnToggleChanged(ChangeAddPrecomputedVelocity);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Geometric Specular AA", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.specularAA.isOn;
                    toggle.OnToggleChanged(ChangeSpecularAA);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Specular Occlusion Mode", indentLevel)), (row) =>
            {
                row.Add(new EnumField(SpecularOcclusionMode.Off), (field) =>
                {
                    field.value = m_Node.specularOcclusionMode;
                    field.RegisterValueChangedCallback(ChangeSpecularOcclusionMode);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Override Baked GI", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.overrideBakedGI.isOn;
                    toggle.OnToggleChanged(ChangeoverrideBakedGI);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Depth Offset", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.depthOffset.isOn;
                    toggle.OnToggleChanged(ChangeDepthOffset);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Use Light Facing Normal", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.useLightFacingNormal.isOn;
                    toggle.OnToggleChanged(ChangeUseLightFacingNormal);
                });
            });

            ps.Add(new PropertyRow(CreateLabel("Support LOD CrossFade", indentLevel)), (row) =>
            {
                row.Add(new Toggle(), (toggle) =>
                {
                    toggle.value = m_Node.supportLodCrossFade.isOn;
                    toggle.OnToggleChanged(ChangeSupportLODCrossFade);
                });
            });

            Add(ps);
            Add(GetShaderGUIOverridePropertySheet());
        }
Пример #17
0
        /// <summary>
        /// This is the main procedure
        /// </summary>
        /// <param name="args">Command line parameters</param>
        /// <returns>Error codes (0 for success, non-zero on Error)</returns>
        private int main(IEnumerable<string> args)
        {
            var options = args.Where(each => each.StartsWith("--")).Switches();
            var parameters = args.Parameters().ToArray();

            var buildinfo = string.Empty;

            Console.CancelKeyPress += (x, y) => {
                Console.WriteLine("Stopping ptk.");
                if (_cmdexe != null)
                    _cmdexe.Kill();
                if (_gitexe != null)
                    _gitexe.Kill();
                if (_hgexe != null)
                    _hgexe.Kill();
                if (_ptk != null)
                    _ptk.Kill();
            //                if (_traceexe != null) {
              //                  _traceexe.Kill();
            //            }
            };

            #region Parse Options

            // set up options which were defined by the user
            foreach (string arg in options.Keys) {
                IEnumerable<string> argumentParameters = options[arg];

                switch (arg) {
                    case "nologo":
                        // disable logo (will print "\n" anyway)
                        this.Assembly().SetLogo("");
                        break;

                    case "verbose":
                        _verbose = true;
                        break;

                    case "skip-built":
                        _skipBuilt = true;
                        _originalEnvironment.AddOrSet("skip-built", "true");
                        break;

                    case "load":
                        // user specified a custom PropertySheet
                        buildinfo = argumentParameters.LastOrDefault().GetFullPath();
                        if (!File.Exists(buildinfo)) {
                            return Fail("Unable to find buildinfo file [{0}]. \r\n\r\n    Use --help for command line help.", buildinfo);
                        }

                        break;

                    case "mingw-install":
                    case "msys-install":
                        _searchPaths += argumentParameters.LastOrDefault().GetFullPath() + ";";
                        break;

                    case "rescan-tools":
                        ProgramFinder.IgnoreCache = true;
                        break;

                    case "show-tools":
                        _showTools = true;
                        break;

                    case "help":
                        return Help();

                    default:
                        var p = argumentParameters.LastOrDefault();
                        if (string.IsNullOrEmpty(p)) {
                            if( _originalEnvironment.ContainsKey(arg) ) {
                                _originalEnvironment.Remove(arg);
                            }
                        } else{
                            _originalEnvironment.AddOrSet(arg, p);
                        }
                        break;
                }
            }

            // _originalEnvironment.Add("COAPP", CoApp.Toolkit.Engine.PackageManagerSettings.CoAppRootDirectory);
            _originalEnvironment.AddOrSet("COAPP", "C:/programdata/");

            while (string.IsNullOrEmpty(buildinfo) || !File.Exists(buildinfo)) {
                // if the user didn't pass in the file, walk up the tree to find the first directory that has a COPKG\.buildinfo file
                buildinfo = (from a in @".\COPKG\".DirectoryEnumerateFilesSmarter("*.buildinfo", SearchOption.TopDirectoryOnly)
                                     orderby a.Length ascending
                                     select a.GetFullPath()).FirstOrDefault() ?? @".\COPKG\.buildinfo".GetFullPath();

                // try the parent directory.
                var p = Path.GetDirectoryName(Environment.CurrentDirectory);
                if (string.IsNullOrEmpty(p)) {
                    return Fail("Unable to find buildinfo file [COPKG\\.buildinfo]--Even walking up the current tree.\r\n\r\n    Use --help for command line help.");
                }
                Environment.CurrentDirectory = p;
            }

            // make sure that we're in the parent directory of the .buildinfo file.
            Environment.CurrentDirectory = Path.GetDirectoryName(Path.GetDirectoryName(buildinfo));

            sessionFeeds = new[] {Environment.CurrentDirectory, Path.GetDirectoryName(buildinfo)};

            // tell the user what we are
            Logo();

            #endregion

            // connect to coapp service

            // set up several tools we need
            _cmdexe = new ProcessUtility("cmd.exe");
            //var f = new ProgramFinder("").ScanForFile("trace.exe");

            //if(!string.IsNullOrEmpty(f)) {
                //_traceexe = new ProcessUtility(new ProgramFinder("").ScanForFile("trace.exe"));
            //}

            _ptk = new ProcessUtility(Assembly.GetEntryAssembly().Location);
            // if this package is tracked by git, we can use git
            _useGit = Directory.Exists(".git".GetFullPath());            // if this package is tracked by mercurial, we can use mercurial
            _useHg = _useGit ? false : Directory.Exists(".hg".GetFullPath());

            // source control is mandatory! create a repository for this package
            if (!(_useGit || _useHg) && _verbose) {
                Console.WriteLine("WARNING: Source should be checked out using git or hg-git.");
            }

            // find git in the file system
            // - we prefer the CMD script over git.exe
            // git.exe may be located at "C:\Program Files\Git\bin"
            // git.cmd may be located at "C:\Program Files\Git\cmd"
            if (_useGit) {
                if (_verbose) {
                    Console.WriteLine("Using git for verification");
                }
                // attemt to find git.cmd
                _gitcmd = ProgramFinder.ProgramFilesAndDotNet.ScanForFile("git.cmd");
                _gitexe = null;
                if (string.IsNullOrEmpty(_gitcmd)) {
                    var f = ProgramFinder.ProgramFilesAndDotNet.ScanForFile("git.exe");
                    if (string.IsNullOrEmpty(f)) {
                        return Fail("Can not find git.cmd or git.exe (required to perform verification.)");
                    }
                    _gitexe = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("git.exe"));
                }
            }

            if (_useHg) {
                var f = ProgramFinder.ProgramFilesAndDotNet.ScanForFile("hg.exe");
                if (string.IsNullOrEmpty(f)) {
                    return Fail("Can not find hg.exe (required to perform verification.)");
                }
                _hgexe = new ProcessUtility(f);
            }

            // find sdk batch files.

            /* FIXME: URGENT.
             * C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat
                C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin\vcvars32.bat
                C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin\amd64\vcvarsamd64.bat
                C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin\x86_amd64\vcvarsx86_amd64.bat
             * VC7.0: C:\Program Files\Microsoft Visual Studio .NET\Vc7\bin\vcvars32.bat

             * */

            _setenvcmd71 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("setenv.cmd", excludeFilters: new[] { @"\Windows Azure SDK\**" , "winddk**" }, includeFilters: new [] {"sdk**", "v7.1**"}, rememberMissingFile:true, tagWithCosmeticVersion:"7.1");
            _setenvcmd7 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("setenv.cmd", excludeFilters: new[] { @"\Windows Azure SDK\**", "7.1**", "winddk**" }, includeFilters: new[] { "sdk**", "v7**" }, rememberMissingFile: true, tagWithCosmeticVersion: "7.0");
            _setenvcmd6 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("setenv.cmd", excludeFilters: new[] { @"\Windows Azure SDK\**", "winddk**" }, includeFilters: new[] { "sdk**", "6**" }, rememberMissingFile: true, tagWithCosmeticVersion: "6");

            _wdksetenvcmd7600 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("setenv.bat", excludeFilters: new[] { @"\Windows Azure SDK\**"}, includeFilters: new[] { "winddk**"  }, rememberMissingFile: true, tagWithCosmeticVersion: "7600.16385.1");

            /// SDK Setenv (sdk2003): c:\program files (x86)\Microsoft SDK\SetEnv.bat

            _vcvarsallbat10 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("vcvarsall.bat", includeFilters: new[] { "vc**", "10.0**" }, rememberMissingFile: true, tagWithCosmeticVersion: "10.0");
            _vcvarsallbat9 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("vcvarsall.bat", includeFilters: new[] { "vc**", "9.0**" }, rememberMissingFile: true, tagWithCosmeticVersion: "9.0");
            _vcvarsallbat8 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("vcvarsall.bat", includeFilters: new[] { "vc**", "8**" }, rememberMissingFile: true, tagWithCosmeticVersion: "8");
            _vcvarsallbat7 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("vcvarsall.bat", includeFilters: new[] { "vc**", "7.0**" }, rememberMissingFile: true, tagWithCosmeticVersion: "7.0");
            _vcvarsallbat71 = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("vcvarsall.bat", includeFilters: new[] { "vc**", "7.1**" }, rememberMissingFile: true, tagWithCosmeticVersion: "7.1");
            _vcvars32bat = ProgramFinder.ProgramFilesAndDotNetAndSdk.ScanForFile("vcvars32.bat", includeFilters: new[] { "vc98**" }, rememberMissingFile: true, tagWithCosmeticVersion: "6");

            // _originalEnvironment.AddOrSet("COAPP", "C:/programdata/");
            var sdks = new List<string>();
            if (_setenvcmd71 != null) {
                sdks.Add("sdk7.1");
            }
            if (_setenvcmd7 != null) {
                sdks.Add("sdk7");
            }
            if (_setenvcmd6 != null) {
                sdks.Add("sdk6");
            }

            _originalEnvironment.AddOrSet("installed_sdks", sdks.Aggregate((s, s1) => s + ", " + s1));

            var compilers = new List<string>();

            if( _vcvarsallbat10 != null ) {
                compilers.Add("vc10");
            }
            if( _vcvarsallbat9 != null ) {
                compilers.Add("vc9");
            }
            if( _vcvarsallbat8 != null ) {
                compilers.Add("vc8");
            }
            if( _vcvarsallbat71 != null ) {
                compilers.Add("vc7.1");
            }
            if( _vcvarsallbat7 != null ) {
                compilers.Add("vc7");
            }
            if( _vcvars32bat != null ) {
                compilers.Add("vc6");
            }

            _originalEnvironment.AddOrSet("installed_compilers", sdks.Aggregate((s, s1) => s + ", " + s1));

            if (_showTools) {
                if (_useGit) {
                    Console.WriteLine("Git: {0}", _gitcmd ??  (_gitexe != null ? _gitexe.Executable : "Not-Found"));
                }
                if (_useHg) {
                    Console.WriteLine("hg: {0}", _hgexe.Executable);
                }
                Console.WriteLine("SDK Setenv (7.1): {0}", _setenvcmd71 ?? "Not-Found");
                Console.WriteLine("SDK Setenv (7.0): {0}", _setenvcmd7 ?? "Not-Found");
                Console.WriteLine("SDK Setenv (6): {0}", _setenvcmd6 ?? "Not-Found");

                Console.WriteLine("VC vcvarsall (10.0): {0}", _vcvarsallbat10 ?? "Not-Found");
                Console.WriteLine("VC vcvarsall (9.0): {0}", _vcvarsallbat9 ?? "Not-Found");
                Console.WriteLine("VC vcvarsall (8.0): {0}", _vcvarsallbat8 ?? "Not-Found");
                Console.WriteLine("VC vcvarsall (7.0): {0}", _vcvarsallbat7 ?? "Not-Found");
                Console.WriteLine("VC vcvarsall (7.1): {0}", _vcvarsallbat71 ?? "Not-Found");
                Console.WriteLine("VC vcvars32 (6): {0}", _vcvars32bat ?? "Not-Found");

                Console.WriteLine("ptk: {0}", _ptk.Executable);
                //Console.WriteLine("trace: {0}", _traceexe.Executable);
            }

            // tell the user we can't work without instructions
            if (!parameters.Any()) {
                return Fail("Missing action . \r\n\r\n    Use --help for command line help.");
            }

            // load property sheet (that is the .buildinfo file by default)
            _propertySheet = null;
            try {
                // load and parse. propertySheet will contain everything else we need for later
                _propertySheet = PropertySheet.Load(buildinfo);

                DefineRules = _propertySheet.Rules.Where(each => each.Id == "define" && each.Name == "*").ToArray();

                _propertySheet.GetMacroValue += (valueName) => {
                    if (valueName == "DEFAULTLAMBDAVALUE") {
                        return ".";
                    }

                    string defaultValue = null;
                    if( valueName.Contains("??")) {
                        var parts = valueName.Split(new[] {'?'}, StringSplitOptions.RemoveEmptyEntries);
                        defaultValue = parts.Length > 1 ? parts[1].Trim() : string.Empty;
                        valueName = parts[0];
                    }

                     var property = (from rule in DefineRules where rule.HasProperty(valueName) select rule[valueName]).FirstOrDefault();

                     if (property != null && property.HasValues && property.Values.Count() > 1) {
                         // it's a collection of values.
                         // let's take the collection and return it as a comma seperated string.
                         return property.Values.Aggregate((s, s1) => s + ", " + s1);
                     }

                    return (from rule in DefineRules where rule.HasProperty(valueName) select rule[valueName].Value).FirstOrDefault() ?? Environment.GetEnvironmentVariable(valueName) ?? defaultValue;
                };

                _propertySheet.GetCollection += (collectionName) => {
                    var property = (from rule in DefineRules where rule.HasProperty(collectionName) select rule[collectionName]).FirstOrDefault();
                    if( property != null && property.HasValues && property.Values.Count() > 1 ) {
                        return property.Values;
                    }
                    var collection = _propertySheet.GetMacroValue(collectionName);
                    return collection != null ? collection.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(each => each.Trim()) : Enumerable.Empty<object>();
                };
            }
            catch (EndUserParseException pspe) {
                using (new ConsoleColors(ConsoleColor.Yellow, ConsoleColor.Black)) {
                    Console.Write(pspe.Message);
                    Console.WriteLine("--found '{0}'", pspe.Token.Data);
                }

                return Fail("Error parsing .buildinfo file");
            }

            var builds = from rule in _propertySheet.Rules where rule.Name != "*" && (rule.HasProperty("default") && rule["default"].Value.IsTrue()) select rule;
            var command = string.Empty;

            switch(parameters.FirstOrDefault().ToLower()) {
                case "build ":
                case "clean":
                case "verify":
                case "status":
                case "trace":
                case "list":
                    command = parameters.FirstOrDefault().ToLower();
                    parameters = parameters.Skip(1).ToArray();
                    break;

                default:
                    command = "build";
                    break;
            }
            if (parameters.Any()) {
                var allbuilds = from rule in _propertySheet.Rules where rule.Name != "*" select rule;
                builds = parameters.Aggregate(Enumerable.Empty<Rule>(), (current, p) => current.Union(from build in allbuilds where build.Name.NewIsWildcardMatch(p) select build));
            }

            // are there even builds present?
            if(!builds.Any() ) {
                return Fail("No valid build configurations selected.");
            }

            // do the user's bidding
            try {
                switch (command) {
                    case "build":
                        ResetEnvironment();
                        Build(builds);

                        break;
                    case "clean":
                        ResetEnvironment();
                        Clean(builds);
                        using (new ConsoleColors(ConsoleColor.White, ConsoleColor.Black)) {
                            Console.WriteLine("Project Cleaned.");
                        }
                        break;
                    case "verify":
                        ResetEnvironment();
                        // Clean(builds); // clean up other builds in the list first.
                        Verify(builds);
                        using (new ConsoleColors(ConsoleColor.White, ConsoleColor.Black)) {
                            Console.WriteLine("Project Verified.");
                        }
                        break;
                    case "status":
                        ResetEnvironment();
                        Status(builds);
                        using (new ConsoleColors(ConsoleColor.White, ConsoleColor.Black)) {
                            Console.WriteLine("Project is in clean state.");
                        }
                        break;
                    //case "trace":
                      //  Trace(builds);
                        //break;
                    case "list":
                        Console.WriteLine("Buildinfo from [{0}]\r\n", buildinfo);
                        (from build in builds
                            let compiler = build["compiler"]
                            let sdk = build["sdk"]
                            let platform = build["platform"]
                            let targets = build["targets"]
                            select new {
                                Configuration = build.Name,
                                Compiler = compiler != null ? compiler.Value : "sdk7.1",
                                Sdk = sdk != null ? sdk.Value : "sdk7.1",
                                Platform = platform != null ? platform.Value.NormalizePlatform() : "x86",
                                Number_of_Outputs = targets != null ? targets.Values.Count() : 0
                            }).ToTable().ConsoleOut();
                        break;
                    default:
                        return Fail("'{0}' is not a valid command. \r\n\r\n    Use --help for assistance.", command);
                }
            }
            catch (ConsoleException e) {
                // these exceptions are expected
                return Fail("   {0}", e.Message);
            }
            catch (Exception e) {
                // it's probably okay to crash within proper commands (because something else crashed)
                Console.WriteLine(e.StackTrace);
                return Fail("   {0}", e.Message);
            }

            return 0;
        }
Пример #18
0
 public virtual void newProperties(PropertySheet ps)
 {
     this.linguist = (Linguist)ps.getComponent("linguist");
 }