private void UpdateMaterial() { var targetSurfaceTechnique = "Variant"; var targetAtmosphereTechnique = "Variant"; if (starObserver != null) { if (InsideAtmosphere(starObserver.transform.position) == false) { targetSurfaceTechnique += "Outer"; targetAtmosphereTechnique += "Outer"; } } if (atmosphereSurfacePerPixel == true) { targetSurfaceTechnique += "PerPixel"; } // Update surface? if (surfaceMaterials == null || (surfaceTechnique != targetSurfaceTechnique || SGT_ArrayHelper.ContainsSomething(surfaceMaterials) == false || surfaceMaterials.Length != SGT_SurfaceConfiguration_.SurfaceCount(SurfaceConfiguration))) { SGT_Helper.DestroyObjects(surfaceMaterials); surfaceTechnique = targetSurfaceTechnique; surfaceMaterials = SGT_SurfaceConfiguration_.CreateMaterials(surfaceMultiMesh.Configuration, "Hidden/SGT/StarSurface/" + surfaceTechnique, surfaceRenderQueue); } else { SGT_Helper.SetRenderQueues(surfaceMaterials, surfaceRenderQueue); } // Update atmosphere? if (atmosphereTechnique != targetAtmosphereTechnique || atmosphereMaterial == null) { SGT_Helper.DestroyObject(atmosphereMaterial); atmosphereTechnique = targetAtmosphereTechnique; atmosphereMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/StarAtmosphere/" + atmosphereTechnique, atmosphereRenderQueue); } else { SGT_Helper.SetRenderQueue(atmosphereMaterial, atmosphereRenderQueue); } }
private void UpdateTechnique() { var targetSurfaceTechnique = "Variant"; var targetAtmosphereTechnique = string.Empty; var tagetCloudsTechnique = string.Empty; if (atmosphere == true) { targetSurfaceTechnique += "Atmosphere"; targetAtmosphereTechnique = "Variant"; if (planetObserver != null) { if (InsideAtmosphere(planetObserver.transform.position) == false) { targetSurfaceTechnique += "Outer"; targetAtmosphereTechnique += "Outer"; } } if (atmosphereScattering == true) { //targetSurfaceTechnique += "Scattering"; targetAtmosphereTechnique += "Scattering"; } } if (clouds == true) { tagetCloudsTechnique = "Variant"; } if (surfaceTextureNormal.ContainsSomething == true) { targetSurfaceTechnique += "Normal"; } if (surfaceTextureSpecular.ContainsSomething == true) { targetSurfaceTechnique += "Specular"; } if (shadow == true) { switch (shadowCasterType) { case SGT_ShadowOccluder.Ring: { targetSurfaceTechnique += "RingShadow"; if (atmosphere == true) { targetAtmosphereTechnique += "RingShadow"; } if (clouds == true) { tagetCloudsTechnique += "RingShadow"; } } break; case SGT_ShadowOccluder.Planet: { targetSurfaceTechnique += "PlanetShadow"; if (atmosphere == true) { targetAtmosphereTechnique += "PlanetShadow"; } if (clouds == true) { tagetCloudsTechnique += "PlanetShadow"; } } break; } } if (surfaceTextureDetail != null) { targetSurfaceTechnique += "Detail"; } if (surfaceMaterials != null && (surfaceTechnique != targetSurfaceTechnique || SGT_ArrayHelper.ContainsSomething(surfaceMaterials) == false || surfaceMaterials.Length != SGT_SurfaceConfiguration_.SurfaceCount(SurfaceConfiguration))) { surfaceMaterials = SGT_Helper.DestroyObjects(surfaceMaterials); } if (atmosphereMaterial != null && (atmosphere == false || atmosphereTechnique != targetAtmosphereTechnique)) { atmosphereMaterial = SGT_Helper.DestroyObject(atmosphereMaterial); } if (cloudsMaterials != null && (clouds == false || cloudsTechnique != tagetCloudsTechnique || SGT_ArrayHelper.ContainsSomething(cloudsMaterials) == false || cloudsMaterials.Length != SGT_SurfaceConfiguration_.SurfaceCount(CloudsConfiguration))) { cloudsMaterials = SGT_Helper.DestroyObjects(cloudsMaterials); } // Create planet surface shaders? if (surfaceMaterials == null) { updateShader |= ShaderFlags.Surface; surfaceTechnique = targetSurfaceTechnique; surfaceMaterials = SGT_SurfaceConfiguration_.CreateMaterials(SurfaceConfiguration, "Hidden/SGT/PlanetSurface/" + surfaceTechnique, surfaceRenderQueue); } else { SGT_Helper.SetRenderQueues(surfaceMaterials, surfaceRenderQueue); } // Create planet atmosphere shaders? if (atmosphere == true) { if (atmosphereMaterial == null) { updateShader |= ShaderFlags.Atmosphere; atmosphereTechnique = targetAtmosphereTechnique; atmosphereMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/PlanetAtmosphere/" + atmosphereTechnique, atmosphereRenderQueue); } else { SGT_Helper.SetRenderQueue(atmosphereMaterial, atmosphereRenderQueue); } } // Create planet cloud shaders? if (clouds == true) { if (cloudsMaterials == null) { updateShader |= ShaderFlags.Clouds; cloudsTechnique = tagetCloudsTechnique; cloudsMaterials = SGT_SurfaceConfiguration_.CreateMaterials(CloudsConfiguration, "Hidden/SGT/PlanetClouds/" + cloudsTechnique, atmosphereRenderQueue); } else { SGT_Helper.SetRenderQueues(cloudsMaterials, atmosphereRenderQueue); } } else { if (cloudsMaterials != null) { cloudsMaterials = SGT_Helper.DestroyObjects(cloudsMaterials); } } }