Coder Social home page Coder Social logo

mgsx-dev / gdx-gltf Goto Github PK

View Code? Open in Web Editor NEW
206.0 10.0 51.0 44.1 MB

GLTF 2.0 3D format support and PBR shader implementation for LibGDX

License: Apache License 2.0

Java 84.34% GLSL 14.81% Ruby 0.45% Batchfile 0.40%
gltf2-loader gltf gltf2 libgdx pbr-shader webgl

gdx-gltf's Introduction

status GitHub release (latest SemVer including pre-releases) Release GitHub release (latest SemVer including pre-releases)

LibGDX GLTF 2.0 support and PBR shader implementation. Alternative to libGDX G3D format.

Introduction

What's glTF befenits over G3D/FBX in libGDX?

  • Simpler workflow : no fbx-conv required, you can load gltf files directly.
  • Load cameras, lights, custom properties from Blender and other 3D softwares.
  • Support loading LINES and POINTS primitives.
  • Shape keys / Animated shape keys (aka MorphTarget) feature.
  • Multiple animations playback
  • Non linear animations keyframes interpolation ("step" and "cubic" supported)
  • Out of the box shaders for normal maps, metallic/roughness, Image based lighting (IBL) and more.
  • Texture coordinates transform.
  • 64k vertices supported (instead of 32k). Meshes with integer indices are split to 64k chunks as well.
  • Faster loading time, see benchmark

What's more than a 3D format parser in gdx-gltf library?

  • Scene management facility : Sky box, shadows, and more.
  • Physic Based Rendering (PBR) shaders : for realistic (or not) high quality rendering.
  • Spot light support.
  • Export various objects to glTF file (whole scene, model, mesh, etc).

Can i only load glTF files and use them with regular libgdx 3D API?

  • Yes, it's the same API, only materials differs : by default gdx-gltf uses its own shader (PBR) to enable all glTF features.
  • Note that libgdx default shader doesn't implements spot lights.
  • If you don't want/need high quality rendering (PBR), you still can use DefaultShaderProvider and DepthShaderProvider. In this case you may need to convert your materials (see MaterialConverter class).

Demo and gallery

Library demo (aka model viewer) is available for several platforms:

Games made with this library:

GL Transmission Format (glTF) 2.0 Support

Implementation based on official glTF 2.0 Specification

Shaders inspired by glTF-WebGL-PBR and glTF-Sample-Viewer :

GLTF extensions implemented:

Getting started

Tutorials

Here is few tutorials that help you starting with both Blender and gdx-gltf.

Compatibility

  • gdx-gltf 1.x requires libGDX 1.9.10+
  • gdx-gltf 2.x requires libGDX 1.9.11+

Before upgrading your gdx-gltf version, please read changes history.

Install

gdx-gltf is available via Jitpack.

ensure you have jitpack repository declared in your Gradle configuration and add a gltfVersion variable.

Version can be any release (latest release is recommended) or -SNAPSHOT

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
	ext {
        ...
        gltfVersion = '-SNAPSHOT'
    }
}

Add dependency in your core project (replace -SNAPSHOT by latest release to use a stable version) :

project(":core") {
    dependencies {
    	...
        api "com.github.mgsx-dev.gdx-gltf:gltf:$gltfVersion"
    }
}

For GWT (html) projects you need to add source dependency and inherit GWT module in your core .gwt.xml file.

project(":html") {
    dependencies {
    	...
        api "com.github.mgsx-dev.gdx-gltf:gltf:$gltfVersion:sources"
    }
}
<module>
	<inherits name='GLTF' />
	...
</module>

Loading asset files

Directly

SceneAsset sceneAsset = new GLTFLoader().load(Gdx.files.internal("myModel.gltf"));
SceneAsset sceneAsset = new GLBLoader().load(Gdx.files.internal("myModel.glb"));

Using AssetManager loaders

assetManager.setLoader(SceneAsset.class, ".gltf", new GLTFAssetLoader());
assetManager.setLoader(SceneAsset.class, ".glb", new GLBAssetLoader());
...
assetManager.load("myModel.gltf", SceneAsset.class);
...
SceneAsset sceneAsset = assetManager.get("myModel.gltf", SceneAsset.class);

Render models

This library provides a convenient scene manager to handle glTF models and PBR shader.

see few provided examples for more information:

For advanced usage, please read full documentation

Export objects from libgdx

This library provides convenient methods to export various object type to glTF file. For instance, You can create some mesh programmatically in libgdx and export them to glTF files and optionally import them in Blender:

new GLTFExporter().export(model, Gdx.files.local("myModel.gltf")

You can also export a scene with its lights and camera. All gltf features are supported for export: animations, bones, etc. Note that only "gltf separate files" mode is currently supported for export.

Export models from Blender

As Blender 2.80, glTF exporter addon is included and enabled by default.

Image Based Lighting (IBL)

Demo is shipped with a pre-generated lighting environment. If you want to use others or generate them yourself, please read IBL guide Alternatively this library provide some quick IBL generators, it's not as accurate as HDRI based IBL but can be useful to quickly setup a lighting environement. see IBLBuilder class.

More about the library

Project structure

This repository is made of a library and a demo :

  • gltf library module (LibGDX extension). see gdx-gltf readme for futher information.
  • demo folder contains a LibGDX demo project with usual modules (core, desktop, android, html, ...) see gdx-gltf-demo readme for futher information.

Limitations

Mesh limitations

Because LibGDX (and some GPUs) only supports unsigned short indices, meshes with integer indices are split into 64k chunks automatically at load time. For best loading performance, it's recommended to split your meshes beforehand (eg. in Blender).

Note that Blender vertex count can be misleading because exported geometry may contains more vertices because of normal split, texture coordinates split or vertex color split.

WebGL limitations

LibGDX Pixmap loading from binary data is not supported by its GWT emulation. So, GLTF embeded and binary formats are not supported for html/WebGL target.

CubeMap seamless limitations

CubeMap seamless is a feature that perform correct cubeMap filtering. Without this feature, you may notice some artifacts for materials with high roughness since these artifacts are more visible at low resolution. The library automatically enable this feature when possible, based on these conditions :

  • For GLES 2 and WebGL 1, this feature is not supported at all.
  • For GLES 3 and WebGL 2, this feature is always supported and always activated.
  • For Desktop, it can be enabled if platform supports OpenGL 3.2+ or GL_ARB_seamless_cube_map

GL version requirements

PBR shader needs textureLod in order to render material roughness with a radiance map (IBL) which is only available in those cases :

  • Desktop OpenGL 3.0+ or EXT_shader_texture_lod extension.
  • Android or iOS with either OpenGL ES 3.0+ or EXT_shader_texture_lod extension.
  • WebGL 2.0+ or EXT_shader_texture_lod extension.

If target platform doesn't fulfill those requirements, you can still use the library (eg. to load your GLTF files) but PBR rendering will be a bit broken.

Troubleshooting

Rigged model partially rendered

It's a common pitfall. Most of the time, that means you didn't configure numBones for your SceneManager shader providers. It's highly recommended to properly configure them for your need. Default configuration is rarely optimized or adapted to your need. For example, if the maximum bones among all your models is 60, and you only need one directional light for all scenes in your game, you should create your SceneManager like this:

PBRShaderConfig config = PBRShaderProvider.createDefaultConfig();
config.numBones = 60;
config.numDirectionalLights = 1;
config.numPointLights = 0;

Config depthConfig = PBRShaderProvider.createDefaultDepthConfig();
depthConfig.numBones = 60;

SceneManager sceneManager = new SceneManager(new PBRShaderProvider(config), new PBRDepthShaderProvider(depthConfig));

Max uniforms: Constant register limit exceeded, do not fit in N vectors

You may encounter this shader compilation error in case too many uniform needed on current hardware.

Constant register limit exceeded at ... more than 1024 registers needed to compiled program

or

Error: uniform variables in vertex shader do not fit in 256 vectors.

It typically means you may have too many bones. A single bone takes 4 uniforms (mat4), desktop GPU typically supports 1024 uniforms and lowend mobile 256 uniforms. That mean you should keep bones count under 50 per skeleton.

Tangent vertex attributes

When tangent attribute is missing and needed (when normal map is used), those are generated automatically. For best loading performance, it's recommended to export them within your GLTF files.

Max vertex attributes : too many vertex attributes

You may encounter this error if you have too many vertex attributes in one of your mesh.

Most GPU support up to 16 vertex attributes

This limit can be quickly reached depending on mesh information :

  • a_position: 1
  • a_normal: 1
  • a_tangent: 1 (optional)
  • a_color: 1 (optional)
  • a_texCoordX: up to 2 UVs layers
  • a_boneWeightX: up to 8 bones influences
  • a_positionX: up to 8 positions
  • a_normalX: up to 8 normals
  • a_tangentX: up to 8 tangents

pbrSpecularGlossiness extension not supported

You may encounter this warning when loading a model :

KHR_materials_pbrSpecularGlossiness extension is deprecated by glTF 2.0 specification and not fully supported.

This extension is now archived and no longer recommended by glTF 2.0 specification.

It was never really supported by this this library and won't be, use it at your own risks.

Issues with ProGuard and such

This library requires reflection in order to import/export GLTF files. Some classes should be filtered for tools like ProGuard. You could simply exclude all libgdx and gdx-gltf code :

keep 'class com.badlogic.gdx.** { *; }'
keep 'class net.mgsx.gltf.** { *; }'
keepattributes 'Signature'

Or only exclude gdx-gltf data package :

-keep class net.mgsx.gltf.data.** {
	public *;
}

gdx-gltf's People

Contributors

antzgames avatar d-mokliakov avatar dar-dev avatar dzikoysk avatar hangman avatar healingdrawing avatar m8vago avatar mgsx-dev avatar monstroussoftware avatar nulleuro avatar wolfgang-ch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdx-gltf's Issues

Desktop demo crash when enabling outline

The stack trace should speak for itself.
But for the sake of completeness, the steps to reproduce:

  • run the demo jar
  • [optional] load a model
  • enable the outline
    => crash

Demo version: 1.0.0

image

Render only visible

Is it possible somewhere to implement a check, the visible object through the camera? If the world is large, then the render is called for all objects, regardless of whether they are in the field of view or not.
image
For convenience, I divided the map into parts of 100 * 100 units, and I export it in separate files. Next, I check where the character is and load the part that is needed. So that the seam is not visible, I need to keep nine parts, and everything that is there is called by the render.

IBL Composer crash when setting unsupported environment map size

Steps to reproduce:

It could show a message that the size is unsupported or even better disable the options to choose those resolutions.

This also happens when setting the irradience map to 8k but not when setting the radience map to 8k.
I got no stack trace for it though.

image

And just to make it a little more challenging for you:
The crash won't occur with this hdri map https://hdrihaven.com/hdri/?c=nature&h=gamrig in 8k and setting the environment map size to 16k. At least it doesn't crash for me.

Better filenames for exported textures

by default it's "textureX.png" which conflicts when exporting several models to the same folder.

prefixing by GLTF filename would be better and have lot less conflicts.

Load pixmap from bytes in WebGL

Hello @mgsx-dev, I am trying to run a project using gdx-gltf in the browser using gwt but I am getting this error on the console:

GwtApplication: exception: load pixmap from bytes not supported for WebGL

The exception is thrown by PixmapBinaryLoaderHack.java

Edit: Originally I thought the limitation was on gdx-gltf but I found that the GWT Pixmap has no construtor using array of bytes. This is a limitation of libGDX I am doing some research.

Project status

Hey, first of all - this project looks amazing ❤️ I'm pretty sure that most of ppl using G3D format might be interested in this solution, they just probably don't know it even exists 😢

More to the point, how stable and active is it? There is a couple of issues and the last commit was 3 months ago, I'm just curious about the future.

Default IBL

for now, users have to generate their own IBL cubemaps or use provided one from demo module.

That's not convenient for new users to have something working out of the box.

There are several ways to address it :

  • ship a default IBL in library module (especially BRDF LUT texture) with either one of the demo or a new one with pretty neutral tint.
  • ship several IBL maps in a separate module (eg. gdx-gltf-ibl) that user can optionally use.

What would be the best way to handle huge meshes?

@mgsx-dev I know that the limitations of the number of vertices/indexes comes from libGDX. I also know that is always possible to break the mesh using a 3D software.
But let's say for the sake of convenience it needs to be handled via code. What do you think would be the best approach?

The way I can think of is (when loading a mesh): to load a mesh into an intermediate structure that would handle indexes as integers and the whole mesh as a list of edges. Then create multiple planes(or boxes) to slice the mesh (for each sliced edge, it would become two smaller edges).
And after slicing "enough" each chunk (defined by planes) would become a new mesh node (with less indexes than the original mesh).

Do you think that approach would work? Can you think of a simpler way to do it?

Error loading vertex-attribute-colors of all Blender-exported GLTF models

  1. If I use Vertex Paint in Blender 2.91.0 to color my model, and export it as GLTF, the rendered colors are very wrong (either red, blue, magenta or black, instead of tints of orange, green, etc.).
  2. If I use a model with vertex colors, downloaded from Google Poly (which offers 2 GLTF versions for download: https://poly.google.com/view/d6STyhH76Qe), the model is rendered with the correct colors (green). But if I import it in Blender and just export it as GLTF without modifying it, the Blender-exported model is rendered with some magenta colors, instead of green. Trying to debug the issue, it seems some of the a_color floats in the mesh are NaN(!). This is the first vertex color (4 floats) loaded by this gdx-gltf library into the Mesh vertices:
    -original model: 0.26317474, 0.5542271, 0.065753885, 1.0
    -same Blender-exported model: -6.417576E-31, NaN, -6.417576E-31, NaN

Blender_color_vertex_attribute_error_test_model.zip

I need my models with vertex colors. How do I fix this?

Documentation or Example on Rendering Procedural Mesh

I've struggled with getting a procedural model to render correctly. I am building a simple heightmap which displays correctly in the default pipeline; however, after modifying the materials when adding it to a scene it renders black.

image

I have several models in the same scene rendering on the same SceneManager render call with the same lights. Is there a particular texture that must be present for lighting to work correctly? I just want to make sure I am not spinning my wheels in the wrong area.

App crashing

HI,
Facing issue in both (.glb) and (gltf) file.

2019-02-28 15:33:44.156 31927-32093/net.mgsx.gltf.demo E/AndroidRuntime: FATAL EXCEPTION: GLThread 102412
Process: net.mgsx.gltf.demo, PID: 31927
com.badlogic.gdx.utils.GdxRuntimeException: Fragment shader:
WARNING: 0:3: extension 'GL_EXT_shader_texture_lod' is not supported
ERROR: 0:313: 'textureCubeLodEXT' : no matching overloaded function found
ERROR: 0:313: 'SRGBtoLINEAR' : no matching overloaded function found
ERROR: 0:313: 'rgb' : field selection requires structure, vector, or matrix on left hand side
ERROR: 0:313: '=' : cannot convert from 'const float' to '3-component vector of float'
ERROR: 4 compilation errors. No code generated.

    at com.badlogic.gdx.graphics.g3d.shaders.BaseShader.init(BaseShader.java:167)
    at net.mgsx.gltf.scene3d.shaders.PBRShader.init(PBRShader.java:265)
    at com.badlogic.gdx.graphics.g3d.shaders.DefaultShader.init(DefaultShader.java:595)
    at com.badlogic.gdx.graphics.g3d.utils.BaseShaderProvider.getShader(BaseShaderProvider.java:35)
    at com.badlogic.gdx.graphics.g3d.ModelBatch.render(ModelBatch.java:263)
    at net.mgsx.gltf.scene3d.scene.SceneManager.render(SceneManager.java:85)
    at net.mgsx.gltf.demo.GLTFDemo.render(GLTFDemo.java:530)
    at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:495)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)

2019-02-28 15:33:48.205 31927-31927/net.mgsx.gltf.demo E/AndroidGraphics: waiting for pause synchronization took too long; assuming deadlock and killing

GLSL error in cubemap-make.fs.glsl : atan2() should be atan()

I don't know why GLSL does this, but it doesn't define atan2() in GLSL ES (see Shaderific for reference), and instead just uses atan(). This causes IBL Composer to fail on some machines, it seems; Discord user Jaaf showed this shader compilation error which seems directly related to atan2().

You can also just look at the syntax highlighting for asin() vs. atan2() in https://github.com/mgsx-dev/gdx-gltf/blob/master/ibl-composer/src/net/mgsx/gltf/shaders/cubemap-make.fs.glsl#L26 ; atan2 isn't highlighted but asin is. Some vendors may define atan2() in addition to atan() with two arguments, but I don't think it's ever standard.

Incorrect seamless cubemap option

it was added in this commit but it doesn't cover all cases: GLES doesn't provide this option, some version doesn't have seamless cubemap at all (GLES 2 and WebGL 1) and others have it always enabled (GLES 3 and webGL2). So this option should be turned on only for desktop OpenGL.

Frustum culling renderables

SceneManager currently seems to render everything - it would be great if it checked which objects are in the frustum (for shadows too).

Issue with GLTFQuickStartExample android

Hi,
Going through the library I have used the GLTFQuickStartExample class as a example to load a simple gltf model. But running the app results in a crash with error

2021-01-16 16:14:13.402 30170-30205/com.example.maxst3demo E/AndroidRuntime: FATAL EXCEPTION: GLThread 3491 Process: com.example.maxst3demo, PID: 30170 java.lang.NullPointerException: Attempt to invoke interface method 'com.badlogic.gdx.files.FileHandle com.badlogic.gdx.Files.internal(java.lang.String)' on a null object reference at com.example.maxst3demo.imageTracker.GLTFQuickStartExample.create(GLTFQuickStartExample.java:48) at com.example.maxst3demo.imageTracker.ImageTrackerRenderer.addGM(ImageTrackerRenderer.java:107) at com.example.maxst3demo.imageTracker.ImageTrackerActivity.load3DModel(ImageTrackerActivity.java:97) at com.example.maxst3demo.imageTracker.ImageTrackerActivity.lambda$cZoV0UmnlP2C_Kv2pF17Z95xcBc(Unknown Source:0) at com.example.maxst3demo.imageTracker.-$$Lambda$ImageTrackerActivity$cZoV0UmnlP2C_Kv2pF17Z95xcBc.run(Unknown Source:2) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1502) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)

Do i have to call some type of init method before calling the sceneAsset=gltfLoader.load(Gdx.files.internal("models/BoomBox/glTF/BoomBox.gltf"));
load method ?

How can I have AnimationController play the loaded animation ?

I've managed loaded a simple animation in a test. I'm pretty sure the animation nodes, channels are built correctly.
But when I debugged into com.badlogic.gdx.graphics.g3d.utils.AnimationController#update(float), it's current AnimationDesc member is null.
Does this means it's not started playing? How can I have AnimationController update the loaded animation?

FYI. the test code and assets

public class AnimationLoaderTest extends Game {

	public static void main(String[] args) {
		new LwjglApplication(new AnimationLoaderTest());
	}

	private Scene scene;
	private SceneManager sceneManager;
	private PerspectiveCamera camera;
	private SceneAsset sceneAsset;

	@Override
	public void create() {
		sceneAsset = new GLTFLoader().load(Gdx.files.classpath("gltftutorials/khronosgroup/github/simple.gltf"));
		scene = new Scene(sceneAsset.scene);
		sceneManager = new SceneManager();
		sceneManager.addScene(scene);
		
		// setup camera
		camera = new PerspectiveCamera(60f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
		camera.near = 0.01f;
		camera.far =  4000f;
		camera.position.set(0, 0, 3);
		camera.lookAt(Vector3.Zero);
		sceneManager.setCamera(camera);
	}

	@Override
	public void render() {
		float deltaTime = Gdx.graphics.getDeltaTime();
		camera.update();
		// render
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
		sceneManager.update(deltaTime);
		sceneManager.render();
	}
}

simple.gltf

Exported GTLF file from Blender doesn't show up

Hi there, I find this library very insteresting so I decided to give it a shot.

But when I load a gltf file from Blender it doesn't show up. So to make sure I wasn't making any mistake I copy pasted the quickstart example and imported a simple mesh made from a cube and it still didn't show up.
But when I downloaded the demo gltf and related files it worked, can you provide any help ?

[IBL Composer] Swing open file dialog hidden

(At least) on Windows 10 the Swing open file dialog is hidden behind the Composer app window.
The dialog also doesn't show up in the task bar so users might think the app freezed. If the app window is additionally maximized you can't minimize it anymore (don't know why) after clicking on open hdr file, so the only way to get to the dialog is alt+tabbing.

Simplest and imo best solution is to minimize the app window so the dialog pops in peoples faces. After opening a file the app window should automatically get back to it's prior state.

Faster BinaryDataFileResolver

for(int j=0 ; j<chunkLen ; j++) bufferData.put(stream.readByte()); // TODO optimize with stream copy utils ?

Hello, I think I've made an improvement to the creation of the ByteBuffer by using libgdx's StreamUtils:

byte[] arr = StreamUtils.copyStreamToByteArray(stream);
ByteBuffer bufferData = ByteBuffer.allocate(chunkLen);
bufferData.order(ByteOrder.LITTLE_ENDIAN);
bufferData.put(arr);
bufferData.flip();
bufferMap.put(bufferMap.size, bufferData);

Old version: 47 seconds
New version: 43 milliseconds

Great job with gdx-gltf by the way!

Demo crash in chrome for android (highp not supported)

Error running Web demo in chrome android :

  • android 4.2.2
  • chrome 71
Uncaught Error: java.lang.RuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: 
Fragment shader: 
WARNING: 0:33: 'GL_OES_standard_derivatives' : extension is not supported 
ERROR: 0:44: 'highp' : precision is not supported in fragment shader

[.WebGL-0x62001db8]GL ERROR :GL_INVALID_ENUM : glGetIntegerv: pname was GL_MAX_SAMPLES_ANGLE
[.WebGL-0x62001db8]GL ERROR :GL_INVALID_ENUM : glTexParameterf: pname was GL_TEXTURE_MAG_FILTER

Doubt about rotation

Good afternoon, I have a question about how to rotate, to see if you are so kind to help me.
When I load the gltf file it is shown from a lateral perspective and I would like to rotate it so that it is shown frontally.
thank you very much, I look forward to your help

Sin-título-1

Port shader code to GLSL 130

Just some warnings for now but it'd be better to have both GLSL 120 and 130 code.
Maybe using macro.

Vertex info
-----------
0(14) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(28) : warning C7555: 'attribute' is deprecated, use 'in/out' instead
0(71) : warning C7555: 'attribute' is deprecated, use 'in/out' instead
0(74) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(81) : warning C7555: 'attribute' is deprecated, use 'in/out' instead
0(86) : warning C7555: 'attribute' is deprecated, use 'in/out' instead
0(87) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(182) : warning C7555: 'varying' is deprecated, use 'in/out' instead

Fragment info
-------------
0(38) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(61) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(126) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(227) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(319) : warning C7533: global function textureCube is deprecated after version 120
0(555) : warning C7533: global variable gl_FragColor is deprecated after version 120

Quick question: Export

Hello everyone.
I've heard on Discord there is a export feature in the works, just wish to be sure about what is this about.
So, can I use this library to export gltf files made from inside LibGDX?

Thanks in advance for any help.

Bye, Ivano.

An easy way to render emissive only

Render emissive only is a common use case when using bloom effects and such.

For now, user code need to implement a modified version of the default PBR shader.

It would be nice to provide something out of the box :

  • a special shader for direct rendering (when GL20 is used)
  • configurable render target (when GL30 is used)

Control emissivie factor

Hey, as a test I'm trying to port this scene: crypt location, preview:

image

As you can see it contains such a high glowing elements, but it's not really noticeable using standard values:

image

I've found that glTF supports emissions and you've even have it in the pbr fragment shader:

The model has properly marked elements with emission, I can see it in emission preview:

image

So my question is - is there any way to increase the glowing effect? I think that some kind of extra multiplication factor for emission could solve this issue.

Runtime instance loading

Is there a way to load player characters and control them independently?
I spawn models (currently converted from fbx-conv... not good) and i want to use gltf (as i do for the scene/map)
However having each actor/player in a separate scene is not very easy to manage and how bad is it for performance?

Bad lighting in demo on Android device

Lighting is not correct on some Android device : maybe due to some GLES2 limitations (mipmap filtering ? highp ?)

  • Android 4.2.2
  • Device : ASUS_MeMO_Pad_10
  • Demo : BoomBox (default)

Vertex shader do not fit in 256 vectors

Good afternoon, I get the following error:

com.badlogic.gdx.utils.GdxRuntimeException: Shader compilation failed:
--From Vertex Shader:
Error: uniform variables in vertex shader do not fit in 256 vectors.
--From Fragment Shader:
Error: uniform variables in vertex shader do not fit in 256 vectors.

at net.mgsx.gltf.scene3d.shaders.PBRShaderProvider.createShader(PBRShaderProvider.java:295)
at com.badlogic.gdx.graphics.g3d.utils.BaseShaderProvider.getShader(BaseShaderProvider.java:34)
at com.badlogic.gdx.graphics.g3d.ModelBatch.render(ModelBatch.java:262)
at net.mgsx.gltf.scene3d.scene.SceneManager.renderColors(SceneManager.java:149)
at net.mgsx.gltf.scene3d.scene.SceneManager.render(SceneManager.java:116)
at com.proof.gltf.GLTFLoader.render(GLTFLoader.java:352)
at com.badlogic.gdx.backends.android.AndroidGraphicsLiveWallpaper.onDrawFrame(AndroidGraphicsLiveWallpaper.java:220)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)

How do I build gdx-gltf-demo.jar?

The readme ( https://github.com/mgsx-dev/gdx-gltf/blob/master/demo/README.md ) says to run gdx-gltf-demo.jar. I tried gradlew assembleRelease and gradlew jar and couldn't find gdx-gltf-demo.jar. I haven't worked with multi-module gradle setups much, but I tried going to demo/desktop and running gradle tasks (yes, with gradle 2.14.1 🤦), and it failed with a nondescript NPE:

:demo:desktop:tasks FAILED

FAILURE: Build failed with an exception.

* What went wrong:
java.lang.NullPointerException (no error message)

HiDPI support for the demo and IBL composer

The UI scale is too small on HiDPI screens.
If I'm not missing something there's no manual way to change it, so it would be nice to have it scale automatically based on the systems scale setting or at least being able to set it manually.
(Windows)
111

Others have solved it if you want to take a look (Not the best solutions but easy to implement):

  • Liftoff uses a stretch viewport
  • CrashInvaders TexturePacker gives an option to scale the GUI manually

A way to use mipmaps from Blender models

not an issue with the library itself, it handles all sampler configurations including mipmaps and then auto mipmap generation.
The issue come from blender and blender GLTF exporter which don't have options for mipmaps.
For these use cases, it could be nice to allow user code to force/override it at loading time.
It could be a loader option which would be global for all models loaded with this loader. This way, users could load some models with or without this option in order to have fine grain control.

Better names for Scene related stuff

Some classes names are a bit misleading for libgdx users
we have :

  • SceneAsset is what you load, it contains several SceneModel, there are no equivalent in libgdx since GLTF allow multiple scenes (multiple Model) in the same file.
  • SceneModel is the equivalent of Model in libgdx.
  • Scene is the equivalent of ModelInstance in libgdx, it could be renamed as "SceneInstance".
  • SceneManager has no equivalent in libgdx, it handles both animations and rendering. Singular Scene word is misleading since it handles several scenes (scene instances), maybe SceneGraph or SceneTree could be better names.

Shared managed textures (AssetManager)

There seems to be an issue with managed textures that are shared between different models.
Let's say model A and B do share a texture, now when model A is disposed, the shared texture is also disposed as if it's reference count is 0 where it should be 1. Textures of models should be ref counted, right? So I consider this a bug.

I'm not too sure if this is a bug in gdx-gltf or libgdx though but since you're a libgdx contributor it's probably better to start here and go down to libgdx if necessary.

I've tried to understand the ManagedTextureResolver and it's interaction with the asset manager and failed gloriously.
Nevertheless, here's a runnable demonstration: https://github.com/Hangman/texture-resolver-test
Warning: gradle 7 is used, not ancient 2.1 :P If you run into any problems due to this... deleting the gradle cache worked for me.

[IBL Composer] crash when opening unsupported hdri files

When opening a file that is not supported, the Composer app will crash.
We had this case on Discord where someone wanted to open an EXR file from hdri haven.
While this generally is only a minor point it can confuse beginners. The app should tell the user "hey the file you want to open is not supported, only .hdr files are", something like that.

Stack trace:
image

light frustum culling

now we have range for point lights and spot lights. We can then implement some frustum culling.
This may be an optional feature on SceneManager.

BaseColor in materials are not compatible with Gouraud shader (default libgdx shader)

You can see the issue in the Demo / viewer : a materials with only a red baseColor will be rendered as grey.

the workaround is to convert baseColor attributes to diffuse attributes for all materials when loading your models.

Could be fixed like this :

  • provide an option to load materials for gouraud shading
  • provide a way to easily convert materials for gouraud shading
  • use the converter in the viewer

Or, fix that in the gouraud shader directly by using the right attribute.

Provides few cheaper shader alternatives

Current PBR shader is a bit greedy, the idea is to provide alternatives for lower quality requirements / lowend devices.
This way, users could still use GLTF workflow and features with some options for rendering quality.
Also, i could be nice to document how to let users provide their own shaders.

Options:

  • Gouraud: the libgdx classical shader reworked a bit.
  • Phong: inspired by xoppa phong shader, adapted as well.
  • PBR (default): the actual PBR shader.

About SpecularGlossiness, GLTF has an extension for that but it's not supported by Blender GLTF exporter. So for now it's required to add this kind of textures at runtime (adding material attributes).
Specular texture attribute should be supported in all 3 shader alternatives.

Crash when use AndroidStudio open and run

java.lang.NoSuchMethodError: No virtual method position(I)Ljava/nio/ByteBuffer; in class Ljava/nio/ByteBuffer; or its super classes (declaration of 'java.nio.ByteBuffer' appears in /system/framework/core-libart.jar)
at net.mgsx.gltf.loaders.shared.data.DataResolver.getBufferByte(DataResolver.java:84)
        at net.mgsx.gltf.loaders.shared.data.DataResolver.getBufferShort(DataResolver.java:78)
        at net.mgsx.gltf.loaders.shared.geometry.MeshLoader.loadIndices(MeshLoader.java:353)
        at net.mgsx.gltf.loaders.shared.geometry.MeshLoader.load(MeshLoader.java:54)
        at net.mgsx.gltf.loaders.shared.GLTFLoaderBase.getNode(GLTFLoaderBase.java:277)
        at net.mgsx.gltf.loaders.shared.GLTFLoaderBase.loadScene(GLTFLoaderBase.java:199)
        at net.mgsx.gltf.loaders.shared.GLTFLoaderBase.loadScenes(GLTFLoaderBase.java:178)
        at net.mgsx.gltf.loaders.shared.GLTFLoaderBase.load(GLTFLoaderBase.java:126)
        at net.mgsx.gltf.loaders.gltf.GLTFLoader.load(GLTFLoader.java:16)
        at net.mgsx.gltf.loaders.gltf.GLTFLoader.load(GLTFLoader.java:11)
        at net.mgsx.gltf.examples.GLTFQuickStartExample.create(GLTFQuickStartExample.java:41)
        at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:278)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1520)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.