finish plumbing for new material parameters

This commit is contained in:
Pixelflinger
2019-11-26 14:59:56 -08:00
committed by Mathias Agopian
parent f70b820cbe
commit ee0080487a
8 changed files with 103 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ This file contains one line summaries of commits that are worthy of mentioning i
A new header is inserted each time a *tag* is created.
## Next release
- Added support for solid and thin layer cubemap and screen-space refraction.
- Improve high roughness material rendering by default when regenerating environments maps

View File

@@ -84,6 +84,23 @@ Java_com_google_android_filament_Material_nGetBlendingMode(JNIEnv*, jclass,
return (jint) material->getBlendingMode();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_Material_nGetRefraction(JNIEnv*, jclass,
jlong nativeMaterial) {
Material* material = (Material*) nativeMaterial;
return (jint) material->getRefraction();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_Material_nGetRefractionType(JNIEnv*, jclass,
jlong nativeMaterial) {
Material* material = (Material*) nativeMaterial;
return (jint) material->getRefractionType();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_Material_nGetVertexDomain(JNIEnv*, jclass,

View File

@@ -141,6 +141,31 @@ public class Material {
SCREEN,
}
/**
* Supported refraction modes
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:refraction">
* Blending and transparency: refraction</a>
*/
public enum Refraction {
NONE,
CUBEMAP,
SCREEN_SPACE
}
/**
* Supported refraction types
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:refractiontype">
* Blending and transparency: refractionType</a>
*/
public enum RefractionType {
SOLID,
THIN
}
/**
* Supported types of vertex domains
*
@@ -351,6 +376,29 @@ public class Material {
return BlendingMode.values()[nGetBlendingMode(getNativeObject())];
}
/**
* Returns the refraction mode of this material.
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:refraction">
* Blending and transparency: refraction</a>
*/
public Refraction getRefraction() {
return Refraction.values()[nGetRefraction(getNativeObject())];
}
/**
* Returns the refraction type of this material.
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:refractiontype">
* Blending and transparency: refractionType</a>
*/
public RefractionType getRefractionType() {
return RefractionType.values()[nGetRefractionType(getNativeObject())];
}
/**
* Returns the vertex domain of this material.
*
@@ -847,6 +895,9 @@ public class Material {
private static native float nGetMaskThreshold(long nativeMaterial);
private static native float nGetSpecularAntiAliasingVariance(long nativeMaterial);
private static native float nGetSpecularAntiAliasingThreshold(long nativeMaterial);
private static native int nGetRefraction(long nativeMaterial);
private static native int nGetRefractionType(long nativeMaterial);
private static native int nGetParameterCount(long nativeMaterial);
private static native void nGetParameters(long nativeMaterial,

View File

@@ -179,6 +179,12 @@ public:
//! Returns the list of vertex attributes required by this material.
AttributeBitset getRequiredAttributes() const noexcept;
//! Returns the refraction mode used by this material.
Refraction getRefraction() const noexcept;
// Return the refraction type used by this material.
RefractionType getRefractionType() const noexcept;
/**
* Returns the number of parameters declared by this material.
* The returned value can be 0.

View File

@@ -160,6 +160,8 @@ FMaterial::FMaterial(FEngine& engine, const Material::Builder& builder)
parser->getVertexDomain(&mVertexDomain);
parser->getMaterialDomain(&mMaterialDomain);
parser->getRequiredAttributes(&mRequiredAttributes);
parser->getRefraction(&mRefraction);
parser->getRefractionType(&mRefractionType);
if (mBlendingMode == BlendingMode::MASKED) {
parser->getMaskThreshold(&mMaskThreshold);
@@ -601,6 +603,14 @@ AttributeBitset Material::getRequiredAttributes() const noexcept {
return upcast(this)->getRequiredAttributes();
}
Refraction Material::getRefraction() const noexcept {
return upcast(this)->getRefraction();
}
RefractionType Material::getRefractionType() const noexcept {
return upcast(this)->getRefractionType();
}
bool Material::hasParameter(const char* name) const noexcept {
return upcast(this)->hasParameter(name);
}

View File

@@ -246,6 +246,18 @@ bool MaterialParser::getRequiredAttributes(AttributeBitset* value) const noexcep
return true;
}
bool MaterialParser::getRefraction(Refraction* value) const noexcept {
static_assert(sizeof(Refraction) == sizeof(uint8_t),
"Refraction expected size is wrong");
return mImpl.getFromSimpleChunk(ChunkType::MaterialRefraction, (uint8_t*)value);
}
bool MaterialParser::getRefractionType(RefractionType* value) const noexcept {
static_assert(sizeof(RefractionType) == sizeof(uint8_t),
"RefractionType expected size is wrong");
return mImpl.getFromSimpleChunk(ChunkType::MaterialRefractionType, (uint8_t*)value);
}
bool MaterialParser::getShader(ShaderBuilder& shader,
ShaderModel shaderModel, uint8_t variant, ShaderType stage) noexcept {
return mImpl.mMaterialChunk.getShader(shader,

View File

@@ -75,6 +75,8 @@ public:
bool getMaskThreshold(float*) const noexcept;
bool hasShadowMultiplier(bool*) const noexcept;
bool getRequiredAttributes(AttributeBitset*) const noexcept;
bool getRefraction(Refraction* value) const noexcept;
bool getRefractionType(RefractionType* value) const noexcept;
bool hasCustomDepthShader(bool* value) const noexcept;
bool hasSpecularAntiAliasing(bool* value) const noexcept;
bool getSpecularAntiAliasingVariance(float* value) const noexcept;

View File

@@ -115,6 +115,8 @@ public:
float getMaskThreshold() const noexcept { return mMaskThreshold; }
bool hasShadowMultiplier() const noexcept { return mHasShadowMultiplier; }
AttributeBitset getRequiredAttributes() const noexcept { return mRequiredAttributes; }
Refraction getRefraction() const noexcept { return mRefraction; }
RefractionType getRefractionType() const noexcept { return mRefractionType; }
bool hasSpecularAntiAliasing() const noexcept { return mSpecularAntiAliasing; }
float getSpecularAntiAliasingVariance() const noexcept { return mSpecularAntiAliasingVariance; }
@@ -170,6 +172,8 @@ private:
MaterialDomain mMaterialDomain = MaterialDomain::SURFACE;
CullingMode mCullingMode = CullingMode::NONE;
AttributeBitset mRequiredAttributes;
Refraction mRefraction = Refraction::NONE;
RefractionType mRefractionType = RefractionType::SOLID;
uint64_t mMaterialProperties = 0;
float mMaskThreshold = 0.4f;