View on GitHub Sample viewer app

Changes the appearance of the atmosphere in a scene.

Image of Set atmosphere effect in scene sample

Use case

Atmospheric effect can be used to make the scene view look more realistic.

How to use the sample

Select one of the three available atmosphere effects. The sky will change to display the selected atmosphere effect.

How it works

  1. Create an ArcGISScene and add it to a SceneView composable.
  2. Expose the selected AtmosphereEffect from a ViewModel and observe it in the Compose screen using collectAsStateWithLifecycle.
  3. Pass the AtmosphereEffect value into the SceneView composable, so changing the selected value updates the composable SceneView.

Relevant API

  • ArcGISScene
  • ArcGISTiledElevationSource
  • AtmosphereEffect
  • SceneView
  • Viewpoint

Additional information

There are three atmosphere effect options:

  • Realistic - A realistic atmosphere effect is applied over the entire surface.
  • HorizonOnly - Atmosphere effect applied to the sky (horizon) only.
  • None - No atmosphere effect. The sky is rendered black with a starfield consisting of randomly placed white dots.

Tags

atmosphere, horizon, scene, sky

Sample Code

MainActivity.kt MainActivity.kt SetAtmosphereEffectInSceneViewModel.kt SetAtmosphereEffectInSceneScreen.kt
/* Copyright 2025 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.esri.arcgismaps.sample.setatmosphereeffectinscene
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import com.esri.arcgismaps.sample.setatmosphereeffectinscene.screens.SetAtmosphereEffectInSceneScreen
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// authentication with an API key or named user is
// required to access basemaps and other location services
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)
setContent {
SampleAppTheme {
SetAtmosphereEffectInSceneApp()
}
}
}
@Composable
private fun SetAtmosphereEffectInSceneApp() {
Surface(color = MaterialTheme.colorScheme.background) {
SetAtmosphereEffectInSceneScreen(
sampleName = getString(R.string.set_atmosphere_effect_in_scene_app_name)
)
}
}
}