Compare commits

..

16 Commits

Author SHA1 Message Date
Fernando Raviola
555a1396ca Data verification before server upload (#6518)
Data verification before server upload
2023-05-18 15:29:50 +10:00
Fernando Raviola
57ce236fe4 Improve Session API, send formatted string to server (#6498)
Add fgdbg::Session.h, Pass.h, Resource.h dtos/models
2023-05-18 15:29:50 +10:00
raviola
527428a629 Add fgdbg::Session.h, Pass.h, Resource.h dtos/models 2023-05-18 15:29:50 +10:00
Fernando Raviola
a5913e2c36 Add fgdbg::Session.h, Pass.h, Resource.h dtos/models (#6270)
* Add fgdbg::Session.h, Pass.h, Resource.h dtos/models

* Add session name

* Update Engine to use new API
2023-05-18 15:29:50 +10:00
Fernando Raviola
48a31f484a fgdbg client project structure + simple server connection (#6210)
* fgdbg client project structure + simple server connection

* pr feedback
2023-05-18 15:29:50 +10:00
Fernando Raviola
21cf0f40c4 Add DebugServer for fgdbg with support for Websockets (#6169)
* Add dummy DebugServer for fgdbg with support for Websockets

* PR feedback
2023-05-18 15:29:50 +10:00
raviola
16a351bf15 rename debug.server to debug.matdbg 2023-05-18 15:29:27 +10:00
raviola
c76b6d7bed Use smart pointer 2023-05-18 15:27:57 +10:00
raviola
827f82fa84 PR suggestions 2023-05-18 15:27:57 +10:00
Fernando Raviola
9d7317a4a9 Concat namespaces
Co-authored-by: Mathias Agopian <mathias@google.com>
2023-05-18 15:27:57 +10:00
Fernando Raviola
786008c2ed Add FrameGraph debugger lib: package structure + CmakeLists.txt 2023-05-18 15:27:57 +10:00
Mathias Agopian
da17b6f867 New RenderableManager API to opt-out of fog
Fog can now be opted-out on a per renderable basis. When fog is disabled
on a renderable it removes the requirement that this renderable's 
materials have the FOG variant.
2023-05-17 15:58:56 -07:00
Romain Guy
002becdc4f Don't use large runners yet (#6814) 2023-05-17 13:46:55 -07:00
Romain Guy
2ade1778b1 Don't rely on Java8 to invoke sdkmanager (#6809) 2023-05-16 13:01:56 -07:00
Mathias Agopian
f6c8ce1fd1 New API to apply a transform to the large-scale fog.
This works by making the fog an entity which can be used to create
a TransformManager component an participate to the transform hierarchy.

This feature can be used as more advanced way to set the fog's floor,
which now can have an orientation (essentially be a plane).
This is useful for coordinate systems that are not y-up.
2023-05-16 12:42:59 -07:00
Mathias Agopian
8aa1435fbd fogHeight is not needed in the shader 2023-05-16 12:42:59 -07:00
209 changed files with 1356 additions and 95 deletions

BIN
.build.sh.un~ Normal file

Binary file not shown.

View File

@@ -10,7 +10,7 @@ on:
jobs:
build-android:
name: build-android
runs-on: macos-latest-xl
runs-on: macos-latest
steps:
- uses: actions/checkout@v3.3.0

View File

@@ -10,7 +10,7 @@ on:
jobs:
build-ios:
name: build-ios
runs-on: macos-latest-xl
runs-on: macos-latest
steps:
- uses: actions/checkout@v3.3.0

View File

@@ -10,7 +10,7 @@ on:
jobs:
build-mac:
name: build-mac
runs-on: macos-latest-xl
runs-on: macos-latest
steps:
- uses: actions/checkout@v3.3.0

View File

@@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [macos-latest-xl, ubuntu-22.04-16core]
os: [macos-latest, ubuntu-22.04]
steps:
- uses: actions/checkout@v3.3.0
@@ -40,7 +40,7 @@ jobs:
build-android:
name: build-android
runs-on: macos-latest-xl
runs-on: macos-latest
steps:
- uses: actions/checkout@v3.3.0
@@ -54,7 +54,7 @@ jobs:
build-ios:
name: build-iOS
runs-on: macos-latest-xl
runs-on: macos-latest
steps:
- uses: actions/checkout@v3.3.0
@@ -67,7 +67,7 @@ jobs:
build-web:
name: build-web
runs-on: macos-latest-xl
runs-on: macos-latest
steps:
- uses: actions/checkout@v3.3.0

View File

@@ -31,7 +31,7 @@ jobs:
strategy:
matrix:
os: [macos-latest-xl, ubuntu-22.04-16core]
os: [macos-latest, ubuntu-22.04]
steps:
- name: Decide Git ref
@@ -65,7 +65,7 @@ jobs:
build-web:
name: build-web
runs-on: macos-latest-xl
runs-on: macos-latest
if: github.event_name == 'release' || github.event.inputs.platform == 'web'
steps:
@@ -98,7 +98,7 @@ jobs:
build-android:
name: build-android
runs-on: macos-latest-xl
runs-on: macos-latest
if: github.event_name == 'release' || github.event.inputs.platform == 'android'
steps:
@@ -153,7 +153,7 @@ jobs:
build-ios:
name: build-ios
runs-on: macos-latest-xl
runs-on: macos-latest
if: github.event_name == 'release' || github.event.inputs.platform == 'ios'
steps:

View File

@@ -10,7 +10,7 @@ on:
jobs:
build-web:
name: build-web
runs-on: macos-latest-xl
runs-on: macos-latest
steps:
- uses: actions/checkout@v3.3.0

View File

@@ -479,6 +479,13 @@ else()
option(FILAMENT_ENABLE_MATDBG "Enable the material debugger" OFF)
endif()
# By default, link in fgdbg for Desktop + Debug
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND IS_HOST_PLATFORM)
option(FILAMENT_ENABLE_FGDBG "Enable the framegraph debugger" ON)
else()
option(FILAMENT_ENABLE_FGDBG "Enable the framegraph debugger" OFF)
endif()
# Only optimize materials in Release mode (so error message lines match the source code)
if (CMAKE_BUILD_TYPE MATCHES Release)
option(FILAMENT_DISABLE_MATOPT "Disable material optimizations" OFF)
@@ -711,6 +718,10 @@ if (FILAMENT_BUILD_FILAMAT OR IS_HOST_PLATFORM)
if (FILAMENT_ENABLE_MATDBG OR IS_HOST_PLATFORM)
add_subdirectory(${LIBRARIES}/matdbg)
endif()
if (FILAMENT_ENABLE_FGDBG OR IS_HOST_PLATFORM)
add_subdirectory(${LIBRARIES}/fgdbg)
endif()
endif()
if (FILAMENT_SUPPORTS_VULKAN)

View File

@@ -8,3 +8,5 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
## Release notes for next branch cut
- engine: a new feature to set a transform on the global-scale fog [⚠️ **Recompile materials**]
- engine: large-scale fog can now be opted-out on a per-renderable basis

View File

@@ -31,7 +31,7 @@ repositories {
}
dependencies {
implementation 'com.google.android.filament:filament-android:1.37.0'
implementation 'com.google.android.filament:filament-android:1.36.0'
}
```
@@ -50,7 +50,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
iOS projects can use CocoaPods to install the latest release:
```
pod 'Filament', '~> 1.37.0'
pod 'Filament', '~> 1.36.0'
```
### Snapshots
@@ -312,6 +312,7 @@ and tools.
- `bluegl`: OpenGL bindings for macOS, Linux and Windows
- `bluevk`: Vulkan bindings for macOS, Linux, Windows and Android
- `camutils`: Camera manipulation utilities
- `fgdbg`: Frame Graph inspector and debugger (debug builds only)
- `filabridge`: Library shared by the Filament engine and host tools
- `filaflat`: Serialization/deserialization library used for materials
- `filagui`: Helper library for [Dear ImGui](https://github.com/ocornut/imgui)

View File

@@ -201,12 +201,19 @@ Java_com_google_android_filament_RenderableManager_nBuilderSkinning(JNIEnv*, jcl
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_RenderableManager_nEnableSkinningBuffers(JNIEnv*, jclass,
Java_com_google_android_filament_RenderableManager_nBuilderEnableSkinningBuffers(JNIEnv*, jclass,
jlong nativeBuilder, jboolean enabled) {
RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder;
builder->enableSkinningBuffers(enabled);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_RenderableManager_nBuilderFog(JNIEnv*, jclass,
jlong nativeBuilder, jboolean enabled) {
RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder;
builder->fog(enabled);
}
extern "C" JNIEXPORT jint JNICALL
Java_com_google_android_filament_RenderableManager_nBuilderSkinningBones(JNIEnv* env, jclass,
jlong nativeBuilder, jint boneCount, jobject bones, jint remaining) {
@@ -360,6 +367,20 @@ Java_com_google_android_filament_RenderableManager_nSetCulling(JNIEnv*, jclass,
rm->setCulling((RenderableManager::Instance) i, enabled);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_RenderableManager_nSetFogEnabled(JNIEnv*, jclass,
jlong nativeRenderableManager, jint i, jboolean enabled) {
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
rm->setFogEnabled((RenderableManager::Instance) i, enabled);
}
extern "C" JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_RenderableManager_nGetFogEnabled(JNIEnv*, jclass,
jlong nativeRenderableManager, jint i) {
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
return (jboolean)rm->getFogEnabled((RenderableManager::Instance) i);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_RenderableManager_nSetCastShadows(JNIEnv*, jclass,
jlong nativeRenderableManager, jint i, jboolean enabled) {

View File

@@ -505,3 +505,11 @@ Java_com_google_android_filament_View_nGetMaterialGlobal(JNIEnv *env, jclass cla
std::copy_n(result.v, 4, out);
env->ReleaseFloatArrayElements(out_, out, 0);
}
extern "C"
JNIEXPORT int JNICALL
Java_com_google_android_filament_View_nGetFogEntity(JNIEnv *env, jclass clazz,
jlong nativeView) {
View *view = (View *) nativeView;
return (jint)view->getFogEntity().getId();
}

View File

@@ -417,7 +417,19 @@ public class RenderableManager {
*/
@NonNull
public Builder enableSkinningBuffers(boolean enabled) {
nEnableSkinningBuffers(mNativeBuilder, enabled);
nBuilderEnableSkinningBuffers(mNativeBuilder, enabled);
return this;
}
/**
* Controls if this renderable is affected by the large-scale fog.
* @param enabled If true, enables large-scale fog on this object. Disables it otherwise.
* True by default.
* @return this <code>Builder</code> object for chaining calls
*/
@NonNull
public Builder fog(boolean enabled) {
nBuilderFog(mNativeBuilder, enabled);
return this;
}
@@ -729,6 +741,23 @@ public class RenderableManager {
nSetCulling(mNativeObject, i, enabled);
}
/**
* Changes whether or not the large-scale fog is applied to this renderable
* @see Builder#fog
*/
public void setFogEnabled(@EntityInstance int i, boolean enabled) {
nSetFogEnabled(mNativeObject, i, enabled);
}
/**
* Returns whether large-scale fog is enabled for this renderable.
* @return True if fog is enabled for this renderable.
* @see Builder#fog
*/
public boolean getFogEnabled(@EntityInstance int i) {
return nGetFogEnabled(mNativeObject, i);
}
/**
* Enables or disables a light channel.
* Light channel 0 is enabled by default.
@@ -951,7 +980,8 @@ public class RenderableManager {
private static native void nBuilderSkinningBuffer(long nativeBuilder, long nativeSkinningBuffer, int boneCount, int offset);
private static native void nBuilderMorphing(long nativeBuilder, int targetCount);
private static native void nBuilderSetMorphTargetBufferAt(long nativeBuilder, int level, int primitiveIndex, long nativeMorphTargetBuffer, int offset, int count);
private static native void nEnableSkinningBuffers(long nativeBuilder, boolean enabled);
private static native void nBuilderEnableSkinningBuffers(long nativeBuilder, boolean enabled);
private static native void nBuilderFog(long nativeBuilder, boolean enabled);
private static native void nBuilderLightChannel(long nativeRenderableManager, int channel, boolean enable);
private static native void nBuilderInstances(long nativeRenderableManager, int instances);
@@ -966,6 +996,8 @@ public class RenderableManager {
private static native void nSetPriority(long nativeRenderableManager, int i, int priority);
private static native void nSetChannel(long nativeRenderableManager, int i, int channel);
private static native void nSetCulling(long nativeRenderableManager, int i, boolean enabled);
private static native void nSetFogEnabled(long nativeRenderableManager, int i, boolean enabled);
private static native boolean nGetFogEnabled(long nativeRenderableManager, int i);
private static native void nSetLightChannel(long nativeRenderableManager, int i, int channel, boolean enable);
private static native boolean nGetLightChannel(long nativeRenderableManager, int i, int channel);
private static native void nSetCastShadows(long nativeRenderableManager, int i, boolean enabled);

View File

@@ -1148,6 +1148,20 @@ public class View {
return out;
}
/**
* Get an Entity representing the large scale fog object.
* This entity is always inherited by the View's Scene.
*
* It is for example possible to create a TransformManager component with this
* Entity and apply a transformation globally on the fog.
*
* @return an Entity representing the large scale fog object.
*/
@Entity
public int getFogEntity() {
return nGetFogEntity(getNativeObject());
}
public long getNativeObject() {
if (mNativeObject == 0) {
throw new IllegalStateException("Calling method on destroyed View");
@@ -1206,6 +1220,7 @@ public class View {
private static native boolean nIsStencilBufferEnabled(long nativeView);
private static native void nSetMaterialGlobal(long nativeView, int index, float x, float y, float z, float w);
private static native void nGetMaterialGlobal(long nativeView, int index, float[] out);
private static native int nGetFogEntity(long nativeView);
/**

View File

@@ -1,5 +1,5 @@
GROUP=com.google.android.filament
VERSION_NAME=1.37.0
VERSION_NAME=1.36.0
POM_DESCRIPTION=Real-time physically based rendering engine for Android.

View File

@@ -172,6 +172,8 @@ MATOPT_GRADLE_OPTION=""
ASAN_UBSAN_OPTION=""
FGDBG_OPTION="-DFILAMENT_ENABLE_FGDBG=OFF"
IOS_BUILD_SIMULATOR=false
BUILD_UNIVERSAL_LIBRARIES=false
@@ -233,6 +235,7 @@ function build_desktop_target {
${MATDBG_OPTION} \
${MATOPT_OPTION} \
${ASAN_UBSAN_OPTION} \
${FGDBG_OPTION} \
${deployment_target} \
${architectures} \
../..
@@ -360,6 +363,7 @@ function build_android_target {
-DCMAKE_TOOLCHAIN_FILE="../../build/toolchain-${arch}-linux-android.cmake" \
${MATDBG_OPTION} \
${MATOPT_OPTION} \
${FGDBG_OPTION} \
${VULKAN_ANDROID_OPTION} \
../..
fi
@@ -594,6 +598,7 @@ function build_ios_target {
-DCMAKE_TOOLCHAIN_FILE=../../third_party/clang/iOS.cmake \
${MATDBG_OPTION} \
${MATOPT_OPTION} \
${FGDBG_OPTION} \
../..
fi
@@ -778,6 +783,7 @@ while getopts ":hacCfgijmp:q:uvslwtedk:b" opt; do
PRINT_MATDBG_HELP=true
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=ON, -DFILAMENT_BUILD_FILAMAT=ON"
MATDBG_GRADLE_OPTION="-Pcom.google.android.filament.matdbg"
FGDBG_OPTION="-DFILAMENT_ENABLE_FGDBG=ON"
;;
f)
ISSUE_CMAKE_ALWAYS=true

View File

@@ -57,8 +57,7 @@ FILAMENT_NDK_VERSION=${FILAMENT_NDK_VERSION:-$(cat `dirname $0`/ndk.version)}
# Install the required NDK version specifically (if not present)
if [[ ! -d "${ANDROID_HOME}/ndk/$FILAMENT_NDK_VERSION" ]]; then
# NOTE: We MUST use Java 1.8 to run sdkmanager currently, it fails starting with Java 11
JAVA_HOME=${JAVA_HOME_8_X64} ${ANDROID_HOME}/tools/bin/sdkmanager "ndk;$FILAMENT_NDK_VERSION" > /dev/null
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager "ndk;$FILAMENT_NDK_VERSION" > /dev/null
fi
# Only build 1 64 bit target during presubmit to cut down build times during presubmit

View File

@@ -511,6 +511,13 @@ target_link_libraries(${TARGET} PUBLIC filaflat)
target_link_libraries(${TARGET} PUBLIC filabridge)
target_link_libraries(${TARGET} PUBLIC ibl-lite)
if (FILAMENT_ENABLE_FGDBG)
target_link_libraries(${TARGET} PUBLIC fgdbg)
add_definitions(-DFILAMENT_ENABLE_FGDBG=1)
else()
add_definitions(-DFILAMENT_ENABLE_FGDBG=0)
endif()
if (FILAMENT_ENABLE_MATDBG)
target_link_libraries(${TARGET} PUBLIC matdbg)
add_definitions(-DFILAMENT_ENABLE_MATDBG=1)

View File

@@ -38,7 +38,7 @@
uint32_t height;
} wl;
}// anonymous namespace
#elif defined(__linux__) && defined(FILAMENT_SUPPORTS_X11)
#elif defined(__linux__) && defined(FILAMENT_SUPPORTS_X11) && (defined(FILAMENT_SUPPORTS_XCB) || defined(FILAMENT_SUPPORTS_XLIB))
#include <dlfcn.h>
#if defined(FILAMENT_SUPPORTS_XCB)
#include <xcb/xcb.h>
@@ -169,9 +169,7 @@ PlatformVulkan::SurfaceBundle PlatformVulkan::createVkSurfaceKHR(void* nativeWin
"Unable to load vkCreateXlibSurfaceKHR function.");
#endif
}
#if defined(FILAMENT_SUPPORTS_XCB) || defined(FILAMENT_SUPPORTS_XLIB)
bool useXcb = false;
#endif
bool useXcb = false;
#if defined(FILAMENT_SUPPORTS_XCB)
#if defined(FILAMENT_SUPPORTS_XLIB)
useXcb = (flags & SWAP_CHAIN_CONFIG_ENABLE_XCB) != 0;

View File

@@ -303,6 +303,14 @@ public:
*/
Builder& enableSkinningBuffers(bool enabled = true) noexcept;
/**
* Controls if this renderable is affected by the large-scale fog.
* @param enabled If true, enables large-scale fog on this object. Disables it otherwise.
* True by default.
* @return A reference to this Builder for chaining calls.
*/
Builder& fog(bool enabled = true) noexcept;
/**
* Enables GPU vertex skinning for up to 255 bones, 0 by default.
*
@@ -536,6 +544,19 @@ public:
*/
void setCulling(Instance instance, bool enable) noexcept;
/**
* Changes whether or not the large-scale fog is applied to this renderable
* @see Builder::fog()
*/
void setFogEnabled(Instance instance, bool enable) noexcept;
/**
* Returns whether large-scale fog is enabled for this renderable.
* @return True if fog is enabled for this renderable.
* @see Builder::fog()
*/
bool getFogEnabled(Instance instance) const noexcept;
/**
* Enables or disables a light channel.
* Light channel 0 is enabled by default.

View File

@@ -827,6 +827,17 @@ public:
*/
math::float4 getMaterialGlobal(uint32_t index) const;
/**
* Get an Entity representing the large scale fog object.
* This entity is always inherited by the View's Scene.
*
* It is for example possible to create a TransformManager component with this
* Entity and apply a transformation globally on the fog.
*
* @return an Entity representing the large scale fog object.
*/
utils::Entity getFogEntity() const noexcept;
/**
* List of available ambient occlusion techniques
* @deprecated use AmbientOcclusionOptions::enabled instead

View File

@@ -128,16 +128,32 @@ void PerViewUniforms::prepareTemporalNoise(FEngine& engine,
s.temporalNoise = options.enabled ? temporalNoise : 0.0f;
}
void PerViewUniforms::prepareFog(float3 const& cameraPosition, FogOptions const& options) noexcept {
void PerViewUniforms::prepareFog(const CameraInfo& cameraInfo,
mat4 const& userWorldFromFog, FogOptions const& options) noexcept {
// Fog should be calculated in the "user's world coordinates" so that it's not
// affected by the IBL rotation.
// fogFromWorldMatrix below is only used to transform the view vector in the shader, which is
// why we store the cofactor matrix.
mat4f const viewFromWorld = cameraInfo.view;
mat4 const worldFromUserWorld = cameraInfo.worldOrigin;
mat4 const worldFromFog = worldFromUserWorld * userWorldFromFog;
mat4 const viewFromFog = viewFromWorld * worldFromFog;
mat4 const fogFromView = inverse(viewFromFog);
mat3 const fogFromWorld = inverse(worldFromFog.upperLeft());
// camera position relative to the fog's origin
auto const userCameraPosition = fogFromView[3].xyz;
const float heightFalloff = std::max(0.0f, options.heightFalloff);
// precalculate the constant part of density integral
const float density = -heightFalloff * (cameraPosition.y - options.height);
const float density = -float(heightFalloff * (userCameraPosition.y - options.height));
auto& s = mUniforms.edit();
s.fogStart = options.distance;
s.fogMaxOpacity = options.maximumOpacity;
s.fogHeight = options.height;
s.fogHeightFalloff = heightFalloff;
s.fogCutOffDistance = options.cutOffDistance;
s.fogColor = options.color;
@@ -145,6 +161,7 @@ void PerViewUniforms::prepareFog(float3 const& cameraPosition, FogOptions const&
s.fogInscatteringStart = options.inScatteringStart;
s.fogInscatteringSize = options.inScatteringSize;
s.fogColorFromIbl = options.fogColorFromIbl ? 1.0f : 0.0f;
s.fogFromWorldMatrix = mat3f{ cof(fogFromWorld) };
}
void PerViewUniforms::prepareSSAO(Handle<HwTexture> ssao,

View File

@@ -85,7 +85,8 @@ public:
void prepareTime(FEngine& engine, math::float4 const& userTime) noexcept;
void prepareTemporalNoise(FEngine& engine, TemporalAntiAliasingOptions const& options) noexcept;
void prepareExposure(float ev100) noexcept;
void prepareFog(math::float3 const& cameraPosition, FogOptions const& options) noexcept;
void prepareFog(const CameraInfo& cameraInfo,
math::mat4 const& fogTransform, FogOptions const& options) noexcept;
void prepareStructure(TextureHandle structure) noexcept;
void prepareSSAO(TextureHandle ssao, AmbientOcclusionOptions const& options) noexcept;
void prepareBlending(bool needsAlphaChannel) noexcept;

View File

@@ -431,7 +431,7 @@ UTILS_NOINLINE
RenderPass::Command* RenderPass::generateCommandsImpl(uint32_t extraFlags,
Command* UTILS_RESTRICT curr,
FScene::RenderableSoa const& UTILS_RESTRICT soa, Range<uint32_t> range,
Variant variant, RenderFlags renderFlags, FScene::VisibleMaskType visibilityMask,
Variant const variant, RenderFlags renderFlags, FScene::VisibleMaskType visibilityMask,
float3 cameraPosition, float3 cameraForward) noexcept {
// generateCommands() writes both the draw and depth commands simultaneously such that
@@ -479,6 +479,8 @@ RenderPass::Command* RenderPass::generateCommandsImpl(uint32_t extraFlags,
continue;
}
Variant renderableVariant = variant;
// Signed distance from camera plane to object's center. Positive distances are in front of
// the camera. Some objects with a center behind the camera can still be visible
// so their distance will be negative (this happens a lot for the shadow map).
@@ -523,9 +525,9 @@ RenderPass::Command* RenderPass::generateCommandsImpl(uint32_t extraFlags,
// if we are already an SSR variant, the SRE bit is already set,
// there is no harm setting it again
static_assert(Variant::SPECIAL_SSR & Variant::SRE);
variant.setShadowReceiver(
renderableVariant.setShadowReceiver(
Variant::isSSRVariant(variant) || (soaVisibility[i].receiveShadows & hasShadowing));
variant.setSkinning(hasSkinningOrMorphing);
renderableVariant.setSkinning(hasSkinningOrMorphing);
if constexpr (isDepthPass) {
cmdDepth.key = uint64_t(Pass::DEPTH);
@@ -540,6 +542,9 @@ RenderPass::Command* RenderPass::generateCommandsImpl(uint32_t extraFlags,
cmdDepth.primitive.materialVariant.setSkinning(hasSkinningOrMorphing);
cmdDepth.primitive.rasterState.inverseFrontFaces = inverseFrontFaces;
}
if constexpr (isColorPass) {
renderableVariant.setFog(soaVisibility[i].fog && Variant::isFogVariant(variant));
}
const bool shadowCaster = soaVisibility[i].castShadows & hasShadowing;
const bool writeDepthForShadowCasters = depthContainsShadowCasters & shadowCaster;
@@ -560,7 +565,7 @@ RenderPass::Command* RenderPass::generateCommandsImpl(uint32_t extraFlags,
if constexpr (isColorPass) {
cmdColor.primitive.primitiveHandle = primitive.getHwHandle();
RenderPass::setupColorCommand(cmdColor, variant, mi, inverseFrontFaces);
RenderPass::setupColorCommand(cmdColor, renderableVariant, mi, inverseFrontFaces);
cmdColor.primitive.skinningHandle = skinning.handle;
cmdColor.primitive.skinningOffset = skinning.offset;

View File

@@ -165,4 +165,12 @@ bool RenderableManager::getLightChannel(Instance instance, unsigned int channel)
return downcast(this)->getLightChannel(instance, channel);
}
void RenderableManager::setFogEnabled(RenderableManager::Instance instance, bool enable) noexcept {
downcast(this)->setFogEnabled(instance, enable);
}
bool RenderableManager::getFogEnabled(RenderableManager::Instance instance) const noexcept {
return downcast(this)->getFogEnabled(instance);
}
} // namespace filament

View File

@@ -296,4 +296,8 @@ math::float4 View::getMaterialGlobal(uint32_t index) const {
return downcast(this)->getMaterialGlobal(index);
}
utils::Entity View::getFogEntity() const noexcept {
return downcast(this)->getFogEntity();
}
} // namespace filament

View File

@@ -60,6 +60,7 @@ struct RenderableManager::BuilderDetails {
bool mReceiveShadows : 1;
bool mScreenSpaceContactShadows : 1;
bool mSkinningBufferMode : 1;
bool mFogEnabled : 1;
size_t mSkinningBoneCount = 0;
size_t mMorphTargetCount = 0;
Bone const* mUserBones = nullptr;
@@ -70,7 +71,7 @@ struct RenderableManager::BuilderDetails {
explicit BuilderDetails(size_t count)
: mEntries(count), mCulling(true), mCastShadows(false), mReceiveShadows(true),
mScreenSpaceContactShadows(false), mSkinningBufferMode(false) {
mScreenSpaceContactShadows(false), mSkinningBufferMode(false), mFogEnabled(true) {
}
// this is only needed for the explicit instantiation below
BuilderDetails() = default;
@@ -204,6 +205,11 @@ RenderableManager::Builder& RenderableManager::Builder::enableSkinningBuffers(bo
return *this;
}
RenderableManager::Builder& RenderableManager::Builder::fog(bool enabled) noexcept {
mImpl->mFogEnabled = enabled;
return *this;
}
RenderableManager::Builder& RenderableManager::Builder::morphing(size_t targetCount) noexcept {
mImpl->mMorphTargetCount = targetCount;
return *this;
@@ -373,6 +379,7 @@ void FRenderableManager::create(
setCulling(ci, builder->mCulling);
setSkinning(ci, false);
setMorphing(ci, builder->mMorphTargetCount);
setFogEnabled(ci, builder->mFogEnabled);
mManager[ci].channels = builder->mLightChannels;
InstancesInfo& instances = manager[ci].instances;

View File

@@ -64,6 +64,7 @@ public:
bool morphing : 1;
bool screenSpaceContactShadows : 1;
bool reversedWindingOrder : 1;
bool fog : 1;
};
static_assert(sizeof(Visibility) == sizeof(uint16_t), "Visibility should be 16 bits");
@@ -114,6 +115,8 @@ public:
inline void setReceiveShadows(Instance instance, bool enable) noexcept;
inline void setScreenSpaceContactShadows(Instance instance, bool enable) noexcept;
inline void setCulling(Instance instance, bool enable) noexcept;
inline void setFogEnabled(Instance instance, bool enable) noexcept;
inline bool getFogEnabled(Instance instance) const noexcept;
inline void setPrimitives(Instance instance, utils::Slice<FRenderPrimitive> const& primitives) noexcept;
@@ -339,6 +342,17 @@ void FRenderableManager::setCulling(Instance instance, bool enable) noexcept {
}
}
void FRenderableManager::setFogEnabled(Instance instance, bool enable) noexcept {
if (instance) {
Visibility& visibility = mManager[instance].visibility;
visibility.fog = enable;
}
}
bool FRenderableManager::getFogEnabled(RenderableManager::Instance instance) const noexcept {
return getVisibility(instance).fog;
}
void FRenderableManager::setSkinning(Instance instance, bool enable) noexcept {
if (instance) {
Visibility& visibility = mManager[instance].visibility;

Binary file not shown.

View File

@@ -230,6 +230,13 @@ uint32_t FEngine::getJobSystemThreadPoolSize() noexcept {
void FEngine::init() {
SYSTRACE_CALL();
#if FILAMENT_ENABLE_FGDBG
if (!debug.fgdbg) {
auto server = std::make_shared<fgdbg::DebugServer>();
debug.fgdbg = std::make_unique<fgdbg::Session>("sample", server);
}
#endif
// this must be first.
assert_invariant( intptr_t(&mDriverApiStorage) % alignof(DriverApi) == 0 );
::new(&mDriverApiStorage) DriverApi(*mDriver, mCommandBufferQueue.getCircularBuffer());
@@ -590,16 +597,16 @@ int FEngine::loop() {
#endif
if (portString != nullptr) {
const int port = atoi(portString);
debug.server = new matdbg::DebugServer(mBackend, port);
debug.matdbg = std::make_unique<matdbg::DebugServer>(mBackend, port);
// Sometimes the server can fail to spin up (e.g. if the above port is already in use).
// When this occurs, carry onward, developers can look at civetweb.txt for details.
if (!debug.server->isReady()) {
delete debug.server;
debug.server = nullptr;
if (!debug.matdbg->isReady()) {
delete debug.matdbg.get();
debug.matdbg = nullptr;
} else {
debug.server->setEditCallback(FMaterial::onEditCallback);
debug.server->setQueryCallback(FMaterial::onQueryCallback);
debug.matdbg->setEditCallback(FMaterial::onEditCallback);
debug.matdbg->setQueryCallback(FMaterial::onQueryCallback);
}
}
#endif
@@ -624,6 +631,22 @@ int FEngine::loop() {
uint32_t const id = std::thread::hardware_concurrency() - 1;
while (true) {
#if FILAMENT_ENABLE_FGDBG
// TODO (@feresr): Only for testing purposes, remove
if (debug.fgdbg) {
debug.fgdbg->clear();
debug.fgdbg->addPass({ "Pass 1", 1, { 1, 3 }, { 1 }});
debug.fgdbg->addPass({ "Pass 2", 2, { 4 }, { 1, 2 }});
debug.fgdbg->addPass({ "Pass 3", 3, { 2 }, { 4 }});
debug.fgdbg->addPass({ "Pass 4", 4, {}, { 4 }});
debug.fgdbg->addPass({ "Pass 5", 5, {1, 3}, { 1 }});
debug.fgdbg->addResource({ "resource 1", 1, 100 });
debug.fgdbg->addResource({ "resource 2", 2, 100 });
debug.fgdbg->addResource({ "resource 3", 3, 100 });
debug.fgdbg->addResource({ "resource 4", 4, 100 });
debug.fgdbg->update();
}
#endif
// looks like thread affinity needs to be reset regularly (on Android)
JobSystem::setThreadAffinityById(id);
if (!execute()) {

View File

@@ -58,6 +58,14 @@
#include <filament/Texture.h>
#include <filament/VertexBuffer.h>
#if FILAMENT_ENABLE_FGDBG
#include <fgdbg/Session.h>
#else
namespace filament::fgdbg {
class DebugServer;
} // namespace filament::fgdbg
#endif
#if FILAMENT_ENABLE_MATDBG
#include <matdbg/DebugServer.h>
#else
@@ -519,7 +527,8 @@ public:
bool doFrameCapture = false;
bool disable_buffer_padding = false;
} renderer;
matdbg::DebugServer* server = nullptr;
std::unique_ptr<matdbg::DebugServer> matdbg = nullptr;
std::unique_ptr<fgdbg::Session> fgdbg = nullptr;
} debug;
};

View File

@@ -214,7 +214,7 @@ FMaterial::FMaterial(FEngine& engine, const Material::Builder& builder)
#if FILAMENT_ENABLE_MATDBG
// Register the material with matdbg.
matdbg::DebugServer* server = downcast(engine).debug.server;
matdbg::DebugServer* server = downcast(engine).debug.matdbg.get();
if (UTILS_UNLIKELY(server)) {
auto details = builder.mImpl;
mDebuggerId = server->addMaterial(mName, details->mPayload, details->mSize, this);

View File

@@ -56,9 +56,10 @@ static constexpr float PID_CONTROLLER_Ki = 0.002f;
static constexpr float PID_CONTROLLER_Kd = 0.0f;
FView::FView(FEngine& engine)
: mFroxelizer(engine),
mPerViewUniforms(engine),
mShadowMapManager(engine) {
: mFroxelizer(engine),
mFogEntity(engine.getEntityManager().create()),
mPerViewUniforms(engine),
mShadowMapManager(engine) {
DriverApi& driver = engine.getDriverApi();
FDebugRegistry& debugRegistry = engine.getDebugRegistry();
@@ -66,10 +67,10 @@ FView::FView(FEngine& engine)
debugRegistry.registerProperty("d.view.camera_at_origin",
&engine.debug.view.camera_at_origin);
// Integral term is used to fight back the dead-band below, we limit how much it can act.
// The integral term is used to fight back the dead-band below, we limit how much it can act.
mPidController.setIntegralLimits(-100.0f, 100.0f);
// dead-band, 1% for scaling down, 5% for scaling up. This stabilizes all the jitters.
// Dead-band, 1% for scaling down, 5% for scaling up. This stabilizes all the jitters.
mPidController.setOutputDeadBand(-0.01f, 0.05f);
#ifndef NDEBUG
@@ -86,7 +87,7 @@ FView::FView(FEngine& engine)
engine.debug.view.pid.kp, engine.debug.view.pid.ki, engine.debug.view.pid.kd);
#endif
// allocate ubos
// allocate UBOs
mLightUbh = driver.createBufferObject(CONFIG_MAX_LIGHT_COUNT * sizeof(LightsUib),
BufferObjectBinding::UNIFORM, BufferUsage::DYNAMIC);
@@ -114,6 +115,8 @@ void FView::terminate(FEngine& engine) {
mShadowMapManager.terminate(engine);
mPerViewUniforms.terminate(driver);
mFroxelizer.terminate(driver);
engine.getEntityManager().destroy(mFogEntity);
}
void FView::setViewport(filament::Viewport const& viewport) noexcept {
@@ -639,10 +642,11 @@ void FView::prepare(FEngine& engine, DriverApi& driver, ArenaScope& arena,
* Update driver state
*/
auto const userModelMatrix = inverse(cameraInfo.getUserViewMatrix());
auto const userCameraPosition = userModelMatrix[3].xyz;
auto const& tcm = engine.getTransformManager();
auto const fogTransform = tcm.getWorldTransformAccurate(tcm.getInstance(mFogEntity));
mPerViewUniforms.prepareTime(engine, userTime);
mPerViewUniforms.prepareFog(userCameraPosition, mFogOptions);
mPerViewUniforms.prepareFog(cameraInfo, fogTransform, mFogOptions);
mPerViewUniforms.prepareTemporalNoise(engine, mTemporalAntiAliasingOptions);
mPerViewUniforms.prepareBlending(needsAlphaChannel);
mPerViewUniforms.prepareMaterialGlobals(mMaterialGlobals);

View File

@@ -415,6 +415,10 @@ public:
math::float4 getMaterialGlobal(uint32_t index) const;
utils::Entity getFogEntity() const noexcept {
return mFogEntity;
}
private:
struct FPickingQuery : public PickingQuery {
@@ -511,6 +515,7 @@ private:
BlendMode mBlendMode = BlendMode::OPAQUE;
const FColorGrading* mColorGrading = nullptr;
const FColorGrading* mDefaultColorGrading = nullptr;
utils::Entity mFogEntity{};
PIDController mPidController;
DynamicResolutionOptions mDynamicResolution;

View File

@@ -1,12 +1,12 @@
Pod::Spec.new do |spec|
spec.name = "Filament"
spec.version = "1.37.0"
spec.version = "1.36.0"
spec.license = { :type => "Apache 2.0", :file => "LICENSE" }
spec.homepage = "https://google.github.io/filament"
spec.authors = "Google LLC."
spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL."
spec.platform = :ios, "11.0"
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.37.0/filament-v1.37.0-ios.tgz" }
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.36.0/filament-v1.36.0-ios.tgz" }
# Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon.
spec.pod_target_xcconfig = {

22
libs/fgdbg/CMakeLists.txt Normal file
View File

@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.19)
project(fgdbg)
set(TARGET fgdbg)
set(PUBLIC_HDR_DIR include)
# ==================================================================================================
# Sources and headers
# ==================================================================================================
set(PUBLIC_HDRS include/fgdbg/DebugServer.h include/fgdbg/Session.h)
set(SRCS src/DebugServer.cpp src/Session.cpp)
# ==================================================================================================
# Include and target definitions
# ==================================================================================================
add_library(${TARGET} STATIC ${PUBLIC_HDRS} ${SRCS})
target_link_libraries(${TARGET} PUBLIC civetweb utils)
target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR})
include_directories(${PUBLIC_HDR_DIR})

1
libs/fgdbg/README.md Normal file
View File

@@ -0,0 +1 @@
# FrameGraph Debugger (WIP)

9
libs/fgdbg/client/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/caches
/.idea/gradle.xml
.DS_Store
/build

View File

@@ -0,0 +1,2 @@
#Thu Oct 20 11:28:41 AEDT 2022
gradle.version=7.3.3

Binary file not shown.

View File

@@ -0,0 +1,48 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.8.0"
id("org.jetbrains.compose") version "1.3.0"
kotlin("plugin.serialization") version "1.4.20"
}
group = "com.google.filament"
version = "1.0"
val ktorVersion: String by project
repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven {
url = uri("https://maven.pkg.jetbrains.space/public/p/ktor/eap")
name = "ktor-eap"
}
}
dependencies {
implementation(compose.desktop.currentOs)
dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.ktor:ktor-client-websockets:$ktorVersion")
implementation("com.charleskorn.kaml:kaml:0.51.0")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "fgdbg"
packageVersion = "1.0.0"
}
}
}

Binary file not shown.

View File

@@ -0,0 +1 @@
Р и и и и и и и и и и н в в в б

Some files were not shown because too many files have changed in this diff Show More