public void OnEnable() {
		RTP_LODmanager _target=(RTP_LODmanager)target;
		temp_globalSettingsHolder=null; // pomocnicza referencja (w przypadku gdy manipulowano przy U4 materials i nie zatwierdzono zmian poprzez kompilacje)

		if (!_target.dont_sync) SyncFeatures();
		_target.dont_sync=false;
	}
	public void OnDisable() {
		if (temp_globalSettingsHolder!=null) {
			temp_globalSettingsHolder.useTerrainMaterial=temp_useTerrainMaterial;
			temp_globalSettingsHolder=null;
		}

		SyncFeatures();
	}
示例#3
0
    public void ApplyTerrainSettings(int val = -1)
    {
        Terrain activeTerrain = Terrain.activeTerrain;
        int     num           = (val == -1) ? QualitySettings.GetQualityLevel() : val;

        if (activeTerrain)
        {
            activeTerrain.heightmapPixelError = CJTools.Math.GetProportionalClamp(70f, 20f, (float)num, 0f, 4f);
            if (num == 0)
            {
                activeTerrain.basemapDistance = 0f;
            }
            else
            {
                activeTerrain.basemapDistance = CJTools.Math.GetProportionalClamp(10f, 25f, (float)num, 1f, 4f);
            }
            activeTerrain.castShadows = false;
            ReliefTerrain component = activeTerrain.gameObject.GetComponent <ReliefTerrain>();
            ReliefTerrainGlobalSettingsHolder reliefTerrainGlobalSettingsHolder = (component != null) ? component.globalSettingsHolder : null;
            if (reliefTerrainGlobalSettingsHolder != null)
            {
                reliefTerrainGlobalSettingsHolder.DIST_STEPS          = CJTools.Math.GetProportionalClamp(4f, 25f, (float)num, 0f, 4f);
                reliefTerrainGlobalSettingsHolder.WAVELENGTH          = CJTools.Math.GetProportionalClamp(16f, 2.5f, (float)num, 0f, 4f);
                reliefTerrainGlobalSettingsHolder.SHADOW_STEPS        = CJTools.Math.GetProportionalClamp(0f, 25f, (float)num, 0f, 4f);
                reliefTerrainGlobalSettingsHolder.WAVELENGTH_SHADOWS  = CJTools.Math.GetProportionalClamp(16f, 0.5f, (float)num, 0f, 4f);
                reliefTerrainGlobalSettingsHolder.distance_start      = CJTools.Math.GetProportionalClamp(5f, 15f, (float)num, 0f, 4f);
                reliefTerrainGlobalSettingsHolder.distance_transition = CJTools.Math.GetProportionalClamp(5f, 10f, (float)num, 0f, 4f);
                if (reliefTerrainGlobalSettingsHolder.distance_start_bumpglobal < reliefTerrainGlobalSettingsHolder.distance_start)
                {
                    reliefTerrainGlobalSettingsHolder.distance_start_bumpglobal = reliefTerrainGlobalSettingsHolder.distance_start;
                }
                RTP_LODmanager rtp_LODmanagerScript = reliefTerrainGlobalSettingsHolder.Get_RTP_LODmanagerScript();
                if (rtp_LODmanagerScript)
                {
                    TerrainShaderLod rtp_LODlevel = rtp_LODmanagerScript.RTP_LODlevel;
                    if (num == 0)
                    {
                        rtp_LODmanagerScript.RTP_LODlevel = TerrainShaderLod.SIMPLE;
                    }
                    else if (num == 1)
                    {
                        rtp_LODmanagerScript.RTP_LODlevel = TerrainShaderLod.PM;
                    }
                    else
                    {
                        rtp_LODmanagerScript.RTP_LODlevel = TerrainShaderLod.POM;
                    }
                    if (rtp_LODlevel != rtp_LODmanagerScript.RTP_LODlevel)
                    {
                        rtp_LODmanagerScript.RefreshLODlevel();
                    }
                }
                reliefTerrainGlobalSettingsHolder.RefreshAll();
            }
        }
    }
示例#4
0
    private void Finish()
    {
#if RTP
        if (prefs.generateTextures)
        {
            ReliefTerrain reliefTerrain = prefs.terrains[0].GetComponent <ReliefTerrain>();
            ReliefTerrainGlobalSettingsHolder settingsHolder = reliefTerrain.globalSettingsHolder;

            settingsHolder.numLayers = 4;
            settingsHolder.splats    = new Texture2D[4];
            settingsHolder.Bumps     = new Texture2D[4];
            settingsHolder.Heights   = new Texture2D[4];

            for (int i = 0; i < 4; i++)
            {
                settingsHolder.splats[i]  = rtpTextures[i * 3];
                settingsHolder.Heights[i] = rtpTextures[i * 3 + 1];
                settingsHolder.Bumps[i]   = rtpTextures[i * 3 + 2];
            }

            settingsHolder.GlobalColorMapBlendValues   = new Vector3(1, 1, 1);
            settingsHolder._GlobalColorMapNearMIP      = 1;
            settingsHolder.GlobalColorMapSaturation    = 1;
            settingsHolder.GlobalColorMapSaturationFar = 1;
            settingsHolder.GlobalColorMapBrightness    = 1;
            settingsHolder.GlobalColorMapBrightnessFar = 1;

            foreach (Terrain item in prefs.terrains)
            {
                item.GetComponent <ReliefTerrain>().RefreshTextures();
            }

            settingsHolder.Refresh();
        }
#endif

        if (prefs.adjustMeshSize)
        {
            float w = originalBoundsRange.x;
            float h = originalBoundsRange.z;

            float sW = w / prefs.newTerrainCountX;
            float sH = h / prefs.newTerrainCountY;
            float sY = originalBoundsRange.y * 1.5f;

            float tsw = sW;
            float tsh = sH;

            if (prefs.textureCaptureMode == MeshToTerrainTextureCaptureMode.camera)
            {
                tsw = tsw / prefs.textureResolution * (prefs.textureResolution + 4);
                tsh = tsh / prefs.textureResolution * (prefs.textureResolution + 4);
            }
            else
            {
                tsw = tsw / prefs.textureWidth * (prefs.textureWidth + 2);
                tsh = tsh / prefs.textureHeight * (prefs.textureHeight + 2);
            }

            float offX = (w - sW * prefs.newTerrainCountX) / 2;
            float offY = (h - sH * prefs.newTerrainCountY) / 2;

            for (int x = 0; x < prefs.newTerrainCountX; x++)
            {
                for (int y = 0; y < prefs.newTerrainCountY; y++)
                {
                    Terrain t = prefs.terrains[y * prefs.newTerrainCountX + x];
                    t.transform.localPosition = new Vector3(x * sW + offX, 0, y * sH + offY);
                    t.terrainData.size        = new Vector3(sW, sY, sH);

#if !RTP
                    if (prefs.generateTextures)
                    {
#if UNITY_2018_3_OR_NEWER
                        TerrainLayer[] terrainLayers = t.terrainData.terrainLayers;
                        TerrainLayer   item          = terrainLayers[0];
#else
                        SplatPrototype[] splatPrototypes = t.terrainData.splatPrototypes;
                        SplatPrototype   item            = splatPrototypes[0];
#endif

                        item.tileSize = new Vector2(tsw, tsh);

                        if (prefs.textureCaptureMode == MeshToTerrainTextureCaptureMode.camera)
                        {
                            item.tileOffset = new Vector2(t.terrainData.size.x / prefs.textureResolution / 1.5f, t.terrainData.size.z / prefs.textureResolution / 1.5f);
                        }
                        else
                        {
                            item.tileOffset = new Vector2(t.terrainData.size.x / prefs.textureWidth / 1.5f, t.terrainData.size.z / prefs.textureHeight / 1.5f);
                        }

#if UNITY_2018_3_OR_NEWER
                        t.terrainData.terrainLayers = terrainLayers;
#else
                        t.terrainData.splatPrototypes = splatPrototypes;
#endif
                    }
#endif
                }
            }
        }

        if (prefs.terrainType == MeshToTerrainSelectTerrainType.newTerrains)
        {
            EditorGUIUtility.PingObject(container);
        }
        else
        {
            foreach (Terrain t in prefs.terrains)
            {
                EditorGUIUtility.PingObject(t.gameObject);
            }
        }

        Dispose();

        phase = MeshToTerrainPhase.idle;
    }
示例#5
0
    public void GetGlobalSettingsHolder()
    {
        #if UNITY_EDITOR
        if (globalSettingsHolder!=null) {
            // refresh num tiles in case we've just removed all except for this one
            bool IamTerrain=GetComponent(typeof(Terrain));
            if (IamTerrain) {
                ReliefTerrain[] script_objs=(ReliefTerrain[])GameObject.FindObjectsOfType(typeof(ReliefTerrain));
                globalSettingsHolder.numTiles=0;
                for(int p=0; p<script_objs.Length; p++) {
                    if (script_objs[p].globalSettingsHolder!=null) {
                        if (script_objs[p].globalSettingsHolder!=globalSettingsHolder) {
                            //Debug.Log("RTP assert - leaving one globalSettingsHolder...");
                            globalSettingsHolder=script_objs[p].globalSettingsHolder;
                        }
                        if (IamTerrain && script_objs[p].GetComponent(typeof(Terrain))!=null) {
                            globalSettingsHolder.numTiles++;
                        }
                    }
                }
                if (globalSettingsHolder.numTiles==1 || globalSettingsHolder.useTerrainMaterial) {
                    // we don't have to use texture redefinitions
                    GetSplatsFromGlobalSettingsHolder();
                }
            }
        }
        #endif
        if (globalSettingsHolder==null) {
            //Debug.Log("E"+name);
            ReliefTerrain[] script_objs=(ReliefTerrain[])GameObject.FindObjectsOfType(typeof(ReliefTerrain));
            bool IamTerrain=GetComponent(typeof(Terrain));
            for(int p=0; p<script_objs.Length; p++) {
                if (script_objs[p].globalSettingsHolder!=null && ((IamTerrain && script_objs[p].GetComponent(typeof(Terrain))!=null) || (!IamTerrain && script_objs[p].GetComponent(typeof(Terrain))==null))) {
                    //Debug.Log ("E2 "+script_objs[p].name);
                    globalSettingsHolder=script_objs[p].globalSettingsHolder;
                    if (globalSettingsHolder.Get_RTP_LODmanagerScript() && !globalSettingsHolder.Get_RTP_LODmanagerScript().RTP_WETNESS_FIRST && !globalSettingsHolder.Get_RTP_LODmanagerScript().RTP_WETNESS_ADD) {
                        BumpGlobalCombined=script_objs[p].BumpGlobalCombined;
                        globalCombinedModifed_flag=false;
                    }
                    break;
                }
            }
            if (globalSettingsHolder==null) {
                // there is no globalSettingsHolder object of my type (terrain/mesh) on the scene - I'm first object
                globalSettingsHolder=new ReliefTerrainGlobalSettingsHolder();

                if (IamTerrain) {
                    globalSettingsHolder.numTiles=0; // will be set to 1 with incrementation below
                    Terrain terrainComp = (Terrain)GetComponent(typeof(Terrain));
                    globalSettingsHolder.splats=new Texture2D[terrainComp.terrainData.splatPrototypes.Length];
                    for(int i=0; i<terrainComp.terrainData.splatPrototypes.Length; i++) {
                        globalSettingsHolder.splats[i]=terrainComp.terrainData.splatPrototypes[i].texture;
                    }
                } else {
                    globalSettingsHolder.splats=new Texture2D[4];
                }
                globalSettingsHolder.numLayers=globalSettingsHolder.splats.Length;
                globalSettingsHolder.ReturnToDefaults();
            } else {
                if (IamTerrain) {
                    GetSplatsFromGlobalSettingsHolder();
                }
            }

            source_controls_mask=new Texture2D[12];
            source_controls=new Texture2D[12];
            source_controls_channels=new ColorChannels[12];
            source_controls_mask_channels=new ColorChannels[12];

            splat_layer_seq=new int[12] {0,1,2,3,4,5,6,7,8,9,10,11};
            splat_layer_boost=new float[12] {1,1,1,1,1,1,1,1,1,1,1,1};
            splat_layer_calc=new bool[12];
            splat_layer_masked=new bool[12];
            source_controls_invert=new bool[12];
            source_controls_mask_invert=new bool[12];

            if (IamTerrain) globalSettingsHolder.numTiles++;
        }
    }
    public void SyncGlobalPropsAcrossTerrainGroups()
    {
        ReliefTerrain[] terrainObjects=(ReliefTerrain[])(GameObject.FindObjectsOfType(typeof(ReliefTerrain)));
        ReliefTerrainGlobalSettingsHolder[] globalHolders=new ReliefTerrainGlobalSettingsHolder[terrainObjects.Length];
        int numSeparateGroups=0;
        for(int i=0; i<terrainObjects.Length; i++) {
            bool alreadyPresent=false;
            for(int j=0; j<numSeparateGroups; j++) {
                if (globalHolders[j]==terrainObjects[i].globalSettingsHolder) {
                    alreadyPresent=true;
                    break;
                }
            }
            if (!alreadyPresent) {
                globalHolders[numSeparateGroups++] = terrainObjects[i].globalSettingsHolder;
            }
        }
        if (numSeparateGroups>1) {
            for(int i=0; i<numSeparateGroups; i++) {
                globalHolders[i].useTerrainMaterial=true;
            }
        }
        for(int i=0; i<numSeparateGroups; i++) {
            if (globalHolders[i]!=this) {
                globalHolders[i].trees_shadow_distance_start=trees_shadow_distance_start;
                globalHolders[i].trees_shadow_distance_transition=trees_shadow_distance_transition;
                globalHolders[i].trees_shadow_value=trees_shadow_value;
                globalHolders[i].global_normalMap_multiplier=global_normalMap_multiplier;

                globalHolders[i].trees_pixel_distance_start=trees_pixel_distance_start;
                globalHolders[i].trees_pixel_distance_transition=trees_pixel_distance_transition;
                globalHolders[i].trees_pixel_blend_val=trees_pixel_blend_val;
                globalHolders[i].global_normalMap_farUsage=global_normalMap_farUsage;

                globalHolders[i]._AmbientEmissiveMultiplier=_AmbientEmissiveMultiplier;
                globalHolders[i]._AmbientEmissiveRelief=_AmbientEmissiveRelief;

                globalHolders[i]._snow_strength=_snow_strength;
                globalHolders[i]._global_color_brightness_to_snow=_global_color_brightness_to_snow;
                globalHolders[i]._snow_slope_factor=_snow_slope_factor;
                globalHolders[i]._snow_edge_definition=_snow_edge_definition;
                globalHolders[i]._snow_height_treshold=_snow_height_treshold;
                globalHolders[i]._snow_height_transition=_snow_height_transition;
                globalHolders[i]._snow_color=_snow_color;
                globalHolders[i]._snow_specular=_snow_specular;
                globalHolders[i]._snow_gloss=_snow_gloss;
                globalHolders[i]._snow_reflectivness=_snow_reflectivness;
                globalHolders[i]._snow_deep_factor=_snow_deep_factor;
                globalHolders[i]._snow_fresnel=_snow_fresnel;
                globalHolders[i]._snow_diff_fresnel=_snow_diff_fresnel;

                globalHolders[i]._snow_IBL_DiffuseStrength=_snow_IBL_DiffuseStrength;
                globalHolders[i]._snow_IBL_SpecStrength=_snow_IBL_SpecStrength;

                globalHolders[i].TERRAIN_CausticsWaterLevel=TERRAIN_CausticsWaterLevel;
                globalHolders[i].TERRAIN_CausticsWaterLevelByAngle=TERRAIN_CausticsWaterLevelByAngle;
                globalHolders[i].TERRAIN_CausticsWaterDeepFadeLength=TERRAIN_CausticsWaterDeepFadeLength;
                globalHolders[i].TERRAIN_CausticsWaterShallowFadeLength=TERRAIN_CausticsWaterShallowFadeLength;

                globalHolders[i].TERRAIN_GlobalWetness=TERRAIN_GlobalWetness;
                globalHolders[i].TERRAIN_RainIntensity=TERRAIN_RainIntensity;

                globalHolders[i].rtp_customAmbientCorrection=rtp_customAmbientCorrection;

                globalHolders[i].TERRAIN_IBL_DiffAO_Damp=TERRAIN_IBL_DiffAO_Damp;
                globalHolders[i].TERRAIN_IBLRefl_SpecAO_Damp=TERRAIN_IBLRefl_SpecAO_Damp;

                globalHolders[i].RTP_LightDefVector=RTP_LightDefVector;
                globalHolders[i].RTP_LightDefVector=RTP_LightDefVector;
                globalHolders[i].RTP_ReflexLightDiffuseColor=RTP_ReflexLightDiffuseColor;
                globalHolders[i].RTP_ReflexLightDiffuseColor2=RTP_ReflexLightDiffuseColor2;
                globalHolders[i].RTP_ReflexLightSpecColor=RTP_ReflexLightSpecColor;
            }
        }
    }
示例#7
0
 public void GetGlobalSettingsHolder()
 {
     if (this.globalSettingsHolder == null)
     {
         ReliefTerrain[] array = (ReliefTerrain[])UnityEngine.Object.FindObjectsOfType(typeof(ReliefTerrain));
         bool            flag  = base.GetComponent(typeof(Terrain));
         for (int i = 0; i < array.Length; i++)
         {
             if (array[i].transform.parent == base.transform.parent && array[i].globalSettingsHolder != null && ((flag && array[i].GetComponent(typeof(Terrain)) != null) || (!flag && array[i].GetComponent(typeof(Terrain)) == null)))
             {
                 this.globalSettingsHolder = array[i].globalSettingsHolder;
                 if (this.globalSettingsHolder.Get_RTP_LODmanagerScript() && !this.globalSettingsHolder.Get_RTP_LODmanagerScript().RTP_WETNESS_FIRST&& !this.globalSettingsHolder.Get_RTP_LODmanagerScript().RTP_WETNESS_ADD)
                 {
                     this.BumpGlobalCombined         = array[i].BumpGlobalCombined;
                     this.globalCombinedModifed_flag = false;
                 }
                 break;
             }
         }
         if (this.globalSettingsHolder == null)
         {
             this.globalSettingsHolder = new ReliefTerrainGlobalSettingsHolder();
             if (flag)
             {
                 this.globalSettingsHolder.numTiles = 0;
                 Terrain terrain = (Terrain)base.GetComponent(typeof(Terrain));
                 this.globalSettingsHolder.splats = new Texture2D[terrain.terrainData.splatPrototypes.Length];
                 for (int j = 0; j < terrain.terrainData.splatPrototypes.Length; j++)
                 {
                     this.globalSettingsHolder.splats[j] = terrain.terrainData.splatPrototypes[j].texture;
                 }
             }
             else
             {
                 this.globalSettingsHolder.splats = new Texture2D[4];
             }
             this.globalSettingsHolder.numLayers = this.globalSettingsHolder.splats.Length;
             this.globalSettingsHolder.ReturnToDefaults(string.Empty, -1);
         }
         else if (flag)
         {
             this.GetSplatsFromGlobalSettingsHolder();
         }
         this.source_controls_mask          = new Texture2D[12];
         this.source_controls               = new Texture2D[12];
         this.source_controls_channels      = new RTPColorChannels[12];
         this.source_controls_mask_channels = new RTPColorChannels[12];
         this.splat_layer_seq               = new int[]
         {
             0,
             1,
             2,
             3,
             4,
             5,
             6,
             7,
             8,
             9,
             10,
             11
         };
         this.splat_layer_boost = new float[]
         {
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f
         };
         this.splat_layer_calc            = new bool[12];
         this.splat_layer_masked          = new bool[12];
         this.source_controls_invert      = new bool[12];
         this.source_controls_mask_invert = new bool[12];
         if (flag)
         {
             this.globalSettingsHolder.numTiles++;
         }
     }
 }
	public override void OnInspectorGUI () {
		RTP_LODmanager _target=(RTP_LODmanager)target;
		Color skin_color=GUI.color;
		
		int samplers_left;
		int samplers_used;
		
		if (!_target.SHADER_USAGE_FirstPass && !_target.SHADER_USAGE_Terrain2Geometry) {
			EditorGUILayout.HelpBox("You don't use terrain RTP shaders nor mesh versions. Check shaders needed below and recompile them using choosen features.", MessageType.Error, true);
		} else {
			EditorGUILayout.BeginVertical("Box");
			EditorGUILayout.HelpBox("LOD level can be adjusted realtime by setting RTP_LODlevel to one of the following enums:\n\n1. TerrainShaderLod.POM\n2. TerrainShaderLod.PM\n3. TerrainShaderLod.SIMPLE\n4. TerrainShaderLod.CLASSIC\n\nwith shadow flags like below and calling function RefreshLODlevel() on manager script (refer to file \"RTP_LODmanager.cs\").\n\nREMEMBER - actual shader LOD level is influenced by MaxLOD param available per pass.",MessageType.Warning, true);
			GUI.color=new Color(1,1,0.5f,1);
			EditorGUILayout.LabelField("LOD level", EditorStyles.boldLabel);
			GUI.color=skin_color;		
			
			_target.RTP_LODlevel=(TerrainShaderLod)EditorGUILayout.EnumPopup(_target.RTP_LODlevel);
			
			EditorGUI.BeginDisabledGroup( _target.RTP_LODlevel!=TerrainShaderLod.POM );
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("RTP_SHADOWS", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
				if ( _target.RTP_LODlevel!=TerrainShaderLod.POM ) {
					EditorGUILayout.Toggle(false);
				} else {
					_target.RTP_SHADOWS=EditorGUILayout.Toggle(_target.RTP_SHADOWS);
				}
			EditorGUILayout.EndHorizontal();
			EditorGUI.BeginDisabledGroup(!_target.RTP_SHADOWS);
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("RTP_SOFT_SHADOWS", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
				if ( _target.RTP_LODlevel!=TerrainShaderLod.POM || !_target.RTP_SHADOWS) {
					EditorGUILayout.Toggle(false);
				} else {
					_target.RTP_SOFT_SHADOWS=EditorGUILayout.Toggle(_target.RTP_SOFT_SHADOWS);
				}		
			EditorGUILayout.EndHorizontal();
			EditorGUI.EndDisabledGroup();
			EditorGUI.EndDisabledGroup();
			
			if (GUILayout.Button("Refresh LOD level")) {
				_target.RefreshLODlevel();
				EditorUtility.SetDirty(_target);
			}
			
			EditorGUILayout.Space();
			EditorGUILayout.Space();
			EditorGUILayout.EndVertical();
		}
		
		EditorGUILayout.BeginVertical("Box");
		EditorGUILayout.HelpBox("Tweaking features below you will need shaders RECOMPILATION (may take a few minutes)  to see changes.\n\nHint: you can build shaders for choosen platforms only (i.e. only d3d9 when you're working on PC - this will compile much faster, remember to enable rest of platforms when releasing).",MessageType.Info, true);
		
		GUI.color=new Color(1,1,0.5f,1); 
		EditorGUILayout.LabelField("Used shaders", EditorStyles.boldLabel);
		GUI.color=skin_color;		
		
		ReliefTerrain[] rts=(ReliefTerrain[])GameObject.FindObjectsOfType(typeof(ReliefTerrain));
		ReliefTerrain rt=null;
#if !UNITY_3_5
		ReliefTerrainGlobalSettingsHolder holder=null;
		int numHolders=0;
		for(int i=0; i<rts.Length; i++) {
			if (rts[i].GetComponent(typeof(Terrain))) {
				if (rts[i].globalSettingsHolder!=holder) {
					if (rts[i].globalSettingsHolder!=null) rt=rts[i];
					holder=rts[i].globalSettingsHolder;
					numHolders++;
				}
			}
		}
		if (numHolders>1) {
			for(int i=0; i<rts.Length; i++) {
				if (rts[i].GetComponent(typeof(Terrain))) {
					if (rts[i].globalSettingsHolder!=null) {
						rts[i].globalSettingsHolder.useTerrainMaterial=true;
					}
				}
			}
		}


		if (!_forceMaterials) {
		if (rt!=null) {
			EditorGUILayout.HelpBox("Unity4 allow to use material on terrain, but this can get insanely slow (CPU&GPU) for many terrain objects present. Consider using this if you've got less than 9 terrain tiles ONLY. For 1-4 tiles it's OK and can benefit from additional GPU optimization.", MessageType.Warning, true);
			if (rt.globalSettingsHolder.useTerrainMaterial) {
				EditorGUILayout.HelpBox("When materials are used, you can fix refreshing issue here (black/broken terrain shading when saving scene or alt-tabbing). Beware - fixing the issue means _increased_ _CPU_ _load_ ! So remember to uncheck this+recompile shaders when making final build of your project !", MessageType.Warning, true);
			}
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("Use U4 terrain materials", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
				EditorGUI.BeginDisabledGroup(numHolders>1);
					if (rt!=null && rt.globalSettingsHolder!=null) {
						bool nval=EditorGUILayout.Toggle((numHolders>1) || rt.globalSettingsHolder.useTerrainMaterial);
						if (nval!=rt.globalSettingsHolder.useTerrainMaterial) {
							if (rt.globalSettingsHolder.useTerrainMaterial==false && nval==true && _target.FIX_REFRESHING_ISSUE==false) {
								EditorUtility.DisplayDialog("RTP Notification", "You've choosed to use materials. Option to fix refreshing issue has been also turned on (recompile shaders to take effect). It's for making your life easier when working in editor.\n\nBUT remember to _turn off_ fix checkbox+compile shaders before you make a build to not stress CPU unnecesarilly.","OK");
								_target.FIX_REFRESHING_ISSUE=true;
							}
							temp_useTerrainMaterial=rt.globalSettingsHolder.useTerrainMaterial;
							temp_globalSettingsHolder=rt.globalSettingsHolder;

							rt.globalSettingsHolder.useTerrainMaterial=nval;
						}
					}
				EditorGUI.EndDisabledGroup();
				if (rt.globalSettingsHolder.useTerrainMaterial) {
					EditorGUILayout.LabelField("Fix refreshing issue", GUILayout.MinWidth(120), GUILayout.MaxWidth(120));
					_target.FIX_REFRESHING_ISSUE=EditorGUILayout.Toggle(_target.FIX_REFRESHING_ISSUE);
				} else {
					// comment out all props in non material mode (to not overwrite global props by material props)
					_target.FIX_REFRESHING_ISSUE=false;
				}
			EditorGUILayout.EndHorizontal();
		} else {
			// RTP on mesh, so rt hasn't been defined above
		}
		GUILayout.Space(15);
		}


		for(int i=0; i<rts.Length; i++) {
			if (rts[i].GetComponent(typeof(Terrain))) {
				rt=rts[i];
				break;
			}
		}
		if (rt && (rt.globalSettingsHolder!=null) && rt.globalSettingsHolder.numTiles>1 && !rt.globalSettingsHolder.useTerrainMaterial) {
#else
		for(int i=0; i<rts.Length; i++) {
			if (rts[i].GetComponent(typeof(Terrain))) {
				rt=rts[i];
				break;
			}
		}				
		if (rt && (rt.globalSettingsHolder!=null) && rt.globalSettingsHolder.numTiles>1) {
#endif		
			bool prev_RTP_4LAYERS_MODE=_target.RTP_4LAYERS_MODE;
			_target.RTP_4LAYERS_MODE=true;
			if (prev_RTP_4LAYERS_MODE!=_target.RTP_4LAYERS_MODE) {
				CheckAddPassPresent();
			}
		}
		
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("RTP on terrain - first pass", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.SHADER_USAGE_FirstPass=EditorGUILayout.Toggle(_target.SHADER_USAGE_FirstPass);
			if (!_target.SHADER_USAGE_FirstPass) _target.SHADER_USAGE_AddPass=false;
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("RTP on terrain - add pass", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.SHADER_USAGE_AddPass=EditorGUILayout.Toggle(_target.SHADER_USAGE_AddPass);
		EditorGUILayout.EndHorizontal();
#if !UNITY_3_5
		EditorGUILayout.BeginHorizontal();
			if (rt!=null && rt.globalSettingsHolder!=null) {
				EditorGUI.BeginDisabledGroup(!(_target.SHADER_USAGE_FirstPass && rt.globalSettingsHolder.useTerrainMaterial));
				EditorGUILayout.LabelField("RTP on terrain - far distance", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
				_target.SHADER_USAGE_TerrainFarOnly=EditorGUILayout.Toggle(_target.SHADER_USAGE_FirstPass && rt.globalSettingsHolder.useTerrainMaterial);
				EditorGUI.EndDisabledGroup();
			} else {
				EditorGUILayout.LabelField("RTP on terrain - far distance", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
				_target.SHADER_USAGE_TerrainFarOnly=EditorGUILayout.Toggle(_target.SHADER_USAGE_FirstPass);
			}
		EditorGUILayout.EndHorizontal();
#endif		
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("RTP on terrain - mesh blending", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.SHADER_USAGE_BlendBase=EditorGUILayout.Toggle(_target.SHADER_USAGE_BlendBase);
		EditorGUILayout.EndHorizontal();
		
		EditorGUILayout.Space();		
		
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("RTP on mesh", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.SHADER_USAGE_Terrain2Geometry=EditorGUILayout.Toggle(_target.SHADER_USAGE_Terrain2Geometry);
			if ( _target.SHADER_USAGE_Terrain2Geometry && ((_target.numLayers>8) || (_target.numLayers>4 && _target.RTP_4LAYERS_MODE)) ) {
				_target.SHADER_USAGE_AddPassGeom=true;
			} else {
				_target.SHADER_USAGE_AddPassGeom=false;
			}
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("RTP on mesh - mesh blending", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.SHADER_USAGE_Terrain2GeometryBlendBase=EditorGUILayout.Toggle(_target.SHADER_USAGE_Terrain2GeometryBlendBase);
		EditorGUILayout.EndHorizontal();
			
		EditorGUILayout.Space();		
		EditorGUILayout.Space();	
		
		GUI.color=new Color(1,1,0.5f,1);
		EditorGUILayout.LabelField("Target platforms", EditorStyles.boldLabel);
		GUI.color=skin_color;		
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("d3d9 (PC)", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.PLATFORM_D3D9=EditorGUILayout.Toggle(_target.PLATFORM_D3D9);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("opengl (Mac)", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.PLATFORM_OPENGL=EditorGUILayout.Toggle(_target.PLATFORM_OPENGL);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("gles (WebGL)", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.PLATFORM_GLES=EditorGUILayout.Toggle(_target.PLATFORM_GLES);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("gles3 (hi-end Mobile)", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.PLATFORM_GLES3=EditorGUILayout.Toggle(_target.PLATFORM_GLES3);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("metal (hi-end iOS)", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.PLATFORM_METAL=EditorGUILayout.Toggle(_target.PLATFORM_METAL);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("xbox360", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.PLATFORM_XBOX360=EditorGUILayout.Toggle(_target.PLATFORM_XBOX360);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("ps3", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.PLATFORM_PS3=EditorGUILayout.Toggle(_target.PLATFORM_PS3);
		EditorGUILayout.EndHorizontal();

//#if !UNITY_3_5
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("d3d11 (DX11/XBOXONE/PS4)", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.PLATFORM_D3D11=EditorGUILayout.Toggle(_target.PLATFORM_D3D11);
		EditorGUILayout.EndHorizontal();
		if (_target.PLATFORM_D3D11) {
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("   Tessellation / phong", GUILayout.MinWidth(210), GUILayout.MaxWidth(210));
				bool nTessFlag=EditorGUILayout.Toggle(_target.RTP_TESSELLATION);
				if (_target.RTP_TESSELLATION!=nTessFlag) {
					_target.RTP_TESSELLATION=nTessFlag;
					if (_target.RTP_TESSELLATION) {
						// tessellation is for DX11 only
						_target.PLATFORM_D3D9=false;
						_target.PLATFORM_OPENGL=false;
						_target.PLATFORM_GLES=false;
						_target.PLATFORM_GLES3=false;
						_target.PLATFORM_METAL=false;
						_target.PLATFORM_XBOX360=false;
						_target.PLATFORM_PS3=false;
						// no trees texture available (uzywam blend_val wiec moglibysmy to ograniczenie naprawic przez wprowadzenie dodatkowej zmiennej w shaderze, ale textury trees i tak NIKT nie uzywa...)
						_target.RTP_TREESGLOBAL=false;
					}
				}
			EditorGUILayout.EndHorizontal();
				EditorGUI.BeginDisabledGroup(!_target.RTP_TESSELLATION);
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("     Height&normal from texture", GUILayout.MinWidth(210), GUILayout.MaxWidth(210));
					_target.RTP_TESSELLATION_SAMPLE_TEXTURE=EditorGUILayout.Toggle(_target.RTP_TESSELLATION_SAMPLE_TEXTURE);
				EditorGUILayout.EndHorizontal();
				if (!_target.RTP_TESSELLATION_SAMPLE_TEXTURE) {
					_target.RTP_HEIGHTMAP_SAMPLE_BICUBIC=false;
				}
				EditorGUI.BeginDisabledGroup(!_target.RTP_TESSELLATION_SAMPLE_TEXTURE);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("     texture above bicubic filtering", GUILayout.MinWidth(210), GUILayout.MaxWidth(210));
						_target.RTP_HEIGHTMAP_SAMPLE_BICUBIC=EditorGUILayout.Toggle(_target.RTP_HEIGHTMAP_SAMPLE_BICUBIC);
					EditorGUILayout.EndHorizontal();
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("     displace detail heightmaps", GUILayout.MinWidth(210), GUILayout.MaxWidth(210));
						_target.RTP_DETAIL_HEIGHTMAP_SAMPLE=EditorGUILayout.Toggle(_target.RTP_DETAIL_HEIGHTMAP_SAMPLE);
					EditorGUILayout.EndHorizontal();
				EditorGUI.EndDisabledGroup();

				EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("     full shadow pass", GUILayout.MinWidth(210), GUILayout.MaxWidth(210));
				_target.RTP_ADDSHADOW=EditorGUILayout.Toggle(_target.RTP_ADDSHADOW);
				EditorGUILayout.EndHorizontal();
				if (!_target.RTP_TESSELLATION) _target.RTP_ADDSHADOW=false;

			EditorGUI.EndDisabledGroup();
		} else {
			_target.RTP_TESSELLATION=false;
			_target.RTP_ADDSHADOW=false;
		}
		_target.PLATFORM_XBOXONE = _target.PLATFORM_PS4 = _target.PLATFORM_D3D11;
//#endif
		
		EditorGUILayout.Space();		
		EditorGUILayout.Space();		

		EditorGUILayout.HelpBox("When checked you'll have only simple lighting in forward rendering path (usable when you've got many lights in scene - performance might get low).", MessageType.None, true);
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("No forward add", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.RTP_NOFORWARDADD=EditorGUILayout.Toggle(_target.RTP_NOFORWARDADD);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.HelpBox("Option below does matter only when no forward add is disabled. You can decide then whether you want to handle shadows from point/spot lights in forward or not.", MessageType.None, true);
		EditorGUILayout.BeginHorizontal();
			EditorGUI.BeginDisabledGroup(_target.RTP_NOFORWARDADD);
			EditorGUILayout.LabelField("full forward shadows", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			if (_target.RTP_NOFORWARDADD) _target.RTP_FULLFORWARDSHADOWS=false;
			_target.RTP_FULLFORWARDSHADOWS=EditorGUILayout.Toggle(_target.RTP_FULLFORWARDSHADOWS);
			EditorGUI.EndDisabledGroup();
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.HelpBox("When checked you won't be able to use lightmapping on your terrain (mesh), but you'll have one more feature available that needs texture (rain droplets, caustics, vertical texture, dedicated snow color/normal or heightblend between passes inside addpass).", MessageType.None, true);
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("No lightmaps", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.RTP_NOLIGHTMAP=EditorGUILayout.Toggle(_target.RTP_NOLIGHTMAP);
		EditorGUILayout.EndHorizontal();
		if (!_target.RTP_NOLIGHTMAP) {
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("", GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
			EditorGUILayout.BeginVertical();
				EditorGUILayout.HelpBox("When checked directional lightmaps won't be used (can save up to 2 texture samplers).", MessageType.None, true);
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("No directional lightmaps", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
					_target.RTP_NODIRLIGHTMAP=EditorGUILayout.Toggle(_target.RTP_NODIRLIGHTMAP);
				EditorGUILayout.EndHorizontal();
				#if UNITY_5
					EditorGUILayout.HelpBox("When checked dynamic lightmaps (U5) won't be used (can save up to 3 texture samplers).", MessageType.None, true);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("No dynamic lightmaps", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
						_target.RTP_NODYNLIGHTMAP=EditorGUILayout.Toggle(_target.RTP_NODYNLIGHTMAP);
					EditorGUILayout.EndHorizontal();
				#endif
			EditorGUILayout.EndVertical();
			EditorGUILayout.EndHorizontal();
		}
		EditorGUILayout.HelpBox("Selecting below option will disable Unity's global ambient light color to be applied on RTP shaders (terrain/mesh and geom blend).", MessageType.None, true);
		EditorGUILayout.HelpBox("Select option below to not overbright while using other ambient light sources (IBL diffuse / SH) !", MessageType.Warning, true);
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("No ambient", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.RTP_NOAMBIENT=EditorGUILayout.Toggle(_target.RTP_NOAMBIENT);
		EditorGUILayout.EndHorizontal();

		EditorGUILayout.HelpBox("Independent tiling is useful when you'd like to use multiple terrains of different size on the scene.", MessageType.None, true);
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("Independent detail tiling", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.RTP_INDEPENDENT_TILING=EditorGUILayout.Toggle(_target.RTP_INDEPENDENT_TILING);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.HelpBox("With this option enabled you'll be able to cut holes using alpha channel of global colormap (where it's completely black we clip pixels).", MessageType.None, true);
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("Enable holes cut", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
			_target.RTP_CUT_HOLES=EditorGUILayout.Toggle(_target.RTP_CUT_HOLES);
		EditorGUILayout.EndHorizontal();
		
		#if !UNITY_5
		EditorGUILayout.HelpBox("Here you can select fog that will be used in RTP shaders. You can not change its type dynamically as it is baked into shader code.", MessageType.None, true);
		EditorGUILayout.BeginHorizontal();
			GUILayout.Label("Fog type", GUILayout.Width(60));
			_target.RTP_FOGTYPE=(RTPFogType)EditorGUILayout.EnumPopup(_target.RTP_FOGTYPE);
			if (GUILayout.Button("RenderSettings > RTP")) {
				if (RenderSettings.fog) {
					if (RenderSettings.fogMode==FogMode.ExponentialSquared) {
						_target.RTP_FOGTYPE=RTPFogType.Exp2;
					} else if (RenderSettings.fogMode==FogMode.Linear) {
						_target.RTP_FOGTYPE=RTPFogType.Linear;
					} else {
						_target.RTP_FOGTYPE=RTPFogType.Exponential;
					}
				} else {
					_target.RTP_FOGTYPE=RTPFogType.None;
				}
			}
			if (GUILayout.Button("RTP > RenderSettings")) {
				if (_target.RTP_FOGTYPE==RTPFogType.None) {
					RenderSettings.fog=false;
				} else {
					RenderSettings.fog=true;
					if (_target.RTP_FOGTYPE==RTPFogType.Exp2) {
						RenderSettings.fogMode=FogMode.ExponentialSquared;
					} else if (_target.RTP_FOGTYPE==RTPFogType.Linear) {
						RenderSettings.fogMode=FogMode.Linear;
					} else {
						RenderSettings.fogMode=FogMode.Exponential;
					}
				}
			}
		EditorGUILayout.EndHorizontal();
		#endif
		
		{ EditorGUILayout.BeginVertical("Box");
			GUI.color=new Color(1,1,0.5f,1);
			EditorGUILayout.LabelField("Shading options", EditorStyles.boldLabel);
			GUI.color=skin_color;					
			GUILayout	.Space(3);
		
			EditorGUILayout.BeginHorizontal();
				GUI.color=new Color(0.7f,1,0.7f,1);
				EditorGUILayout.LabelField("Color space is linear", EditorStyles.boldLabel, GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
				GUI.color=skin_color;					
				bool nType=EditorGUILayout.Toggle(_target.RTP_COLORSPACE_LINEAR, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
				if (nType!=_target.RTP_COLORSPACE_LINEAR) {
					_target.RTP_COLORSPACE_LINEAR=nType;
					#if !UNITY_5
						RTPFogUpdate fUpdater=_target.GetComponent(typeof(RTPFogUpdate)) as RTPFogUpdate;
						if (fUpdater) {
							fUpdater.LinearColorSpace=_target.RTP_COLORSPACE_LINEAR;
							RTPFogUpdate.Refresh(_target.RTP_COLORSPACE_LINEAR);
						}
					#endif
				}
			EditorGUILayout.EndHorizontal();
			
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("Complementary ambience lighting", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
				_target.RTP_COMPLEMENTARY_LIGHTS=EditorGUILayout.Toggle(_target.RTP_COMPLEMENTARY_LIGHTS, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
			EditorGUILayout.EndHorizontal();
			if (_target.RTP_COMPLEMENTARY_LIGHTS) {
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("  ambience lighting with spec term", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
					_target.RTP_SPEC_COMPLEMENTARY_LIGHTS=EditorGUILayout.Toggle(_target.RTP_SPEC_COMPLEMENTARY_LIGHTS, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
				EditorGUILayout.EndHorizontal();		
			}		
			
			EditorGUILayout.HelpBox("Advanced PBL features for direct lighting (works fully in forward, for deferred visibility doesn't work, fresnel works for 1 defined directional light)",MessageType.None, true);
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("   PBL fresnel term", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
				_target.RTP_PBL_FRESNEL=EditorGUILayout.Toggle(_target.RTP_PBL_FRESNEL, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
			EditorGUILayout.EndHorizontal();
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("   PBL visibility term", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
				_target.RTP_PBL_VISIBILITY_FUNCTION=EditorGUILayout.Toggle(_target.RTP_PBL_VISIBILITY_FUNCTION, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
			EditorGUILayout.EndHorizontal();
			
			EditorGUILayout.HelpBox("You should always keep below option check unless you're using 3rd party PBL/PBS shading solution that redefines hidden internal prepass shader for deferred. An example would be installing open source Lux package (dig forum for more info). In such case you should UNCHECK option below.\n\nNote, that RTP's built-in energy conserving normalisation CAN NOT exactly fit gloss shape in forward - you'll need to tweak PBL settings per layer to get similar results.",MessageType.Warning, true);
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("PBL fit for legacy deferred", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
				_target.RTP_DEFERRED_PBL_NORMALISATION=EditorGUILayout.Toggle(_target.RTP_DEFERRED_PBL_NORMALISATION, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
			EditorGUILayout.EndHorizontal();
			
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("Use skyshop global cubemaps", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
				_target.RTP_SKYSHOP_SYNC=EditorGUILayout.Toggle(_target.RTP_SKYSHOP_SYNC, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
			EditorGUILayout.EndHorizontal();
			if (_target.RTP_SKYSHOP_SYNC) {
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("  skyshop cubemaps rotation", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
					_target.RTP_SKYSHOP_SKY_ROTATION=EditorGUILayout.Toggle(_target.RTP_SKYSHOP_SKY_ROTATION, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
				EditorGUILayout.EndHorizontal();
			}				
			
			GUILayout.Space(10);
			EditorGUILayout.HelpBox("In %99 cases you won't use option below. Only if you really like to skip all specularity/reflection effects & PBL, you can try it. This will gain additional performance, but remember - specular controlers in RTP inspector will have NO effect either.", MessageType.Warning, true);
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("No specularity", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
			_target.NO_SPECULARITY=EditorGUILayout.Toggle(_target.NO_SPECULARITY, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
			EditorGUILayout.EndHorizontal();

		EditorGUILayout.EndVertical(); }// shading options
		
		EditorGUILayout.Space();		
		
		if (_target.RTP_SUPER_SIMPLE) _target.RTP_SIMPLE_FAR_FIRST=true;
		if (_target.RTP_SUPER_SIMPLE) _target.RTP_SIMPLE_FAR_ADD=true;
		
		if (_target.SHADER_USAGE_FirstPass || _target.SHADER_USAGE_Terrain2Geometry) {
			samplers_left=1;
			if (_target.RTP_4LAYERS_MODE) samplers_left+=2;
			if (_target.RTP_NOLIGHTMAP) {
				if (_target.RTP_NOFORWARDADD) {
					samplers_left+=2;
				} else {
					if (!_target.RTP_FULLFORWARDSHADOWS) {
						samplers_left+=1;
					}
				}
			}
			if (_target.RTP_USE_COLOR_ATLAS_FIRST)	 samplers_left+=3;
			samplers_used=0;
			if (!_target.RTP_SUPER_SIMPLE) {
				samplers_used+=(_target.RTP_WETNESS_FIRST && _target.RTP_WET_RIPPLE_TEXTURE_FIRST && !_target.SIMPLE_WATER_FIRST) ? 1:0;
				samplers_used+=_target.RTP_VERTICAL_TEXTURE_FIRST && (!(_target.RTP_CAUSTICS_FIRST && _target.RTP_VERTALPHA_CAUSTICS)) ? 1:0;
				samplers_used+=_target.RTP_CAUSTICS_FIRST ? 1:0;
				if (_target.RTP_4LAYERS_MODE && _target.RTP_SNOW_FIRST) {
					samplers_used+=(_target.RTP_SNW_CHOOSEN_LAYER_COLOR_FIRST && _target.RTP_SNW_CHOOSEN_LAYER_COLOR_NUM_FIRST>=4) ? 1:0;
					samplers_used+=(_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_FIRST && _target.RTP_SNW_CHOOSEN_LAYER_NORMAL_NUM_FIRST>=4) ? 1:0;
				}
			} else if (_target.RTP_SS_GRAYSCALE_DETAIL_COLORS_FIRST) {
				samplers_left+=3;
			}
			samplers_used+=_target.RTP_NORMALGLOBAL && !_target.RTP_TESSELLATION ? 1:0;
			samplers_used+=_target.RTP_TESSELLATION && _target.RTP_TESSELLATION_SAMPLE_TEXTURE ? 1:0;
			samplers_used+=_target.RTP_TREESGLOBAL ? 1:0;
			samplers_used+=_target.RTP_AMBIENT_EMISSIVE_MAP ? 1:0;
			samplers_used+=_target.RTP_IBL_SPEC_FIRST ? 1:0;	
			samplers_used+=_target.RTP_IBL_DIFFUSE_FIRST ? 1:0;	
			
			if (samplers_used>samplers_left) {
				EditorGUILayout.HelpBox("Firstpass MIGHT NOT COMPILE. You're using "+samplers_used+" aux textures out of "+samplers_left+" available. Try to disable vertical texture, rain droplets, caustics, global normal/trees or change dedicated color/normal texture for snow. For Add Pass try to disable crosspass heightblend.",MessageType.Error, true);
			}
		}		

		if (_target.SHADER_USAGE_AddPass || _target.SHADER_USAGE_AddPassGeom) {		
			samplers_left=3;
			if (_target.RTP_NOLIGHTMAP) {
				if (_target.RTP_NOFORWARDADD) {
					samplers_left+=2;
				} else {
					if (!_target.RTP_FULLFORWARDSHADOWS) {
						samplers_left+=1;
					}
				}
			}
			if (_target.RTP_USE_COLOR_ATLAS_ADD) samplers_left+=3;
			samplers_used=0;
			if (!_target.RTP_SUPER_SIMPLE) {
				samplers_used+=(_target.RTP_WETNESS_ADD && _target.RTP_WET_RIPPLE_TEXTURE_ADD && !_target.SIMPLE_WATER_ADD) ? 1:0;
				samplers_used+=_target.RTP_VERTICAL_TEXTURE_ADD && (!(_target.RTP_CAUSTICS_ADD && _target.RTP_VERTALPHA_CAUSTICS)) ? 1:0;
				samplers_used+=_target.RTP_CAUSTICS_ADD ? 1:0;
				samplers_used+=_target.RTP_CROSSPASS_HEIGHTBLEND ? 2:0;
				//if (_target.RTP_4LAYERS_MODE && _target.RTP_SNOW_ADD) {
				if (_target.RTP_SNOW_ADD) {
					samplers_used+=(_target.RTP_SNW_CHOOSEN_LAYER_COLOR_ADD && _target.RTP_SNW_CHOOSEN_LAYER_COLOR_NUM_ADD>=4) ? 1:0;
					samplers_used+=(_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_ADD && _target.RTP_SNW_CHOOSEN_LAYER_NORMAL_NUM_ADD>=4) ? 1:0;
				}
			} else if (_target.RTP_SS_GRAYSCALE_DETAIL_COLORS_ADD) {
				samplers_left+=3;
			}
			samplers_used+=_target.RTP_NORMALGLOBAL && !_target.RTP_TESSELLATION ? 1:0;
			samplers_used+=_target.RTP_TESSELLATION && _target.RTP_TESSELLATION_SAMPLE_TEXTURE ? 1:0;
			samplers_used+=_target.RTP_TREESGLOBAL ? 1:0;
			samplers_used+=_target.RTP_AMBIENT_EMISSIVE_MAP ? 1:0;	
			samplers_used+=_target.RTP_IBL_SPEC_ADD ? 1:0;	
			samplers_used+=_target.RTP_IBL_DIFFUSE_ADD ? 1:0;	
			
			if (samplers_used>samplers_left) {
				EditorGUILayout.HelpBox("Addpass WON'T COMPILE. You're using "+samplers_used+" aux textures out of "+samplers_left+" available. Try to disable Crosspass heightblend, vertical texture, rain droplets, caustics, global normal/trees or change dedicated color/normal texture for snow.",MessageType.Error, true);
			}
		}			
		
		GUI.color=new Color(0.9f,1,0.9f,1);
		if (GUILayout.Button("Recompile shaders\nfor given feature set")) {
			temp_globalSettingsHolder=null; // clear instance reference (jesli user manipulowal przy parametrach U4 material nie musimy ich resetowac przy OnDisable)
			RefreshFeatures();
			EditorUtility.SetDirty(_target);
		}
		EditorGUILayout.EndVertical();
		GUI.color=skin_color;		

		if (_target.SHADER_USAGE_FirstPass || _target.SHADER_USAGE_Terrain2Geometry) {
//////////////////////////////////////////////////////////////////////////////////////////////////////
// features - first pass
//		
		EditorGUILayout.BeginVertical("Box");
		GUI.color=new Color(1,1,0.5f,1);
		EditorGUILayout.LabelField("RTP features - First Pass (4 or 8 layers) & Arbitrary Mesh", EditorStyles.boldLabel);
		GUI.color=skin_color;		
		
		EditorGUILayout.BeginHorizontal();
		GUILayout.Label("", GUILayout.Width(6));
		if (_target.show_first_features) {
			_target.show_first_features=EditorGUILayout.Foldout(_target.show_first_features, "Hide");
		} else {
			_target.show_first_features=EditorGUILayout.Foldout(_target.show_first_features, "Show");
		}
		EditorGUILayout.EndHorizontal();
				
		if (_target.show_first_features) {
		
			//
			// first pass general options
			//
			EditorGUILayout.BeginVertical("Box");		
			EditorGUILayout.LabelField("General options", EditorStyles.boldLabel);
			//EditorGUILayout.HelpBox("", MessageType.None, true);		
					
			bool _8_layers_disabled=false;
#if !UNITY_3_5				
			if (rt && (rt.globalSettingsHolder!=null) && !rt.globalSettingsHolder.useTerrainMaterial && rt.globalSettingsHolder.numTiles>1) {
				_8_layers_disabled=true;
				EditorGUILayout.HelpBox("8 LAYERS mode impossible for multiple terrains w/o materials (refer to \"Use U4 terrain materials\" above).",MessageType.Warning, true);
			}
#else
			if (rt && (rt.globalSettingsHolder!=null) && rt.globalSettingsHolder.numTiles>1) {
				_8_layers_disabled=true;
				EditorGUILayout.HelpBox("8 LAYERS mode impossible for multiple terrains in U3.",MessageType.Warning, true);
			}
#endif
			EditorGUI.BeginDisabledGroup(_8_layers_disabled);
			EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("8 LAYERS in first pass", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
				bool RTP_4LAYERS_MODE_prev=_target.RTP_4LAYERS_MODE;
				_target.RTP_4LAYERS_MODE=!EditorGUILayout.Toggle(!_target.RTP_4LAYERS_MODE);
				if (RTP_4LAYERS_MODE_prev!=_target.RTP_4LAYERS_MODE) {
					CheckAddPassPresent();
				}
			EditorGUILayout.EndHorizontal();
			EditorGUI.EndDisabledGroup();
				
			if (!_target.RTP_4LAYERS_MODE) {
				EditorGUILayout.HelpBox("In 8 layers rendered in frist pass (4 layers unchecked above) use below option to significantly speed-up rendering. Overlapping areas of layers 0-3 and 4-7 won't be rendered, but reduced to immediate transitions.",MessageType.None, true);
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("  No overlap in 8 layers mode", GUILayout.MinWidth(176), GUILayout.MaxWidth(176));
					_target.RTP_HARD_CROSSPASS=EditorGUILayout.Toggle(_target.RTP_HARD_CROSSPASS);
				EditorGUILayout.EndHorizontal();
				if (!_target.RTP_HARD_CROSSPASS) {
					EditorGUILayout.HelpBox("Hint: organize splats the way areas that overlap are minimized - this will render faster.",MessageType.None, true);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("debug overlapped", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
						_target.RTP_SHOW_OVERLAPPED=EditorGUILayout.Toggle(_target.RTP_4LAYERS_MODE ? false : _target.RTP_SHOW_OVERLAPPED);
					EditorGUILayout.EndHorizontal();
				}			
				_target.RTP_SUPER_SIMPLE=false;
				_target.RTP_USE_COLOR_ATLAS_FIRST=false;
			}
			if (_target.RTP_SUPER_SIMPLE) {
				_target.RTP_USE_COLOR_ATLAS_FIRST=false;
				_target.RTP_USE_COLOR_ATLAS_ADD=false;
			}

			if (_target.RTP_4LAYERS_MODE) {
				EditorGUILayout.Space();
				EditorGUILayout.HelpBox("Massive terrain mode takes very simple version of the RTP shader. This lets you use global color and optionaly - global normal, perlin, bumpmaps at close distance (where CLOSE now means - perlin distance !), pixel trees/shadows and very simple close-distance detail colors (grayscale tinted by global colormap).",MessageType.Warning, true);
				#if UNITY_5
				if (_target.RTP_SUPER_SIMPLE) {
					EditorGUILayout.HelpBox("For unknown (U5.0.0f4) reason it works only in deferred mode.",MessageType.Error, true);
				}
				#endif
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Massive terrain mode", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
					_target.RTP_SUPER_SIMPLE=EditorGUILayout.Toggle(_target.RTP_SUPER_SIMPLE);
					if (_target.RTP_SUPER_SIMPLE) {
						_target.RTP_WETNESS_FIRST=false;
						_target.RTP_WETNESS_ADD=false;
					}
				EditorGUILayout.EndHorizontal();
				if (_target.RTP_SUPER_SIMPLE) {
					//EditorGUI.BeginDisabledGroup(true);
					EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Detail colors as grayscale combined", GUILayout.MinWidth(225), GUILayout.MaxWidth(225));
					_target.RTP_SS_GRAYSCALE_DETAIL_COLORS_FIRST=EditorGUILayout.Toggle(_target.RTP_SS_GRAYSCALE_DETAIL_COLORS_FIRST);
					EditorGUILayout.EndHorizontal();
					//EditorGUI.EndDisabledGroup();				
				}
				if (!_target.RTP_SUPER_SIMPLE) {
					EditorGUILayout.HelpBox("Using color atlas in 4 layers mode costs a bit of performance, but saves 3 texture samplers.",MessageType.Info, true);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Use color atlas", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						_target.RTP_USE_COLOR_ATLAS_FIRST=EditorGUILayout.Toggle(_target.RTP_USE_COLOR_ATLAS_FIRST);
					EditorGUILayout.EndHorizontal();
				}
			}
				
			ReliefTerrain[] _script_objs=(ReliefTerrain[])GameObject.FindObjectsOfType(typeof(ReliefTerrain));
			for(int p=0; p<_script_objs.Length; p++) {
				_script_objs[p].globalSettingsHolder.super_simple_active=_target.RTP_SUPER_SIMPLE;
			}				
				
			EditorGUILayout.Space();
			
			if (!_target.RTP_SUPER_SIMPLE)  {
				EditorGUILayout.HelpBox("Actual shader LOD will be selected when it's lower or equal \"MaxLOD\" below. In triplanar POM shading is unavailable (will be reduced to PM).", MessageType.Warning, true);
				_target.MAX_LOD_FIRST=(RTPLodLevel)EditorGUILayout.EnumPopup("MaxLOD",_target.MAX_LOD_FIRST);
				if (_target.RTP_TRIPLANAR_FIRST && (int)_target.MAX_LOD_FIRST<(int)RTPLodLevel.PM) {
					EditorUtility.DisplayDialog("RTP Notification", "POM shading is disabled using Triplanar.","OK");
					_target.MAX_LOD_FIRST=RTPLodLevel.PM;
				}
				if (!_target.RTP_4LAYERS_MODE && _target.RTP_HARD_CROSSPASS) {
					EditorGUILayout.HelpBox("\"MaxLOD for 4-7\" has to be lower or equal than \"MaxLOD\" and will be applied to layers 4-7 in 8 layers mode with no overlapping.", MessageType.Warning, true);
					_target.MAX_LOD_FIRST_PLUS4=(RTPLodLevel)EditorGUILayout.EnumPopup("MaxLOD for 4-7", _target.MAX_LOD_FIRST_PLUS4);
					if ((int)_target.MAX_LOD_FIRST_PLUS4<(int)_target.MAX_LOD_FIRST) _target.MAX_LOD_FIRST_PLUS4=_target.MAX_LOD_FIRST;
				}
				if ((int)_target.MAX_LOD_ADD<(int)_target.MAX_LOD_FIRST) {
					_target.MAX_LOD_ADD=_target.MAX_LOD_FIRST;
					EditorUtility.DisplayDialog("RTP Notification", "AddPass MaxLOD level shouldn't be greater than FirstPass MaxLOD.","OK");
				}
				
			}
			// first pass general options
			EditorGUILayout.EndVertical();
			
			GUILayout.Space(10);
			
			//
			// first pass more specific options
			//
			
			if (_target.RTP_SUPER_SIMPLE)  {
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Use detail bump maps", GUILayout.MinWidth(225), GUILayout.MaxWidth(225));
					_target.RTP_USE_BUMPMAPS_FIRST=EditorGUILayout.Toggle(_target.RTP_USE_BUMPMAPS_FIRST);
				EditorGUILayout.EndHorizontal();
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Use perlin normal", GUILayout.MinWidth(225), GUILayout.MaxWidth(225));
					_target.RTP_USE_PERLIN_FIRST=EditorGUILayout.Toggle(_target.RTP_USE_PERLIN_FIRST);
				EditorGUILayout.EndHorizontal();
			}
				
			if (!_target.RTP_SUPER_SIMPLE)  {
				// UV blend
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("UV blend / distance replacement", EditorStyles.boldLabel);
	//				EditorGUILayout.HelpBox("", MessageType.None, true);		
							
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("UV blend", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_UV_BLEND_FIRST=EditorGUILayout.Toggle(_target.RTP_UV_BLEND_FIRST);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_UV_BLEND_FIRST) {
						if (_target.RTP_SIMPLE_FAR_FIRST && _target.RTP_DISTANCE_ONLY_UV_BLEND_FIRST) {
							EditorGUILayout.HelpBox("Using \"No detail colors at far distance\" with option below does not make much sense (result will be almost unnoticeable).", MessageType.Warning, true);
						}
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("UV blend at distance only", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
							_target.RTP_DISTANCE_ONLY_UV_BLEND_FIRST=EditorGUILayout.Toggle(_target.RTP_DISTANCE_ONLY_UV_BLEND_FIRST, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.HelpBox("With option below you can introduce normals from UV blend layer at far distance. Normals taken DOES NOT incorporate layer TEXTURE routing.", MessageType.None, true);
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("Far dist normals from UV blend", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
							_target.RTP_NORMALS_FOR_REPLACE_UV_BLEND_FIRST=EditorGUILayout.Toggle(_target.RTP_NORMALS_FOR_REPLACE_UV_BLEND_FIRST, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.HelpBox("Here you map UV blend layers so that one layer can be uv blended with another.", MessageType.None, true);
						EditorGUILayout.BeginHorizontal();
							string[] options=new string[ (_target.RTP_4LAYERS_MODE ? 4:8) ];
							for(int k=0; k<(_target.RTP_4LAYERS_MODE ? 4:8); k++) {
								for(int j=0; j<(_target.RTP_4LAYERS_MODE ? 4:8); j++) {
									options[j]=k+" from "+j;
								}
								_target.UV_BLEND_ROUTE_NUM_FIRST[k]=EditorGUILayout.Popup(_target.UV_BLEND_ROUTE_NUM_FIRST[k], options);
								if (k==3 && !_target.RTP_4LAYERS_MODE) {
									EditorGUILayout.EndHorizontal();
									EditorGUILayout.BeginHorizontal();
								}
							}
						EditorGUILayout.EndHorizontal();
					}
				// uv blend
				EditorGUILayout.EndVertical(); }

			} // !super-simple
			
			GUILayout.Space(5);
			
			// Global maps (works in super simple and in regular mode)
			{ EditorGUILayout.BeginVertical("Box");
			
				EditorGUILayout.LabelField("Global maps features", EditorStyles.boldLabel);
//				EditorGUILayout.HelpBox("", MessageType.None, true);			

				//EditorGUILayout.HelpBox("Option below speeds-up far distance rendering (we don't use splat detail colors there).", MessageType.None, true);
				if (_target.RTP_SUPER_SIMPLE) {
					EditorGUI.BeginDisabledGroup(true);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("No detail colors at far distance", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
						EditorGUILayout.Toggle(true);
					EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
				} else {
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("No detail colors at far distance", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
						_target.RTP_SIMPLE_FAR_FIRST=EditorGUILayout.Toggle(_target.RTP_SIMPLE_FAR_FIRST);
					EditorGUILayout.EndHorizontal();
				}
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Global color blend multiplicative", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
					_target.RTP_COLOR_MAP_BLEND_MULTIPLY_FIRST=EditorGUILayout.Toggle(_target.RTP_COLOR_MAP_BLEND_MULTIPLY_FIRST);
				EditorGUILayout.EndHorizontal();
				if (!_target.RTP_SUPER_SIMPLE) {
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Advanced color map blending", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
						_target.ADV_COLOR_MAP_BLENDING_FIRST=EditorGUILayout.Toggle(_target.ADV_COLOR_MAP_BLENDING_FIRST);
						if (_target.ADV_COLOR_MAP_BLENDING_FIRST) {
							if (!_target.RTP_COLOR_MAP_BLEND_MULTIPLY_FIRST) {
								EditorUtility.DisplayDialog("Notification","Advanced colormap blending requires multiplicative mode.", "OK");
								_target.RTP_COLOR_MAP_BLEND_MULTIPLY_FIRST=true;
							}
						}
					EditorGUILayout.EndHorizontal();
				}	
							
				EditorGUILayout.Space();	
				
				if (_target.RTP_TESSELLATION) {
					EditorGUILayout.HelpBox("When tessellation is used we sample normalmap together with heightmap per (tessellated) vertex. Use \"Prepare Height&Normal Texture for Tessellation\" tool to make such texture.", MessageType.Warning, true);
					EditorGUI.BeginDisabledGroup(true);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Global normal map", GUILayout.MinWidth(270), GUILayout.MaxWidth(270));
						EditorGUILayout.Toggle(false);
					EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
				} else {
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Global normal map", GUILayout.MinWidth(270), GUILayout.MaxWidth(270));
						_target.RTP_NORMALGLOBAL=EditorGUILayout.Toggle(_target.RTP_NORMALGLOBAL);
					EditorGUILayout.EndHorizontal();
				}
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Global trees map (Terrain / World Composer)", GUILayout.MinWidth(270), GUILayout.MaxWidth(270));
					_target.RTP_TREESGLOBAL=EditorGUILayout.Toggle(_target.RTP_TREESGLOBAL);
				EditorGUILayout.EndHorizontal();
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Global ambient emissive map", GUILayout.MinWidth(270), GUILayout.MaxWidth(270));
					_target.RTP_AMBIENT_EMISSIVE_MAP=EditorGUILayout.Toggle(_target.RTP_AMBIENT_EMISSIVE_MAP);
				EditorGUILayout.EndHorizontal();
				if (rt && (rt.globalSettingsHolder!=null) && rt.globalSettingsHolder.numTiles>1 && !rt.globalSettingsHolder.useTerrainMaterial && _target.RTP_AMBIENT_EMISSIVE_MAP && _target.RTP_TREESGLOBAL) {
					EditorUtility.DisplayDialog("Notification","Turning off global trees map (use terrain materials to enable).", "OK");
					_target.RTP_TREESGLOBAL=false;
				}
				// Global maps
			EditorGUILayout.EndVertical(); }	
			
			GUILayout.Space(5);
			
			if (!_target.RTP_SUPER_SIMPLE)  {			
				// Snow feartures
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("Snow features", EditorStyles.boldLabel);
//					EditorGUILayout.HelpBox("", MessageType.None, true);		
				
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Dynamic snow", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
						_target.RTP_SNOW_FIRST=EditorGUILayout.Toggle(_target.RTP_SNOW_FIRST);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_SNOW_FIRST) {
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("Layer for color", GUILayout.MinWidth(150), GUILayout.MaxWidth(150));
							_target.RTP_SNW_CHOOSEN_LAYER_COLOR_FIRST=EditorGUILayout.Toggle(_target.RTP_SNW_CHOOSEN_LAYER_COLOR_FIRST, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
							EditorGUI.BeginDisabledGroup( !_target.RTP_SNW_CHOOSEN_LAYER_COLOR_FIRST );
								_target.RTP_SNW_CHOOSEN_LAYER_COLOR_NUM_FIRST=EditorGUILayout.IntSlider(_target.RTP_SNW_CHOOSEN_LAYER_COLOR_NUM_FIRST,0,7);
							EditorGUI.EndDisabledGroup();
						EditorGUILayout.EndHorizontal();
					
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("Layer for normal", GUILayout.MinWidth(150), GUILayout.MaxWidth(150));
							_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_FIRST=EditorGUILayout.Toggle(_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_FIRST, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
					
							EditorGUI.BeginDisabledGroup( !_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_FIRST );
								_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_NUM_FIRST=EditorGUILayout.IntSlider(_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_NUM_FIRST,0,7);
							EditorGUI.EndDisabledGroup();
						EditorGUILayout.EndHorizontal();
					}		
				// snow
				EditorGUILayout.EndVertical(); }
				
				GUILayout.Space(5);
				
				// Water / caustics
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("Water & Caustics features", EditorStyles.boldLabel);
//					EditorGUILayout.HelpBox("", MessageType.None, true);			

					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Water/wetness", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						bool prev_wetness=_target.RTP_WETNESS_FIRST;
						_target.RTP_WETNESS_FIRST=EditorGUILayout.Toggle(_target.RTP_WETNESS_FIRST);
						if (prev_wetness!=_target.RTP_WETNESS_FIRST && _target.RTP_WETNESS_FIRST) {
							if (_target.RTP_SUPER_DETAIL_MULTS_FIRST) {
								EditorUtility.DisplayDialog("Notification","Turning off superdetail mults feature", "OK");
								_target.RTP_SUPER_DETAIL_MULTS_FIRST=false;
							}
						}
						if (!_target.RTP_WETNESS_FIRST) {
							_target.SIMPLE_WATER_FIRST=false;
							_target.RTP_WET_RIPPLE_TEXTURE_FIRST=false;
						}
					EditorGUILayout.EndHorizontal();
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Simple water only", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						bool nSIMPLE_WATER_FIRST=EditorGUILayout.Toggle(_target.SIMPLE_WATER_FIRST);
						if (nSIMPLE_WATER_FIRST && !_target.SIMPLE_WATER_FIRST) _target.RTP_WET_RIPPLE_TEXTURE_FIRST=false;
						_target.SIMPLE_WATER_FIRST=nSIMPLE_WATER_FIRST;
					EditorGUILayout.EndHorizontal();
					
					EditorGUI.BeginDisabledGroup(!_target.RTP_WETNESS_FIRST || _target.SIMPLE_WATER_FIRST);
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  Animated droplets", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
							_target.RTP_WET_RIPPLE_TEXTURE_FIRST=EditorGUILayout.Toggle(_target.RTP_WET_RIPPLE_TEXTURE_FIRST);
						EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Caustics", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						_target.RTP_CAUSTICS_FIRST=EditorGUILayout.Toggle(_target.RTP_CAUSTICS_FIRST);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_CAUSTICS_FIRST) {
						if (_target.RTP_VERTICAL_TEXTURE_FIRST) {
							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  Vertical texure from caustics", GUILayout.MinWidth(180), GUILayout.MaxWidth(180));
							_target.RTP_VERTALPHA_CAUSTICS=EditorGUILayout.Toggle(_target.RTP_VERTALPHA_CAUSTICS);
							EditorGUILayout.EndHorizontal();
						}
					} 
					if (!_target.RTP_CAUSTICS_FIRST && !_target.RTP_CAUSTICS_ADD) {
						_target.RTP_VERTALPHA_CAUSTICS=false;
					}
							
				// Water & caustics
				EditorGUILayout.EndVertical(); }
				
				GUILayout.Space(5);
								
				// IBL / Refl
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("Reflection & IBL features", EditorStyles.boldLabel);
//					EditorGUILayout.HelpBox("", MessageType.None, true);
							
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Reflection map", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						bool prev_reflection=_target.RTP_REFLECTION_FIRST;
						_target.RTP_REFLECTION_FIRST=EditorGUILayout.Toggle(_target.RTP_REFLECTION_FIRST);
						if (prev_reflection!=_target.RTP_REFLECTION_FIRST) {
							if (_target.RTP_SUPER_DETAIL_MULTS_FIRST) {
								EditorUtility.DisplayDialog("Notification","Turning off superdetail mults feature", "OK");
								_target.RTP_SUPER_DETAIL_MULTS_FIRST=false;
							}
						}				
					EditorGUILayout.EndHorizontal();
					EditorGUI.BeginDisabledGroup(!_target.RTP_REFLECTION_FIRST);
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  Rotate reflection map", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
							_target.RTP_ROTATE_REFLECTION=EditorGUILayout.Toggle(_target.RTP_ROTATE_REFLECTION);
						EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
										
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("IBL diffuse (cube or SH)", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						_target.RTP_IBL_DIFFUSE_FIRST=EditorGUILayout.Toggle(_target.RTP_IBL_DIFFUSE_FIRST);
					EditorGUILayout.EndHorizontal();
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("IBL specular cubemap", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						_target.RTP_IBL_SPEC_FIRST=EditorGUILayout.Toggle(_target.RTP_IBL_SPEC_FIRST);
					EditorGUILayout.EndHorizontal();
				// IBL / Reflections
				EditorGUILayout.EndVertical(); }
				
				GUILayout.Space(5);				
				
				// additional goodies
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("Additional features", EditorStyles.boldLabel);
	//				EditorGUILayout.HelpBox("", MessageType.None, true);	
						
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Sharpen heightblend edges", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS1_FIRST=EditorGUILayout.Toggle(_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS1_FIRST);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS1_FIRST) {
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  Sharpen them even more", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
							_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS2_FIRST=EditorGUILayout.Toggle(_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS2_FIRST);
						EditorGUILayout.EndHorizontal();
					} else {
						_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS2_FIRST=false;							
					}				
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Layer extrude reduction", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_USE_EXTRUDE_REDUCTION_FIRST=EditorGUILayout.Toggle(_target.RTP_USE_EXTRUDE_REDUCTION_FIRST);
					EditorGUILayout.EndHorizontal();
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Heightblend fake AO", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_HEIGHTBLEND_AO_FIRST=EditorGUILayout.Toggle(_target.RTP_HEIGHTBLEND_AO_FIRST);
					EditorGUILayout.EndHorizontal();
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Layer emission", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_EMISSION_FIRST=EditorGUILayout.Toggle(_target.RTP_EMISSION_FIRST);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_EMISSION_FIRST && _target.RTP_WETNESS_FIRST && !_target.SIMPLE_WATER_FIRST) {
						EditorGUILayout.HelpBox("When wetness is defined and fuild on surface is emissive we can mod its emissiveness by output normal (wrinkles of flowing\"water\"). Checkbox below below define change the way we treat output normals (this works fine for \"lava\" like emissive fuilds).", MessageType.None, true);
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  fluid normals wrap", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
							_target.RTP_FUILD_EMISSION_WRAP_FIRST=EditorGUILayout.Toggle(_target.RTP_FUILD_EMISSION_WRAP_FIRST);
						EditorGUILayout.EndHorizontal();
					}
					if (_target.RTP_EMISSION_FIRST) {
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  hot air refraction", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
								_target.RTP_HOTAIR_EMISSION_FIRST=EditorGUILayout.Toggle(_target.RTP_HOTAIR_EMISSION_FIRST);
						EditorGUILayout.EndHorizontal();
					} else {
						_target.RTP_HOTAIR_EMISSION_FIRST=false;
					}
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Vertical texture map", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_VERTICAL_TEXTURE_FIRST=EditorGUILayout.Toggle(_target.RTP_VERTICAL_TEXTURE_FIRST);
					EditorGUILayout.EndHorizontal();
										
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Superdetail", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_SUPER_DETAIL_FIRST=EditorGUILayout.Toggle(_target.RTP_SUPER_DETAIL_FIRST);
					EditorGUILayout.EndHorizontal();
			
					EditorGUI.BeginDisabledGroup(!_target.RTP_SUPER_DETAIL_FIRST);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("  Mult channels", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						bool prev_superdetail=_target.RTP_SUPER_DETAIL_MULTS_FIRST;
						_target.RTP_SUPER_DETAIL_MULTS_FIRST=EditorGUILayout.Toggle(_target.RTP_SUPER_DETAIL_MULTS_FIRST);
						if (prev_superdetail!=_target.RTP_SUPER_DETAIL_MULTS_FIRST) {
							if (_target.RTP_WETNESS_FIRST) {
								EditorUtility.DisplayDialog("Notification","Turning off water feature", "OK");
								_target.RTP_WETNESS_FIRST=false;
							}
							if (_target.RTP_REFLECTION_FIRST) {
								EditorUtility.DisplayDialog("Notification","Turning off reflections feature", "OK");
								_target.RTP_REFLECTION_FIRST=false;
							}
						}				
					EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
											
	//				EditorGUI.BeginDisabledGroup(!_target.RTP_4LAYERS_MODE);
	//					EditorGUILayout.HelpBox("In 4 layers mode we can use shadow maps that speed-up shadow calculations (one color atlas also needed like in 8 layers mode).",MessageType.None, true);
	//					EditorGUILayout.BeginHorizontal();
	//						EditorGUILayout.LabelField("Self-shadow maps", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
	//						_target.RTP_MAPPED_SHADOWS_FIRST=EditorGUILayout.Toggle(_target.RTP_MAPPED_SHADOWS_FIRST);
	//					EditorGUILayout.EndHorizontal();
	//				EditorGUI.EndDisabledGroup();
			
	//				EditorGUILayout.Space();
	//				EditorGUILayout.Space();
					
					if (_target.RTP_4LAYERS_MODE) {
						EditorGUILayout.HelpBox("In triplanar POM is reduced to PM.",MessageType.None, true);
					} else {
						EditorGUILayout.HelpBox("In 8 layers mode triplanar works for first four layers only. It's advisable (still not necessary) to use it with \"No overlap in 8 layers mode\" to avoid discontinuities at overlaping areas on slopes. Additionaly POM is reduced to PM.",MessageType.Warning, true);
					}
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("First-Pass Triplanar", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_TRIPLANAR_FIRST=EditorGUILayout.Toggle(_target.RTP_TRIPLANAR_FIRST);
					EditorGUILayout.EndHorizontal();
					
				// additional goodies
				EditorGUILayout.EndVertical(); }
				
				EditorGUILayout.Space();
			} // super-simple
		}
		EditorGUILayout.EndVertical(); // features - first pass
		} //EOF if (used firstpass shader or rtp on mesh)
		
		EditorGUILayout.Space();
		EditorGUILayout.Space();
		EditorGUILayout.Space();
		
		if ((_target.SHADER_USAGE_AddPass || _target.SHADER_USAGE_AddPassGeom)) {
			
//////////////////////////////////////////////////////////////////////////////////////////////////////
// features - add pass
//		
		EditorGUILayout.BeginVertical("Box");
		GUI.color=new Color(1,1,0.5f,1);
		EditorGUILayout.LabelField("RTP features - Add Pass (4layers)", EditorStyles.boldLabel);
		GUI.color=skin_color;		
		
		EditorGUILayout.BeginHorizontal();
		GUILayout.Label("", GUILayout.Width(6));
		if (_target.show_add_features) {
			_target.show_add_features=EditorGUILayout.Foldout(_target.show_add_features, "Hide");
		} else {
			_target.show_add_features=EditorGUILayout.Foldout(_target.show_add_features, "Show");
		}
		EditorGUILayout.EndHorizontal();
				
		if (_target.show_add_features) {
			//
			//  pass general options
			//
			EditorGUILayout.BeginVertical("Box");		
			EditorGUILayout.LabelField("General options", EditorStyles.boldLabel);
			//EditorGUILayout.HelpBox("", MessageType.None, true);				
			if (!_target.RTP_SUPER_SIMPLE) {
				EditorGUILayout.HelpBox("When add pass is present (using 8 layers in 4 layers per pass mode), you can ask shaders to make height blending between passes. Works for terrains only (shader on arbitrary mesh doesn't have such thing as add pass). Doesn't work when 12 layers are used.",MessageType.Warning, true);
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Crosspass heightblend", GUILayout.MinWidth(176), GUILayout.MaxWidth(176));
					_target.RTP_CROSSPASS_HEIGHTBLEND=EditorGUILayout.Toggle(_target.RTP_CROSSPASS_HEIGHTBLEND);
				EditorGUILayout.EndHorizontal();
			}
			if (_target.RTP_SUPER_SIMPLE) {
				//EditorGUI.BeginDisabledGroup(true);
				EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("Detail colors as grayscale combined", GUILayout.MinWidth(225), GUILayout.MaxWidth(225));
				_target.RTP_SS_GRAYSCALE_DETAIL_COLORS_FIRST=EditorGUILayout.Toggle(_target.RTP_SS_GRAYSCALE_DETAIL_COLORS_FIRST);
				EditorGUILayout.EndHorizontal();
				//EditorGUI.EndDisabledGroup();				
			}
			if (!_target.RTP_SUPER_SIMPLE) {
				EditorGUILayout.HelpBox("Using color atlas in add pass costs a bit of performance, but saves 3 texture samplers.",MessageType.Info, true);
				EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField("Use color atlas", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
					_target.RTP_USE_COLOR_ATLAS_ADD=EditorGUILayout.Toggle(_target.RTP_USE_COLOR_ATLAS_ADD);
				EditorGUILayout.EndHorizontal();
				
				EditorGUILayout.HelpBox("Actual shader LOD will be selected when it's lower or equal \"MaxLOD\" below. In triplanar POM shading is unavailable (will be reduced to PM).", MessageType.Warning, true);
				_target.MAX_LOD_ADD=(RTPLodLevel)EditorGUILayout.EnumPopup("MaxLOD",_target.MAX_LOD_ADD);
				if (_target.RTP_TRIPLANAR_ADD && (int)_target.MAX_LOD_ADD<(int)RTPLodLevel.PM) {
					EditorUtility.DisplayDialog("RTP Notification", "POM shading is disabled using Triplanar.","OK");
					_target.MAX_LOD_ADD=RTPLodLevel.PM;
				}
			}
					
			EditorGUILayout.EndVertical();

			GUILayout.Space(10);
			
			//
			// add pass more specific options
			//		
				
			if (_target.RTP_SUPER_SIMPLE)  {
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Use detail bump maps", GUILayout.MinWidth(225), GUILayout.MaxWidth(225));
					_target.RTP_USE_BUMPMAPS_ADD=EditorGUILayout.Toggle(_target.RTP_USE_BUMPMAPS_ADD);
					EditorGUILayout.EndHorizontal();
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Use perlin normal", GUILayout.MinWidth(225), GUILayout.MaxWidth(225));
					_target.RTP_USE_PERLIN_ADD=EditorGUILayout.Toggle(_target.RTP_USE_PERLIN_ADD);
				EditorGUILayout.EndHorizontal();
			}		

			if (!_target.RTP_SUPER_SIMPLE)  {
				// UV blend
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("UV blend / distance replacement", EditorStyles.boldLabel);
	//				EditorGUILayout.HelpBox("", MessageType.None, true);		
							
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("UV blend", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_UV_BLEND_ADD=EditorGUILayout.Toggle(_target.RTP_UV_BLEND_ADD);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_UV_BLEND_ADD) {
						if (_target.RTP_SIMPLE_FAR_ADD && _target.RTP_DISTANCE_ONLY_UV_BLEND_ADD) {
							EditorGUILayout.HelpBox("Using \"No detail colors at far distance\" with option below does not make much sense (result will be almost unnoticeable).", MessageType.Warning, true);
						}
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("UV blend at distance only", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
							_target.RTP_DISTANCE_ONLY_UV_BLEND_ADD=EditorGUILayout.Toggle(_target.RTP_DISTANCE_ONLY_UV_BLEND_ADD, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.HelpBox("With option below you can introduce normals from UV blend layer at far distance. Normals taken DOES NOT incorporate layer TEXTURE routing.", MessageType.None, true);
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("Far dist normals from UV blend", GUILayout.MinWidth(190), GUILayout.MaxWidth(190));
							_target.RTP_NORMALS_FOR_REPLACE_UV_BLEND_ADD=EditorGUILayout.Toggle(_target.RTP_NORMALS_FOR_REPLACE_UV_BLEND_ADD, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
						EditorGUILayout.EndHorizontal();
						EditorGUILayout.HelpBox("Here you map UV blend layers so that one layer can be uv blended with another.", MessageType.None, true);
						EditorGUILayout.BeginHorizontal();
							string[] options=new string[4];
							for(int k=0; k<4; k++) {
								for(int j=0; j<4; j++) {
									options[j]=k+" from "+j;
								}
								_target.UV_BLEND_ROUTE_NUM_ADD[k]=EditorGUILayout.Popup(_target.UV_BLEND_ROUTE_NUM_ADD[k], options);
							}
						EditorGUILayout.EndHorizontal();
					}
				// uv blend
				EditorGUILayout.EndVertical(); }

			} // !super-simple
			
			GUILayout.Space(5);
			
			// Global maps (works in super simple and in regular mode)
			{ EditorGUILayout.BeginVertical("Box");
			
				EditorGUILayout.LabelField("Global maps features", EditorStyles.boldLabel);
//				EditorGUILayout.HelpBox("", MessageType.None, true);			

				//EditorGUILayout.HelpBox("Option below speeds-up far distance rendering (we don't use splat detail colors there).", MessageType.None, true);
				if (_target.RTP_SUPER_SIMPLE) {
					EditorGUI.BeginDisabledGroup(true);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("No detail colors at far distance", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
						EditorGUILayout.Toggle(true);
					EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
				} else {
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("No detail colors at far distance", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
						_target.RTP_SIMPLE_FAR_ADD=EditorGUILayout.Toggle(_target.RTP_SIMPLE_FAR_ADD);
					EditorGUILayout.EndHorizontal();
				}
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Global color blend multiplicative", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
					_target.RTP_COLOR_MAP_BLEND_MULTIPLY_ADD=EditorGUILayout.Toggle(_target.RTP_COLOR_MAP_BLEND_MULTIPLY_ADD);
				EditorGUILayout.EndHorizontal();
				if (!_target.RTP_SUPER_SIMPLE) {
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Advanced color map blending", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
						_target.ADV_COLOR_MAP_BLENDING_ADD=EditorGUILayout.Toggle(_target.ADV_COLOR_MAP_BLENDING_ADD);
						if (_target.ADV_COLOR_MAP_BLENDING_ADD) {
							if (!_target.RTP_COLOR_MAP_BLEND_MULTIPLY_ADD) {
								EditorUtility.DisplayDialog("Notification","Advanced colormap blending requires multiplicative mode.", "OK");
								_target.RTP_COLOR_MAP_BLEND_MULTIPLY_ADD=true;
							}
						}
					EditorGUILayout.EndHorizontal();
				}	
							
				EditorGUILayout.Space();	
				
				if (_target.RTP_TESSELLATION) {
					EditorGUILayout.HelpBox("When tessellation is used we global normalmap is unavailable - we can sample normalmap together with heightmap per (tessellated) vertex. Use \"Prepare Height&Normal Texture for Tessellation\" tool to make such texture.", MessageType.Warning, true);
					EditorGUI.BeginDisabledGroup(true);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Global normal map", GUILayout.MinWidth(270), GUILayout.MaxWidth(270));
						EditorGUILayout.Toggle(false);
					EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
				} else {
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Global normal map", GUILayout.MinWidth(270), GUILayout.MaxWidth(270));
						_target.RTP_NORMALGLOBAL=EditorGUILayout.Toggle(_target.RTP_NORMALGLOBAL);
					EditorGUILayout.EndHorizontal();
				}
				
				///////////////////////////////////////////////////////////////////////////////////////
				// sprawdz konflikt tekstur (jest uzywana przez crosspass heightblend)
				//
				bool _8_layers_disabled=false;
#if !UNITY_3_5				
				if (rt!=null && rt.globalSettingsHolder!=null && !rt.globalSettingsHolder.useTerrainMaterial && rt.globalSettingsHolder.numTiles>1 && _target.RTP_CROSSPASS_HEIGHTBLEND) {
					_8_layers_disabled=true;
				}
#else
				if (rt && (rt.globalSettingsHolder!=null) && rt.globalSettingsHolder.numTiles>1 && !_target.RTP_SUPER_SIMPLE && _target.RTP_CROSSPASS_HEIGHTBLEND) {
					_8_layers_disabled=true;
				}
#endif
				if (_8_layers_disabled) {
					EditorGUILayout.HelpBox("Feature unavailable in AddPass for multiple terrains with \"Crosspass heightblend\" switched on (above).",MessageType.Warning, true);
					_target.RTP_TREESGLOBAL=false;
				}
				EditorGUI.BeginDisabledGroup(_8_layers_disabled);					
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Global trees map (Terrain / World Composer)", GUILayout.MinWidth(270), GUILayout.MaxWidth(270));
					_target.RTP_TREESGLOBAL=EditorGUILayout.Toggle(_target.RTP_TREESGLOBAL);
				EditorGUILayout.EndHorizontal();
				EditorGUI.EndDisabledGroup();	
			
				if (_8_layers_disabled) {
					EditorGUILayout.HelpBox("Feature unavailable in AddPass for multiple terrains with \"Crosspass heightblend\" switched on (above).",MessageType.Warning, true);
					_target.RTP_AMBIENT_EMISSIVE_MAP=false;
				}
				EditorGUI.BeginDisabledGroup(_8_layers_disabled);					
				EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Global ambient emissive map", GUILayout.MinWidth(270), GUILayout.MaxWidth(270));
					_target.RTP_AMBIENT_EMISSIVE_MAP=EditorGUILayout.Toggle(_target.RTP_AMBIENT_EMISSIVE_MAP);
				EditorGUILayout.EndHorizontal();
				EditorGUI.EndDisabledGroup();	
				if (rt && (rt.globalSettingsHolder!=null) && rt.globalSettingsHolder.numTiles>1 && !rt.globalSettingsHolder.useTerrainMaterial && _target.RTP_AMBIENT_EMISSIVE_MAP && _target.RTP_TREESGLOBAL) {
					EditorUtility.DisplayDialog("Notification","Turning off global trees map (use terrain materials to enable).", "OK");
					_target.RTP_TREESGLOBAL=false;
				}
				// Global maps
			EditorGUILayout.EndVertical(); }	
			
			GUILayout.Space(5);
			
			if (!_target.RTP_SUPER_SIMPLE)  {			
				// Snow feartures
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("Snow features", EditorStyles.boldLabel);
//					EditorGUILayout.HelpBox("", MessageType.None, true);		
				
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Dynamic snow", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
						_target.RTP_SNOW_ADD=EditorGUILayout.Toggle(_target.RTP_SNOW_ADD);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_SNOW_ADD) {
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("Layer for color", GUILayout.MinWidth(150), GUILayout.MaxWidth(150));
							_target.RTP_SNW_CHOOSEN_LAYER_COLOR_ADD=EditorGUILayout.Toggle(_target.RTP_SNW_CHOOSEN_LAYER_COLOR_ADD, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
							EditorGUI.BeginDisabledGroup( !_target.RTP_SNW_CHOOSEN_LAYER_COLOR_ADD );
								_target.RTP_SNW_CHOOSEN_LAYER_COLOR_NUM_ADD=EditorGUILayout.IntSlider(_target.RTP_SNW_CHOOSEN_LAYER_COLOR_NUM_ADD,0,3);
							EditorGUI.EndDisabledGroup();
						EditorGUILayout.EndHorizontal();
					
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("Layer for normal", GUILayout.MinWidth(150), GUILayout.MaxWidth(150));
							_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_ADD=EditorGUILayout.Toggle(_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_ADD, GUILayout.MinWidth(20), GUILayout.MaxWidth(20));
							EditorGUI.BeginDisabledGroup( !_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_ADD );
								_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_NUM_ADD=EditorGUILayout.IntSlider(_target.RTP_SNW_CHOOSEN_LAYER_NORMAL_NUM_ADD,0,3);
							EditorGUI.EndDisabledGroup();
						EditorGUILayout.EndHorizontal();
					}			
				// snow
				EditorGUILayout.EndVertical(); }
				
				GUILayout.Space(5);
				
				// Water / caustics
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("Water & Caustics features", EditorStyles.boldLabel);
//					EditorGUILayout.HelpBox("", MessageType.None, true);			

					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Water/wetness", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						bool prev_wetness=_target.RTP_WETNESS_ADD;
						_target.RTP_WETNESS_ADD=EditorGUILayout.Toggle(_target.RTP_WETNESS_ADD);
						if (prev_wetness!=_target.RTP_WETNESS_ADD && _target.RTP_WETNESS_ADD) {
							if (_target.RTP_SUPER_DETAIL_MULTS_ADD) {
								EditorUtility.DisplayDialog("Notification","Turning off superdetail mults feature", "OK");
								_target.RTP_SUPER_DETAIL_MULTS_ADD=false;
							}
						}
						if (!_target.RTP_WETNESS_ADD) {
							_target.SIMPLE_WATER_ADD=false;
							_target.RTP_WET_RIPPLE_TEXTURE_ADD=false;
						}
					EditorGUILayout.EndHorizontal();
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Simple water only", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						bool nSIMPLE_WATER_ADD=EditorGUILayout.Toggle(_target.SIMPLE_WATER_ADD);
						if (nSIMPLE_WATER_ADD && !_target.SIMPLE_WATER_ADD) _target.RTP_WET_RIPPLE_TEXTURE_ADD=false;
						_target.SIMPLE_WATER_ADD=nSIMPLE_WATER_ADD;
					EditorGUILayout.EndHorizontal();
					
					EditorGUI.BeginDisabledGroup(!_target.RTP_WETNESS_ADD || _target.SIMPLE_WATER_ADD);
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  Animated droplets", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
							_target.RTP_WET_RIPPLE_TEXTURE_ADD=EditorGUILayout.Toggle(_target.RTP_WET_RIPPLE_TEXTURE_ADD);
						EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Caustics", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						_target.RTP_CAUSTICS_ADD=EditorGUILayout.Toggle(_target.RTP_CAUSTICS_ADD);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_CAUSTICS_ADD) {
						if (_target.RTP_VERTICAL_TEXTURE_ADD) {
							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  Vertical texure from caustics", GUILayout.MinWidth(180), GUILayout.MaxWidth(180));
							_target.RTP_VERTALPHA_CAUSTICS=EditorGUILayout.Toggle(_target.RTP_VERTALPHA_CAUSTICS);
							EditorGUILayout.EndHorizontal();
						}
					}
					if (!_target.RTP_CAUSTICS_FIRST && !_target.RTP_CAUSTICS_ADD) {
						_target.RTP_VERTALPHA_CAUSTICS=false;
					}
					
				// Water & caustics
				EditorGUILayout.EndVertical(); }
				
				GUILayout.Space(5);
								
				// IBL / Refl
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("Reflection & IBL features", EditorStyles.boldLabel);
//					EditorGUILayout.HelpBox("", MessageType.None, true);
							
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Reflection map", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						bool prev_reflection=_target.RTP_REFLECTION_ADD;
						_target.RTP_REFLECTION_ADD=EditorGUILayout.Toggle(_target.RTP_REFLECTION_ADD);
						if (prev_reflection!=_target.RTP_REFLECTION_ADD) {
							if (_target.RTP_SUPER_DETAIL_MULTS_ADD) {
								EditorUtility.DisplayDialog("Notification","Turning off superdetail mults feature", "OK");
								_target.RTP_SUPER_DETAIL_MULTS_ADD=false;
							}
						}				
					EditorGUILayout.EndHorizontal();
					EditorGUI.BeginDisabledGroup(!_target.RTP_REFLECTION_ADD);
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  Rotate reflection map", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
							_target.RTP_ROTATE_REFLECTION=EditorGUILayout.Toggle(_target.RTP_ROTATE_REFLECTION);
						EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
										
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("IBL diffuse (cube or SH)", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						_target.RTP_IBL_DIFFUSE_ADD=EditorGUILayout.Toggle(_target.RTP_IBL_DIFFUSE_ADD);
					EditorGUILayout.EndHorizontal();
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("IBL specular cubemap", GUILayout.MinWidth(160), GUILayout.MaxWidth(160));
						_target.RTP_IBL_SPEC_ADD=EditorGUILayout.Toggle(_target.RTP_IBL_SPEC_ADD);
					EditorGUILayout.EndHorizontal();
				// IBL / Reflections
				EditorGUILayout.EndVertical(); }
				
				GUILayout.Space(5);				
				
				// additional goodies
				{ EditorGUILayout.BeginVertical("Box");
				
					EditorGUILayout.LabelField("Additional features", EditorStyles.boldLabel);
	//				EditorGUILayout.HelpBox("", MessageType.None, true);	
						
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Sharpen heightblend edges", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS1_ADD=EditorGUILayout.Toggle(_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS1_ADD);
					EditorGUILayout.EndHorizontal();
					if (_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS1_ADD) {
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  Sharpen them even more", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
							_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS2_ADD=EditorGUILayout.Toggle(_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS2_ADD);
						EditorGUILayout.EndHorizontal();
					} else {
						_target.RTP_SHARPEN_HEIGHTBLEND_EDGES_PASS2_ADD=false;							
					}				
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Layer extrude reduction", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_USE_EXTRUDE_REDUCTION_ADD=EditorGUILayout.Toggle(_target.RTP_USE_EXTRUDE_REDUCTION_ADD);
					EditorGUILayout.EndHorizontal();
					
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Heightblend fake AO", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_HEIGHTBLEND_AO_ADD=EditorGUILayout.Toggle(_target.RTP_HEIGHTBLEND_AO_ADD);
					EditorGUILayout.EndHorizontal();
						
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Layer emission", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_EMISSION_ADD=EditorGUILayout.Toggle(_target.RTP_EMISSION_ADD);
					EditorGUILayout.EndHorizontal();	
					if (_target.RTP_EMISSION_ADD && _target.RTP_WETNESS_ADD && !_target.SIMPLE_WATER_ADD) {
						EditorGUILayout.HelpBox("When wetness is defined and fuild on surface is emissive we can mod its emissiveness by output normal (wrinkles of flowing\"water\"). Checkbox below below define change the way we treat output normals (this works fine for \"lava\" like emissive fuilds).", MessageType.None, true);
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  fluid normals wrap", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
							_target.RTP_FUILD_EMISSION_WRAP_ADD=EditorGUILayout.Toggle(_target.RTP_FUILD_EMISSION_WRAP_ADD);
						EditorGUILayout.EndHorizontal();
					}
					if (_target.RTP_EMISSION_ADD) {
						EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField("  hot air refraction", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
								_target.RTP_HOTAIR_EMISSION_ADD=EditorGUILayout.Toggle(_target.RTP_HOTAIR_EMISSION_ADD);
						EditorGUILayout.EndHorizontal();
					} else {
						_target.RTP_HOTAIR_EMISSION_ADD=false;
					}					
									
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Vertical texture map", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_VERTICAL_TEXTURE_ADD=EditorGUILayout.Toggle(_target.RTP_VERTICAL_TEXTURE_ADD);
					EditorGUILayout.EndHorizontal();
										
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("Superdetail", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						_target.RTP_SUPER_DETAIL_ADD=EditorGUILayout.Toggle(_target.RTP_SUPER_DETAIL_ADD);
					EditorGUILayout.EndHorizontal();
			
					EditorGUI.BeginDisabledGroup(!_target.RTP_SUPER_DETAIL_ADD);
					EditorGUILayout.BeginHorizontal();
						EditorGUILayout.LabelField("  Mult channels", GUILayout.MinWidth(170), GUILayout.MaxWidth(170));
						bool prev_superdetail=_target.RTP_SUPER_DETAIL_MULTS_ADD;
						_target.RTP_SUPER_DETAIL_MULTS_ADD=EditorGUILayout.Toggle(_target.RTP_SUPER_DETAIL_MULTS_ADD);
						if (prev_superdetail!=_target.RTP_SUPER_DETAIL_MULTS_ADD) {
							if (_target.RTP_WETNESS_ADD) {
								EditorUtility.DisplayDialog("Notification","Turning off water feature", "OK");
								_target.RTP_WETNESS_ADD=false;
							}
							if (_target.RTP_REFLECTION_ADD) {
								EditorUtility.DisplayDialog("Notification","Turning off reflections feature", "OK");
								_target.RTP_REFLECTION_ADD=false;
							}
						}				
					EditorGUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
											
	//				EditorGUI.BeginDisabledGroup(!_target.RTP_4LAYERS_MODE);
	//					EditorGUILayout.HelpBox("In 4 layers mode we can use shadow maps that speed-up shadow calculations (one color atlas also needed like in 8 layers mode).",MessageType.None, true);
	//					EditorGUILayout.BeginHorizontal();
	//						EditorGUILayout.LabelField("Self-shadow maps", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
	//						_target.RTP_MAPPED_SHADOWS_ADD=EditorGUILayout.Toggle(_target.RTP_MAPPED_SHADOWS_ADD);
	//					EditorGUILayout.EndHorizontal();
	//				EditorGUI.EndDisabledGroup();
			
	//				EditorGUILayout.Space();
	//				EditorGUILayout.Space();
					
					EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("Add-Pass Triplanar", GUILayout.MinWidth(145), GUILayout.MaxWidth(145));
					_target.RTP_TRIPLANAR_ADD=EditorGUILayout.Toggle(_target.RTP_TRIPLANAR_ADD);
					EditorGUILayout.EndHorizontal();
					
					EditorGUILayout.Space();
					
					EditorGUILayout.HelpBox("AddPass is automatically fired for terrain by Unity. However it WON'T be automatically fired for geometry blending base shader when needed.\n\nWhen 2 passes are present on the terrain you SHOULD check this option. DON'T check it when you've got one pass. If number of passes used changed you might need to recompile shaders for your geom blending object to start working fine.", MessageType.Error, true);
					EditorGUILayout.BeginHorizontal();
					EditorGUILayout.LabelField("AddPass for geometry blend base", GUILayout.MinWidth(200), GUILayout.MaxWidth(200));
					_target.ADDPASS_IN_BLENDBASE=EditorGUILayout.Toggle(_target.ADDPASS_IN_BLENDBASE);
					EditorGUILayout.EndHorizontal();
							
				// additional goodies
				EditorGUILayout.EndVertical(); }
				
				EditorGUILayout.Space();
			} // super-simple
		}
		EditorGUILayout.EndVertical(); // features - add pass				
		} //EOF if (used addpass shader)
		
		EditorGUILayout.Space();
	
		EditorGUILayout.BeginVertical("Box");

		EditorGUILayout.HelpBox("By default classic shading isn't \"pure classic\" but handles global colorMap and snow (if enabled). Disable this additional features when desired.",MessageType.None, true);
		EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField("Additional features in classic fallback", GUILayout.MinWidth(220), GUILayout.MaxWidth(220));
			_target.RTP_ADDITIONAL_FEATURES_IN_FALLBACKS=EditorGUILayout.Toggle(_target.RTP_ADDITIONAL_FEATURES_IN_FALLBACKS);
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.EndVertical();
	}
	
	public void RefreshFeatures() {
		force_rebuild=false;
		#if UNITY_5
		UseU5Deferred("Assets/ReliefPack/Shaders/ReliefTerrain/Internal/ReliefTerrainBlendBaseCutout.shader");
		#endif
		bool base_changed=RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/RTP_Base.cginc", false, false, false);
		bool add_changed=RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/RTP_AddBase.cginc", false, true, false);
		mainshaders_flag=true;
		force_rebuild=base_changed;
		RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/ReliefTerrain-FirstPass.shader", true, false, false);
		#if !UNITY_3_5
		force_rebuild=base_changed || add_changed;
		RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/ReliefTerrain-FarOnly.shader", true, false, false);
		#endif
		force_rebuild=add_changed;
		RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/ReliefTerrain-AddPass.shader", true, true, false);
		force_rebuild=base_changed;
		RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/ReliefTerrain2Geometry.shader", true, false, true, true);
		force_rebuild=base_changed || add_changed;
		RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/Internal/ReliefTerrainGeometryBlendBase.shader", true, false, false, true);
		force_rebuild=base_changed || add_changed;
		RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/Internal/ReliefTerrain2GeometryBlendBase.shader", true, false, true, true);
		mainshaders_flag=false;
		force_rebuild=false;
		RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/GeomBlendCompliant/GeometryBlend_BumpedDetailSnow.shader", true, false, false);
		RebuildFeaturesInFile("Assets/ReliefPack/Shaders/ReliefTerrain/GeomBlendCompliant/GeometryBlend_POMDetailSnow.shader", true, false, false);
		AssetDatabase.Refresh();
	}
示例#9
0
 public void GetGlobalSettingsHolder()
 {
     if (this.globalSettingsHolder == null)
     {
         ReliefTerrain[] array = (ReliefTerrain[])UnityEngine.Object.FindObjectsOfType(typeof(ReliefTerrain));
         bool flag = base.GetComponent(typeof(Terrain));
         for (int i = 0; i < array.Length; i++)
         {
             if (array[i].transform.parent == base.transform.parent && array[i].globalSettingsHolder != null && ((flag && array[i].GetComponent(typeof(Terrain)) != null) || (!flag && array[i].GetComponent(typeof(Terrain)) == null)))
             {
                 this.globalSettingsHolder = array[i].globalSettingsHolder;
                 if (this.globalSettingsHolder.Get_RTP_LODmanagerScript() && !this.globalSettingsHolder.Get_RTP_LODmanagerScript().RTP_WETNESS_FIRST && !this.globalSettingsHolder.Get_RTP_LODmanagerScript().RTP_WETNESS_ADD)
                 {
                     this.BumpGlobalCombined = array[i].BumpGlobalCombined;
                     this.globalCombinedModifed_flag = false;
                 }
                 break;
             }
         }
         if (this.globalSettingsHolder == null)
         {
             this.globalSettingsHolder = new ReliefTerrainGlobalSettingsHolder();
             if (flag)
             {
                 this.globalSettingsHolder.numTiles = 0;
                 Terrain terrain = (Terrain)base.GetComponent(typeof(Terrain));
                 this.globalSettingsHolder.splats = new Texture2D[terrain.terrainData.splatPrototypes.Length];
                 for (int j = 0; j < terrain.terrainData.splatPrototypes.Length; j++)
                 {
                     this.globalSettingsHolder.splats[j] = terrain.terrainData.splatPrototypes[j].texture;
                 }
             }
             else
             {
                 this.globalSettingsHolder.splats = new Texture2D[4];
             }
             this.globalSettingsHolder.numLayers = this.globalSettingsHolder.splats.Length;
             this.globalSettingsHolder.ReturnToDefaults(string.Empty, -1);
         }
         else if (flag)
         {
             this.GetSplatsFromGlobalSettingsHolder();
         }
         this.source_controls_mask = new Texture2D[12];
         this.source_controls = new Texture2D[12];
         this.source_controls_channels = new RTPColorChannels[12];
         this.source_controls_mask_channels = new RTPColorChannels[12];
         this.splat_layer_seq = new int[]
         {
             0,
             1,
             2,
             3,
             4,
             5,
             6,
             7,
             8,
             9,
             10,
             11
         };
         this.splat_layer_boost = new float[]
         {
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f,
             1f
         };
         this.splat_layer_calc = new bool[12];
         this.splat_layer_masked = new bool[12];
         this.source_controls_invert = new bool[12];
         this.source_controls_mask_invert = new bool[12];
         if (flag)
         {
             this.globalSettingsHolder.numTiles++;
         }
     }
 }