Repository: godotengine/godot
File: servers/rendering/storage/environment_storage.cpp (C++)

Code before:
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, RS::ENV_REFLECTION_SOURCE_BG);
	return env->reflection_source;
}

void RendererEnvironmentStorage::environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL(env);
	env->camera_feed_id = p_camera_feed_id;
}

int RendererEnvironmentStorage::environment_get_camera_feed_id(RID p_env) const {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, -1);
	return env->camera_feed_id;
}

// Tonemap

void RendererEnvironmentStorage::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white) {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL(env);
	env->exposure = p_exposure;
	env->tone_mapper = p_tone_mapper;
	if (p_tone_mapper == RS::ENV_TONE_MAPPER_LINEAR) {
		env->white = 1.0; // With HDR output this should be the output max value instead.
	} else if (p_tone_mapper == RS::ENV_TONE_MAPPER_AGX) {
		env->white = 16.29;
	} else {
		env->white = MAX(1.0, p_white); // Glow with screen blend mode does not work when white < 1.0.
	}
}

RS::EnvironmentToneMapper RendererEnvironmentStorage::environment_get_tone_mapper(RID p_env) const {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, RS::ENV_TONE_MAPPER_LINEAR);
	return env->tone_mapper;
}

float RendererEnvironmentStorage::environment_get_exposure(RID p_env) const {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, 1.0);
	return env->exposure;
}

float RendererEnvironmentStorage::environment_get_white(RID p_env) const {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, 1.0);
	return env->white;
}


Review comment (suggestion):
```suggestion
		env->white = 1.0; // With HDR output, this should be the output max value instead.
```

Code after:
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, RS::ENV_REFLECTION_SOURCE_BG);
	return env->reflection_source;
}

void RendererEnvironmentStorage::environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL(env);
	env->camera_feed_id = p_camera_feed_id;
}

int RendererEnvironmentStorage::environment_get_camera_feed_id(RID p_env) const {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, -1);
	return env->camera_feed_id;
}

// Tonemap

void RendererEnvironmentStorage::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white) {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL(env);
	env->exposure = p_exposure;
	env->tone_mapper = p_tone_mapper;
	if (p_tone_mapper == RS::ENV_TONE_MAPPER_LINEAR) {
		env->white = 1.0; // With HDR output, this should be the output max value instead.
	} else if (p_tone_mapper == RS::ENV_TONE_MAPPER_AGX) {
		env->white = 16.29;
	} else {
		env->white = MAX(1.0, p_white); // Glow with screen blend mode does not work when white < 1.0.
	}
}

RS::EnvironmentToneMapper RendererEnvironmentStorage::environment_get_tone_mapper(RID p_env) const {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, RS::ENV_TONE_MAPPER_LINEAR);
	return env->tone_mapper;
}

float RendererEnvironmentStorage::environment_get_exposure(RID p_env) const {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, 1.0);
	return env->exposure;
}

float RendererEnvironmentStorage::environment_get_white(RID p_env) const {
	Environment *env = environment_owner.get_or_null(p_env);
	ERR_FAIL_NULL_V(env, 1.0);
	return env->white;
}