Ambient Occlusion APIs are more descriptive
Use “AmbientOcclusion” instead of SSAO in all APIs.
This commit is contained in:
committed by
Mathias Agopian
parent
011daa952e
commit
cbae6120e1
@@ -221,21 +221,21 @@ Java_com_google_android_filament_View_nIsFrontFaceWindingInverted(JNIEnv*,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetSSAO(JNIEnv*, jclass, jlong nativeView, jint ordinal) {
|
||||
Java_com_google_android_filament_View_nSetAmbientOcclusion(JNIEnv*, jclass, jlong nativeView, jint ordinal) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setSSAO((View::SSAO)ordinal);
|
||||
view->setAmbientOcclusion((View::AmbientOcclusion)ordinal);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetSSAO(JNIEnv*, jclass, jlong nativeView) {
|
||||
Java_com_google_android_filament_View_nGetAmbientOcclusion(JNIEnv*, jclass, jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return (jint)view->getSSAO();
|
||||
return (jint)view->getAmbientOcclusion();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetSSAOOptions(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_View_nSetAmbientOcclusionOptions(JNIEnv*, jclass,
|
||||
jlong nativeView, jfloat radius, jfloat bias, jfloat power) {
|
||||
View* view = (View*) nativeView;
|
||||
View::SSAOOptions options = { .radius = radius, .bias = bias, .power = power};
|
||||
view->setSSAOOptions(options);
|
||||
View::AmbientOcclusionOptions options = { .radius = radius, .bias = bias, .power = power};
|
||||
view->setAmbientOcclusionOptions(options);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class View {
|
||||
private DynamicResolutionOptions mDynamicResolution;
|
||||
private RenderQuality mRenderQuality;
|
||||
private DepthPrepass mDepthPrepass = DepthPrepass.DEFAULT;
|
||||
private SSAOOptions mSSAOOptions;
|
||||
private AmbientOcclusionOptions mAmbientOcclusionOptions;
|
||||
|
||||
public static class DynamicResolutionOptions {
|
||||
public boolean enabled = false;
|
||||
@@ -45,7 +45,7 @@ public class View {
|
||||
public int history = 9;
|
||||
}
|
||||
|
||||
public static class SSAOOptions {
|
||||
public static class AmbientOcclusionOptions {
|
||||
public float radius = 0.3f;
|
||||
public float bias = 0.005f;
|
||||
public float power = 0.0f;
|
||||
@@ -62,7 +62,7 @@ public class View {
|
||||
public QualityLevel hdrColorBuffer = QualityLevel.HIGH;
|
||||
}
|
||||
|
||||
public enum SSAO {
|
||||
public enum AmbientOcclusion {
|
||||
NONE,
|
||||
SSAO
|
||||
}
|
||||
@@ -264,26 +264,26 @@ public class View {
|
||||
nSetDynamicLightingOptions(getNativeObject(), zLightNear, zLightFar);
|
||||
}
|
||||
|
||||
public void setSSAO(@NonNull SSAO ssao) {
|
||||
nSetSSAO(getNativeObject(), ssao.ordinal());
|
||||
public void setAmbientOcclusion(@NonNull AmbientOcclusion ao) {
|
||||
nSetAmbientOcclusion(getNativeObject(), ao.ordinal());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public SSAO getSSAO() {
|
||||
return SSAO.values()[nGetSSAO(getNativeObject())];
|
||||
public AmbientOcclusion getAmbientOcclusion() {
|
||||
return AmbientOcclusion.values()[nGetAmbientOcclusion(getNativeObject())];
|
||||
}
|
||||
|
||||
public void setSSAOOptions(@NonNull SSAOOptions options) {
|
||||
mSSAOOptions = options;
|
||||
nSetSSAOOptions(getNativeObject(), options.radius, options.bias, options.power);
|
||||
public void setAmbientOcclusionOptions(@NonNull AmbientOcclusionOptions options) {
|
||||
mAmbientOcclusionOptions = options;
|
||||
nSetAmbientOcclusionOptions(getNativeObject(), options.radius, options.bias, options.power);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public SSAOOptions getSSAOOptions() {
|
||||
if (mSSAOOptions == null) {
|
||||
mSSAOOptions = new SSAOOptions();
|
||||
public AmbientOcclusionOptions getAmbientOcclusionOptions() {
|
||||
if (mAmbientOcclusionOptions == null) {
|
||||
mAmbientOcclusionOptions = new AmbientOcclusionOptions();
|
||||
}
|
||||
return mSSAOOptions;
|
||||
return mAmbientOcclusionOptions;
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
@@ -334,7 +334,7 @@ public class View {
|
||||
private static native boolean nIsPostProcessingEnabled(long nativeView);
|
||||
private static native void nSetFrontFaceWindingInverted(long nativeView, boolean inverted);
|
||||
private static native boolean nIsFrontFaceWindingInverted(long nativeView);
|
||||
private static native void nSetSSAO(long nativeView, int ordinal);
|
||||
private static native int nGetSSAO(long nativeView);
|
||||
private static native void nSetSSAOOptions(long nativeView, float radius, float bias, float power);
|
||||
private static native void nSetAmbientOcclusion(long nativeView, int ordinal);
|
||||
private static native int nGetAmbientOcclusion(long nativeView);
|
||||
private static native void nSetAmbientOcclusionOptions(long nativeView, float radius, float bias, float power);
|
||||
}
|
||||
|
||||
@@ -140,20 +140,20 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Options for Screen Space Ambient Occlusion (SSAO)
|
||||
* @see setSSAO()
|
||||
* Options for Ambient Occlusion
|
||||
* @see setAmbientOcclusion()
|
||||
*/
|
||||
struct SSAOOptions {
|
||||
float radius = 0.3f; //!< SSAO radius in meters, between 0 and ~5.
|
||||
struct AmbientOcclusionOptions {
|
||||
float radius = 0.3f; //!< Ambient Occlusion radius in meters, between 0 and ~10.
|
||||
float bias = 0.005f; //!< Self-occlusion bias in meters. Use to avoid self-occlusion. Between 0 and a few mm.
|
||||
float power = 0.0f; //!< Controls ambient occlusion's contrast. Between 0 (linear) and 1 (squared)
|
||||
};
|
||||
|
||||
/**
|
||||
* List of available SSAO techniques
|
||||
* List of available ambient occlusion techniques
|
||||
*/
|
||||
enum class SSAO : uint8_t {
|
||||
NONE = 0, //!< No SSAO
|
||||
enum class AmbientOcclusion : uint8_t {
|
||||
NONE = 0, //!< No Ambient Occlusion
|
||||
SSAO = 1 //!< Basic, sampling SSAO
|
||||
};
|
||||
|
||||
@@ -190,32 +190,32 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Activates or deactivates SSAO.
|
||||
* Activates or deactivates ambient occlusion.
|
||||
*
|
||||
* @param ssao Type of SSAO to use.
|
||||
* @param ambientOcclusion Type of ambient occlusion to use.
|
||||
*/
|
||||
void setSSAO(SSAO ssao) noexcept;
|
||||
void setAmbientOcclusion(AmbientOcclusion ambientOcclusion) noexcept;
|
||||
|
||||
/**
|
||||
* Query the type of SSAO active for this View.
|
||||
* Query the type of ambient occlusion active for this View.
|
||||
*
|
||||
* @return SSAO type.
|
||||
* @return ambient occlusion type.
|
||||
*/
|
||||
SSAO getSSAO() const noexcept;
|
||||
AmbientOcclusion getAmbientOcclusion() const noexcept;
|
||||
|
||||
/**
|
||||
* Sets SSAO options.
|
||||
* Sets ambient occlusion options.
|
||||
*
|
||||
* @param options Options for SSAO.
|
||||
* @param options Options for ambient occlusion.
|
||||
*/
|
||||
void setSSAOOptions(SSAOOptions const& options) noexcept;
|
||||
void setAmbientOcclusionOptions(AmbientOcclusionOptions const& options) noexcept;
|
||||
|
||||
/**
|
||||
* Gets the SSAO options.
|
||||
* Gets the ambient occlusion options.
|
||||
*
|
||||
* @return SSAO options currently set.
|
||||
* @return ambient occlusion options currently set.
|
||||
*/
|
||||
SSAOOptions const& getSSAOOptions() const noexcept;
|
||||
AmbientOcclusionOptions const& getAmbientOcclusionOptions() const noexcept;
|
||||
|
||||
/**
|
||||
* Sets whether this view is rendered with or without a depth pre-pass.
|
||||
|
||||
@@ -286,7 +286,7 @@ FrameGraphResource PostProcessManager::dynamicScaling(FrameGraph& fg,
|
||||
|
||||
|
||||
FrameGraphResource PostProcessManager::ssao(FrameGraph& fg, FrameGraphResource depth,
|
||||
View::SSAOOptions const& options) noexcept {
|
||||
View::AmbientOcclusionOptions const& options) noexcept {
|
||||
|
||||
FEngine* engine = mEngine;
|
||||
Handle<HwRenderPrimitive> fullScreenRenderPrimitive = engine->getFullScreenRenderPrimitive();
|
||||
@@ -294,7 +294,7 @@ FrameGraphResource PostProcessManager::ssao(FrameGraph& fg, FrameGraphResource d
|
||||
struct SSAOPassData {
|
||||
FrameGraphResource depth;
|
||||
FrameGraphResource ssao;
|
||||
View::SSAOOptions options;
|
||||
View::AmbientOcclusionOptions options;
|
||||
};
|
||||
|
||||
auto& SSAODepthPass = fg.addPass<SSAOPassData>("SSAO Pass",
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
|
||||
FrameGraphResource ssao(FrameGraph& fg, FrameGraphResource depth,
|
||||
View::SSAOOptions const& options) noexcept;
|
||||
View::AmbientOcclusionOptions const& options) noexcept;
|
||||
|
||||
backend::Handle<backend::HwTexture> getNoSSAOTexture() const {
|
||||
return mNoSSAOTexture;
|
||||
|
||||
@@ -262,7 +262,7 @@ void FRenderer::renderJob(ArenaScope& arena, FView& view) {
|
||||
// because either way, we have to go through the geometry twice.
|
||||
constexpr bool REUSE_SSAO_DEPTH = true;
|
||||
|
||||
const bool useSSAO = view.getSSAO() != View::SSAO::NONE;
|
||||
const bool useSSAO = view.getAmbientOcclusion() != View::AmbientOcclusion::NONE;
|
||||
Command const* depthPassBegin = nullptr;
|
||||
Command const* depthPassEnd = nullptr;
|
||||
Command const* colorPassBegin = nullptr;
|
||||
@@ -322,7 +322,7 @@ void FRenderer::renderJob(ArenaScope& arena, FView& view) {
|
||||
FrameGraphResource depth = ssaoDepthPass.getData().depth;
|
||||
|
||||
// SSAO pass -- automatically culled if not used
|
||||
FrameGraphResource ssao = ppm.ssao(fg, depth, view.getSSAOOptions());
|
||||
FrameGraphResource ssao = ppm.ssao(fg, depth, view.getAmbientOcclusionOptions());
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -922,20 +922,20 @@ void View::setDynamicLightingOptions(float zLightNear, float zLightFar) noexcept
|
||||
upcast(this)->setDynamicLightingOptions(zLightNear, zLightFar);
|
||||
}
|
||||
|
||||
void View::setSSAO(View::SSAO ssao) noexcept {
|
||||
upcast(this)->setSSAO(ssao);
|
||||
void View::setAmbientOcclusion(View::AmbientOcclusion ambientOcclusion) noexcept {
|
||||
upcast(this)->setAmbientOcclusion(ambientOcclusion);
|
||||
}
|
||||
|
||||
View::SSAO View::getSSAO() const noexcept {
|
||||
return upcast(this)->getSSAO();
|
||||
View::AmbientOcclusion View::getAmbientOcclusion() const noexcept {
|
||||
return upcast(this)->getAmbientOcclusion();
|
||||
}
|
||||
|
||||
void View::setSSAOOptions(View::SSAOOptions const& options) noexcept {
|
||||
upcast(this)->setSSAOOptions(options);
|
||||
void View::setAmbientOcclusionOptions(View::AmbientOcclusionOptions const& options) noexcept {
|
||||
upcast(this)->setAmbientOcclusionOptions(options);
|
||||
}
|
||||
|
||||
View::SSAOOptions const& View::getSSAOOptions() const noexcept {
|
||||
return upcast(this)->getSSAOOptions();
|
||||
View::AmbientOcclusionOptions const& View::getAmbientOcclusionOptions() const noexcept {
|
||||
return upcast(this)->getAmbientOcclusionOptions();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -227,23 +227,23 @@ public:
|
||||
return mDepthPrepass;
|
||||
}
|
||||
|
||||
void setSSAO(SSAO ssao) noexcept {
|
||||
mSSAOType = ssao;
|
||||
void setAmbientOcclusion(AmbientOcclusion ambientOcclusion) noexcept {
|
||||
mAmbientOcclusion = ambientOcclusion;
|
||||
}
|
||||
|
||||
SSAO getSSAO() const noexcept {
|
||||
return mSSAOType;
|
||||
AmbientOcclusion getAmbientOcclusion() const noexcept {
|
||||
return mAmbientOcclusion;
|
||||
}
|
||||
|
||||
void setSSAOOptions(SSAOOptions const& options) noexcept {
|
||||
mSSAOOptions = options;
|
||||
mSSAOOptions.radius = math::clamp(0.0f, 10.0f, mSSAOOptions.radius);
|
||||
mSSAOOptions.bias = math::clamp(0.0f, 0.1f, mSSAOOptions.bias);
|
||||
mSSAOOptions.power = math::clamp(0.0f, 1.0f, mSSAOOptions.power);
|
||||
void setAmbientOcclusionOptions(AmbientOcclusionOptions const& options) noexcept {
|
||||
mAmbientOcclusionOptions = options;
|
||||
mAmbientOcclusionOptions.radius = math::clamp(0.0f, 10.0f, mAmbientOcclusionOptions.radius);
|
||||
mAmbientOcclusionOptions.bias = math::clamp(0.0f, 0.1f, mAmbientOcclusionOptions.bias);
|
||||
mAmbientOcclusionOptions.power = math::clamp(0.0f, 1.0f, mAmbientOcclusionOptions.power);
|
||||
}
|
||||
|
||||
SSAOOptions const& getSSAOOptions() const noexcept {
|
||||
return mSSAOOptions;
|
||||
AmbientOcclusionOptions const& getAmbientOcclusionOptions() const noexcept {
|
||||
return mAmbientOcclusionOptions;
|
||||
}
|
||||
|
||||
Range const& getVisibleRenderables() const noexcept {
|
||||
@@ -332,8 +332,8 @@ private:
|
||||
bool mShadowingEnabled = true;
|
||||
bool mHasPostProcessPass = true;
|
||||
DepthPrepass mDepthPrepass = DepthPrepass::DEFAULT;
|
||||
SSAO mSSAOType = SSAO::NONE;
|
||||
SSAOOptions mSSAOOptions{};
|
||||
AmbientOcclusion mAmbientOcclusion = AmbientOcclusion::NONE;
|
||||
AmbientOcclusionOptions mAmbientOcclusionOptions{};
|
||||
|
||||
using duration = std::chrono::duration<float, std::milli>;
|
||||
DynamicResolutionOptions mDynamicResolution;
|
||||
|
||||
@@ -358,7 +358,8 @@ void SimpleViewer::updateUserInterface() {
|
||||
mView->setDithering(mEnableDithering ? View::Dithering::TEMPORAL : View::Dithering::NONE);
|
||||
mView->setAntiAliasing(mEnableFxaa ? View::AntiAliasing::FXAA : View::AntiAliasing::NONE);
|
||||
mView->setSampleCount(mEnableMsaa ? 4 : 1);
|
||||
mView->setSSAO(mEnableSsao ? View::SSAO::SSAO : View::SSAO::NONE);
|
||||
mView->setAmbientOcclusion(
|
||||
mEnableSsao ? View::AmbientOcclusion::SSAO : View::AmbientOcclusion::NONE);
|
||||
|
||||
if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::SliderFloat("IBL intensity", &mIblIntensity, 0.0f, 100000.0f);
|
||||
|
||||
@@ -426,8 +426,9 @@ static void preRender(filament::Engine*, filament::View* view, filament::Scene*,
|
||||
view->setToneMapping(g_params.tonemapping ? View::ToneMapping::ACES : View::ToneMapping::LINEAR);
|
||||
view->setDithering(g_params.dithering ? View::Dithering::TEMPORAL : View::Dithering::NONE);
|
||||
view->setSampleCount((uint8_t) (g_params.msaa ? 4 : 1));
|
||||
view->setSSAO(g_params.ssao ? View::SSAO::SSAO : View::SSAO::NONE);
|
||||
view->setSSAOOptions(g_params.ssaoOptions);
|
||||
view->setAmbientOcclusion(
|
||||
g_params.ssao ? View::AmbientOcclusion::SSAO : View::AmbientOcclusion::NONE);
|
||||
view->setAmbientOcclusionOptions(g_params.ssaoOptions);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
@@ -91,7 +91,7 @@ struct SandboxParameters {
|
||||
float polygonOffsetConstant = 0.5;
|
||||
float polygonOffsetSlope = 2.0;
|
||||
bool ssao = false;
|
||||
filament::View::SSAOOptions ssaoOptions;
|
||||
filament::View::AmbientOcclusionOptions ssaoOptions;
|
||||
};
|
||||
|
||||
inline void createInstances(SandboxParameters& params, filament::Engine& engine) {
|
||||
|
||||
Reference in New Issue
Block a user