mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-18 07:22:31 +02:00
Fix material key on Android
This commit is contained in:
parent
b1fb4c2d0f
commit
dca3061107
33 changed files with 65 additions and 50 deletions
|
@ -11,6 +11,15 @@
|
|||
<@if not MODEL_MATERIAL_SLH@>
|
||||
<@def MODEL_MATERIAL_SLH@>
|
||||
|
||||
// The material values (at least the material key) must be precisely bitwise accurate
|
||||
// to what is provided by the uniform buffer, or the material key has the wrong bits
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
#define BITFIELD highp int
|
||||
#else
|
||||
#define BITFIELD int
|
||||
#endif
|
||||
|
||||
struct Material {
|
||||
vec4 _emissiveOpacity;
|
||||
vec4 _albedoRoughness;
|
||||
|
@ -39,27 +48,30 @@ float getMaterialShininess(Material m) { return 1.0 - getMaterialRoughness(m); }
|
|||
|
||||
float getMaterialScattering(Material m) { return m._scatteringSpare2Key.x; }
|
||||
|
||||
int getMaterialKey(Material m) { return floatBitsToInt(m._scatteringSpare2Key.w); }
|
||||
BITFIELD getMaterialKey(Material m) { return floatBitsToInt(m._scatteringSpare2Key.w); }
|
||||
|
||||
const int EMISSIVE_VAL_BIT = 0x00000001;
|
||||
const int UNLIT_VAL_BIT = 0x00000002;
|
||||
const int ALBEDO_VAL_BIT = 0x00000004;
|
||||
const int METALLIC_VAL_BIT = 0x00000008;
|
||||
const int GLOSSY_VAL_BIT = 0x00000010;
|
||||
const int OPACITY_VAL_BIT = 0x00000020;
|
||||
const int OPACITY_MASK_MAP_BIT = 0x00000040;
|
||||
const int OPACITY_TRANSLUCENT_MAP_BIT = 0x00000080;
|
||||
const int SCATTERING_VAL_BIT = 0x00000100;
|
||||
const BITFIELD EMISSIVE_VAL_BIT = 0x00000001;
|
||||
const BITFIELD UNLIT_VAL_BIT = 0x00000002;
|
||||
const BITFIELD ALBEDO_VAL_BIT = 0x00000004;
|
||||
const BITFIELD METALLIC_VAL_BIT = 0x00000008;
|
||||
const BITFIELD GLOSSY_VAL_BIT = 0x00000010;
|
||||
const BITFIELD OPACITY_VAL_BIT = 0x00000020;
|
||||
const BITFIELD OPACITY_MASK_MAP_BIT = 0x00000040;
|
||||
const BITFIELD OPACITY_TRANSLUCENT_MAP_BIT = 0x00000080;
|
||||
const BITFIELD SCATTERING_VAL_BIT = 0x00000100;
|
||||
|
||||
|
||||
const int EMISSIVE_MAP_BIT = 0x00000200;
|
||||
const int ALBEDO_MAP_BIT = 0x00000400;
|
||||
const int METALLIC_MAP_BIT = 0x00000800;
|
||||
const int ROUGHNESS_MAP_BIT = 0x00001000;
|
||||
const int NORMAL_MAP_BIT = 0x00002000;
|
||||
const int OCCLUSION_MAP_BIT = 0x00004000;
|
||||
const int LIGHTMAP_MAP_BIT = 0x00008000;
|
||||
const int SCATTERING_MAP_BIT = 0x00010000;
|
||||
const BITFIELD EMISSIVE_MAP_BIT = 0x00000200;
|
||||
const BITFIELD ALBEDO_MAP_BIT = 0x00000400;
|
||||
const BITFIELD METALLIC_MAP_BIT = 0x00000800;
|
||||
const BITFIELD ROUGHNESS_MAP_BIT = 0x00001000;
|
||||
const BITFIELD NORMAL_MAP_BIT = 0x00002000;
|
||||
const BITFIELD OCCLUSION_MAP_BIT = 0x00004000;
|
||||
const BITFIELD LIGHTMAP_MAP_BIT = 0x00008000;
|
||||
const BITFIELD SCATTERING_MAP_BIT = 0x00010000;
|
||||
|
||||
#ifdef GL_ES
|
||||
precision lowp float;
|
||||
#endif
|
||||
|
||||
<@endif@>
|
||||
|
|
|
@ -34,7 +34,10 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
#ifdef GL_ES
|
||||
highp
|
||||
#endif
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<! <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> !>
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, scatteringTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
||||
<! <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> !>
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ in float _alpha;
|
|||
void main(void) {
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
|
|
|
@ -27,7 +27,7 @@ in vec2 _texCoord1;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ in vec3 _color;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ in vec3 _color;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ in vec3 _color;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ in vec3 _color;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ in vec3 _color;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, scatteringTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, scatteringTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ in vec3 _color;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ in vec3 _color;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
||||
float opacity = getMaterialOpacity(mat) * _alpha;
|
||||
|
|
|
@ -36,7 +36,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
||||
float opacity = getMaterialOpacity(mat) * _alpha;
|
||||
|
|
|
@ -27,7 +27,7 @@ in float _alpha;
|
|||
void main(void) {
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
|
|
|
@ -36,7 +36,7 @@ void main(void) {
|
|||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
|
|
|
@ -33,7 +33,7 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ out vec4 _fragColor;
|
|||
|
||||
void main(void) {
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ out vec4 _fragColor;
|
|||
void main(void) {
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
|
|
|
@ -27,7 +27,7 @@ out vec4 _fragColor;
|
|||
void main(void) {
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
|
|
Loading…
Reference in a new issue