byte[] get_color_channel(Texture2D source_tex, RTPColorChannels sourceChannel)
 {
     Color32[] cols = source_tex.GetPixels32();
     byte[]    ret  = new byte[cols.Length];
     if (sourceChannel == RTPColorChannels.R)
     {
         for (int i = 0; i < cols.Length; i++)
         {
             ret[i] = cols[i].r;
         }
     }
     if (sourceChannel == RTPColorChannels.G)
     {
         for (int i = 0; i < cols.Length; i++)
         {
             ret[i] = cols[i].g;
         }
     }
     if (sourceChannel == RTPColorChannels.B)
     {
         for (int i = 0; i < cols.Length; i++)
         {
             ret[i] = cols[i].b;
         }
     }
     if (sourceChannel == RTPColorChannels.A)
     {
         for (int i = 0; i < cols.Length; i++)
         {
             ret[i] = cols[i].a;
         }
     }
     return(ret);
 }
	void OnGUI() {
		if (finalize) {
			// select created texture
			Selection.activeObject=AssetDatabase.LoadAssetAtPath(save_path, typeof(Texture2D));
			finalize=false;
		}
		
		EditorGUILayout.Space();
        source_tex0 = EditorGUILayout.ObjectField("Source Texture 0", source_tex0, typeof(Texture2D), false) as Texture2D;
		EditorGUILayout.Space();
        source_tex1 = EditorGUILayout.ObjectField("Source Texture 1", source_tex1, typeof(Texture2D), false) as Texture2D;
		EditorGUILayout.Space();
        source_tex2 = EditorGUILayout.ObjectField("Source Texture 2", source_tex2, typeof(Texture2D), false) as Texture2D;
		EditorGUILayout.Space();
        source_tex3 = EditorGUILayout.ObjectField("Source Texture 3", source_tex3, typeof(Texture2D), false) as Texture2D;
		
		EditorGUILayout.Space();
		if (source_tex0) {
			int sources_ready=0;
			if (check_texture(source_tex0, 0, source_tex0.width, source_tex0.height)) { sources_ready++; sourceChannel0 = (RTPColorChannels)EditorGUILayout.EnumPopup("Target R from source 0", sourceChannel0); }
	        if (check_texture(source_tex1, 1, source_tex0.width, source_tex0.height)) { sources_ready++; sourceChannel1 = (RTPColorChannels)EditorGUILayout.EnumPopup("Target G from source 1", sourceChannel1); }
	        if (check_texture(source_tex2, 2, source_tex0.width, source_tex0.height)) { sources_ready++; sourceChannel2 = (RTPColorChannels)EditorGUILayout.EnumPopup("Target B from source 2", sourceChannel2); }
	        if (check_texture(source_tex3, 3, source_tex0.width, source_tex0.height)) { sources_ready++; sourceChannel3 = (RTPColorChannels)EditorGUILayout.EnumPopup("Target A from source 3", sourceChannel3); }
			
			if (sources_ready==4) {
				if (GUILayout.Button("Render mixed texture")) {
					rendered_tex=new Texture2D(source_tex0.width, source_tex0.height, TextureFormat.ARGB32, true);
					byte[] colsR=get_color_channel(source_tex0, sourceChannel0);
					byte[] colsG=get_color_channel(source_tex1, sourceChannel1);
					byte[] colsB=get_color_channel(source_tex2, sourceChannel2);
					byte[] colsA=get_color_channel(source_tex3, sourceChannel3);
					Color32[] cols=rendered_tex.GetPixels32();
					for(int i=0; i<cols.Length; i++) {
						cols[i].r=colsR[i];
						cols[i].g=colsG[i];
						cols[i].b=colsB[i];
						cols[i].a=colsA[i];
					}
					rendered_tex.SetPixels32(cols);
					if (Selection.activeObject is Texture2D) {
						save_path=AssetDatabase.GetAssetPath(Selection.activeObject as Texture2D);
						directory=Path.GetDirectoryName(save_path);
						file=Path.GetFileNameWithoutExtension(save_path)+".png";
					} else {
						if (save_path=="") {
							directory=Path.GetDirectoryName(AssetDatabase.GetAssetPath(source_tex0));
							file=Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(source_tex0))+"(mixed).png";
						}
					}
				}
			}
		}
		if (rendered_tex) {
			linearTexture=GUILayout.Toggle(linearTexture, "Linear texture (Bypass sRGB Sampling)");
			if (GUILayout.Button("Save texture")) {
				SaveTexture(directory, file);
			}
		}
	}
 byte[] get_color_channel(Texture2D source_tex, RTPColorChannels sourceChannel)
 {
     Color32[] cols=source_tex.GetPixels32();
     byte[] ret=new byte[cols.Length];
     if (sourceChannel==RTPColorChannels.R) for(int i=0; i<cols.Length; i++) 	ret[i]=cols[i].r;
     if (sourceChannel==RTPColorChannels.G) for(int i=0; i<cols.Length; i++) 	ret[i]=cols[i].g;
     if (sourceChannel==RTPColorChannels.B) for(int i=0; i<cols.Length; i++) 	ret[i]=cols[i].b;
     if (sourceChannel==RTPColorChannels.A) for(int i=0; i<cols.Length; i++) 	ret[i]=cols[i].a;
     return ret;
 }
    void OnGUI()
    {
        if (finalize)
        {
            // select created texture
            Selection.activeObject = AssetDatabase.LoadAssetAtPath(save_path, typeof(Texture2D));
            finalize = false;
        }

        EditorGUILayout.Space();
        source_tex0 = EditorGUILayout.ObjectField("Source Texture 0", source_tex0, typeof(Texture2D), false) as Texture2D;
        EditorGUILayout.Space();
        source_tex1 = EditorGUILayout.ObjectField("Source Texture 1", source_tex1, typeof(Texture2D), false) as Texture2D;
        EditorGUILayout.Space();
        source_tex2 = EditorGUILayout.ObjectField("Source Texture 2", source_tex2, typeof(Texture2D), false) as Texture2D;
        EditorGUILayout.Space();
        source_tex3 = EditorGUILayout.ObjectField("Source Texture 3", source_tex3, typeof(Texture2D), false) as Texture2D;

        EditorGUILayout.Space();
        if (source_tex0)
        {
            int sources_ready = 0;
            if (check_texture(source_tex0, 0, source_tex0.width, source_tex0.height))
            {
                sources_ready++; sourceChannel0 = (RTPColorChannels)EditorGUILayout.EnumPopup("Target R from source 0", sourceChannel0);
            }
            if (check_texture(source_tex1, 1, source_tex0.width, source_tex0.height))
            {
                sources_ready++; sourceChannel1 = (RTPColorChannels)EditorGUILayout.EnumPopup("Target G from source 1", sourceChannel1);
            }
            if (check_texture(source_tex2, 2, source_tex0.width, source_tex0.height))
            {
                sources_ready++; sourceChannel2 = (RTPColorChannels)EditorGUILayout.EnumPopup("Target B from source 2", sourceChannel2);
            }
            if (check_texture(source_tex3, 3, source_tex0.width, source_tex0.height))
            {
                sources_ready++; sourceChannel3 = (RTPColorChannels)EditorGUILayout.EnumPopup("Target A from source 3", sourceChannel3);
            }

            if (sources_ready == 4)
            {
                if (GUILayout.Button("Render mixed texture"))
                {
                    rendered_tex = new Texture2D(source_tex0.width, source_tex0.height, TextureFormat.ARGB32, true);
                    byte[]    colsR = get_color_channel(source_tex0, sourceChannel0);
                    byte[]    colsG = get_color_channel(source_tex1, sourceChannel1);
                    byte[]    colsB = get_color_channel(source_tex2, sourceChannel2);
                    byte[]    colsA = get_color_channel(source_tex3, sourceChannel3);
                    Color32[] cols  = rendered_tex.GetPixels32();
                    for (int i = 0; i < cols.Length; i++)
                    {
                        cols[i].r = colsR[i];
                        cols[i].g = colsG[i];
                        cols[i].b = colsB[i];
                        cols[i].a = colsA[i];
                    }
                    rendered_tex.SetPixels32(cols);
                    if (Selection.activeObject is Texture2D)
                    {
                        save_path = AssetDatabase.GetAssetPath(Selection.activeObject as Texture2D);
                        directory = Path.GetDirectoryName(save_path);
                        file      = Path.GetFileNameWithoutExtension(save_path) + ".png";
                    }
                    else
                    {
                        if (save_path == "")
                        {
                            directory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(source_tex0));
                            file      = Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(source_tex0)) + "(mixed).png";
                        }
                    }
                }
            }
        }
        if (rendered_tex)
        {
            linearTexture = GUILayout.Toggle(linearTexture, "Linear texture (Bypass sRGB Sampling)");
            if (GUILayout.Button("Save texture"))
            {
                SaveTexture(directory, file);
            }
        }
    }
예제 #5
0
		private bool checkChange(ref RTPColorChannels val, RTPColorChannels nval) {
			bool changed=(nval!=val);
			if (changed) {
				if ((EditorApplication.timeSinceStartup-changedTime)>0.5) {
					changedTime=EditorApplication.timeSinceStartup;
					#if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
					Undo.RegisterUndo((ReliefTerrain)target, "Undo relief terrain edit");
					#else
					Undo.RecordObject((ReliefTerrain)target, "Undo relief terrain edit");
					#endif
				}
			}
			dirtyFlag=dirtyFlag || changed;
			val=nval;
			return changed;
		}
    public void RestorePreset(ReliefTerrainPresetHolder holder)
    {
        numLayers=holder.numLayers;
        splats=new Texture2D[holder.splats.Length];
        for(int i=0; i<holder.splats.Length; i++) {
            splats[i]=holder.splats[i];
        }

        splat_atlases=new Texture2D[3];
        for(int i=0; i<splat_atlases.Length; i++) {
            splat_atlases[i]=holder.splat_atlases[i];
        }

        gloss_baked=holder.gloss_baked;
        // actualy used textures will be rebuild on next Refresh()
        splats_glossBaked=new Texture2D[12];
        atlas_glossBaked=new Texture2D[3];

        RTP_MIP_BIAS=holder.RTP_MIP_BIAS;
        _SpecColor=holder._SpecColor;
        RTP_DeferredAddPassSpec=holder.RTP_DeferredAddPassSpec;

        MasterLayerBrightness=holder.MasterLayerBrightness;
        MasterLayerSaturation=holder.MasterLayerSaturation;

        SuperDetailA_channel=holder.SuperDetailA_channel;
        SuperDetailB_channel=holder.SuperDetailB_channel;

        Bump01=holder.Bump01;
        Bump23=holder.Bump23;
        Bump45=holder.Bump45;
        Bump67=holder.Bump67;
        Bump89=holder.Bump89;
        BumpAB=holder.BumpAB;

        SSColorCombinedA=holder.SSColorCombinedA;
        SSColorCombinedB=holder.SSColorCombinedB;

        BumpGlobal=holder.BumpGlobal;

        VerticalTexture=holder.VerticalTexture;
        BumpMapGlobalScale=holder.BumpMapGlobalScale;
        GlobalColorMapBlendValues=holder.GlobalColorMapBlendValues;
        GlobalColorMapSaturation=holder.GlobalColorMapSaturation;
        GlobalColorMapSaturationFar=holder.GlobalColorMapSaturationFar;
        //GlobalColorMapSaturationByPerlin=holder.GlobalColorMapSaturationByPerlin;
        GlobalColorMapDistortByPerlin=holder.GlobalColorMapDistortByPerlin;
        GlobalColorMapBrightness=holder.GlobalColorMapBrightness;
        GlobalColorMapBrightnessFar=holder.GlobalColorMapBrightnessFar;
        _GlobalColorMapNearMIP=holder._GlobalColorMapNearMIP;
        _FarNormalDamp=holder._FarNormalDamp;

        blendMultiplier=holder.blendMultiplier;

        HeightMap=holder.HeightMap;
        HeightMap2=holder.HeightMap2;
        HeightMap3=holder.HeightMap3;

        ReliefTransform=holder.ReliefTransform;
        DIST_STEPS=holder.DIST_STEPS;
        WAVELENGTH=holder.WAVELENGTH;
        ReliefBorderBlend=holder.ReliefBorderBlend;

        ExtrudeHeight=holder.ExtrudeHeight;
        LightmapShading=holder.LightmapShading;

        SHADOW_STEPS=holder.SHADOW_STEPS;
        WAVELENGTH_SHADOWS=holder.WAVELENGTH_SHADOWS;
        SHADOW_SMOOTH_STEPS=holder.SHADOW_SMOOTH_STEPS;
        SelfShadowStrength=holder.SelfShadowStrength;
        ShadowSmoothing=holder.ShadowSmoothing;

        distance_start=holder.distance_start;
        distance_transition=holder.distance_transition;
        distance_start_bumpglobal=holder.distance_start_bumpglobal;
        distance_transition_bumpglobal=holder.distance_transition_bumpglobal;
        rtp_perlin_start_val=holder.rtp_perlin_start_val;

        _Phong = holder._Phong;
        tessHeight = holder.tessHeight;
        _TessSubdivisions = holder._TessSubdivisions;
        _TessSubdivisionsFar = holder._TessSubdivisionsFar;
        _TessYOffset = holder._TessYOffset;

        trees_shadow_distance_start=holder.trees_shadow_distance_start;
        trees_shadow_distance_transition=holder.trees_shadow_distance_transition;
        trees_shadow_value=holder.trees_shadow_value;
        trees_pixel_distance_start=holder.trees_pixel_distance_start;
        trees_pixel_distance_transition=holder.trees_pixel_distance_transition;
        trees_pixel_blend_val=holder.trees_pixel_blend_val;
        global_normalMap_multiplier=holder.global_normalMap_multiplier;
        global_normalMap_farUsage=holder.global_normalMap_farUsage;

        _AmbientEmissiveMultiplier=holder._AmbientEmissiveMultiplier;
        _AmbientEmissiveRelief=holder._AmbientEmissiveRelief;

        rtp_mipoffset_globalnorm=holder.rtp_mipoffset_globalnorm;
        _SuperDetailTiling=holder._SuperDetailTiling;
        SuperDetailA=holder.SuperDetailA;
        SuperDetailB=holder.SuperDetailB;

        // reflection
        TERRAIN_ReflectionMap=holder.TERRAIN_ReflectionMap;
        TERRAIN_ReflectionMap_channel=holder.TERRAIN_ReflectionMap_channel;
        TERRAIN_ReflColorA=holder.TERRAIN_ReflColorA;
        TERRAIN_ReflColorB=holder.TERRAIN_ReflColorB;
        TERRAIN_ReflColorC=holder.TERRAIN_ReflColorC;
        TERRAIN_ReflColorCenter=holder.TERRAIN_ReflColorCenter;
        TERRAIN_ReflGlossAttenuation=holder.TERRAIN_ReflGlossAttenuation;
        TERRAIN_ReflectionRotSpeed=holder.TERRAIN_ReflectionRotSpeed;

        // water/wet
        TERRAIN_GlobalWetness=holder.TERRAIN_GlobalWetness;

        TERRAIN_RippleMap=holder.TERRAIN_RippleMap;
        TERRAIN_RippleScale=holder.TERRAIN_RippleScale;
        TERRAIN_FlowScale=holder.TERRAIN_FlowScale;
        TERRAIN_FlowSpeed=holder.TERRAIN_FlowSpeed;
        TERRAIN_FlowCycleScale=holder.TERRAIN_FlowCycleScale;
        TERRAIN_FlowMipOffset=holder.TERRAIN_FlowMipOffset;
        TERRAIN_WetDarkening=holder.TERRAIN_WetDarkening;
        TERRAIN_WetDropletsStrength=holder.TERRAIN_WetDropletsStrength;
        TERRAIN_WetHeight_Treshold=holder.TERRAIN_WetHeight_Treshold;
        TERRAIN_WetHeight_Transition=holder.TERRAIN_WetHeight_Transition;

        TERRAIN_RainIntensity=holder.TERRAIN_RainIntensity;
        TERRAIN_DropletsSpeed=holder.TERRAIN_DropletsSpeed;

        TERRAIN_mipoffset_flowSpeed=holder.TERRAIN_mipoffset_flowSpeed;

        // caustics
        TERRAIN_CausticsAnimSpeed=holder.TERRAIN_CausticsAnimSpeed;
        TERRAIN_CausticsColor=holder.TERRAIN_CausticsColor;
        TERRAIN_CausticsWaterLevel=holder.TERRAIN_CausticsWaterLevel;
        TERRAIN_CausticsWaterLevelByAngle=holder.TERRAIN_CausticsWaterLevelByAngle;
        TERRAIN_CausticsWaterDeepFadeLength=holder.TERRAIN_CausticsWaterDeepFadeLength;
        TERRAIN_CausticsWaterShallowFadeLength=holder.TERRAIN_CausticsWaterShallowFadeLength;
        TERRAIN_CausticsTilingScale=holder.TERRAIN_CausticsTilingScale;
        TERRAIN_CausticsTex=holder.TERRAIN_CausticsTex;

        rtp_customAmbientCorrection=holder.rtp_customAmbientCorrection;
        TERRAIN_IBL_DiffAO_Damp=holder.TERRAIN_IBL_DiffAO_Damp;
        TERRAIN_IBLRefl_SpecAO_Damp=holder.TERRAIN_IBLRefl_SpecAO_Damp;
        _CubemapDiff=holder._CubemapDiff;
        _CubemapSpec=holder._CubemapSpec;

        RTP_AOsharpness=holder.RTP_AOsharpness;
        RTP_AOamp=holder.RTP_AOamp;
        RTP_LightDefVector=holder.RTP_LightDefVector;
        RTP_ReflexLightDiffuseColor=holder.RTP_ReflexLightDiffuseColor;
        RTP_ReflexLightDiffuseColor2=holder.RTP_ReflexLightDiffuseColor2;
        RTP_ReflexLightSpecColor=holder.RTP_ReflexLightSpecColor;

        EmissionRefractFiltering=holder.EmissionRefractFiltering;
        EmissionRefractAnimSpeed=holder.EmissionRefractAnimSpeed;

        VerticalTextureGlobalBumpInfluence=holder.VerticalTextureGlobalBumpInfluence;
        VerticalTextureTiling=holder.VerticalTextureTiling;

        // snow
        _snow_strength=holder._snow_strength;
        _global_color_brightness_to_snow=holder._global_color_brightness_to_snow;
        _snow_slope_factor=holder._snow_slope_factor;
        _snow_edge_definition=holder._snow_edge_definition;
        _snow_height_treshold=holder._snow_height_treshold;
        _snow_height_transition=holder._snow_height_transition;
        _snow_color=holder._snow_color;
        _snow_specular=holder._snow_specular;
        _snow_gloss=holder._snow_gloss;
        _snow_reflectivness=holder._snow_reflectivness;
        _snow_deep_factor=holder._snow_deep_factor;
        _snow_fresnel=holder._snow_fresnel;
        _snow_diff_fresnel=holder._snow_diff_fresnel;
        _snow_IBL_DiffuseStrength=holder._snow_IBL_DiffuseStrength;
        _snow_IBL_SpecStrength=holder._snow_IBL_SpecStrength;

        //////////////////////
        // layer_dependent arrays
        //////////////////////
        Bumps=new Texture2D[holder.Bumps.Length];
        Spec=new float[holder.Bumps.Length];
        FarSpecCorrection=new float[holder.Bumps.Length];
        MixScale=new float[holder.Bumps.Length];
        MixBlend=new float[holder.Bumps.Length];
        MixSaturation=new float[holder.Bumps.Length];

        // RTP3.1
        RTP_gloss2mask=new float[holder.Bumps.Length];
        RTP_gloss_mult=new float[holder.Bumps.Length];
        RTP_gloss_shaping=new float[holder.Bumps.Length];
        RTP_Fresnel=new float[holder.Bumps.Length];
        RTP_FresnelAtten=new float[holder.Bumps.Length];
        RTP_DiffFresnel=new float[holder.Bumps.Length];
        RTP_IBL_bump_smoothness=new float[holder.Bumps.Length];
        RTP_IBL_DiffuseStrength=new float[holder.Bumps.Length];
        RTP_IBL_SpecStrength=new float[holder.Bumps.Length];
        _DeferredSpecDampAddPass=new float[holder.Bumps.Length];

        MixBrightness=new float[holder.Bumps.Length];
        MixReplace=new float[holder.Bumps.Length];
        LayerBrightness=new float[holder.Bumps.Length];
        LayerBrightness2Spec=new float[holder.Bumps.Length];
        LayerAlbedo2SpecColor=new float[holder.Bumps.Length];
        LayerSaturation=new float[holder.Bumps.Length];
        LayerEmission=new float[holder.Bumps.Length];
        LayerEmissionColor=new Color[holder.Bumps.Length];
        LayerEmissionRefractStrength=new float[holder.Bumps.Length];
        LayerEmissionRefractHBedge=new float[holder.Bumps.Length];

        GlobalColorPerLayer=new float[holder.Bumps.Length];
        GlobalColorBottom=new float[holder.Bumps.Length];
        GlobalColorTop=new float[holder.Bumps.Length];
        GlobalColorColormapLoSat=new float[holder.Bumps.Length];
        GlobalColorColormapHiSat=new float[holder.Bumps.Length];
        GlobalColorLayerLoSat=new float[holder.Bumps.Length];
        GlobalColorLayerHiSat=new float[holder.Bumps.Length];
        GlobalColorLoBlend=new float[holder.Bumps.Length];
        GlobalColorHiBlend=new float[holder.Bumps.Length];

        PER_LAYER_HEIGHT_MODIFIER=new float[holder.Bumps.Length];
        _SuperDetailStrengthMultA=new float[holder.Bumps.Length];
        _SuperDetailStrengthMultASelfMaskNear=new float[holder.Bumps.Length];
        _SuperDetailStrengthMultASelfMaskFar=new float[holder.Bumps.Length];
        _SuperDetailStrengthMultB=new float[holder.Bumps.Length];
        _SuperDetailStrengthMultBSelfMaskNear=new float[holder.Bumps.Length];
        _SuperDetailStrengthMultBSelfMaskFar=new float[holder.Bumps.Length];
        _SuperDetailStrengthNormal=new float[holder.Bumps.Length];
        _BumpMapGlobalStrength=new float[holder.Bumps.Length];

        AO_strength=new float[holder.Bumps.Length];
        VerticalTextureStrength=new float[holder.Bumps.Length];

        Heights=new Texture2D[holder.Bumps.Length];

        _snow_strength_per_layer=new float[holder.Bumps.Length];
        Substances=new ProceduralMaterial[holder.Bumps.Length];

        // wet
        TERRAIN_LayerWetStrength=new float[holder.Bumps.Length];
        TERRAIN_WaterLevel=new float[holder.Bumps.Length];
        TERRAIN_WaterLevelSlopeDamp=new float[holder.Bumps.Length];
        TERRAIN_WaterEdge=new float[holder.Bumps.Length];
        TERRAIN_WaterSpecularity=new float[holder.Bumps.Length];
        TERRAIN_WaterGloss=new float[holder.Bumps.Length];
        TERRAIN_WaterGlossDamper=new float[holder.Bumps.Length];
        TERRAIN_WaterOpacity=new float[holder.Bumps.Length];
        TERRAIN_Refraction=new float[holder.Bumps.Length];
        TERRAIN_WetRefraction=new float[holder.Bumps.Length];
        TERRAIN_Flow=new float[holder.Bumps.Length];
        TERRAIN_WetFlow=new float[holder.Bumps.Length];
        TERRAIN_WetSpecularity=new float[holder.Bumps.Length];
        TERRAIN_WetGloss=new float[holder.Bumps.Length];
        TERRAIN_WaterColor=new Color[holder.Bumps.Length];

        TERRAIN_WaterIBL_SpecWetStrength=new float[holder.Bumps.Length];
        TERRAIN_WaterIBL_SpecWaterStrength=new float[holder.Bumps.Length];
        TERRAIN_WaterEmission=new float[holder.Bumps.Length];

        for(int i=0; i<holder.Bumps.Length; i++) {
            Bumps[i]=holder.Bumps[i];
            Spec[i]=holder.Spec[i];
            FarSpecCorrection[i]=holder.FarSpecCorrection[i];
            MixScale[i]=holder.MixScale[i];
            MixBlend[i]=holder.MixBlend[i];
            MixSaturation[i]=holder.MixSaturation[i];

            // RTP3.1
            // update-set to default
            if (CheckAndUpdate(ref holder.RTP_gloss2mask, 0.5f, holder.Bumps.Length)) {
                for(int k=0; k<numLayers; k++) {
                    Spec[k]=1; // zresetuj od razu mnożnik glossa (RTP3.1 - zmienna ma inne znaczenie)
                }
            }
            CheckAndUpdate(ref holder.RTP_gloss_mult, 1f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.RTP_gloss_shaping, 0.5f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.RTP_Fresnel, 0, holder.Bumps.Length);
            CheckAndUpdate(ref holder.RTP_FresnelAtten, 0, holder.Bumps.Length);
            CheckAndUpdate(ref holder.RTP_DiffFresnel, 0, holder.Bumps.Length);
            CheckAndUpdate(ref holder.RTP_IBL_bump_smoothness, 0.7f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.RTP_IBL_DiffuseStrength, 0.5f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.RTP_IBL_SpecStrength, 0.5f, holder.Bumps.Length);
            CheckAndUpdate(ref holder._DeferredSpecDampAddPass, 1f, holder.Bumps.Length);

            CheckAndUpdate(ref holder.TERRAIN_WaterSpecularity, 0.5f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.TERRAIN_WaterGloss, 0.1f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.TERRAIN_WaterGlossDamper, 0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.TERRAIN_WetSpecularity, 0.2f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.TERRAIN_WetGloss, 0.05f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.TERRAIN_WetFlow, 0.05f, holder.Bumps.Length);

            CheckAndUpdate(ref holder.MixBrightness, 2.0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.MixReplace, 0.0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.LayerBrightness, 1.0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.LayerBrightness2Spec, 0.0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.LayerAlbedo2SpecColor, 0.0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.LayerSaturation, 1.0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.LayerEmission, 1.0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.LayerEmissionColor, Color.black, holder.Bumps.Length);
            CheckAndUpdate(ref holder.FarSpecCorrection, 0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.LayerEmissionRefractStrength, 0f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.LayerEmissionRefractHBedge, 0f, holder.Bumps.Length);

            CheckAndUpdate(ref holder.TERRAIN_WaterIBL_SpecWetStrength, 0.1f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.TERRAIN_WaterIBL_SpecWaterStrength, 0.5f, holder.Bumps.Length);
            CheckAndUpdate(ref holder.TERRAIN_WaterEmission, 0f, holder.Bumps.Length);

            RTP_gloss2mask[i]=holder.RTP_gloss2mask[i];
            RTP_gloss_mult[i]=holder.RTP_gloss_mult[i];
            RTP_gloss_shaping[i]=holder.RTP_gloss_shaping[i];
            RTP_Fresnel[i]=holder.RTP_Fresnel[i];
            RTP_FresnelAtten[i]=holder.RTP_FresnelAtten[i];
            RTP_DiffFresnel[i]=holder.RTP_DiffFresnel[i];
            RTP_IBL_bump_smoothness[i]=holder.RTP_IBL_bump_smoothness[i];
            RTP_IBL_DiffuseStrength[i]=holder.RTP_IBL_DiffuseStrength[i];
            RTP_IBL_SpecStrength[i]=holder.RTP_IBL_SpecStrength[i];
            _DeferredSpecDampAddPass[i]=holder._DeferredSpecDampAddPass[i];

            MixBrightness[i]=holder.MixBrightness[i];
            MixReplace[i]=holder.MixReplace[i];
            LayerBrightness[i]=holder.LayerBrightness[i];
            LayerBrightness2Spec[i]=holder.LayerBrightness2Spec[i];
            LayerAlbedo2SpecColor[i]=holder.LayerAlbedo2SpecColor[i];
            LayerSaturation[i]=holder.LayerSaturation[i];
            LayerEmission[i]=holder.LayerEmission[i];
            LayerEmissionColor[i]=holder.LayerEmissionColor[i];
            LayerEmissionRefractStrength[i]=holder.LayerEmissionRefractStrength[i];
            LayerEmissionRefractHBedge[i]=holder.LayerEmissionRefractHBedge[i];

            GlobalColorPerLayer[i]=holder.GlobalColorPerLayer[i];
            GlobalColorBottom[i]=holder.GlobalColorBottom[i];
            GlobalColorTop[i]=holder.GlobalColorTop[i];
            GlobalColorColormapLoSat[i]=holder.GlobalColorColormapLoSat[i];
            GlobalColorColormapHiSat[i]=holder.GlobalColorColormapHiSat[i];
            GlobalColorLayerLoSat[i]=holder.GlobalColorLayerLoSat[i];
            GlobalColorLayerHiSat[i]=holder.GlobalColorLayerHiSat[i];
            GlobalColorLoBlend[i]=holder.GlobalColorLoBlend[i];
            GlobalColorHiBlend[i]=holder.GlobalColorHiBlend[i];

            PER_LAYER_HEIGHT_MODIFIER[i]=holder.PER_LAYER_HEIGHT_MODIFIER[i];
            _SuperDetailStrengthMultA[i]=holder._SuperDetailStrengthMultA[i];
            _SuperDetailStrengthMultASelfMaskNear[i]=holder._SuperDetailStrengthMultASelfMaskNear[i];
            _SuperDetailStrengthMultASelfMaskFar[i]=holder._SuperDetailStrengthMultASelfMaskFar[i];
            _SuperDetailStrengthMultB[i]=holder._SuperDetailStrengthMultB[i];
            _SuperDetailStrengthMultBSelfMaskNear[i]=holder._SuperDetailStrengthMultBSelfMaskNear[i];
            _SuperDetailStrengthMultBSelfMaskFar[i]=holder._SuperDetailStrengthMultBSelfMaskFar[i];
            _SuperDetailStrengthNormal[i]=holder._SuperDetailStrengthNormal[i];
            _BumpMapGlobalStrength[i]=holder._BumpMapGlobalStrength[i];

            VerticalTextureStrength[i]=holder.VerticalTextureStrength[i];
            AO_strength[i]=holder.AO_strength[i];

            Heights[i]=holder.Heights[i];

            _snow_strength_per_layer[i]=holder._snow_strength_per_layer[i];
            Substances[i]=holder.Substances[i];

            // wet
            TERRAIN_LayerWetStrength[i]=holder.TERRAIN_LayerWetStrength[i];
            TERRAIN_WaterLevel[i]=holder.TERRAIN_WaterLevel[i];
            TERRAIN_WaterLevelSlopeDamp[i]=holder.TERRAIN_WaterLevelSlopeDamp[i];
            TERRAIN_WaterEdge[i]=holder.TERRAIN_WaterEdge[i];
            TERRAIN_WaterSpecularity[i]=holder.TERRAIN_WaterSpecularity[i];
            TERRAIN_WaterGloss[i]=holder.TERRAIN_WaterGloss[i];
            TERRAIN_WaterGlossDamper[i]=holder.TERRAIN_WaterGlossDamper[i];
            TERRAIN_WaterOpacity[i]=holder.TERRAIN_WaterOpacity[i];
            TERRAIN_Refraction[i]=holder.TERRAIN_Refraction[i];
            TERRAIN_WetRefraction[i]=holder.TERRAIN_WetRefraction[i];
            TERRAIN_Flow[i]=holder.TERRAIN_Flow[i];
            TERRAIN_WetFlow[i]=holder.TERRAIN_WetFlow[i];
            TERRAIN_WetSpecularity[i]=holder.TERRAIN_WetSpecularity[i];
            TERRAIN_WetGloss[i]=holder.TERRAIN_WetGloss[i];
            TERRAIN_WaterColor[i]=holder.TERRAIN_WaterColor[i];
            TERRAIN_WaterIBL_SpecWetStrength[i]=holder.TERRAIN_WaterIBL_SpecWetStrength[i];
            TERRAIN_WaterIBL_SpecWaterStrength[i]=holder.TERRAIN_WaterIBL_SpecWaterStrength[i];
            TERRAIN_WaterEmission[i]=holder.TERRAIN_WaterEmission[i];
        }
    }
예제 #7
0
 public bool ClearBlend(RTPColorChannels channel=RTPColorChannels.A, float val=0)
 {
     if (!blendedObject || blendedObject.GetComponent(typeof(Collider))==null || ((blendedObject.GetComponent(typeof(MeshRenderer))==null) && (blendedObject.GetComponent(typeof(Terrain))==null))) {
         Debug.LogError("Select an object (terrain or GameObject with mesh) to be blended with this object.");
         return false;
     }
     Mesh mesh = ((MeshFilter)GetComponent(typeof(MeshFilter))).sharedMesh;
     Color[] colors=mesh.colors;
     if (colors==null || colors.Length==0) {
         colors=new Color[mesh.vertices.Length];
     }
     for(int i=0; i<colors.Length; i++) {
         colors[i][(int)channel]=val;
     }
     mesh.colors=colors;
     pmesh=mesh;
     if (channel==RTPColorChannels.A && !VoxelBlendedObject) {
         if (underlying_renderer) {
             MeshFilter mf=underlying_renderer.GetComponent(typeof(MeshFilter)) as MeshFilter;
             if (mf) {
                 colors=mf.sharedMesh.colors;
                 if (colors==null || colors.Length==0) {
                     colors=new Color[mf.sharedMesh.vertices.Length];
                 }
                 for(int i=0; i<colors.Length; i++) {
                     colors[i][(int)channel]=val;
                 }
                 mf.sharedMesh.colors=colors;
             }
         }
     }
     return true;
 }