示例#1
0
        public void Configure(GStylizedTerrain terrain, int prototypeIndex, MaterialPropertyBlock propertyBlock)
        {
            GGrassPrototype proto = terrain.TerrainData.Foliage.Grasses.Prototypes[prototypeIndex];

            propertyBlock.SetTexture(NOISE_TEX, GRuntimeSettings.Instance.foliageRendering.windNoiseTexture);

            IEnumerator <GWindZone> windZone = GWindZone.ActiveWindZones.GetEnumerator();

            if (windZone.MoveNext())
            {
                GWindZone w = windZone.Current;
                propertyBlock.SetVector(WIND, w.GetWindParams());
            }

            propertyBlock.SetColor(COLOR, proto.Color);
            if (proto.Shape != GGrassShape.DetailObject && proto.Texture != null)
            {
                propertyBlock.SetTexture(MAIN_TEX, proto.Texture);
            }
            propertyBlock.SetFloat(BEND_FACTOR, proto.BendFactor);

            if (terrain.TerrainData.Foliage.EnableInteractiveGrass)
            {
                propertyBlock.SetTexture(VECTOR_FIELD, terrain.GetGrassVectorFieldRenderTexture());
                propertyBlock.SetMatrix(WORLD_TO_NORMALIZED, terrain.GetWorldToNormalizedMatrix());
            }

            float fadeMaxDistance = terrain.TerrainData.Rendering.GrassDistance;
            float fadeMinDistance = Mathf.Clamp(terrain.TerrainData.Rendering.GrassFadeStart, 0f, 0.99f) * fadeMaxDistance;

            propertyBlock.SetFloat(FADE_MIN_DISTANCE, fadeMinDistance);
            propertyBlock.SetFloat(FADE_MAX_DISTANCE, fadeMaxDistance);
        }
        public static GWindZone CreateWindZone()
        {
            GameObject g = new GameObject("Wind Zone");

            g.transform.position   = Vector3.zero;
            g.transform.rotation   = Quaternion.identity;
            g.transform.localScale = Vector3.one;

            GWindZone wind = g.AddComponent <GWindZone>();

            return(wind);
        }
示例#3
0
        private static void DrawUtilitiesGUI()
        {
            string label = "8. Utilities";
            string id    = "wizard-utilities";

            GEditorCommon.Foldout(label, false, id, () =>
            {
                GEditorCommon.Header("Wind Zone");
                EditorGUILayout.LabelField("Adding Wind Zone to customize how grass react to wind in this level.");
                if (GUILayout.Button("Create Wind Zone"))
                {
                    GWindZone wind = GWizard.CreateWindZone();
                    EditorGUIUtility.PingObject(wind.gameObject);
                    Selection.activeGameObject = wind.gameObject;
                }
            });
        }