public void ApplyTerrainLODSettings(int val = -1) { Terrain activeTerrain = Terrain.activeTerrain; RTP_LODmanager rtp_LODmanager; if (activeTerrain == null) { rtp_LODmanager = null; } else { ReliefTerrain component = activeTerrain.gameObject.GetComponent <ReliefTerrain>(); rtp_LODmanager = ((component != null) ? component.globalSettingsHolder.Get_RTP_LODmanagerScript() : null); } RTP_LODmanager rtp_LODmanager2 = rtp_LODmanager; if (rtp_LODmanager2) { switch (val) { case 0: rtp_LODmanager2.RTP_LODlevel = TerrainShaderLod.SIMPLE; break; case 1: rtp_LODmanager2.RTP_LODlevel = TerrainShaderLod.PM; break; case 2: rtp_LODmanager2.RTP_LODlevel = TerrainShaderLod.POM; break; } rtp_LODmanager2.RefreshLODlevel(); } }
private void RefreshAll() { ReliefTerrain reliefTerrain = (ReliefTerrain)UnityEngine.Object.FindObjectOfType(typeof(ReliefTerrain)); if (reliefTerrain != null && reliefTerrain.globalSettingsHolder != null) { reliefTerrain.globalSettingsHolder.RefreshAll(); } }
void RefreshAll() { ReliefTerrain rt = (ReliefTerrain)GameObject.FindObjectOfType(typeof(ReliefTerrain)); if (rt != null && rt.globalSettingsHolder != null) { rt.globalSettingsHolder.RefreshAll(); } }
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(); } } }
private void Awake() { ReliefTerrain[] array = (ReliefTerrain[])UnityEngine.Object.FindObjectsOfType(typeof(ReliefTerrain)); for (int i = 0; i < array.Length; i++) { if (array[i].GetComponent(typeof(Terrain))) { this.rt = array[i]; break; } } this.RefreshLODlevel(); }
public void Refresh() { if (rtp == null) { rtp = MapMagic.instance.GetComponent <ReliefTerrain>(); } foreach (Chunk chunk in MapMagic.instance.chunks.All()) { Material mat = chunk.terrain.materialTemplate; rtp.RefreshTextures(mat); rtp.globalSettingsHolder.Refresh(mat, rtp); } }
public static void DrawRTPComponentWarning() { #if RTP if (GraphWindow.current.mapMagic == null) { return; } if (GraphWindow.current.mapMagic?.gameObject.GetComponent <ReliefTerrain>() == null || GraphWindow.current.mapMagic?.gameObject.GetComponent <Renderer>() == null) { using (Cell.LinePx(70)) { GUIStyle backStyle = UI.current.textures.GetElementStyle("DPUI/Backgrounds/Foldout"); using (Cell.Row) Draw.Label("RTP or Renderer \ncomponents are \nnot assigned to \nMapMagic object"); using (Cell.RowPx(30)) if (Draw.Button("Fix")) { if (GraphWindow.current.mapMagic.gameObject.GetComponent <Renderer>() == null) { MeshRenderer renderer = GraphWindow.current.mapMagic.gameObject.AddComponent <MeshRenderer>(); renderer.enabled = false; } if (GraphWindow.current.mapMagic.gameObject.GetComponent <ReliefTerrain>() == null) { ReliefTerrain rtp = GraphWindow.current.mapMagic.gameObject.AddComponent <ReliefTerrain>(); //filling empty splats Texture2D emptyTex = TextureExtensions.ColorTexture(4, 4, new Color(0.5f, 0.5f, 0.5f, 1f)); emptyTex.name = "Empty"; rtp.globalSettingsHolder.splats = new Texture2D[] { emptyTex, emptyTex, emptyTex, emptyTex }; } } } Cell.EmptyLinePx(5); } #endif }
public static void DrawRTPComponentWarning () { #if RTP if (MapMagic.instance.gameObject.GetComponent<ReliefTerrain>()==null || MapMagic.instance.gameObject.GetComponent<Renderer>()==null) { using (Cell.LinePx(70))) { Cell.current.margins = new Padding(4); GUIStyle backStyle = UI.current.textures.GetElementStyle("DPUI/Backgrounds/Foldout"); Draw.Element(backStyle, Cell.current); Draw.Element(backStyle, Cell.current); Draw.Label("RTP or Renderer \ncomponents are \nnot assigned to \nMapMagic object", cell:UI.Empty(Size.row)); if (Draw.Button("Fix", cell:UI.Empty(Size.RowPixels(30)))) { if (MapMagic.instance.gameObject.GetComponent<Renderer>() == null) { MeshRenderer renderer = MapMagic.instance.gameObject.AddComponent<MeshRenderer>(); renderer.enabled = false; } if (MapMagic.instance.gameObject.GetComponent<ReliefTerrain>() == null) { ReliefTerrain rtp = MapMagic.instance.gameObject.AddComponent<ReliefTerrain>(); //filling empty splats Texture2D emptyTex = TextureExtensions.ColorTexture(4,4,new Color(0.5f, 0.5f, 0.5f, 1f)); emptyTex.name = "Empty"; rtp.globalSettingsHolder.splats = new Texture2D[] { emptyTex,emptyTex,emptyTex,emptyTex }; } MapMagic.instance.OnSettingsChanged(); } } UI.Empty(Size.LinePixels(5)); } #endif }
public void RecalcControlMaps(Terrain terrainComp, ReliefTerrain rt) { float[,,] splatData=terrainComp.terrainData.GetAlphamaps(0,0,terrainComp.terrainData.alphamapResolution, terrainComp.terrainData.alphamapResolution); Color[] cols_control; float[,] norm_array=new float[terrainComp.terrainData.alphamapResolution,terrainComp.terrainData.alphamapResolution]; if (rt.splat_layer_ordered_mode) { // ordered mode for(int k=0; k<terrainComp.terrainData.alphamapLayers; k++) { int n=rt.splat_layer_seq[k]; // value for current layer if (rt.splat_layer_calc[n]) { int idx=0; if (rt.source_controls[n]) { cols_control=rt.source_controls[n].GetPixels(); } else { cols_control=new Color[terrainComp.terrainData.alphamapResolution*terrainComp.terrainData.alphamapResolution]; if (rt.source_controls_invert[n]) { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.black; } else { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.white; } } int channel_idx=(int)rt.source_controls_channels[n]; // apply mask if (rt.splat_layer_masked[n] && rt.source_controls_mask[n]) { Color[] cols_mask=rt.source_controls_mask[n].GetPixels(); idx=0; int channel_idx_mask=(int)rt.source_controls_mask_channels[n]; for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { cols_control[idx][channel_idx]*=cols_mask[idx][channel_idx_mask]; idx++; } } idx=0; } for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { norm_array[i,j]=cols_control[idx++][channel_idx]*rt.splat_layer_boost[n]; if (norm_array[i,j]>1) norm_array[i,j]=1; } } } else { for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { norm_array[i,j]=splatData[i,j,n]; if (norm_array[i,j]>1) norm_array[i,j]=1; } } } // damp underlying layers for(int l=0; l<k; l++) { int m=rt.splat_layer_seq[l]; for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { splatData[i,j,m]*=(1-norm_array[i,j]); } } } // write current layer if (rt.splat_layer_calc[n]) { int idx=0; if (rt.source_controls[n]) { cols_control=rt.source_controls[n].GetPixels(); } else { cols_control=new Color[terrainComp.terrainData.alphamapResolution*terrainComp.terrainData.alphamapResolution]; if (rt.source_controls_invert[n]) { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.black; } else { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.white; } } int channel_idx=(int)rt.source_controls_channels[n]; // apply mask if (rt.splat_layer_masked[n] && rt.source_controls_mask[n]) { Color[] cols_mask=rt.source_controls_mask[n].GetPixels(); idx=0; int channel_idx_mask=(int)rt.source_controls_mask_channels[n]; for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { cols_control[idx][channel_idx]*=cols_mask[idx][channel_idx_mask]; idx++; } } idx=0; } for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { splatData[i,j,n]=cols_control[idx++][channel_idx]*rt.splat_layer_boost[n]; if (splatData[i,j,n]>1) splatData[i,j,n]=1; } } } } } else { // unordered mode for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { norm_array[i,j]=0; } } for(int n=0; n<terrainComp.terrainData.alphamapLayers; n++) { if (rt.splat_layer_calc[n]) { int idx=0; if (rt.source_controls[n]) { cols_control=rt.source_controls[n].GetPixels(); } else { cols_control=new Color[terrainComp.terrainData.alphamapResolution*terrainComp.terrainData.alphamapResolution]; if (rt.source_controls_invert[n]) { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.black; } else { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.white; } } int channel_idx=(int)rt.source_controls_channels[n]; // apply mask if (rt.splat_layer_masked[n] && rt.source_controls_mask[n]) { Color[] cols_mask=rt.source_controls_mask[n].GetPixels(); idx=0; int channel_idx_mask=(int)rt.source_controls_mask_channels[n]; for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { cols_control[idx][channel_idx]*=cols_mask[idx][channel_idx_mask]; idx++; } } idx=0; } for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { norm_array[i,j]+=cols_control[idx++][channel_idx]*rt.splat_layer_boost[n]; } } } else { for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { norm_array[i,j]+=splatData[i,j,n]; } } } } for(int n=0; n<terrainComp.terrainData.alphamapLayers; n++) { if (rt.splat_layer_calc[n]) { int idx=0; if (rt.source_controls[n]) { cols_control=rt.source_controls[n].GetPixels(); } else { cols_control=new Color[terrainComp.terrainData.alphamapResolution*terrainComp.terrainData.alphamapResolution]; if (rt.source_controls_invert[n]) { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.black; } else { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.white; } } int channel_idx=(int)rt.source_controls_channels[n]; // apply mask if (rt.splat_layer_masked[n] && rt.source_controls_mask[n]) { Color[] cols_mask=rt.source_controls_mask[n].GetPixels(); idx=0; int channel_idx_mask=(int)rt.source_controls_mask_channels[n]; for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { cols_control[idx][channel_idx]*=cols_mask[idx][channel_idx_mask]; idx++; } } idx=0; } for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { splatData[i,j,n]=cols_control[idx++][channel_idx]*rt.splat_layer_boost[n]/norm_array[i,j]; } } } else { for(int i=0; i<terrainComp.terrainData.alphamapResolution; i++) { for(int j=0; j<terrainComp.terrainData.alphamapResolution; j++) { splatData[i,j,n]=splatData[i,j,n]/norm_array[i,j]; } } } } } terrainComp.terrainData.SetAlphamaps(0,0, splatData); }
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; }
private void SetTexturesToTerrain(Terrain t) { #if UNITY_2018_3_OR_NEWER #if !RTP Texture2D texture = GetTexture(t); float tsx = prefs.textureWidth - 4; float tsy = prefs.textureHeight - 4; Vector2 tileSize = new Vector2(t.terrainData.size.x + t.terrainData.size.x / tsx * 4, t.terrainData.size.z + t.terrainData.size.z / tsy * 4); Vector2 tileOffset = new Vector2(t.terrainData.size.x / prefs.textureWidth / 2, t.terrainData.size.z / prefs.textureHeight / 2); TerrainLayer tl = new TerrainLayer { tileSize = tileSize, tileOffset = tileOffset, diffuseTexture = texture }; t.terrainData.terrainLayers = new[] { tl }; #else LoadRTPTextures(); TerrainLayer[] tls = new TerrainLayer[4]; for (int i = 0; i < 4; i++) { tls[i] = new TerrainLayer { diffuseTexture = rtpTextures[i * 3] }; } t.terrainData.terrainLayers = tls; ReliefTerrain reliefTerrain = t.gameObject.GetComponent <ReliefTerrain>() ?? t.gameObject.AddComponent <ReliefTerrain>(); reliefTerrain.InitArrays(); reliefTerrain.ColorGlobal = GetTexture(t); #endif #else #if !RTP Texture2D texture = GetTexture(t); float tsx = prefs.textureWidth - 4; float tsy = prefs.textureHeight - 4; Vector2 tileSize = new Vector2(t.terrainData.size.x + t.terrainData.size.x / tsx * 4, t.terrainData.size.z + t.terrainData.size.z / tsy * 4); Vector2 tileOffset = new Vector2(t.terrainData.size.x / prefs.textureWidth / 2, t.terrainData.size.z / prefs.textureHeight / 2); SplatPrototype sp = new SplatPrototype { tileSize = tileSize, tileOffset = tileOffset, texture = texture }; t.terrainData.splatPrototypes = new [] { sp }; #else LoadRTPTextures(); SplatPrototype[] sps = new SplatPrototype[4]; for (int i = 0; i < 4; i++) { sps[i] = new SplatPrototype { texture = rtpTextures[i * 3] }; } t.terrainData.splatPrototypes = sps; ReliefTerrain reliefTerrain = t.gameObject.GetComponent <ReliefTerrain>() ?? t.gameObject.AddComponent <ReliefTerrain>(); reliefTerrain.InitArrays(); reliefTerrain.ColorGlobal = GetTexture(t); #endif #endif }
private void UpdateTextureCamera(Terrain t) { int mLayer = 1 << prefs.meshLayer; float raycastDistance = maxBounds.y - minBounds.y + 10; Vector3 vScale = t.terrainData.size; float tsx = prefs.textureResolution + 1; float tsy = prefs.textureResolution + 1; vScale.x = vScale.x / tsx; vScale.z = vScale.z / tsy; Vector3 beginPoint = t.transform.position; if (prefs.direction == MeshToTerrainDirection.normal) { beginPoint.y += raycastDistance; } else { beginPoint.y = maxBounds.y - raycastDistance; } Vector3 curPoint = beginPoint + new Vector3(prefs.textureResolution / 2 * vScale.x, 0, prefs.textureResolution / 2 * vScale.z); GameObject cameraGO = new GameObject("__Mesh to Terrain Camera__"); Camera camera = cameraGO.AddComponent <Camera>(); cameraGO.transform.position = curPoint; cameraGO.transform.rotation = Quaternion.Euler(prefs.direction == MeshToTerrainDirection.normal? 90: -90, 0, 0); camera.orthographic = true; camera.orthographicSize = boundsRange.x / 2 / prefs.newTerrainCountX; camera.clearFlags = CameraClearFlags.Color; camera.backgroundColor = prefs.textureEmptyColor; camera.cullingMask = mLayer; camera.targetTexture = new RenderTexture(prefs.textureResolution, prefs.textureResolution, 16); RenderTexture currentRT = RenderTexture.active; RenderTexture.active = camera.targetTexture; camera.Render(); Texture2D texture = new Texture2D(prefs.textureResolution, prefs.textureResolution); texture.ReadPixels(new Rect(0, 0, prefs.textureResolution, prefs.textureResolution), 0, 0); texture.Apply(); RenderTexture.active = currentRT; string textureFilename = Path.Combine(resultFolder, t.name + ".png"); File.WriteAllBytes(textureFilename, texture.EncodeToPNG()); AssetDatabase.Refresh(); TextureImporter importer = AssetImporter.GetAtPath(textureFilename) as TextureImporter; if (importer != null) { importer.maxTextureSize = Mathf.Max(prefs.textureWidth, prefs.textureHeight); importer.wrapMode = TextureWrapMode.Clamp; AssetDatabase.ImportAsset(textureFilename, ImportAssetOptions.ForceUpdate); } texture = (Texture2D)AssetDatabase.LoadAssetAtPath(textureFilename, typeof(Texture2D)); DestroyImmediate(cameraGO); #if !RTP Vector2 tileSize = new Vector2( t.terrainData.size.x / prefs.textureResolution * (prefs.textureResolution + 2), t.terrainData.size.z / prefs.textureResolution * (prefs.textureResolution + 2)); Vector2 tileOffset = new Vector2( t.terrainData.size.x / prefs.textureResolution / 2, t.terrainData.size.z / prefs.textureResolution / 2); #if UNITY_2018_3_OR_NEWER TerrainLayer l = new TerrainLayer { tileSize = tileSize, tileOffset = tileOffset, diffuseTexture = texture }; string layerPath = Path.Combine(resultFolder, t.name + ".terrainlayer"); AssetDatabase.CreateAsset(l, layerPath); AssetDatabase.Refresh(); t.terrainData.terrainLayers = new[] { AssetDatabase.LoadAssetAtPath <TerrainLayer>(layerPath) }; #else SplatPrototype sp = new SplatPrototype { tileSize = tileSize, tileOffset = tileOffset, texture = texture }; t.terrainData.splatPrototypes = new[] { sp }; #endif #else LoadRTPTextures(); #if UNITY_2018_3_OR_NEWER TerrainLayer[] ls = new TerrainLayer[4]; for (int i = 0; i < 4; i++) { TerrainLayer l = ls[i] = new TerrainLayer { diffuseTexture = rtpTextures[i * 3] }; string layerPath = Path.Combine(resultFolder, t.name + " " + i + ".terrainlayer"); AssetDatabase.CreateAsset(l, layerPath); AssetDatabase.Refresh(); ls[i] = AssetDatabase.LoadAssetAtPath <TerrainLayer>(layerPath); } t.terrainData.terrainLayers = ls; #else SplatPrototype[] sps = new SplatPrototype[4]; for (int i = 0; i < 4; i++) { sps[i] = new SplatPrototype { texture = rtpTextures[i * 3] }; } t.terrainData.splatPrototypes = sps; #endif ReliefTerrain reliefTerrain = t.gameObject.GetComponent <ReliefTerrain>() ?? t.gameObject.AddComponent <ReliefTerrain>(); reliefTerrain.InitArrays(); reliefTerrain.ColorGlobal = texture; #endif activeIndex++; progress = activeIndex / (float)prefs.terrains.Count; if (activeIndex >= prefs.terrains.Count) { activeIndex = 0; phase = MeshToTerrainPhase.finish; } }
public void SetupValues() { if (this.blendedObject && (this.blendedObject.GetComponent(typeof(MeshRenderer)) != null || this.blendedObject.GetComponent(typeof(Terrain)) != null)) { if (this.underlying_transform == null) { this.underlying_transform = base.transform.Find("RTP_blend_underlying"); } if (this.underlying_transform != null) { GameObject gameObject = this.underlying_transform.gameObject; this.underlying_renderer = (MeshRenderer)gameObject.GetComponent(typeof(MeshRenderer)); } if (this.underlying_renderer != null && this.underlying_renderer.sharedMaterial != null) { ReliefTerrain reliefTerrain = (ReliefTerrain)this.blendedObject.GetComponent(typeof(ReliefTerrain)); if (reliefTerrain) { Material sharedMaterial = this.underlying_renderer.sharedMaterial; reliefTerrain.RefreshTextures(sharedMaterial, false); reliefTerrain.globalSettingsHolder.Refresh(sharedMaterial, null); if (sharedMaterial.HasProperty("RTP_DeferredAddPassSpec")) { sharedMaterial.SetFloat("RTP_DeferredAddPassSpec", this._DeferredBlendGloss); } if (reliefTerrain.controlA) { sharedMaterial.SetTexture("_Control", reliefTerrain.controlA); } if (reliefTerrain.ColorGlobal) { sharedMaterial.SetTexture("_Splat0", reliefTerrain.ColorGlobal); } if (reliefTerrain.NormalGlobal) { sharedMaterial.SetTexture("_Splat1", reliefTerrain.NormalGlobal); } if (reliefTerrain.TreesGlobal) { sharedMaterial.SetTexture("_Splat2", reliefTerrain.TreesGlobal); } if (reliefTerrain.BumpGlobalCombined) { sharedMaterial.SetTexture("_Splat3", reliefTerrain.BumpGlobalCombined); } } Terrain terrain = (Terrain)this.blendedObject.GetComponent(typeof(Terrain)); if (terrain) { this.underlying_renderer.lightmapIndex = terrain.lightmapIndex; this.underlying_renderer.lightmapScaleOffset = terrain.lightmapScaleOffset; this.underlying_renderer.realtimeLightmapIndex = terrain.realtimeLightmapIndex; this.underlying_renderer.realtimeLightmapScaleOffset = terrain.realtimeLightmapScaleOffset; } else { this.underlying_renderer.lightmapIndex = this.blendedObject.GetComponent <Renderer>().lightmapIndex; this.underlying_renderer.lightmapScaleOffset = this.blendedObject.GetComponent <Renderer>().lightmapScaleOffset; this.underlying_renderer.realtimeLightmapIndex = this.blendedObject.GetComponent <Renderer>().realtimeLightmapIndex; this.underlying_renderer.realtimeLightmapScaleOffset = this.blendedObject.GetComponent <Renderer>().realtimeLightmapScaleOffset; } if (this.Sticked) { if (terrain) { base.GetComponent <Renderer>().lightmapIndex = terrain.lightmapIndex; base.GetComponent <Renderer>().lightmapScaleOffset = terrain.lightmapScaleOffset; base.GetComponent <Renderer>().realtimeLightmapIndex = terrain.realtimeLightmapIndex; base.GetComponent <Renderer>().realtimeLightmapScaleOffset = terrain.realtimeLightmapScaleOffset; return; } base.GetComponent <Renderer>().lightmapIndex = this.blendedObject.GetComponent <Renderer>().lightmapIndex; base.GetComponent <Renderer>().lightmapScaleOffset = this.blendedObject.GetComponent <Renderer>().lightmapScaleOffset; base.GetComponent <Renderer>().realtimeLightmapIndex = this.blendedObject.GetComponent <Renderer>().realtimeLightmapIndex; base.GetComponent <Renderer>().realtimeLightmapScaleOffset = this.blendedObject.GetComponent <Renderer>().realtimeLightmapScaleOffset; } } } }
public override void OnGUI(GeneratorsAsset gens) { #if RTP if (rtp == null) { rtp = MapMagic.instance.GetComponent <ReliefTerrain>(); } if (renderer == null) { renderer = MapMagic.instance.GetComponent <MeshRenderer>(); } //wrong material and settings warnings if (MapMagic.instance.copyComponents) { layout.Par(42); layout.Label("Copy Component should be turned off to prevent copying RTP to chunks.", rect: layout.Inset(0.8f), helpbox: true); if (layout.Button("Fix", rect: layout.Inset(0.2f))) { MapMagic.instance.copyComponents = false; } } if (rtp == null) { layout.Par(42); layout.Label("Could not find Relief Terrain component on MapMagic object.", rect: layout.Inset(0.8f), helpbox: true); if (layout.Button("Fix", rect: layout.Inset(0.2f))) { renderer = MapMagic.instance.gameObject.GetComponent <MeshRenderer>(); if (renderer == null) { renderer = MapMagic.instance.gameObject.AddComponent <MeshRenderer>(); } renderer.enabled = false; rtp = MapMagic.instance.gameObject.AddComponent <ReliefTerrain>(); //if (MapMagic.instance.gameObject.GetComponent<InstantUpdater>()==null) MapMagic.instance.gameObject.AddComponent<InstantUpdater>(); //filling empty splats Texture2D emptyTex = Extensions.ColorTexture(4, 4, new Color(0.5f, 0.5f, 0.5f, 1f)); emptyTex.name = "Empty"; rtp.globalSettingsHolder.splats = new Texture2D[] { emptyTex, emptyTex, emptyTex, emptyTex }; } } if (MapMagic.instance.terrainMaterialType != Terrain.MaterialType.Custom) { layout.Par(30); layout.Label("Material Type is not switched to Custom.", rect: layout.Inset(0.8f), helpbox: true); if (layout.Button("Fix", rect: layout.Inset(0.2f))) { MapMagic.instance.terrainMaterialType = Terrain.MaterialType.Custom; foreach (Chunk tw in MapMagic.instance.chunks.All()) { tw.SetSettings(); } } } if (MapMagic.instance.assignCustomTerrainMaterial) { layout.Par(30); layout.Label("Assign Custom Material is turned on.", rect: layout.Inset(0.8f), helpbox: true); if (layout.Button("Fix", rect: layout.Inset(0.2f))) { MapMagic.instance.assignCustomTerrainMaterial = false; } } if (MapMagic.instance.GetComponent <InstantUpdater>() == null) { layout.Par(52); layout.Label("Use Instant Updater component to apply RTP changes to all the terrains.", rect: layout.Inset(0.8f), helpbox: true); if (layout.Button("Fix", rect: layout.Inset(0.2f))) { MapMagic.instance.gameObject.AddComponent <InstantUpdater>(); } } /*if (!MapMagic.instance.materialTemplateMode) * { * layout.Par(30); * layout.Label("Material Template Mode is off.", rect:layout.Inset(0.8f), helpbox:true); * if (layout.Button("Fix",rect:layout.Inset(0.2f))) MapMagic.instance.materialTemplateMode = true; * }*/ /*if ((renderer != null) && * (renderer.sharedMaterial == null || !renderer.sharedMaterial.shader.name.Contains("ReliefTerrain"))) * { * layout.Par(50); * layout.Label("No Relief Terrain material is assigned as Custom Material in Terrain Settings.", rect:layout.Inset(0.8f), helpbox:true); * if (layout.Button("Fix",rect:layout.Inset(0.2f))) * { * //if (renderer.sharedMaterial == null) * //{ * Shader shader = Shader.Find("Relief Pack/ReliefTerrain-FirstPass"); * if (shader != null) renderer.sharedMaterial = new Material(shader); * else Debug.Log ("MapMagic: Could not find Relief Pack/ReliefTerrain-FirstPass shader. Make sure RTP is installed or switch material type to Standard."); * //} * MapMagic.instance.customTerrainMaterial = renderer.sharedMaterial; * foreach (Chunk tw in MapMagic.instance.chunks.All()) tw.SetSettings(); * } * }*/ if (rtp == null) { return; } bool doubleLayer = false; for (int i = 0; i < baseLayers.Length; i++) { for (int j = 0; j < baseLayers.Length; j++) { if (i == j) { continue; } if (baseLayers[i].index == baseLayers[j].index) { doubleLayer = true; } } } if (doubleLayer) { layout.Par(30); layout.Label("Seems that multiple layers use the same splat index.", rect: layout.Inset(0.8f), helpbox: true); if (layout.Button("Fix", rect: layout.Inset(0.2f))) { ResetLayers(baseLayers.Length); } } //refreshing layers from rtp Texture2D[] splats = rtp.globalSettingsHolder.splats; if (baseLayers.Length != splats.Length) { ResetLayers(splats.Length); } //drawing layers layout.margin = 20; layout.rightMargin = 20; layout.fieldSize = 1f; for (int i = baseLayers.Length - 1; i >= 0; i--) { //if (baseLayers[i] == null) //baseLayers[i] = new Layer(); if (layout.DrawWithBackground(OnLayerGUI, active:i == selected, num:i, frameDisabled:false)) { selected = i; } } layout.Par(3); layout.Par(); //layout.DrawArrayAdd(ref baseLayers, ref selected, layout.Inset(0.25f)); //layout.DrawArrayRemove(ref baseLayers, ref selected, layout.Inset(0.25f)); layout.DrawArrayUp(ref baseLayers, ref selected, layout.Inset(0.25f), reverseOrder: true); layout.DrawArrayDown(ref baseLayers, ref selected, layout.Inset(0.25f), reverseOrder: true); layout.margin = 3; layout.rightMargin = 3; layout.Par(64); layout.Label("Use Relief Terrain component to set layer properties. \"Refresh All\" in RTP settings might be required.", rect: layout.Inset(), helpbox: true); #else layout.margin = 5; layout.rightMargin = 5; layout.Par(45); layout.Label("Cannot find Relief Terrain plugin. Restart Unity if you have just installed it.", rect: layout.Inset(), helpbox: true); #endif }
void OnGUI() { if (!LODmanager) { GetLODManager(); return; } GUILayout.Space(10); GUILayout.BeginVertical("box"); GUILayout.Label("" + FPSmeter.fps); if (panel_enabled) { shadows = GUILayout.Toggle(shadows, "disable Unity's shadows"); Light light = GameObject.Find("Directional light").GetComponent <Light>() as Light; light.shadows = shadows ? LightShadows.None : LightShadows.Soft; forward_path = GUILayout.Toggle(forward_path, "forward rendering"); Camera cam = GameObject.Find("Main Camera").GetComponent <Camera>() as Camera; cam.renderingPath = forward_path ? RenderingPath.Forward : RenderingPath.DeferredShading; if (forward_path) { RenderSettings.ambientLight = new Color32(25, 25, 25, 0); } else { RenderSettings.ambientLight = new Color32(93, 103, 122, 0); } // water = GUILayout.Toggle(water, "show water"); //#if UNITY_3_5 // go_water.active=water; //#else // go_water.SetActive(water); //#endif TerrainShaderLod pom = LODmanager.RTP_LODlevel; TerrainShaderLod npom = pom; switch (pom) { case TerrainShaderLod.POM: if (GUILayout.Button("POM shading")) { npom = TerrainShaderLod.PM; } break; case TerrainShaderLod.PM: if (GUILayout.Button("PM shading")) { npom = TerrainShaderLod.SIMPLE; } break; case TerrainShaderLod.SIMPLE: if (GUILayout.Button("SIMPLE shading")) { npom = TerrainShaderLod.POM; //npom =TerrainShaderLod.CLASSIC; } break; //case TerrainShaderLod.CLASSIC: // if (GUILayout.Button("CLASSIC shading")) npom=TerrainShaderLod.POM; //break; } switch (npom) { case TerrainShaderLod.POM: if (npom != pom) { Terrain terrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain))) as Terrain; ReliefTerrain script = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; script.globalSettingsHolder.Refresh(); LODmanager.RTP_LODlevel = TerrainShaderLod.POM; LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.PM: if (npom != pom) { Terrain terrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain))) as Terrain; ReliefTerrain script = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; script.globalSettingsHolder.Refresh(); LODmanager.RTP_LODlevel = TerrainShaderLod.PM; LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.SIMPLE: if (npom != pom) { Terrain terrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain))) as Terrain; ReliefTerrain script = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; script.globalSettingsHolder.Refresh(); LODmanager.RTP_LODlevel = TerrainShaderLod.SIMPLE; LODmanager.RefreshLODlevel(); } break; //case TerrainShaderLod.CLASSIC: // if (npom!=pom) { // Terrain terrain=(GameObject.Find("Terrain").GetComponent (typeof(Terrain))) as Terrain; // ReliefTerrain script=terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; // script.globalSettingsHolder.Refresh(); // LODmanager.RTP_LODlevel=TerrainShaderLod.CLASSIC; // LODmanager.RefreshLODlevel(); // } //break; } pom = npom; if (pom == TerrainShaderLod.POM) { terrain_self_shadow = LODmanager.RTP_SHADOWS; bool nterrain_self_shadow = GUILayout.Toggle(terrain_self_shadow, "self shadowing"); if (nterrain_self_shadow != terrain_self_shadow) { LODmanager.RTP_SHADOWS = nterrain_self_shadow; LODmanager.RefreshLODlevel(); } terrain_self_shadow = nterrain_self_shadow; if (terrain_self_shadow) { terrain_smooth_shadows = LODmanager.RTP_SOFT_SHADOWS; bool nterrain_smooth_shadows = GUILayout.Toggle(terrain_smooth_shadows, "smooth shadows"); if (nterrain_smooth_shadows != terrain_smooth_shadows) { LODmanager.RTP_SOFT_SHADOWS = nterrain_smooth_shadows; LODmanager.RefreshLODlevel(); } terrain_smooth_shadows = nterrain_smooth_shadows; } } if (LODmanager.RTP_SNOW_FIRST) { Terrain terrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain))) as Terrain; ReliefTerrain script = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; GUILayout.BeginHorizontal(); GUILayout.Label("Snow", GUILayout.MaxWidth(40)); float nval = GUILayout.HorizontalSlider(script.globalSettingsHolder._snow_strength, 0, 1); if (nval != script.globalSettingsHolder._snow_strength) { script.globalSettingsHolder._snow_strength = nval; script.globalSettingsHolder.Refresh(); } GUILayout.EndHorizontal(); } GUILayout.Label("Light", GUILayout.MaxWidth(40)); light_dir = GUILayout.HorizontalSlider(light_dir, 0, 360); light.transform.rotation = Quaternion.Euler(40, light_dir, 0); // GUILayout.Label ("Interp", GUILayout.MaxWidth(40)); // float n_interp = GUILayout.HorizontalSlider(preset_param_interp, 0, 1); // if (n_interp!=preset_param_interp) { // preset_param_interp=n_interp; // Terrain terrain=(GameObject.Find("Terrain").GetComponent (typeof(Terrain))) as Terrain; // ReliefTerrain script=terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; // ReliefTerrainPresetHolder holderA=script.GetPresetByName("terrain stateA"); // ReliefTerrainPresetHolder holderB=script.GetPresetByName("terrain stateB"); // if (holderA!=null && holderB!=null) { // script.InterpolatePresets(holderA.PresetID, holderB.PresetID, preset_param_interp); // script.globalSettingsHolder.Refresh(); // } // } if (!Application.isWebPlayer) { if (GUILayout.Button("QUIT")) { Application.Quit(); } } GUILayout.Label(" F (hold) - freeze camera"); GUILayout.Label(" ,/. - change cam position"); } else { if (!Application.isWebPlayer) { if (GUILayout.Button("QUIT")) { Application.Quit(); } } } GUILayout.Label(" P - toggle panel"); GUILayout.EndVertical(); }
public void RefreshLODlevel() { ReliefTerrain[] rts = (ReliefTerrain[])GameObject.FindObjectsOfType(typeof(ReliefTerrain)); ReliefTerrain rt = null; for (int i = 0; i < rts.Length; i++) { if (rts[i].GetComponent(typeof(Terrain))) { rt = rts[i]; break; } } if (rt != null && rt.globalSettingsHolder != null) { if (terrain_shader == null) { terrain_shader = Shader.Find("Relief Pack/ReliefTerrain-FirstPass"); } if (terrain_shader_add == null) { terrain_shader_add = Shader.Find("Hidden/Relief Pack/ReliefTerrain-AddPass"); } } else { if (terrain_shader == null) { terrain_shader = Shader.Find("Hidden/TerrainEngine/Splatmap/Lightmap-FirstPass"); } if (terrain_shader_add == null) { terrain_shader_add = Shader.Find("Hidden/TerrainEngine/Splatmap/Lightmap-AddPass"); } if (terrain_shader == null) { terrain_shader = Shader.Find("Nature/Terrain/Diffuse"); } if (terrain_shader_add == null) { terrain_shader_add = Shader.Find("Hidden/TerrainEngine/Splatmap/Diffuse-AddPass"); } } if (terrain_shader_far == null) { terrain_shader_far = Shader.Find("Hidden/Relief Pack/ReliefTerrain-FarOnly"); } if (terrain2geom_shader == null) { terrain2geom_shader = Shader.Find("Relief Pack/Terrain2Geometry"); } if (terrain_geomBlend_shader == null) { terrain_geomBlend_shader = Shader.Find("Hidden/Relief Pack/ReliefTerrainGeometryBlendBase"); } if (terrain2geom_geomBlend_shader == null) { terrain2geom_geomBlend_shader = Shader.Find("Hidden/Relief Pack/ReliefTerrain2GeometryBlendBase"); } if (terrain_geomBlend_GeometryBlend_BumpedDetailSnow == null) { terrain_geomBlend_GeometryBlend_BumpedDetailSnow = Shader.Find("Relief Pack - GeometryBlend/Bumped Detail Snow"); } if (geomblend_GeometryBlend_WaterShader_2VertexPaint_HB == null) { geomblend_GeometryBlend_WaterShader_2VertexPaint_HB = Shader.Find("Relief Pack - GeometryBlend/Water/2 Layers/ HeightBlend"); } if (geomBlend_GeometryBlend_WaterShader_FlowMap_HB == null) { geomBlend_GeometryBlend_WaterShader_FlowMap_HB = Shader.Find("Relief Pack - GeometryBlend/Water/ FlowMap - HeightBlend"); } int maxLOD; //if (RTP_LODlevel==TerrainShaderLod.CLASSIC) { // maxLOD=100; //} else { { maxLOD = 700; if (RTP_LODlevel == TerrainShaderLod.POM) { if (RTP_SHADOWS) { if (RTP_SOFT_SHADOWS) { Shader.EnableKeyword("RTP_POM_SHADING_HI"); Shader.DisableKeyword("RTP_POM_SHADING_MED"); Shader.DisableKeyword("RTP_POM_SHADING_LO"); } else { Shader.EnableKeyword("RTP_POM_SHADING_MED"); Shader.DisableKeyword("RTP_POM_SHADING_HI"); Shader.DisableKeyword("RTP_POM_SHADING_LO"); } } else { Shader.EnableKeyword("RTP_POM_SHADING_LO"); Shader.DisableKeyword("RTP_POM_SHADING_MED"); Shader.DisableKeyword("RTP_POM_SHADING_HI"); } Shader.DisableKeyword("RTP_PM_SHADING"); Shader.DisableKeyword("RTP_SIMPLE_SHADING"); } else if (RTP_LODlevel == TerrainShaderLod.PM) { Shader.DisableKeyword("RTP_POM_SHADING_HI"); Shader.DisableKeyword("RTP_POM_SHADING_MED"); Shader.DisableKeyword("RTP_POM_SHADING_LO"); Shader.EnableKeyword("RTP_PM_SHADING"); Shader.DisableKeyword("RTP_SIMPLE_SHADING"); } else { Shader.DisableKeyword("RTP_POM_SHADING_HI"); Shader.DisableKeyword("RTP_POM_SHADING_MED"); Shader.DisableKeyword("RTP_POM_SHADING_LO"); Shader.DisableKeyword("RTP_PM_SHADING"); Shader.EnableKeyword("RTP_SIMPLE_SHADING"); } } if (terrain_shader != null) { terrain_shader.maximumLOD = maxLOD; } if (terrain_shader_far != null) { terrain_shader_far.maximumLOD = maxLOD; } if (terrain_shader_add != null) { terrain_shader_add.maximumLOD = maxLOD; } if (terrain2geom_shader != null) { terrain2geom_shader.maximumLOD = maxLOD; } if (terrain_geomBlend_shader != null) { terrain_geomBlend_shader.maximumLOD = maxLOD; } if (terrain2geom_geomBlend_shader != null) { terrain2geom_geomBlend_shader.maximumLOD = maxLOD; } if (terrain_geomBlend_GeometryBlend_BumpedDetailSnow != null) { terrain_geomBlend_GeometryBlend_BumpedDetailSnow.maximumLOD = maxLOD; } if (geomblend_GeometryBlend_WaterShader_2VertexPaint_HB != null) { geomblend_GeometryBlend_WaterShader_2VertexPaint_HB.maximumLOD = maxLOD; } if (geomBlend_GeometryBlend_WaterShader_FlowMap_HB != null) { geomBlend_GeometryBlend_WaterShader_FlowMap_HB.maximumLOD = maxLOD; } }
private void OnGUI() { if (!this.LODmanager) { this.GetLODManager(); return; } GUILayout.Space(10f); GUILayout.BeginVertical("box", Array.Empty <GUILayoutOption>()); GUILayout.Label(string.Concat(FPSmeter.fps), Array.Empty <GUILayoutOption>()); if (this.panel_enabled) { this.shadows = GUILayout.Toggle(this.shadows, "disable Unity's shadows", Array.Empty <GUILayoutOption>()); Light component = GameObject.Find("Directional light").GetComponent <Light>(); component.shadows = (this.shadows ? LightShadows.None : LightShadows.Soft); this.forward_path = GUILayout.Toggle(this.forward_path, "forward rendering", Array.Empty <GUILayoutOption>()); GameObject.Find("Main Camera").GetComponent <Camera>().renderingPath = (this.forward_path ? RenderingPath.Forward : RenderingPath.DeferredShading); if (this.forward_path) { RenderSettings.ambientLight = new Color32(25, 25, 25, 0); } else { RenderSettings.ambientLight = new Color32(93, 103, 122, 0); } TerrainShaderLod rtp_LODlevel = this.LODmanager.RTP_LODlevel; TerrainShaderLod terrainShaderLod = rtp_LODlevel; switch (rtp_LODlevel) { case TerrainShaderLod.POM: if (GUILayout.Button("POM shading", Array.Empty <GUILayoutOption>())) { terrainShaderLod = TerrainShaderLod.PM; } break; case TerrainShaderLod.PM: if (GUILayout.Button("PM shading", Array.Empty <GUILayoutOption>())) { terrainShaderLod = TerrainShaderLod.SIMPLE; } break; case TerrainShaderLod.SIMPLE: if (GUILayout.Button("SIMPLE shading", Array.Empty <GUILayoutOption>())) { terrainShaderLod = TerrainShaderLod.POM; } break; } switch (terrainShaderLod) { case TerrainShaderLod.POM: if (terrainShaderLod != rtp_LODlevel) { ((GameObject.Find("Terrain").GetComponent(typeof(Terrain)) as Terrain).GetComponent(typeof(ReliefTerrain)) as ReliefTerrain).globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.POM; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.PM: if (terrainShaderLod != rtp_LODlevel) { ((GameObject.Find("Terrain").GetComponent(typeof(Terrain)) as Terrain).GetComponent(typeof(ReliefTerrain)) as ReliefTerrain).globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.PM; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.SIMPLE: if (terrainShaderLod != rtp_LODlevel) { ((GameObject.Find("Terrain").GetComponent(typeof(Terrain)) as Terrain).GetComponent(typeof(ReliefTerrain)) as ReliefTerrain).globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.SIMPLE; this.LODmanager.RefreshLODlevel(); } break; } if (terrainShaderLod == TerrainShaderLod.POM) { this.terrain_self_shadow = this.LODmanager.RTP_SHADOWS; bool flag = GUILayout.Toggle(this.terrain_self_shadow, "self shadowing", Array.Empty <GUILayoutOption>()); if (flag != this.terrain_self_shadow) { this.LODmanager.RTP_SHADOWS = flag; this.LODmanager.RefreshLODlevel(); } this.terrain_self_shadow = flag; if (this.terrain_self_shadow) { this.terrain_smooth_shadows = this.LODmanager.RTP_SOFT_SHADOWS; bool flag2 = GUILayout.Toggle(this.terrain_smooth_shadows, "smooth shadows", Array.Empty <GUILayoutOption>()); if (flag2 != this.terrain_smooth_shadows) { this.LODmanager.RTP_SOFT_SHADOWS = flag2; this.LODmanager.RefreshLODlevel(); } this.terrain_smooth_shadows = flag2; } } if (this.LODmanager.RTP_SNOW_FIRST) { ReliefTerrain reliefTerrain = (GameObject.Find("Terrain").GetComponent(typeof(Terrain)) as Terrain).GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Label("Snow", new GUILayoutOption[] { GUILayout.MaxWidth(40f) }); float num = GUILayout.HorizontalSlider(reliefTerrain.globalSettingsHolder._snow_strength, 0f, 1f, Array.Empty <GUILayoutOption>()); if (num != reliefTerrain.globalSettingsHolder._snow_strength) { reliefTerrain.globalSettingsHolder._snow_strength = num; reliefTerrain.globalSettingsHolder.Refresh(null, null); } GUILayout.EndHorizontal(); } GUILayout.Label("Light", new GUILayoutOption[] { GUILayout.MaxWidth(40f) }); this.light_dir = GUILayout.HorizontalSlider(this.light_dir, 0f, 360f, Array.Empty <GUILayoutOption>()); component.transform.rotation = Quaternion.Euler(40f, this.light_dir, 0f); GUILayout.Label(" F (hold) - freeze camera", Array.Empty <GUILayoutOption>()); GUILayout.Label(" ,/. - change cam position", Array.Empty <GUILayoutOption>()); } GUILayout.Label(" P - toggle panel", Array.Empty <GUILayoutOption>()); GUILayout.EndVertical(); }
private void SetTexturesToTerrain(Terrain t, Texture2D texture) { #if UNITY_2018_3_OR_NEWER #if !RTP float tsx = prefs.textureWidth - 4; float tsy = prefs.textureHeight - 4; Vector2 tileSize = new Vector2(t.terrainData.size.x + t.terrainData.size.x / tsx * 4, t.terrainData.size.z + t.terrainData.size.z / tsy * 4); Vector2 tileOffset = new Vector2(t.terrainData.size.x / prefs.textureWidth / 2, t.terrainData.size.z / prefs.textureHeight / 2); TerrainLayer tl = new TerrainLayer { tileSize = tileSize, tileOffset = tileOffset, diffuseTexture = texture }; string filename = Path.Combine(resultFolder, t.name + ".terrainlayer"); AssetDatabase.CreateAsset(tl, filename); AssetDatabase.Refresh(); t.terrainData.terrainLayers = new[] { AssetDatabase.LoadAssetAtPath <TerrainLayer>(filename) }; SetAlphaMaps(t); #else LoadRTPTextures(); TerrainLayer[] tls = new TerrainLayer[4]; for (int i = 0; i < 4; i++) { tls[i] = new TerrainLayer { diffuseTexture = rtpTextures[i * 3] }; } t.terrainData.terrainLayers = tls; SetAlphaMaps(t); ReliefTerrain reliefTerrain = t.gameObject.GetComponent <ReliefTerrain>() ?? t.gameObject.AddComponent <ReliefTerrain>(); reliefTerrain.InitArrays(); reliefTerrain.ColorGlobal = texture; #endif #else #if !RTP float tsx = prefs.textureWidth - 4; float tsy = prefs.textureHeight - 4; Vector2 tileSize = new Vector2(t.terrainData.size.x + t.terrainData.size.x / tsx * 4, t.terrainData.size.z + t.terrainData.size.z / tsy * 4); Vector2 tileOffset = new Vector2(t.terrainData.size.x / prefs.textureWidth / 2, t.terrainData.size.z / prefs.textureHeight / 2); SplatPrototype sp = new SplatPrototype { tileSize = tileSize, tileOffset = tileOffset, texture = texture }; t.terrainData.splatPrototypes = new [] { sp }; #else LoadRTPTextures(); SplatPrototype[] sps = new SplatPrototype[4]; for (int i = 0; i < 4; i++) { sps[i] = new SplatPrototype { texture = rtpTextures[i * 3] }; } t.terrainData.splatPrototypes = sps; ReliefTerrain reliefTerrain = t.gameObject.GetComponent <ReliefTerrain>() ?? t.gameObject.AddComponent <ReliefTerrain>(); reliefTerrain.InitArrays(); reliefTerrain.ColorGlobal = texture; #endif #endif }
public static IEnumerator Apply(CoordRect rect, Terrain terrain, object dataBox, Func <float, bool> stop = null) { #if RTP //guard if old-style rtp approach is used ReliefTerrain chunkRTP = terrain.gameObject.GetComponent <ReliefTerrain>(); if (chunkRTP != null && chunkRTP.enabled) { Debug.Log("MapMagic: RTP component on terain chunk detected. RTP Output Generator works with one RTP script assigned to main MM object only. Make sure that Copy Components is turned off."); chunkRTP.enabled = false; } yield return(null); //loading objects RTPTuple tuple = (RTPTuple)dataBox; if (tuple == null) { yield break; } //creating control textures Texture2D controlA = new Texture2D(MapMagic.instance.resolution, MapMagic.instance.resolution); controlA.wrapMode = TextureWrapMode.Clamp; controlA.SetPixels(0, 0, controlA.width, controlA.height, tuple.colorsA); controlA.Apply(); yield return(null); Texture2D controlB = null; if (tuple.colorsB != null) { controlB = new Texture2D(MapMagic.instance.resolution, MapMagic.instance.resolution); controlB.wrapMode = TextureWrapMode.Clamp; controlB.SetPixels(0, 0, controlB.width, controlB.height, tuple.colorsB); controlB.Apply(); yield return(null); } //welding if (MapMagic.instance != null && MapMagic.instance.splatsWeldMargins != 0) { Coord coord = Coord.PickCell(rect.offset, MapMagic.instance.resolution); //Chunk chunk = MapMagic.instance.chunks[coord.x, coord.z]; Chunk neigPrevX = MapMagic.instance.chunks[coord.x - 1, coord.z]; if (neigPrevX != null && neigPrevX.worker.ready && neigPrevX.terrain.materialTemplate.HasProperty("_Control1")) { WeldTerrains.WeldTextureToPrevX(controlA, (Texture2D)neigPrevX.terrain.materialTemplate.GetTexture("_Control1")); if (controlB != null && neigPrevX.terrain.materialTemplate.HasProperty("_Control2")) { WeldTerrains.WeldTextureToPrevX(controlB, (Texture2D)neigPrevX.terrain.materialTemplate.GetTexture("_Control2")); } } Chunk neigNextX = MapMagic.instance.chunks[coord.x + 1, coord.z]; if (neigNextX != null && neigNextX.worker.ready && neigNextX.terrain.materialTemplate.HasProperty("_Control1")) { WeldTerrains.WeldTextureToNextX(controlA, (Texture2D)neigNextX.terrain.materialTemplate.GetTexture("_Control1")); if (controlB != null && neigNextX.terrain.materialTemplate.HasProperty("_Control2")) { WeldTerrains.WeldTextureToNextX(controlB, (Texture2D)neigNextX.terrain.materialTemplate.GetTexture("_Control2")); } } Chunk neigPrevZ = MapMagic.instance.chunks[coord.x, coord.z - 1]; if (neigPrevZ != null && neigPrevZ.worker.ready && neigPrevZ.terrain.materialTemplate.HasProperty("_Control1")) { WeldTerrains.WeldTextureToPrevZ(controlA, (Texture2D)neigPrevZ.terrain.materialTemplate.GetTexture("_Control1")); if (controlB != null && neigPrevZ.terrain.materialTemplate.HasProperty("_Control2")) { WeldTerrains.WeldTextureToPrevZ(controlB, (Texture2D)neigPrevZ.terrain.materialTemplate.GetTexture("_Control2")); } } Chunk neigNextZ = MapMagic.instance.chunks[coord.x, coord.z + 1]; if (neigNextZ != null && neigNextZ.worker.ready && neigNextZ.terrain.materialTemplate.HasProperty("_Control1")) { WeldTerrains.WeldTextureToNextZ(controlA, (Texture2D)neigNextZ.terrain.materialTemplate.GetTexture("_Control1")); if (controlB != null && neigNextZ.terrain.materialTemplate.HasProperty("_Control2")) { WeldTerrains.WeldTextureToNextZ(controlB, (Texture2D)neigNextZ.terrain.materialTemplate.GetTexture("_Control2")); } } } yield return(null); //assigning material propery block (not saving for fixed terrains) //#if UNITY_5_5_OR_NEWER //assign textures using material property //MaterialPropertyBlock matProp = new MaterialPropertyBlock(); //matProp.SetTexture("_Control1", controlA); //if (controlB!=null) matProp.SetTexture("_Control2", controlB); //#endif //duplicating material and assign it's values //if (MapMagic.instance.customTerrainMaterial != null) //{ // //duplicating material // terrain.materialTemplate = new Material(MapMagic.instance.customTerrainMaterial); // // //assigning control textures // if (terrain.materialTemplate.HasProperty("_Control1")) // terrain.materialTemplate.SetTexture("_Control1", controlA); // if (controlB != null && terrain.materialTemplate.HasProperty("_Control2")) // terrain.materialTemplate.SetTexture("_Control2", controlB); //} if (rtp == null) { rtp = MapMagic.instance.gameObject.GetComponent <ReliefTerrain>(); } if (rtp == null || rtp.globalSettingsHolder == null) { yield break; } //getting rtp material Material mat = null; if (terrain.materialTemplate != null && terrain.materialTemplate.shader.name == "Relief Pack/ReliefTerrain-FirstPas") //if relief terrain material assigned to terrain { mat = terrain.materialTemplate; } //if (mat==null && chunk.previewBackupMaterial!=null && chunk.previewBackupMaterial.shader.name=="Relief Pack/ReliefTerrain-FirstPas") //if it is backed up for preview // mat = chunk.previewBackupMaterial; if (mat == null) //if still could not find material - creating new { Shader shader = Shader.Find("Relief Pack/ReliefTerrain-FirstPass"); mat = new Material(shader); if (Preview.previewOutput == null) { terrain.materialTemplate = mat; } //else chunk.previewBackupMaterial = mat; } terrain.materialType = Terrain.MaterialType.Custom; //setting rtp.RefreshTextures(mat); rtp.globalSettingsHolder.Refresh(mat, rtp); mat.SetTexture("_Control1", controlA); if (controlB != null) { mat.SetTexture("_Control2", controlB); mat.SetTexture("_Control3", controlB); } #else yield return(null); #endif }
public void RecalcControlMapsForMesh(ReliefTerrain rt) { float[,] splatData; Color[] cols; if (numLayers>4 && rt.controlA!=null && rt.controlB!=null) { if (rt.controlA.width!=rt.controlB.width) { Debug.LogError("Control maps A&B have to be of the same size for recalculation !"); return; } else { bool exit=false; for(int k=0; k<rt.source_controls.Length; k++) { if (rt.splat_layer_calc[k] && rt.source_controls[k]!=null && rt.source_controls[k].width!=rt.controlA.width) { Debug.LogError("Source control map "+k+" should be of the control texture size ("+rt.controlA.width+") !"); exit=true; } } for(int k=0; k<rt.source_controls_mask.Length; k++) { if (rt.splat_layer_masked[k] && rt.source_controls_mask[k]!=null && rt.source_controls_mask[k].width!=rt.controlA.width) { Debug.LogError("Source mask control map "+k+" should be of the control texture size ("+rt.controlA.width+") !"); exit=true; } } if (exit) return; } } if (rt.controlA==null) { rt.controlA=new Texture2D(1024, 1024, TextureFormat.ARGB32, true); cols=new Color[1024*1024]; for(int i=0; i<cols.Length; i++) cols[i]=new Color(1,0,0,0); rt.controlA.Apply(false,false); } else { cols=rt.controlA.GetPixels(0); } splatData=new float[rt.controlA.width*rt.controlA.width, numLayers]; for(int n=0; n<numLayers; n++) { if (n==4) { if (rt.controlB==null) { rt.controlB=new Texture2D(rt.controlA.width, rt.controlA.width, TextureFormat.ARGB32, true); cols=new Color[1024*1024]; for(int i=0; i<cols.Length; i++) cols[i]=new Color(0,0,0,0); rt.controlB.Apply(false,false); } else { cols=rt.controlB.GetPixels(0); } } if (n==8) { if (rt.controlC==null) { rt.controlC=new Texture2D(rt.controlA.width, rt.controlA.width, TextureFormat.ARGB32, true); cols=new Color[1024*1024]; for(int i=0; i<cols.Length; i++) cols[i]=new Color(0,0,0,0); rt.controlC.Apply(false,false); } else { cols=rt.controlC.GetPixels(0); } } for(int i=0; i<cols.Length; i++) { splatData[i,n]=cols[i][n%4]; } } Color[] cols_control; float[] norm_array=new float[rt.controlA.width*rt.controlA.width]; if (rt.splat_layer_ordered_mode) { // ordered mode for(int k=0; k<numLayers; k++) { int n=rt.splat_layer_seq[k]; // value for current layer if (rt.splat_layer_calc[n]) { int idx=0; if (rt.source_controls[n]) { cols_control=rt.source_controls[n].GetPixels(); } else { cols_control=new Color[rt.controlA.width*rt.controlA.width]; if (rt.source_controls_invert[n]) { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.black; } else { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.white; } } int channel_idx=(int)rt.source_controls_channels[n]; // apply mask if (rt.splat_layer_masked[n] && rt.source_controls_mask[n]) { Color[] cols_mask=rt.source_controls_mask[n].GetPixels(); idx=0; int channel_idx_mask=(int)rt.source_controls_mask_channels[n]; for(int i=0; i<rt.controlA.width; i++) { for(int j=0; j<rt.controlA.width; j++) { cols_control[idx][channel_idx]*=cols_mask[idx][channel_idx_mask]; idx++; } } idx=0; } for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { norm_array[i]=cols_control[idx++][channel_idx]*rt.splat_layer_boost[n]; if (norm_array[i]>1) norm_array[i]=1; } } else { for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { norm_array[i]=splatData[i,n]; if (norm_array[i]>1) norm_array[i]=1; } } // damp underlying layers for(int l=0; l<k; l++) { int m=rt.splat_layer_seq[l]; for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { splatData[i,m]*=(1-norm_array[i]); } } // write current layer if (rt.splat_layer_calc[n]) { int idx=0; if (rt.source_controls[n]) { cols_control=rt.source_controls[n].GetPixels(); } else { cols_control=new Color[rt.controlA.width*rt.controlA.width]; if (rt.source_controls_invert[n]) { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.black; } else { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.white; } } int channel_idx=(int)rt.source_controls_channels[n]; // apply mask if (rt.splat_layer_masked[n] && rt.source_controls_mask[n]) { Color[] cols_mask=rt.source_controls_mask[n].GetPixels(); idx=0; int channel_idx_mask=(int)rt.source_controls_mask_channels[n]; for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { cols_control[idx][channel_idx]*=cols_mask[idx][channel_idx_mask]; idx++; } idx=0; } for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { splatData[i,n]=cols_control[idx++][channel_idx]*rt.splat_layer_boost[n]; } } } } else { // unordered mode for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { norm_array[i]=0; } for(int n=0; n<numLayers; n++) { if (rt.splat_layer_calc[n]) { int idx=0; if (rt.source_controls[n]) { cols_control=rt.source_controls[n].GetPixels(); } else { cols_control=new Color[rt.controlA.width*rt.controlA.width]; if (rt.source_controls_invert[n]) { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.black; } else { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.white; } } int channel_idx=(int)rt.source_controls_channels[n]; // apply mask if (rt.splat_layer_masked[n] && rt.source_controls_mask[n]) { Color[] cols_mask=rt.source_controls_mask[n].GetPixels(); idx=0; int channel_idx_mask=(int)rt.source_controls_mask_channels[n]; for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { cols_control[idx][channel_idx]*=cols_mask[idx][channel_idx_mask]; idx++; } idx=0; } for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { norm_array[i]+=cols_control[idx++][channel_idx]*rt.splat_layer_boost[n]; } } else { for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { norm_array[i]+=splatData[i,n]; } } } for(int n=0; n<numLayers; n++) { if (rt.splat_layer_calc[n]) { int idx=0; if (rt.source_controls[n]) { cols_control=rt.source_controls[n].GetPixels(); } else { cols_control=new Color[rt.controlA.width*rt.controlA.width]; if (rt.source_controls_invert[n]) { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.black; } else { for(int i=0; i<cols_control.Length; i++) cols_control[i]=Color.white; } } int channel_idx=(int)rt.source_controls_channels[n]; // apply mask if (rt.splat_layer_masked[n] && rt.source_controls_mask[n]) { Color[] cols_mask=rt.source_controls_mask[n].GetPixels(); idx=0; int channel_idx_mask=(int)rt.source_controls_mask_channels[n]; for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { cols_control[idx][channel_idx]*=cols_mask[idx][channel_idx_mask]; idx++; } idx=0; } for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { splatData[i,n]=cols_control[idx++][channel_idx]*rt.splat_layer_boost[n]/norm_array[i]; } } else { for(int i=0; i<rt.controlA.width*rt.controlA.width; i++) { splatData[i,n]=splatData[i,n]/norm_array[i]; } } } } for(int n=0; n<numLayers; n++) { if (n==0) { for(int i=0; i<cols.Length; i++) { cols[i]=new Color(0,0,0,0); } } for(int i=0; i<cols.Length; i++) { cols[i][n%4]=splatData[i,n]; } if (n==3) { rt.controlA.SetPixels(cols,0); rt.controlA.Apply(true, false); } else if (n==7) { rt.controlB.SetPixels(cols,0); rt.controlB.Apply(true, false); } else if (n==11) { rt.controlC.SetPixels(cols,0); rt.controlC.Apply(true, false); } else if (n==numLayers-1) { if (n<4) { rt.controlA.SetPixels(cols,0); rt.controlA.Apply(true, false); } else if (n<8) { rt.controlB.SetPixels(cols,0); rt.controlB.Apply(true, false); } else { rt.controlC.SetPixels(cols,0); rt.controlC.Apply(true, false); } } } }
private void OnGUI() { if (!this.LODmanager) { this.GetLODManager(); return; } GUILayout.Space(10f); GUILayout.BeginVertical("box", new GUILayoutOption[0]); GUILayout.Label(string.Empty + FPSmeter.fps, new GUILayoutOption[0]); if (this.panel_enabled) { this.shadows = GUILayout.Toggle(this.shadows, "disable Unity's shadows", new GUILayoutOption[0]); Light component = GameObject.Find("Directional light").GetComponent <Light>(); component.shadows = ((!this.shadows) ? LightShadows.Soft : LightShadows.None); this.forward_path = GUILayout.Toggle(this.forward_path, "forward rendering", new GUILayoutOption[0]); Camera component2 = GameObject.Find("Main Camera").GetComponent <Camera>(); component2.renderingPath = ((!this.forward_path) ? RenderingPath.DeferredLighting : RenderingPath.Forward); if (this.forward_path) { RenderSettings.ambientLight = new Color32(25, 25, 25, 0); } else { RenderSettings.ambientLight = new Color32(93, 103, 122, 0); } TerrainShaderLod rTP_LODlevel = this.LODmanager.RTP_LODlevel; TerrainShaderLod terrainShaderLod = rTP_LODlevel; switch (rTP_LODlevel) { case TerrainShaderLod.POM: if (GUILayout.Button("POM shading", new GUILayoutOption[0])) { terrainShaderLod = TerrainShaderLod.PM; } break; case TerrainShaderLod.PM: if (GUILayout.Button("PM shading", new GUILayoutOption[0])) { terrainShaderLod = TerrainShaderLod.SIMPLE; } break; case TerrainShaderLod.SIMPLE: if (GUILayout.Button("SIMPLE shading", new GUILayoutOption[0])) { terrainShaderLod = TerrainShaderLod.CLASSIC; } break; case TerrainShaderLod.CLASSIC: if (GUILayout.Button("CLASSIC shading", new GUILayoutOption[0])) { terrainShaderLod = TerrainShaderLod.POM; } break; } switch (terrainShaderLod) { case TerrainShaderLod.POM: if (terrainShaderLod != rTP_LODlevel) { GameObject gameObject = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain = gameObject.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; reliefTerrain.globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.POM; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.PM: if (terrainShaderLod != rTP_LODlevel) { GameObject gameObject2 = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain2 = gameObject2.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; reliefTerrain2.globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.PM; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.SIMPLE: if (terrainShaderLod != rTP_LODlevel) { GameObject gameObject3 = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain3 = gameObject3.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; reliefTerrain3.globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.SIMPLE; this.LODmanager.RefreshLODlevel(); } break; case TerrainShaderLod.CLASSIC: if (terrainShaderLod != rTP_LODlevel) { GameObject gameObject4 = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain4 = gameObject4.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; reliefTerrain4.globalSettingsHolder.Refresh(null, null); this.LODmanager.RTP_LODlevel = TerrainShaderLod.CLASSIC; this.LODmanager.RefreshLODlevel(); } break; } if (terrainShaderLod == TerrainShaderLod.POM) { this.terrain_self_shadow = this.LODmanager.RTP_SHADOWS; bool flag = GUILayout.Toggle(this.terrain_self_shadow, "self shadowing", new GUILayoutOption[0]); if (flag != this.terrain_self_shadow) { this.LODmanager.RTP_SHADOWS = flag; this.LODmanager.RefreshLODlevel(); } this.terrain_self_shadow = flag; if (this.terrain_self_shadow) { this.terrain_smooth_shadows = this.LODmanager.RTP_SOFT_SHADOWS; bool flag2 = GUILayout.Toggle(this.terrain_smooth_shadows, "smooth shadows", new GUILayoutOption[0]); if (flag2 != this.terrain_smooth_shadows) { this.LODmanager.RTP_SOFT_SHADOWS = flag2; this.LODmanager.RefreshLODlevel(); } this.terrain_smooth_shadows = flag2; } } if (this.LODmanager.RTP_SNOW_FIRST) { GameObject gameObject5 = GameObject.Find("terrainMesh"); ReliefTerrain reliefTerrain5 = gameObject5.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain; GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Snow", new GUILayoutOption[] { GUILayout.MaxWidth(40f) }); float num = GUILayout.HorizontalSlider(reliefTerrain5.globalSettingsHolder._snow_strength, 0f, 1f, new GUILayoutOption[0]); if (num != reliefTerrain5.globalSettingsHolder._snow_strength) { reliefTerrain5.globalSettingsHolder._snow_strength = num; reliefTerrain5.globalSettingsHolder.Refresh(null, null); } GUILayout.EndHorizontal(); } GUILayout.Label("Light", new GUILayoutOption[] { GUILayout.MaxWidth(40f) }); this.light_dir = GUILayout.HorizontalSlider(this.light_dir, 0f, 360f, new GUILayoutOption[0]); component.transform.rotation = Quaternion.Euler(40f, this.light_dir, 0f); if (!Application.isWebPlayer && GUILayout.Button("QUIT", new GUILayoutOption[0])) { Application.Quit(); } GUILayout.Label(" F (hold) - freeze camera", new GUILayoutOption[0]); GUILayout.Label(" ,/. - change cam position", new GUILayoutOption[0]); } else if (!Application.isWebPlayer && GUILayout.Button("QUIT", new GUILayoutOption[0])) { Application.Quit(); } GUILayout.Label(" P - toggle panel", new GUILayoutOption[0]); GUILayout.EndVertical(); }
public void Refresh(Material mat=null, ReliefTerrain rt_caller=null) { if (splats==null) return; #if UNITY_EDITOR if (_RTP_LODmanager==null) { if ((_RTP_LODmanager=GameObject.Find("_RTP_LODmanager"))==null) { _RTP_LODmanager=new GameObject("_RTP_LODmanager"); _RTP_LODmanager.AddComponent(typeof(RTP_LODmanager)); _RTP_LODmanager.AddComponent(typeof(RTPFogUpdate)); _RTP_LODmanagerScript=(RTP_LODmanager)_RTP_LODmanager.GetComponent(typeof(RTP_LODmanager)); EditorUtility.DisplayDialog("RTP Notification", "_RTP_LODmanager object added to the scene.\nIts script handles LOD properties of RTP shaders.","OK"); Selection.activeObject=_RTP_LODmanager; } } if (_RTP_LODmanagerScript==null) { _RTP_LODmanagerScript=(RTP_LODmanager)_RTP_LODmanager.GetComponent(typeof(RTP_LODmanager)); } _4LAYERS_SHADER_USED=_RTP_LODmanagerScript.RTP_4LAYERS_MODE; colorSpaceLinear = ( PlayerSettings.colorSpace==ColorSpace.Linear ); #endif // switch for SetShaderParam - when use_mat defined we're injecting param into material #if !UNITY_3_5 if (mat==null && rt_caller!=null) { if (rt_caller.globalSettingsHolder==this) { Terrain ter=rt_caller.GetComponent(typeof(Terrain)) as Terrain; if (ter) { rt_caller.globalSettingsHolder.Refresh(ter.materialTemplate); } else { if (rt_caller.GetComponent<Renderer>()!=null && rt_caller.GetComponent<Renderer>().sharedMaterial!=null) { rt_caller.globalSettingsHolder.Refresh(rt_caller.GetComponent<Renderer>().sharedMaterial); } } } } #endif use_mat=mat; for(int i=0; i<numLayers; i++) { if (i<4) { ApplyGlossBakedTexture("_SplatA"+i, i); } else if (i<8) { if (_4LAYERS_SHADER_USED) { ApplyGlossBakedTexture("_SplatC"+(i-4), i); // potrzebne przy sniegu (firstpass moze korzystac z koloru i bumpmap 4-7) ApplyGlossBakedTexture("_SplatB"+(i-4), i); } else { ApplyGlossBakedTexture("_SplatB"+(i-4), i); } } else if (i<12) { ApplyGlossBakedTexture("_SplatC"+(i-8), i); } } // > RTP3.1 // update-set to default if (CheckAndUpdate(ref RTP_gloss2mask, 0.5f, numLayers)) { for(int k=0; k<numLayers; k++) { Spec[k]=1; // zresetuj od razu mnożnik glossa (RTP3.1 - zmienna ma inne znaczenie) } } CheckAndUpdate(ref RTP_gloss_mult, 1f, numLayers); CheckAndUpdate(ref RTP_gloss_shaping, 0.5f, numLayers); CheckAndUpdate(ref RTP_Fresnel, 0, numLayers); CheckAndUpdate(ref RTP_FresnelAtten, 0, numLayers); CheckAndUpdate(ref RTP_DiffFresnel, 0, numLayers); CheckAndUpdate(ref RTP_IBL_bump_smoothness, 0.7f, numLayers); CheckAndUpdate(ref RTP_IBL_DiffuseStrength, 0.5f, numLayers); CheckAndUpdate(ref RTP_IBL_SpecStrength, 0.5f, numLayers); CheckAndUpdate(ref _DeferredSpecDampAddPass, 1f, numLayers); CheckAndUpdate(ref TERRAIN_WaterSpecularity, 0.5f, numLayers); CheckAndUpdate(ref TERRAIN_WaterGloss, 0.1f, numLayers); CheckAndUpdate(ref TERRAIN_WaterGlossDamper, 0f, numLayers); CheckAndUpdate(ref TERRAIN_WetSpecularity, 0.2f, numLayers); CheckAndUpdate(ref TERRAIN_WetGloss, 0.05f, numLayers); CheckAndUpdate(ref TERRAIN_WetFlow, 0.05f, numLayers); CheckAndUpdate(ref MixBrightness, 2.0f, numLayers); CheckAndUpdate(ref MixReplace, 0.0f, numLayers); CheckAndUpdate(ref LayerBrightness, 1.0f, numLayers); CheckAndUpdate(ref LayerBrightness2Spec, 0.0f, numLayers); CheckAndUpdate(ref LayerAlbedo2SpecColor, 0.0f, numLayers); CheckAndUpdate(ref LayerSaturation, 1.0f, numLayers); CheckAndUpdate(ref LayerEmission, 0f, numLayers); CheckAndUpdate(ref FarSpecCorrection, 0f, numLayers); CheckAndUpdate(ref LayerEmissionColor, Color.black, numLayers); CheckAndUpdate(ref LayerEmissionRefractStrength, 0, numLayers); CheckAndUpdate(ref LayerEmissionRefractHBedge, 0, numLayers); CheckAndUpdate(ref TERRAIN_WaterIBL_SpecWetStrength, 0.1f, numLayers); CheckAndUpdate(ref TERRAIN_WaterIBL_SpecWaterStrength, 0.5f, numLayers); CheckAndUpdate(ref TERRAIN_WaterEmission, 0f, numLayers); ///////////////////////////////////////////////////////////////////// // // layer independent // ///////////////////////////////////////////////////////////////////// // custom fog (unity's fog doesn't work with this shader - too many texture interpolators) if (RenderSettings.fog) { Shader.SetGlobalFloat("_Fdensity", RenderSettings.fogDensity); if (colorSpaceLinear) { Shader.SetGlobalColor("_FColor", RenderSettings.fogColor.linear); } else { Shader.SetGlobalColor("_FColor", RenderSettings.fogColor); } Shader.SetGlobalFloat("_Fstart", RenderSettings.fogStartDistance); Shader.SetGlobalFloat("_Fend", RenderSettings.fogEndDistance); } else { Shader.SetGlobalFloat("_Fdensity", 0); Shader.SetGlobalFloat("_Fstart", 1000000); Shader.SetGlobalFloat("_Fend", 2000000); } SetShaderParam("terrainTileSize", terrainTileSize); SetShaderParam("RTP_AOamp", RTP_AOamp); SetShaderParam("RTP_AOsharpness", RTP_AOsharpness); SetShaderParam("EmissionRefractFiltering", EmissionRefractFiltering); SetShaderParam("EmissionRefractAnimSpeed", EmissionRefractAnimSpeed); // global SetShaderParam("_VerticalTexture", VerticalTexture); SetShaderParam("_GlobalColorMapBlendValues", GlobalColorMapBlendValues); SetShaderParam("_GlobalColorMapSaturation", GlobalColorMapSaturation); SetShaderParam("_GlobalColorMapSaturationFar", GlobalColorMapSaturationFar); //SetShaderParam("_GlobalColorMapSaturationByPerlin", GlobalColorMapSaturationByPerlin); SetShaderParam("_GlobalColorMapDistortByPerlin", GlobalColorMapDistortByPerlin); SetShaderParam("_GlobalColorMapBrightness", GlobalColorMapBrightness); SetShaderParam("_GlobalColorMapBrightnessFar", GlobalColorMapBrightnessFar); SetShaderParam("_GlobalColorMapNearMIP", _GlobalColorMapNearMIP); SetShaderParam("_RTP_MIP_BIAS", RTP_MIP_BIAS); SetShaderParam("_BumpMapGlobalScale", BumpMapGlobalScale); SetShaderParam("_FarNormalDamp", _FarNormalDamp); SetShaderParam("_SpecColor", _SpecColor); SetShaderParam("RTP_DeferredAddPassSpec", RTP_DeferredAddPassSpec); SetShaderParam("_blend_multiplier", blendMultiplier); SetShaderParam("_TERRAIN_ReliefTransform", ReliefTransform); SetShaderParam("_TERRAIN_ReliefTransformTriplanarZ", ReliefTransform.x); SetShaderParam("_TERRAIN_DIST_STEPS", DIST_STEPS); SetShaderParam("_TERRAIN_WAVELENGTH", WAVELENGTH); SetShaderParam("_TERRAIN_ExtrudeHeight", ExtrudeHeight); SetShaderParam("_TERRAIN_LightmapShading", LightmapShading); SetShaderParam("_TERRAIN_SHADOW_STEPS", SHADOW_STEPS); SetShaderParam("_TERRAIN_WAVELENGTH_SHADOWS", WAVELENGTH_SHADOWS); SetShaderParam("_TERRAIN_SHADOW_SMOOTH_STEPS", SHADOW_SMOOTH_STEPS); SetShaderParam("_TERRAIN_SelfShadowStrength", SelfShadowStrength); SetShaderParam("_TERRAIN_ShadowSmoothing", ShadowSmoothing); SetShaderParam("_TERRAIN_distance_start", distance_start); SetShaderParam("_TERRAIN_distance_transition", distance_transition); SetShaderParam("_TERRAIN_distance_start_bumpglobal", distance_start_bumpglobal); SetShaderParam("_TERRAIN_distance_transition_bumpglobal", distance_transition_bumpglobal); SetShaderParam("rtp_perlin_start_val", rtp_perlin_start_val); Shader.SetGlobalVector("_TERRAIN_trees_shadow_values", new Vector4(trees_shadow_distance_start, trees_shadow_distance_transition, trees_shadow_value, global_normalMap_multiplier)); Shader.SetGlobalVector("_TERRAIN_trees_pixel_values", new Vector4(trees_pixel_distance_start, trees_pixel_distance_transition, trees_pixel_blend_val, global_normalMap_farUsage)); SetShaderParam("_Phong", _Phong); SetShaderParam("_TessSubdivisions", _TessSubdivisions); SetShaderParam("_TessSubdivisionsFar", _TessSubdivisionsFar); SetShaderParam("_TessYOffset", _TessYOffset); Shader.SetGlobalFloat("_AmbientEmissiveMultiplier", _AmbientEmissiveMultiplier); Shader.SetGlobalFloat("_AmbientEmissiveRelief", _AmbientEmissiveRelief); SetShaderParam("_SuperDetailTiling", _SuperDetailTiling); Shader.SetGlobalFloat("rtp_snow_strength", _snow_strength); Shader.SetGlobalFloat("rtp_global_color_brightness_to_snow", _global_color_brightness_to_snow); Shader.SetGlobalFloat("rtp_snow_slope_factor", _snow_slope_factor); Shader.SetGlobalFloat("rtp_snow_edge_definition", _snow_edge_definition); Shader.SetGlobalFloat("rtp_snow_height_treshold", _snow_height_treshold); Shader.SetGlobalFloat("rtp_snow_height_transition", _snow_height_transition); Shader.SetGlobalColor("rtp_snow_color", _snow_color); Shader.SetGlobalFloat("rtp_snow_specular", _snow_specular); Shader.SetGlobalFloat("rtp_snow_gloss", _snow_gloss); Shader.SetGlobalFloat("rtp_snow_reflectivness", _snow_reflectivness); Shader.SetGlobalFloat("rtp_snow_deep_factor", _snow_deep_factor); Shader.SetGlobalFloat("rtp_snow_fresnel", _snow_fresnel); Shader.SetGlobalFloat("rtp_snow_diff_fresnel", _snow_diff_fresnel); Shader.SetGlobalFloat("rtp_snow_IBL_DiffuseStrength", _snow_IBL_DiffuseStrength); Shader.SetGlobalFloat("rtp_snow_IBL_SpecStrength", _snow_IBL_SpecStrength); // caustics SetShaderParam("TERRAIN_CausticsAnimSpeed", TERRAIN_CausticsAnimSpeed); SetShaderParam("TERRAIN_CausticsColor", TERRAIN_CausticsColor); if (TERRAIN_CausticsWaterLevelRefObject) TERRAIN_CausticsWaterLevel=TERRAIN_CausticsWaterLevelRefObject.transform.position.y; Shader.SetGlobalFloat("TERRAIN_CausticsWaterLevel", TERRAIN_CausticsWaterLevel); Shader.SetGlobalFloat("TERRAIN_CausticsWaterLevelByAngle", TERRAIN_CausticsWaterLevelByAngle); Shader.SetGlobalFloat("TERRAIN_CausticsWaterDeepFadeLength", TERRAIN_CausticsWaterDeepFadeLength); Shader.SetGlobalFloat("TERRAIN_CausticsWaterShallowFadeLength", TERRAIN_CausticsWaterShallowFadeLength); SetShaderParam("TERRAIN_CausticsTilingScale", TERRAIN_CausticsTilingScale); SetShaderParam("TERRAIN_CausticsTex", TERRAIN_CausticsTex); if (numLayers>0) { int tex_width=512; for(int i=0; i<numLayers; i++) { if (splats[i]) { tex_width=splats[i].width; break; } } SetShaderParam("rtp_mipoffset_color", -Mathf.Log(1024.0f/tex_width)/Mathf.Log(2) ); if (Bump01!=null) { tex_width=Bump01.width; } SetShaderParam("rtp_mipoffset_bump", -Mathf.Log(1024.0f/tex_width)/Mathf.Log(2)); if (HeightMap) { tex_width=HeightMap.width; } else if (HeightMap2) { tex_width=HeightMap2.width; } else if (HeightMap3) { tex_width=HeightMap3.width; } SetShaderParam("rtp_mipoffset_height", -Mathf.Log(1024.0f/tex_width)/Mathf.Log(2)); tex_width=BumpGlobalCombinedSize; SetShaderParam("rtp_mipoffset_globalnorm", -Mathf.Log(1024.0f/(tex_width*BumpMapGlobalScale))/Mathf.Log(2)+rtp_mipoffset_globalnorm); SetShaderParam("rtp_mipoffset_superdetail", -Mathf.Log(1024.0f/(tex_width*_SuperDetailTiling))/Mathf.Log(2)); SetShaderParam("rtp_mipoffset_flow", -Mathf.Log(1024.0f/(tex_width*TERRAIN_FlowScale))/Mathf.Log(2) + TERRAIN_FlowMipOffset); if (TERRAIN_RippleMap) { tex_width=TERRAIN_RippleMap.width; } SetShaderParam("rtp_mipoffset_ripple", -Mathf.Log(1024.0f/(tex_width*TERRAIN_RippleScale))/Mathf.Log(2)); if (TERRAIN_CausticsTex) { tex_width=TERRAIN_CausticsTex.width; } SetShaderParam("rtp_mipoffset_caustics", -Mathf.Log(1024.0f/(tex_width*TERRAIN_CausticsTilingScale))/Mathf.Log(2)); } SetShaderParam("TERRAIN_ReflectionMap", TERRAIN_ReflectionMap); SetShaderParam("TERRAIN_ReflColorA", TERRAIN_ReflColorA); SetShaderParam("TERRAIN_ReflColorB", TERRAIN_ReflColorB); SetShaderParam("TERRAIN_ReflColorC", TERRAIN_ReflColorC); SetShaderParam("TERRAIN_ReflColorCenter", TERRAIN_ReflColorCenter); SetShaderParam("TERRAIN_ReflGlossAttenuation", TERRAIN_ReflGlossAttenuation); SetShaderParam("TERRAIN_ReflectionRotSpeed", TERRAIN_ReflectionRotSpeed); SetShaderParam("TERRAIN_GlobalWetness", TERRAIN_GlobalWetness); Shader.SetGlobalFloat("TERRAIN_GlobalWetness", TERRAIN_GlobalWetness); SetShaderParam("TERRAIN_RippleMap", TERRAIN_RippleMap); SetShaderParam("TERRAIN_RippleScale", TERRAIN_RippleScale); SetShaderParam("TERRAIN_FlowScale", TERRAIN_FlowScale); SetShaderParam("TERRAIN_FlowMipOffset", TERRAIN_FlowMipOffset); SetShaderParam("TERRAIN_FlowSpeed", TERRAIN_FlowSpeed); SetShaderParam("TERRAIN_FlowCycleScale", TERRAIN_FlowCycleScale); Shader.SetGlobalFloat("TERRAIN_RainIntensity", TERRAIN_RainIntensity); SetShaderParam("TERRAIN_DropletsSpeed", TERRAIN_DropletsSpeed); SetShaderParam("TERRAIN_WetDropletsStrength", TERRAIN_WetDropletsStrength); SetShaderParam("TERRAIN_WetDarkening", TERRAIN_WetDarkening); SetShaderParam("TERRAIN_mipoffset_flowSpeed", TERRAIN_mipoffset_flowSpeed); SetShaderParam("TERRAIN_WetHeight_Treshold", TERRAIN_WetHeight_Treshold); SetShaderParam("TERRAIN_WetHeight_Transition", TERRAIN_WetHeight_Transition); Shader.SetGlobalVector("rtp_customAmbientCorrection", new Vector4(rtp_customAmbientCorrection.r-0.2f, rtp_customAmbientCorrection.g-0.2f, rtp_customAmbientCorrection.b-0.2f, 0)*0.1f); SetShaderParam("_CubemapDiff", _CubemapDiff); SetShaderParam("_CubemapSpec", _CubemapSpec); Shader.SetGlobalFloat("TERRAIN_IBL_DiffAO_Damp", TERRAIN_IBL_DiffAO_Damp); Shader.SetGlobalFloat("TERRAIN_IBLRefl_SpecAO_Damp", TERRAIN_IBLRefl_SpecAO_Damp); Shader.SetGlobalVector("RTP_LightDefVector", RTP_LightDefVector); Shader.SetGlobalFloat("RTP_BackLightStrength", RTP_LightDefVector.x); Shader.SetGlobalFloat("RTP_ReflexLightDiffuseSoftness", RTP_LightDefVector.y); Shader.SetGlobalFloat("RTP_ReflexLightSpecSoftness", RTP_LightDefVector.z); Shader.SetGlobalFloat("RTP_ReflexLightSpecularity", RTP_LightDefVector.w); Shader.SetGlobalColor("RTP_ReflexLightDiffuseColor1", RTP_ReflexLightDiffuseColor); Shader.SetGlobalColor("RTP_ReflexLightDiffuseColor2", RTP_ReflexLightDiffuseColor2); Shader.SetGlobalColor("RTP_ReflexLightSpecColor", RTP_ReflexLightSpecColor); SetShaderParam("_VerticalTextureGlobalBumpInfluence", VerticalTextureGlobalBumpInfluence); SetShaderParam("_VerticalTextureTiling", VerticalTextureTiling); ///////////////////////////////////////////////////////////////////// // // layer dependent numeric // ///////////////////////////////////////////////////////////////////// float[] tmp_RTP_gloss_mult=new float[RTP_gloss_mult.Length]; for(int k=0; k<tmp_RTP_gloss_mult.Length; k++) { if (gloss_baked[k]!=null && gloss_baked[k].baked) { tmp_RTP_gloss_mult[k]=1; } else { tmp_RTP_gloss_mult[k]=RTP_gloss_mult[k]; } } float[] tmp_RTP_gloss_shaping=new float[RTP_gloss_shaping.Length]; for(int k=0; k<tmp_RTP_gloss_shaping.Length; k++) { if (gloss_baked[k]!=null && gloss_baked[k].baked) { tmp_RTP_gloss_shaping[k]=0.5f; } else { tmp_RTP_gloss_shaping[k]=RTP_gloss_shaping[k]; } } SetShaderParam("_Spec0123", getVector(Spec, 0,3)); SetShaderParam("_FarSpecCorrection0123", getVector(FarSpecCorrection, 0,3)); SetShaderParam("_MIPmult0123", getVector(MIPmult, 0,3)); SetShaderParam("_MixScale0123", getVector(MixScale, 0,3)); SetShaderParam("_MixBlend0123", getVector(MixBlend, 0,3)); SetShaderParam("_MixSaturation0123", getVector(MixSaturation, 0, 3)); // RTP3.1 SetShaderParam("RTP_gloss2mask0123", getVector(RTP_gloss2mask, 0,3)); SetShaderParam("RTP_gloss_mult0123", getVector(tmp_RTP_gloss_mult, 0,3)); SetShaderParam("RTP_gloss_shaping0123", getVector(tmp_RTP_gloss_shaping, 0,3)); SetShaderParam("RTP_Fresnel0123", getVector(RTP_Fresnel, 0,3)); SetShaderParam("RTP_FresnelAtten0123", getVector(RTP_FresnelAtten, 0,3)); SetShaderParam("RTP_DiffFresnel0123", getVector(RTP_DiffFresnel, 0,3)); SetShaderParam("RTP_IBL_bump_smoothness0123", getVector(RTP_IBL_bump_smoothness, 0,3)); SetShaderParam("RTP_IBL_DiffuseStrength0123", getVector(RTP_IBL_DiffuseStrength, 0,3)); SetShaderParam("RTP_IBL_SpecStrength0123", getVector(RTP_IBL_SpecStrength, 0,3)); // (only in deferred addpass) //SetShaderParam("_DeferredSpecDampAddPass0123", getVector(_DeferredSpecDampAddPass, 0,3)); SetShaderParam("_MixBrightness0123", getVector(MixBrightness, 0, 3)); SetShaderParam("_MixReplace0123", getVector(MixReplace, 0, 3)); SetShaderParam("_LayerBrightness0123", MasterLayerBrightness*getVector(LayerBrightness, 0, 3)); SetShaderParam("_LayerSaturation0123", MasterLayerSaturation*getVector(LayerSaturation, 0, 3)); SetShaderParam("_LayerEmission0123", getVector(LayerEmission, 0, 3)); SetShaderParam("_LayerEmissionColorR0123", getColorVector(LayerEmissionColor, 0, 3, 0)); SetShaderParam("_LayerEmissionColorG0123", getColorVector(LayerEmissionColor, 0, 3, 1)); SetShaderParam("_LayerEmissionColorB0123", getColorVector(LayerEmissionColor, 0, 3, 2)); SetShaderParam("_LayerEmissionColorA0123", getColorVector(LayerEmissionColor, 0, 3, 3)); SetShaderParam("_LayerBrightness2Spec0123", getVector(LayerBrightness2Spec, 0, 3)); SetShaderParam("_LayerAlbedo2SpecColor0123", getVector(LayerAlbedo2SpecColor, 0, 3)); SetShaderParam("_LayerEmissionRefractStrength0123", getVector(LayerEmissionRefractStrength, 0, 3)); SetShaderParam("_LayerEmissionRefractHBedge0123", getVector(LayerEmissionRefractHBedge, 0, 3)); SetShaderParam("_GlobalColorPerLayer0123", getVector(GlobalColorPerLayer, 0, 3)); SetShaderParam("_GlobalColorBottom0123", getVector(GlobalColorBottom, 0, 3)); SetShaderParam("_GlobalColorTop0123", getVector(GlobalColorTop, 0, 3)); SetShaderParam("_GlobalColorColormapLoSat0123", getVector(GlobalColorColormapLoSat, 0, 3)); SetShaderParam("_GlobalColorColormapHiSat0123", getVector(GlobalColorColormapHiSat, 0, 3)); SetShaderParam("_GlobalColorLayerLoSat0123", getVector(GlobalColorLayerLoSat, 0, 3)); SetShaderParam("_GlobalColorLayerHiSat0123", getVector(GlobalColorLayerHiSat, 0, 3)); SetShaderParam("_GlobalColorLoBlend0123", getVector(GlobalColorLoBlend, 0, 3)); SetShaderParam("_GlobalColorHiBlend0123", getVector(GlobalColorHiBlend, 0, 3)); SetShaderParam("PER_LAYER_HEIGHT_MODIFIER0123", getVector(PER_LAYER_HEIGHT_MODIFIER, 0,3)); SetShaderParam("rtp_snow_strength_per_layer0123", getVector(_snow_strength_per_layer, 0,3)); SetShaderParam("_SuperDetailStrengthMultA0123", getVector(_SuperDetailStrengthMultA, 0,3)); SetShaderParam("_SuperDetailStrengthMultB0123", getVector(_SuperDetailStrengthMultB, 0,3)); SetShaderParam("_SuperDetailStrengthNormal0123", getVector(_SuperDetailStrengthNormal, 0,3)); SetShaderParam("_BumpMapGlobalStrength0123", getVector(_BumpMapGlobalStrength, 0,3)); SetShaderParam("_SuperDetailStrengthMultASelfMaskNear0123", getVector(_SuperDetailStrengthMultASelfMaskNear, 0,3)); SetShaderParam("_SuperDetailStrengthMultASelfMaskFar0123", getVector(_SuperDetailStrengthMultASelfMaskFar, 0,3)); SetShaderParam("_SuperDetailStrengthMultBSelfMaskNear0123", getVector(_SuperDetailStrengthMultBSelfMaskNear, 0,3)); SetShaderParam("_SuperDetailStrengthMultBSelfMaskFar0123", getVector(_SuperDetailStrengthMultBSelfMaskFar, 0,3)); SetShaderParam("TERRAIN_LayerWetStrength0123", getVector(TERRAIN_LayerWetStrength, 0,3)); SetShaderParam("TERRAIN_WaterLevel0123", getVector(TERRAIN_WaterLevel, 0,3)); SetShaderParam("TERRAIN_WaterLevelSlopeDamp0123", getVector(TERRAIN_WaterLevelSlopeDamp, 0,3)); SetShaderParam("TERRAIN_WaterEdge0123", getVector(TERRAIN_WaterEdge, 0,3)); SetShaderParam("TERRAIN_WaterSpecularity0123", getVector(TERRAIN_WaterSpecularity, 0,3)); SetShaderParam("TERRAIN_WaterGloss0123", getVector(TERRAIN_WaterGloss, 0,3)); SetShaderParam("TERRAIN_WaterGlossDamper0123", getVector(TERRAIN_WaterGlossDamper, 0,3)); SetShaderParam("TERRAIN_WaterOpacity0123", getVector(TERRAIN_WaterOpacity, 0,3)); SetShaderParam("TERRAIN_Refraction0123", getVector(TERRAIN_Refraction, 0,3)); SetShaderParam("TERRAIN_WetRefraction0123", getVector(TERRAIN_WetRefraction, 0,3)); SetShaderParam("TERRAIN_Flow0123", getVector(TERRAIN_Flow, 0,3)); SetShaderParam("TERRAIN_WetFlow0123", getVector(TERRAIN_WetFlow, 0,3)); SetShaderParam("TERRAIN_WetSpecularity0123", getVector(TERRAIN_WetSpecularity, 0,3)); SetShaderParam("TERRAIN_WetGloss0123", getVector(TERRAIN_WetGloss, 0,3)); SetShaderParam("TERRAIN_WaterColorR0123", getColorVector(TERRAIN_WaterColor, 0,3, 0)); SetShaderParam("TERRAIN_WaterColorG0123", getColorVector(TERRAIN_WaterColor, 0,3, 1)); SetShaderParam("TERRAIN_WaterColorB0123", getColorVector(TERRAIN_WaterColor, 0,3, 2)); SetShaderParam("TERRAIN_WaterColorA0123", getColorVector(TERRAIN_WaterColor, 0,3, 3)); SetShaderParam("TERRAIN_WaterIBL_SpecWetStrength0123", getVector( TERRAIN_WaterIBL_SpecWetStrength, 0,3)); SetShaderParam("TERRAIN_WaterIBL_SpecWaterStrength0123", getVector( TERRAIN_WaterIBL_SpecWaterStrength, 0,3)); SetShaderParam("TERRAIN_WaterEmission0123", getVector( TERRAIN_WaterEmission, 0,3)); SetShaderParam("RTP_AO_0123", getVector(AO_strength, 0,3)); SetShaderParam("_VerticalTexture0123", getVector(VerticalTextureStrength, 0,3)); if ((numLayers>4) && _4LAYERS_SHADER_USED) { // // przekieruj parametry warstw 4-7 na AddPass // SetShaderParam("_Spec89AB", getVector(Spec, 4,7)); SetShaderParam("_FarSpecCorrection89AB", getVector(FarSpecCorrection, 4,7)); SetShaderParam("_MIPmult89AB", getVector(MIPmult, 4,7)); SetShaderParam("_MixScale89AB", getVector(MixScale, 4,7)); SetShaderParam("_MixBlend89AB", getVector(MixBlend, 4,7)); SetShaderParam("_MixSaturation89AB", getVector(MixSaturation, 4, 7)); // RTP3.1 SetShaderParam("RTP_gloss2mask89AB", getVector(RTP_gloss2mask, 4, 7)); SetShaderParam("RTP_gloss_mult89AB", getVector(tmp_RTP_gloss_mult, 4, 7)); SetShaderParam("RTP_gloss_shaping89AB", getVector(tmp_RTP_gloss_shaping, 4, 7)); SetShaderParam("RTP_Fresnel89AB", getVector(RTP_Fresnel, 4, 7)); SetShaderParam("RTP_FresnelAtten89AB", getVector(RTP_FresnelAtten, 4, 7)); SetShaderParam("RTP_DiffFresnel89AB", getVector(RTP_DiffFresnel, 4, 7)); SetShaderParam("RTP_IBL_bump_smoothness89AB", getVector(RTP_IBL_bump_smoothness, 4, 7)); SetShaderParam("RTP_IBL_DiffuseStrength89AB", getVector(RTP_IBL_DiffuseStrength, 4, 7)); SetShaderParam("RTP_IBL_SpecStrength89AB", getVector(RTP_IBL_SpecStrength, 4, 7)); SetShaderParam("_DeferredSpecDampAddPass89AB", getVector(_DeferredSpecDampAddPass, 4,7)); SetShaderParam("_MixBrightness89AB", getVector(MixBrightness, 4, 7)); SetShaderParam("_MixReplace89AB", getVector(MixReplace, 4, 7)); SetShaderParam("_LayerBrightness89AB", MasterLayerBrightness*getVector(LayerBrightness, 4, 7)); SetShaderParam("_LayerSaturation89AB", MasterLayerSaturation*getVector(LayerSaturation, 4, 7)); SetShaderParam("_LayerEmission89AB", getVector(LayerEmission, 4, 7)); SetShaderParam("_LayerEmissionColorR89AB", getColorVector(LayerEmissionColor, 4, 7, 0)); SetShaderParam("_LayerEmissionColorG89AB", getColorVector(LayerEmissionColor, 4, 7, 1)); SetShaderParam("_LayerEmissionColorB89AB", getColorVector(LayerEmissionColor, 4, 7, 2)); SetShaderParam("_LayerEmissionColorA89AB", getColorVector(LayerEmissionColor, 4, 7, 3)); SetShaderParam("_LayerBrightness2Spec89AB", getVector(LayerBrightness2Spec, 4, 7)); SetShaderParam("_LayerAlbedo2SpecColor89AB", getVector(LayerAlbedo2SpecColor, 4, 7)); SetShaderParam("_LayerEmissionRefractStrength89AB", getVector(LayerEmissionRefractStrength, 4, 7)); SetShaderParam("_LayerEmissionRefractHBedge89AB", getVector(LayerEmissionRefractHBedge, 4, 7)); SetShaderParam("_GlobalColorPerLayer89AB", getVector(GlobalColorPerLayer, 4, 7)); SetShaderParam("_GlobalColorBottom89AB", getVector(GlobalColorBottom, 4, 7)); SetShaderParam("_GlobalColorTop89AB", getVector(GlobalColorTop, 4, 7)); SetShaderParam("_GlobalColorColormapLoSat89AB", getVector(GlobalColorColormapLoSat, 4, 7)); SetShaderParam("_GlobalColorColormapHiSat89AB", getVector(GlobalColorColormapHiSat, 4, 7)); SetShaderParam("_GlobalColorLayerLoSat89AB", getVector(GlobalColorLayerLoSat, 4, 7)); SetShaderParam("_GlobalColorLayerHiSat89AB", getVector(GlobalColorLayerHiSat, 4, 7)); SetShaderParam("_GlobalColorLoBlend89AB", getVector(GlobalColorLoBlend, 4, 7)); SetShaderParam("_GlobalColorHiBlend89AB", getVector(GlobalColorHiBlend, 4, 7)); SetShaderParam("PER_LAYER_HEIGHT_MODIFIER89AB", getVector(PER_LAYER_HEIGHT_MODIFIER, 4,7)); SetShaderParam("rtp_snow_strength_per_layer89AB", getVector(_snow_strength_per_layer, 4,7)); SetShaderParam("_SuperDetailStrengthMultA89AB", getVector(_SuperDetailStrengthMultA, 4,7)); SetShaderParam("_SuperDetailStrengthMultB89AB", getVector(_SuperDetailStrengthMultB, 4,7)); SetShaderParam("_SuperDetailStrengthNormal89AB", getVector(_SuperDetailStrengthNormal, 4,7)); SetShaderParam("_BumpMapGlobalStrength89AB", getVector(_BumpMapGlobalStrength, 4,7)); SetShaderParam("_SuperDetailStrengthMultASelfMaskNear89AB", getVector(_SuperDetailStrengthMultASelfMaskNear, 4,7)); SetShaderParam("_SuperDetailStrengthMultASelfMaskFar89AB", getVector(_SuperDetailStrengthMultASelfMaskFar, 4,7)); SetShaderParam("_SuperDetailStrengthMultBSelfMaskNear89AB", getVector(_SuperDetailStrengthMultBSelfMaskNear, 4,7)); SetShaderParam("_SuperDetailStrengthMultBSelfMaskFar89AB", getVector(_SuperDetailStrengthMultBSelfMaskFar, 4,7)); SetShaderParam("TERRAIN_LayerWetStrength89AB", getVector(TERRAIN_LayerWetStrength, 4,7)); SetShaderParam("TERRAIN_WaterLevel89AB", getVector(TERRAIN_WaterLevel, 4,7)); SetShaderParam("TERRAIN_WaterLevelSlopeDamp89AB", getVector(TERRAIN_WaterLevelSlopeDamp, 4,7)); SetShaderParam("TERRAIN_WaterEdge89AB", getVector(TERRAIN_WaterEdge, 4,7)); SetShaderParam("TERRAIN_WaterSpecularity89AB", getVector(TERRAIN_WaterSpecularity, 4,7)); SetShaderParam("TERRAIN_WaterGloss89AB", getVector(TERRAIN_WaterGloss, 4,7)); SetShaderParam("TERRAIN_WaterGlossDamper89AB", getVector(TERRAIN_WaterGlossDamper, 4,7)); SetShaderParam("TERRAIN_WaterOpacity89AB", getVector(TERRAIN_WaterOpacity, 4,7)); SetShaderParam("TERRAIN_Refraction89AB", getVector(TERRAIN_Refraction, 4,7)); SetShaderParam("TERRAIN_WetRefraction89AB", getVector(TERRAIN_WetRefraction, 4,7)); SetShaderParam("TERRAIN_Flow89AB", getVector(TERRAIN_Flow, 4,7)); SetShaderParam("TERRAIN_WetFlow89AB", getVector(TERRAIN_WetFlow, 4,7)); SetShaderParam("TERRAIN_WetSpecularity89AB", getVector(TERRAIN_WetSpecularity, 4,7)); SetShaderParam("TERRAIN_WetGloss89AB", getVector(TERRAIN_WetGloss, 4,7)); SetShaderParam("TERRAIN_WaterColorR89AB", getColorVector(TERRAIN_WaterColor, 4,7, 0)); SetShaderParam("TERRAIN_WaterColorG89AB", getColorVector(TERRAIN_WaterColor, 4,7, 1)); SetShaderParam("TERRAIN_WaterColorB89AB", getColorVector(TERRAIN_WaterColor, 4,7, 2)); SetShaderParam("TERRAIN_WaterColorA89AB", getColorVector(TERRAIN_WaterColor, 4,7, 3)); SetShaderParam("TERRAIN_WaterIBL_SpecWetStrength89AB", getVector(TERRAIN_WaterIBL_SpecWetStrength, 4,7)); SetShaderParam("TERRAIN_WaterIBL_SpecWaterStrength89AB", getVector(TERRAIN_WaterIBL_SpecWaterStrength, 4,7)); SetShaderParam("TERRAIN_WaterEmission89AB", getVector( TERRAIN_WaterEmission, 4,7)); SetShaderParam("RTP_AO_89AB", getVector(AO_strength, 4,7)); SetShaderParam("_VerticalTexture89AB", getVector(VerticalTextureStrength, 4,7)); } else { SetShaderParam("_Spec4567", getVector(Spec, 4,7)); SetShaderParam("_FarSpecCorrection4567", getVector(FarSpecCorrection, 4,7)); SetShaderParam("_MIPmult4567", getVector(MIPmult, 4,7)); SetShaderParam("_MixScale4567", getVector(MixScale, 4,7)); SetShaderParam("_MixBlend4567", getVector(MixBlend, 4,7)); SetShaderParam("_MixSaturation4567", getVector(MixSaturation, 4, 7)); // RTP3.1 SetShaderParam("RTP_gloss2mask4567", getVector(RTP_gloss2mask, 4, 7)); SetShaderParam("RTP_gloss_mult4567", getVector(tmp_RTP_gloss_mult, 4, 7)); SetShaderParam("RTP_gloss_shaping4567", getVector(tmp_RTP_gloss_shaping, 4, 7)); SetShaderParam("RTP_Fresnel4567", getVector(RTP_Fresnel, 4, 7)); SetShaderParam("RTP_FresnelAtten4567", getVector(RTP_FresnelAtten, 4, 7)); SetShaderParam("RTP_DiffFresnel4567", getVector(RTP_DiffFresnel, 4, 7)); SetShaderParam("RTP_IBL_bump_smoothness4567", getVector(RTP_IBL_bump_smoothness, 4, 7)); SetShaderParam("RTP_IBL_DiffuseStrength4567", getVector(RTP_IBL_DiffuseStrength, 4, 7)); SetShaderParam("RTP_IBL_SpecStrength4567", getVector(RTP_IBL_SpecStrength, 4, 7)); // only in deferred add pass //SetShaderParam("_DeferredSpecDampAddPass4567", getVector(_DeferredSpecDampAddPass, 4,7)); SetShaderParam("_MixBrightness4567", getVector(MixBrightness, 4, 7)); SetShaderParam("_MixReplace4567", getVector(MixReplace, 4, 7)); SetShaderParam("_LayerBrightness4567", MasterLayerBrightness*getVector(LayerBrightness, 4, 7)); SetShaderParam("_LayerSaturation4567", MasterLayerSaturation*getVector(LayerSaturation, 4, 7)); SetShaderParam("_LayerEmission4567", getVector(LayerEmission, 4, 7)); SetShaderParam("_LayerEmissionColorR4567", getColorVector(LayerEmissionColor, 4, 7, 0)); SetShaderParam("_LayerEmissionColorG4567", getColorVector(LayerEmissionColor, 4, 7, 1)); SetShaderParam("_LayerEmissionColorB4567", getColorVector(LayerEmissionColor, 4, 7, 2)); SetShaderParam("_LayerEmissionColorA4567", getColorVector(LayerEmissionColor, 4, 7, 3)); SetShaderParam("_LayerBrightness2Spec4567", getVector(LayerBrightness2Spec, 4, 7)); SetShaderParam("_LayerAlbedo2SpecColor4567", getVector(LayerAlbedo2SpecColor, 4, 7)); SetShaderParam("_LayerEmissionRefractStrength4567", getVector(LayerEmissionRefractStrength, 4, 7)); SetShaderParam("_LayerEmissionRefractHBedge4567", getVector(LayerEmissionRefractHBedge, 4, 7)); SetShaderParam("_GlobalColorPerLayer4567", getVector(GlobalColorPerLayer, 4, 7)); SetShaderParam("_GlobalColorBottom4567", getVector(GlobalColorBottom, 4, 7)); SetShaderParam("_GlobalColorTop4567", getVector(GlobalColorTop, 4, 7)); SetShaderParam("_GlobalColorColormapLoSat4567", getVector(GlobalColorColormapLoSat, 4, 7)); SetShaderParam("_GlobalColorColormapHiSat4567", getVector(GlobalColorColormapHiSat, 4, 7)); SetShaderParam("_GlobalColorLayerLoSat4567", getVector(GlobalColorLayerLoSat, 4, 7)); SetShaderParam("_GlobalColorLayerHiSat4567", getVector(GlobalColorLayerHiSat, 4, 7)); SetShaderParam("_GlobalColorLoBlend4567", getVector(GlobalColorLoBlend, 4, 7)); SetShaderParam("_GlobalColorHiBlend4567", getVector(GlobalColorHiBlend, 4, 7)); SetShaderParam("PER_LAYER_HEIGHT_MODIFIER4567", getVector(PER_LAYER_HEIGHT_MODIFIER, 4,7)); SetShaderParam("rtp_snow_strength_per_layer4567", getVector(_snow_strength_per_layer, 4,7)); SetShaderParam("_SuperDetailStrengthMultA4567", getVector(_SuperDetailStrengthMultA, 4,7)); SetShaderParam("_SuperDetailStrengthMultB4567", getVector(_SuperDetailStrengthMultB, 4,7)); SetShaderParam("_SuperDetailStrengthNormal4567", getVector(_SuperDetailStrengthNormal, 4,7)); SetShaderParam("_BumpMapGlobalStrength4567", getVector(_BumpMapGlobalStrength, 4,7)); SetShaderParam("_SuperDetailStrengthMultASelfMaskNear4567", getVector(_SuperDetailStrengthMultASelfMaskNear, 4,7)); SetShaderParam("_SuperDetailStrengthMultASelfMaskFar4567", getVector(_SuperDetailStrengthMultASelfMaskFar, 4,7)); SetShaderParam("_SuperDetailStrengthMultBSelfMaskNear4567", getVector(_SuperDetailStrengthMultBSelfMaskNear, 4,7)); SetShaderParam("_SuperDetailStrengthMultBSelfMaskFar4567", getVector(_SuperDetailStrengthMultBSelfMaskFar, 4,7)); SetShaderParam("TERRAIN_LayerWetStrength4567", getVector(TERRAIN_LayerWetStrength, 4,7)); SetShaderParam("TERRAIN_WaterLevel4567", getVector(TERRAIN_WaterLevel, 4,7)); SetShaderParam("TERRAIN_WaterLevelSlopeDamp4567", getVector(TERRAIN_WaterLevelSlopeDamp, 4,7)); SetShaderParam("TERRAIN_WaterEdge4567", getVector(TERRAIN_WaterEdge, 4,7)); SetShaderParam("TERRAIN_WaterSpecularity4567", getVector(TERRAIN_WaterSpecularity, 4,7)); SetShaderParam("TERRAIN_WaterGloss4567", getVector(TERRAIN_WaterGloss, 4,7)); SetShaderParam("TERRAIN_WaterGlossDamper4567", getVector(TERRAIN_WaterGlossDamper, 4,7)); SetShaderParam("TERRAIN_WaterOpacity4567", getVector(TERRAIN_WaterOpacity, 4,7)); SetShaderParam("TERRAIN_Refraction4567", getVector(TERRAIN_Refraction, 4,7)); SetShaderParam("TERRAIN_WetRefraction4567", getVector(TERRAIN_WetRefraction, 4,7)); SetShaderParam("TERRAIN_Flow4567", getVector(TERRAIN_Flow, 4,7)); SetShaderParam("TERRAIN_WetFlow4567", getVector(TERRAIN_WetFlow, 4,7)); SetShaderParam("TERRAIN_WetSpecularity4567", getVector(TERRAIN_WetSpecularity, 4,7)); SetShaderParam("TERRAIN_WetGloss4567", getVector(TERRAIN_WetGloss, 4,7)); SetShaderParam("TERRAIN_WaterColorR4567", getColorVector(TERRAIN_WaterColor, 4,7, 0)); SetShaderParam("TERRAIN_WaterColorG4567", getColorVector(TERRAIN_WaterColor, 4,7, 1)); SetShaderParam("TERRAIN_WaterColorB4567", getColorVector(TERRAIN_WaterColor, 4,7, 2)); SetShaderParam("TERRAIN_WaterColorA4567", getColorVector(TERRAIN_WaterColor, 4,7, 3)); SetShaderParam("TERRAIN_WaterIBL_SpecWetStrength4567", getVector( TERRAIN_WaterIBL_SpecWetStrength, 4,7)); SetShaderParam("TERRAIN_WaterIBL_SpecWaterStrength4567", getVector( TERRAIN_WaterIBL_SpecWaterStrength, 4,7)); SetShaderParam("TERRAIN_WaterEmission4567", getVector( TERRAIN_WaterEmission, 4,7)); SetShaderParam("RTP_AO_4567", getVector(AO_strength, 4,7)); SetShaderParam("_VerticalTexture4567", getVector(VerticalTextureStrength, 4,7)); // // AddPass // SetShaderParam("_Spec89AB", getVector(Spec, 8,11)); SetShaderParam("_FarSpecCorrection89AB", getVector(FarSpecCorrection, 8,11)); SetShaderParam("_MIPmult89AB", getVector(MIPmult, 8,11)); SetShaderParam("_MixScale89AB", getVector(MixScale, 8,11)); SetShaderParam("_MixBlend89AB", getVector(MixBlend, 8,11)); SetShaderParam("_MixSaturation89AB", getVector(MixSaturation, 8, 11)); // RTP3.1 SetShaderParam("RTP_gloss2mask89AB", getVector(RTP_gloss2mask, 8,11)); SetShaderParam("RTP_gloss_mult89AB", getVector(tmp_RTP_gloss_mult, 8,11)); SetShaderParam("RTP_gloss_shaping89AB", getVector(tmp_RTP_gloss_shaping, 8,11)); SetShaderParam("RTP_Fresnel89AB", getVector(RTP_Fresnel, 8,11)); SetShaderParam("RTP_FresnelAtten89AB", getVector(RTP_FresnelAtten, 8,11)); SetShaderParam("RTP_DiffFresnel89AB", getVector(RTP_DiffFresnel, 8,11)); SetShaderParam("RTP_IBL_bump_smoothness89AB", getVector(RTP_IBL_bump_smoothness, 8,11)); SetShaderParam("RTP_IBL_DiffuseStrength89AB", getVector(RTP_IBL_DiffuseStrength, 8,11)); SetShaderParam("RTP_IBL_SpecStrength89AB", getVector(RTP_IBL_SpecStrength, 8,11)); SetShaderParam("_DeferredSpecDampAddPass89AB", getVector(_DeferredSpecDampAddPass, 8,11)); SetShaderParam("_MixBrightness89AB", getVector(MixBrightness, 8, 11)); SetShaderParam("_MixReplace89AB", getVector(MixReplace, 8, 11)); SetShaderParam("_LayerBrightness89AB", MasterLayerBrightness*getVector(LayerBrightness, 8, 11)); SetShaderParam("_LayerSaturation89AB", MasterLayerSaturation*getVector(LayerSaturation, 8, 11)); SetShaderParam("_LayerEmission89AB", getVector(LayerEmission, 8, 11)); SetShaderParam("_LayerEmissionColorR89AB", getColorVector(LayerEmissionColor, 8, 11, 0)); SetShaderParam("_LayerEmissionColorG89AB", getColorVector(LayerEmissionColor, 8, 11, 1)); SetShaderParam("_LayerEmissionColorB89AB", getColorVector(LayerEmissionColor, 8, 11, 2)); SetShaderParam("_LayerEmissionColorA89AB", getColorVector(LayerEmissionColor, 8, 11, 3)); SetShaderParam("_LayerBrightness2Spec89AB", getVector(LayerBrightness2Spec, 8, 11)); SetShaderParam("_LayerAlbedo2SpecColor89AB", getVector(LayerAlbedo2SpecColor, 8, 11)); SetShaderParam("_LayerEmissionRefractStrength89AB", getVector(LayerEmissionRefractStrength, 8, 11)); SetShaderParam("_LayerEmissionRefractHBedge89AB", getVector(LayerEmissionRefractHBedge, 8, 11)); SetShaderParam("_GlobalColorPerLayer89AB", getVector(GlobalColorPerLayer, 8, 11)); SetShaderParam("_GlobalColorBottom89AB", getVector(GlobalColorBottom, 8, 11)); SetShaderParam("_GlobalColorTop89AB", getVector(GlobalColorTop, 8, 11)); SetShaderParam("_GlobalColorColormapLoSat89AB", getVector(GlobalColorColormapLoSat, 8, 11)); SetShaderParam("_GlobalColorColormapHiSat89AB", getVector(GlobalColorColormapHiSat, 8, 11)); SetShaderParam("_GlobalColorLayerLoSat89AB", getVector(GlobalColorLayerLoSat, 8, 11)); SetShaderParam("_GlobalColorLayerHiSat89AB", getVector(GlobalColorLayerHiSat, 8, 11)); SetShaderParam("_GlobalColorLoBlend89AB", getVector(GlobalColorLoBlend, 8, 11)); SetShaderParam("_GlobalColorHiBlend89AB", getVector(GlobalColorHiBlend, 8, 11)); SetShaderParam("PER_LAYER_HEIGHT_MODIFIER89AB", getVector(PER_LAYER_HEIGHT_MODIFIER, 8,11)); SetShaderParam("rtp_snow_strength_per_layer89AB", getVector(_snow_strength_per_layer, 8,11)); SetShaderParam("_SuperDetailStrengthMultA89AB", getVector(_SuperDetailStrengthMultA, 8,11)); SetShaderParam("_SuperDetailStrengthMultB89AB", getVector(_SuperDetailStrengthMultB, 8,11)); SetShaderParam("_SuperDetailStrengthNormal89AB", getVector(_SuperDetailStrengthNormal, 8,11)); SetShaderParam("_BumpMapGlobalStrength89AB", getVector(_BumpMapGlobalStrength, 8,11)); SetShaderParam("_SuperDetailStrengthMultASelfMaskNear89AB", getVector(_SuperDetailStrengthMultASelfMaskNear, 8,11)); SetShaderParam("_SuperDetailStrengthMultASelfMaskFar89AB", getVector(_SuperDetailStrengthMultASelfMaskFar, 8,11)); SetShaderParam("_SuperDetailStrengthMultBSelfMaskNear89AB", getVector(_SuperDetailStrengthMultBSelfMaskNear, 8,11)); SetShaderParam("_SuperDetailStrengthMultBSelfMaskFar89AB", getVector(_SuperDetailStrengthMultBSelfMaskFar, 8,11)); SetShaderParam("TERRAIN_LayerWetStrength89AB", getVector(TERRAIN_LayerWetStrength, 8,11)); SetShaderParam("TERRAIN_WaterLevel89AB", getVector(TERRAIN_WaterLevel, 8,11)); SetShaderParam("TERRAIN_WaterLevelSlopeDamp89AB", getVector(TERRAIN_WaterLevelSlopeDamp, 8,11)); SetShaderParam("TERRAIN_WaterEdge89AB", getVector(TERRAIN_WaterEdge, 8,11)); SetShaderParam("TERRAIN_WaterSpecularity89AB", getVector(TERRAIN_WaterSpecularity, 8,11)); SetShaderParam("TERRAIN_WaterGloss89AB", getVector(TERRAIN_WaterGloss, 8,11)); SetShaderParam("TERRAIN_WaterGlossDamper89AB", getVector(TERRAIN_WaterGlossDamper, 8,11)); SetShaderParam("TERRAIN_WaterOpacity89AB", getVector(TERRAIN_WaterOpacity, 8,11)); SetShaderParam("TERRAIN_Refraction89AB", getVector(TERRAIN_Refraction, 8,11)); SetShaderParam("TERRAIN_WetRefraction89AB", getVector(TERRAIN_WetRefraction, 8,11)); SetShaderParam("TERRAIN_Flow89AB", getVector(TERRAIN_Flow, 8,11)); SetShaderParam("TERRAIN_WetFlow89AB", getVector(TERRAIN_WetFlow, 8,11)); SetShaderParam("TERRAIN_WetSpecularity89AB", getVector(TERRAIN_WetSpecularity, 8,11)); SetShaderParam("TERRAIN_WetGloss89AB", getVector(TERRAIN_WetGloss, 8,11)); SetShaderParam("TERRAIN_WaterColorR89AB", getColorVector(TERRAIN_WaterColor, 8,11, 0)); SetShaderParam("TERRAIN_WaterColorG89AB", getColorVector(TERRAIN_WaterColor, 8,11, 1)); SetShaderParam("TERRAIN_WaterColorB89AB", getColorVector(TERRAIN_WaterColor, 8,11, 2)); SetShaderParam("TERRAIN_WaterColorA89AB", getColorVector(TERRAIN_WaterColor, 8,11, 3)); SetShaderParam("TERRAIN_WaterIBL_SpecWetStrength89AB", getVector(TERRAIN_WaterIBL_SpecWetStrength, 8,11)); SetShaderParam("TERRAIN_WaterIBL_SpecWaterStrength89AB", getVector(TERRAIN_WaterIBL_SpecWaterStrength, 8,11)); SetShaderParam("TERRAIN_WaterEmission89AB", getVector( TERRAIN_WaterEmission, 8,11)); SetShaderParam("RTP_AO_89AB", getVector(AO_strength, 8,11)); SetShaderParam("_VerticalTexture89AB", getVector(VerticalTextureStrength, 8,11)); } ///////////////////////////////////////////////////////////////////// // // layer dependent textures // ///////////////////////////////////////////////////////////////////// // update (RTP3.1) if (splat_atlases.Length==2) { Texture2D _atA=splat_atlases[0]; Texture2D _atB=splat_atlases[1]; splat_atlases=new Texture2D[3]; splat_atlases[0]=_atA; splat_atlases[1]=_atB; } ApplyGlossBakedAtlas("_SplatAtlasA", 0); SetShaderParam("_BumpMap01", Bump01); SetShaderParam("_BumpMap23", Bump23); SetShaderParam("_TERRAIN_HeightMap", HeightMap); SetShaderParam("_SSColorCombinedA", SSColorCombinedA); if (numLayers>4) { ApplyGlossBakedAtlas("_SplatAtlasB", 1); ApplyGlossBakedAtlas("_SplatAtlasC", 1); SetShaderParam("_TERRAIN_HeightMap2", HeightMap2); SetShaderParam("_SSColorCombinedB", SSColorCombinedB); } if (numLayers>8) { ApplyGlossBakedAtlas("_SplatAtlasC", 2); } if ((numLayers>4) && _4LAYERS_SHADER_USED) { // // przekieruj parametry warstw 4-7 na AddPass // SetShaderParam("_BumpMap89", Bump45); SetShaderParam("_BumpMapAB", Bump67); SetShaderParam("_TERRAIN_HeightMap3", HeightMap2); // potrzebne przy sniegu (firstpass moze korzystac z koloru i bumpmap 4-7) SetShaderParam("_BumpMap45", Bump45); SetShaderParam("_BumpMap67", Bump67); } else { SetShaderParam("_BumpMap45", Bump45); SetShaderParam("_BumpMap67", Bump67); // // AddPass // SetShaderParam("_BumpMap89", Bump89); SetShaderParam("_BumpMapAB", BumpAB); SetShaderParam("_TERRAIN_HeightMap3", HeightMap3); } use_mat=null; }