First game problems

@britzl
I found this in one of your GitHub Repositories

Lines 447 and 590 seem to be where the problem might be… Thought it might help :slight_smile:
No idea if it’s the right place or what the reason could be though…

The error you are getting with getProgramParameter etc might have something to do with your shaders not using some of the uniform/constants that are exposed in the material file.

Iirc, WebGL might be a bit picky when it comes to shader uniforms/constants that are defined in the material and set/updated through scripts, but not actually used in the shader code…

Are you using the built-in material for your 3D model?

Yes, I am using the default material
image

Well, this does seem to be the problem, although I don’t understand how or why… I Removed the 3D object and now the game loads fine and works well (but is sorta useless without the main “character” :sweat_smile: ) Should I go about making a completely new material or change the shader…

No idea how to proceed here…
I will try the 3D manual again, perhaps I messed something up and I will also look at the other 3D game that helped me before to see if I can figure anything out :slight_smile:

I might have found an issue.

There seems to be a difference in precision between the vertex and fragment shaders for our built in model material. In the vertex shader (model.vp) the uniforms are specified as mediump while in the fragment shader (model.fp) they are set to lowp

Could you try to do the following:

  1. Copy model.fp and model.material from the builtins/materials/ directory, into somewhere under your project.
  2. Open your newly copied model.material file and change the “Fragment Program” to point to the model.fp file you copied.
  3. For every model component you have in your game, change the material to your own copy of model.material. You probably only need to change your character model if this is the only 3D model you are using in your game.
  4. Open your new model.fp file and change the following rows:
uniform lowp sampler2D tex0;
uniform lowp vec4 tint;
uniform lowp vec4 light;

into

uniform mediump sampler2D tex0;
uniform mediump vec4 tint;
uniform mediump vec4 light;

If you were having the same issue as me, this should hopefully make it work on HTML5. Let me know how it goes!

4 Likes

Fixed the problem completely. I will try uploading the game to see what happens, but now the build seems to work nicely.

What I did at first was change from the regular model.material, to the model.material in the render folder that I took from the Tans VS Meteors Project, but it turned out to only partly fix the problems and the lights didn’t work as well as they should…
But doing what @sven wrote here worked perfectly, model rendered well and with correct lighting.
Thank you :slight_smile:

@sicher Hey I saw your post about tutorials and how 3D is definitely planned, just wanted to mention this what sven posted here could be added to it :slight_smile:

Cheers!

3 Likes

I did some improvements on my little Defold test game I am working on :smiley:

Works nicely now, changed the camera to follow the player and some other improvements to make it look slightly better and smooth.

And now the big one comes: How to make it playable on my facebook messenger with Instant games?
I saw the manual https://www.defold.com/manuals/instant-games/

But I am stuck at this:

I have the Facebook app configured, have my FB ID but don’t know how to add this part to the Bundle that I build.

Also, do I need to fbinstant.initialize if I don’t want to use any of the FB API Functions yet?
I just want to be able to play the game in the messenger for now.

Cheers!

2 Likes

Have you added the extension-fbinstant as a dependency according to the instructions? Next do a Fetch Libraries. You should now see a read only folder in your Assets named fbinstant. In this folder there’s a sample index.html file that you can use that already includes the Instant Games SDK. Open game.project and scroll down to the HTML5. Browse and select the index.html file.

It’s fine for testing purposes to not call any of the FB IG API functions.

Yes, I did have the libraries added, I also did fetch them again and there is this folder in my Assets:
image

In there is the Index HTML, that I added in the game.project file here:
image

But now I get this build Error…

My guess is that it’s the spaces in the folder name. Move your project to a folder without spaces.

Nope, looks like that didn’t fix it…

This is odd… no special characters anywhere in the Path and still I get this error…

Hmm, @Mathias_Westerdahl and @Erik_Angelin, it looks like it is searching the local file system and not inside the dependency. Any idea why?

This is when bundling the application?
I would guess it’s an issue when getting resources from within dependencies.
@britzl, I’m guessing you have tried this before when testing it. How did you make it work then?

I’m actually not sure that I’ve tested this. The XOXO project exists in the same project.

We’ve seen the same problem with other assets right? Stuff that should end up in an Android bundle if I’m not mistaken.

@greaneagle As a workaround: Copy the file to somewhere inside your project and use that file instead.

Yes, it’s been reported on Windows
(However, this is not a new feature or bug)
I’ll add a ticket for it

EDIT: I added DEF-3236 for this

3 Likes

And until that is fixed, @britzl s workaround works. At least the build worked. :slight_smile:

@britzl after uploading to FB though did you ever get something like this with the XOXO test project?

The game is stuck at 0% loading…

You probably need to initialise the fbinstant SDK. Put this in the init() function of a script:

fbinstant.initialize(function(self, success)
    fbinstant.start_game(function(self, success)
       -- here you'd start your game when properly integrating instant games
    end)
end)
1 Like

That worked and now I have a game on facebook :slight_smile:

A simple project for testing, but it does work and is playable and other people can notice me playing.

@britzl I noticed that when using that, the game holds at 0% for a while then goes to 100% immediately.

Looking through the available functions here https://github.com/defold/extension-fbinstant/blob/master/README.md

I noticed this:
image

Should that be used somewhere to make the loading seem smoother?

1 Like

7 days, 399 views, 66 messages and you have a 3D game on FB instant games.
I’d say it is a decent result and a good example of how one approaches learning Defold.

Cheers to @greaneagle for being brave, vocal and active =]

3 Likes