mirror of https://github.com/bjornbytes/lovr.git
Shader flag adjustments;
- glowTexture is on by default, but still requires the glow flag. - occlusionTexture is named ambientOcclusion, and is on by default, but is still not used by any builtin shaders/helpers.
This commit is contained in:
parent
0b0faf6dc6
commit
8697466009
|
@ -10,10 +10,10 @@ layout(constant_id = 1007) const bool flag_glow = false;
|
|||
layout(constant_id = 1008) const bool flag_normalMap = false;
|
||||
layout(constant_id = 1009) const bool flag_vertexTangents = true;
|
||||
layout(constant_id = 1010) const bool flag_colorTexture = true;
|
||||
layout(constant_id = 1011) const bool flag_glowTexture = false;
|
||||
layout(constant_id = 1011) const bool flag_glowTexture = true;
|
||||
layout(constant_id = 1012) const bool flag_metalnessTexture = true;
|
||||
layout(constant_id = 1013) const bool flag_roughnessTexture = true;
|
||||
layout(constant_id = 1014) const bool flag_occlusionTexture = false;
|
||||
layout(constant_id = 1014) const bool flag_ambientOcclusion = true;
|
||||
layout(constant_id = 1015) const bool flag_clearcoatTexture = false;
|
||||
layout(constant_id = 1016) const bool flag_tonemap = false;
|
||||
|
||||
|
@ -248,7 +248,7 @@ void initSurface(out Surface surface) {
|
|||
surface.roughness2 = roughness * roughness;
|
||||
|
||||
surface.occlusion = 1.;
|
||||
if (flag_occlusionTexture) surface.occlusion *= getPixel(OcclusionTexture, UV).r * Material.occlusionStrength;
|
||||
if (flag_ambientOcclusion) surface.occlusion *= getPixel(OcclusionTexture, UV).r * Material.occlusionStrength;
|
||||
|
||||
surface.clearcoat = Material.clearcoat;
|
||||
if (flag_clearcoatTexture) surface.clearcoat *= getPixel(ClearcoatTexture, UV).r;
|
||||
|
|
|
@ -613,10 +613,10 @@ static int l_lovrModelDataGetMaterial(lua_State* L) {
|
|||
#define PUSH_IMAGE(t) if (material->t != ~0u) luax_pushtype(L, Image, model->images[material->t]), lua_setfield(L, -2, #t)
|
||||
PUSH_IMAGE(texture);
|
||||
PUSH_IMAGE(glowTexture);
|
||||
PUSH_IMAGE(occlusionTexture);
|
||||
PUSH_IMAGE(metalnessTexture);
|
||||
PUSH_IMAGE(roughnessTexture);
|
||||
PUSH_IMAGE(clearcoatTexture);
|
||||
PUSH_IMAGE(occlusionTexture);
|
||||
PUSH_IMAGE(normalTexture);
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -1369,10 +1369,6 @@ static int l_lovrGraphicsNewMaterial(lua_State* L) {
|
|||
info.glowTexture = luax_opttexture(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, 1, "occlusionTexture");
|
||||
info.occlusionTexture = luax_opttexture(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, 1, "metalnessTexture");
|
||||
info.metalnessTexture = luax_opttexture(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
@ -1385,6 +1381,10 @@ static int l_lovrGraphicsNewMaterial(lua_State* L) {
|
|||
info.clearcoatTexture = luax_opttexture(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, 1, "occlusionTexture");
|
||||
info.occlusionTexture = luax_opttexture(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, 1, "normalTexture");
|
||||
info.normalTexture = luax_opttexture(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
|
|
@ -54,10 +54,10 @@ static int l_lovrMaterialGetProperties(lua_State* L) {
|
|||
lua_pushnumber(L, info->data.alphaCutoff), lua_setfield(L, -2, "alphaCutoff");
|
||||
luax_pushtype(L, Texture, info->texture), lua_setfield(L, -2, "texture");
|
||||
luax_pushtype(L, Texture, info->glowTexture), lua_setfield(L, -2, "glowTexture");
|
||||
luax_pushtype(L, Texture, info->occlusionTexture), lua_setfield(L, -2, "occlusionTexture");
|
||||
luax_pushtype(L, Texture, info->metalnessTexture), lua_setfield(L, -2, "metalnessTexture");
|
||||
luax_pushtype(L, Texture, info->roughnessTexture), lua_setfield(L, -2, "roughnessTexture");
|
||||
luax_pushtype(L, Texture, info->clearcoatTexture), lua_setfield(L, -2, "clearcoatTexture");
|
||||
luax_pushtype(L, Texture, info->occlusionTexture), lua_setfield(L, -2, "occlusionTexture");
|
||||
luax_pushtype(L, Texture, info->normalTexture), lua_setfield(L, -2, "normalTexture");
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -88,10 +88,10 @@ typedef struct {
|
|||
float alphaCutoff;
|
||||
uint32_t texture;
|
||||
uint32_t glowTexture;
|
||||
uint32_t occlusionTexture;
|
||||
uint32_t metalnessTexture;
|
||||
uint32_t roughnessTexture;
|
||||
uint32_t clearcoatTexture;
|
||||
uint32_t occlusionTexture;
|
||||
uint32_t normalTexture;
|
||||
const char* name;
|
||||
} ModelMaterial;
|
||||
|
|
|
@ -709,10 +709,10 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source, ModelDataIO* io
|
|||
material->alphaCutoff = 0.f;
|
||||
material->texture = ~0u;
|
||||
material->glowTexture = ~0u;
|
||||
material->occlusionTexture = ~0u;
|
||||
material->metalnessTexture = ~0u;
|
||||
material->roughnessTexture = ~0u;
|
||||
material->clearcoatTexture = ~0u;
|
||||
material->occlusionTexture = ~0u;
|
||||
material->normalTexture = ~0u;
|
||||
|
||||
for (int k = (token++)->size; k > 0; k--) {
|
||||
|
|
|
@ -60,10 +60,10 @@ static void parseMtl(char* path, char* base, ModelDataIO* io, arr_image_t* image
|
|||
.alphaCutoff = 0.f,
|
||||
.texture = ~0u,
|
||||
.glowTexture = ~0u,
|
||||
.occlusionTexture = ~0u,
|
||||
.metalnessTexture = ~0u,
|
||||
.roughnessTexture = ~0u,
|
||||
.clearcoatTexture = ~0u,
|
||||
.occlusionTexture = ~0u,
|
||||
.normalTexture = ~0u
|
||||
}));
|
||||
} else if (line[0] == 'K' && line[1] == 'd' && line[2] == ' ') {
|
||||
|
|
|
@ -2038,10 +2038,10 @@ Material* lovrMaterialCreate(const MaterialInfo* info) {
|
|||
Texture* textures[] = {
|
||||
info->texture,
|
||||
info->glowTexture,
|
||||
info->occlusionTexture,
|
||||
info->metalnessTexture,
|
||||
info->roughnessTexture,
|
||||
info->clearcoatTexture,
|
||||
info->occlusionTexture,
|
||||
info->normalTexture
|
||||
};
|
||||
|
||||
|
@ -2072,10 +2072,10 @@ void lovrMaterialDestroy(void* ref) {
|
|||
if (block->head == ~0u) block->head = block->tail;
|
||||
lovrRelease(material->info.texture, lovrTextureDestroy);
|
||||
lovrRelease(material->info.glowTexture, lovrTextureDestroy);
|
||||
lovrRelease(material->info.occlusionTexture, lovrTextureDestroy);
|
||||
lovrRelease(material->info.metalnessTexture, lovrTextureDestroy);
|
||||
lovrRelease(material->info.roughnessTexture, lovrTextureDestroy);
|
||||
lovrRelease(material->info.clearcoatTexture, lovrTextureDestroy);
|
||||
lovrRelease(material->info.occlusionTexture, lovrTextureDestroy);
|
||||
lovrRelease(material->info.normalTexture, lovrTextureDestroy);
|
||||
}
|
||||
|
||||
|
@ -2580,10 +2580,10 @@ Model* lovrModelCreate(const ModelInfo* info) {
|
|||
struct { uint32_t index; Texture** texture; } textures[] = {
|
||||
{ properties->texture, &material.texture },
|
||||
{ properties->glowTexture, &material.glowTexture },
|
||||
{ properties->occlusionTexture, &material.occlusionTexture },
|
||||
{ properties->metalnessTexture, &material.metalnessTexture },
|
||||
{ properties->roughnessTexture, &material.roughnessTexture },
|
||||
{ properties->clearcoatTexture, &material.clearcoatTexture },
|
||||
{ properties->occlusionTexture, &material.occlusionTexture },
|
||||
{ properties->normalTexture, &material.normalTexture }
|
||||
};
|
||||
|
||||
|
@ -5789,10 +5789,10 @@ static void trackMaterial(Pass* pass, Material* material, gpu_phase phase, gpu_c
|
|||
|
||||
trackTexture(pass, material->info.texture, phase, cache);
|
||||
trackTexture(pass, material->info.glowTexture, phase, cache);
|
||||
trackTexture(pass, material->info.occlusionTexture, phase, cache);
|
||||
trackTexture(pass, material->info.metalnessTexture, phase, cache);
|
||||
trackTexture(pass, material->info.roughnessTexture, phase, cache);
|
||||
trackTexture(pass, material->info.clearcoatTexture, phase, cache);
|
||||
trackTexture(pass, material->info.occlusionTexture, phase, cache);
|
||||
trackTexture(pass, material->info.normalTexture, phase, cache);
|
||||
}
|
||||
|
||||
|
|
|
@ -340,10 +340,10 @@ typedef struct {
|
|||
MaterialData data;
|
||||
Texture* texture;
|
||||
Texture* glowTexture;
|
||||
Texture* occlusionTexture;
|
||||
Texture* metalnessTexture;
|
||||
Texture* roughnessTexture;
|
||||
Texture* clearcoatTexture;
|
||||
Texture* occlusionTexture;
|
||||
Texture* normalTexture;
|
||||
} MaterialInfo;
|
||||
|
||||
|
|
Loading…
Reference in New Issue