Fixed a crash when loading a gltf file where textures has no sampler entry.
Also adapted how the light map is handled
This commit is contained in:
parent
bed3cc8a17
commit
510562a62d
@ -200,6 +200,9 @@ void main(){
|
||||
#else
|
||||
lightMapColor = texture2D(m_LightMap, texCoord).rgb;
|
||||
#endif
|
||||
#ifdef AO_MAP
|
||||
lightMapColor.gb = lightMapColor.rr;
|
||||
#endif
|
||||
specularColor.rgb *= lightMapColor;
|
||||
albedo.rgb *= lightMapColor;
|
||||
#endif
|
||||
|
@ -75,6 +75,8 @@ MaterialDef PBR Lighting {
|
||||
|
||||
// Set to use TexCoord2 for the lightmap sampling
|
||||
Boolean SeparateTexCoord
|
||||
// the light map is a gray scale ao map, on ly the r channel will be read.
|
||||
Boolean LightMapAsAOMap
|
||||
|
||||
//shadows
|
||||
Int FilterMode
|
||||
@ -154,6 +156,7 @@ MaterialDef PBR Lighting {
|
||||
GLOSSINESSMAP : GlossinessMap
|
||||
NORMAL_TYPE: NormalType
|
||||
VERTEX_COLOR : UseVertexColor
|
||||
AO_MAP: LightMapAsAOMap
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -633,7 +633,12 @@ public class GltfLoader implements AssetLoader {
|
||||
Integer samplerIndex = getAsInteger(textureData, "sampler");
|
||||
|
||||
Texture2D texture2d = readImage(sourceIndex, flip);
|
||||
texture2d = readSampler(samplerIndex, texture2d);
|
||||
|
||||
if (samplerIndex != null) {
|
||||
texture2d = readSampler(samplerIndex, texture2d);
|
||||
} else {
|
||||
texture2d.setWrap(Texture.WrapMode.Repeat);
|
||||
}
|
||||
|
||||
texture2d = customContentManager.readExtensionAndExtras("texture", texture, texture2d);
|
||||
|
||||
|
@ -46,6 +46,12 @@ public abstract class PBRMaterialAdapter extends MaterialAdapter {
|
||||
//Set the normal map type to OpenGl
|
||||
getMaterial().setFloat("NormalType", 1.0f);
|
||||
}
|
||||
if (param.getName().equals("LightMap")) {
|
||||
//Gltf only supports AO maps (gray scales and only the r channel must be read)
|
||||
getMaterial().setBoolean("LightMapAsAOMap", true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return param;
|
||||
|
Loading…
x
Reference in New Issue
Block a user