vujadin / BabylonHx

Port of Babylon.js 3D engine to Haxe.
http:/paradoxplay.com/babylonhx
Apache License 2.0
189 stars 43 forks source link

Rendering bug on windows target #62

Open ramsestom opened 8 years ago

ramsestom commented 8 years ago

When I compile the bump map example on windows (openfl legacy and openfl next) with haxeflixel, I have this error message:

Engine.hx:166: BabylonHx - Cross-Platform 3D Engine | 2015 | www.babylonhx.com Effect.hx:220: Ver Effect.hx:237: Unable to compile effect: color Effect.hx:238: Defines: Effect.hx:239: Error: Ver Effect.hx:220: Ver Effect.hx:237: Unable to compile effect: line Effect.hx:238: Defines: Effect.hx:239: Error: Ver

and the cube is not rendered correctly (I have the haxeflixel logo displayed over each face of the cube. This logo is usually displayed by haxeflixel when a sprite has an error...):

babylonflixel_windows_issue

If I try the same example with pure openfl it works great with openfl legacy but nothing is displayed if I use openfl next (black screen), both on windows and android (which is strange as the same example works correctly with haxeflixel + openfl next on android...).

However, I have to say that this example now works perfectly on android with Haxeflixel (whatever compiled with openfl legacy or openfl next). Which is a great improvement for me! ;)

vujadin commented 8 years ago

It would be interesting to see the example that gives you that error message. It looks like BHx is doing something to GL state which Openfl dont like...

ramsestom commented 8 years ago

Sure. Here is the archive (zip) of the complete sample so you can reproduce the error on your side: http://dl.free.fr/kViHh05Hp You need to have the haxeflixel lib installed to test it (I use haxeflixel dev version currently (the git version) but the result is the same with the latest public haxeflixel release (just tested it))

ramsestom commented 8 years ago

Where you able to reproduce the bug on your side?

vujadin commented 8 years ago

Hey, I never got that zip from you... Use vuja22 at gmail.com

On Tue, Oct 13, 2015 at 5:29 PM, Thomas BERNARD notifications@github.com wrote:

Where you able to reproduce the bug on your side?

— Reply to this email directly or view it on GitHub https://github.com/vujadin/BabylonHx/issues/62#issuecomment-147750841.

ramsestom commented 8 years ago

Well your mail blocked the .zip file. That's why I used an upload site... Just press on the link in my previous message and then on the "Valider et télécharger le fichier" button to download it

vujadin commented 8 years ago

Oh, sorry... I'm reading these messages in gmail and it didn't show your updated message with the download link. And right now I'm in the middle of making a decision to drop the work on BHx and try to (finally) properly port Three.js to Haxe...

ramsestom commented 8 years ago

I think it would be sad to drop BabylonHX now that it is pretty much usable... I don't know what Three can bring that Babylon can't so I am not sure why you would consider to start over with Three but it would be nice to still have some support on BabylonHx now that people have started using it ;) For sure it would be cool to have another 3D engine like Three.js ported to haxe but I hope you won't completely drop BabylonHX (even if I definitively understand that days are only 24h and that you have to make choices) ;) If you port Three.js to haxe, do you know how many time it should take you, approximatively, to have something usable?

vujadin commented 8 years ago

I'm not going to drop BHx, I was little upset (frustrated if you will) a few days ago. I'm working on a game and I've implemented quite a lot of it but (only) then I added skybox to my scene. And I got huge fps dropdown - from 60fps to ~10fps. So I asked question on BJs forum and got an answer from BJs author, he actually rewrote a piece of shader code which did improve my fps but only a little bit - my game was still very slow. Then I got disappointed with such a simple thing having such a big impact, I opened browser on my mobile devices and started comparing ThreeJS examples with BJs examples and saw a huge difference in performance. ThreeJS is a lot faster, at least on my devices. So I wanted to simply drop BHx immediately and turn to my 'first love' ThreeJS. Sorry about this, it happens sometimes :) But I'm definitely going to try again to bring ThreeJS to Haxe. Now is the right time as its architecture is greatly improved and simplified with r73. So don't worry about BHx, huge update is coming in a day or two.

vujadin commented 8 years ago

By the way, another BJs user suggested that I disable lighting on my skybox material:

skyboxMaterial.disableLighting = true;

which did fixed the problem - I have 60fps on my phone, but on tablet and on windows I don't see skybox textures, just black color

mightymarcus commented 8 years ago

Hi vujadin. Did you try to set emissive color instead of diffuse color?

I just wanted to try that, but i got an error under windows when using a skybox.

Effect.hx:240: Unable to compile effect: default Effect.hx:241: Defines: MAP_SKYBOX

define DIRLIGHT0

define NORMAL

define LIGHT0

MAP_3D

define BonesPerMesh 0

define NUM_BONE_INFLUENCERS 0

I saw the three.js samples too and found them really nice. You mentioned three.js is a lot faster. It seems to me too, at least when there are many many different meshes. But perhaps they combined the meshes to a single one / grouped them together.

I'm making a game and stick with Bhx for that, because it will do nicely for that simple game. I want to make Browser-Games and it's great to have the option to compile to native, but nowadays this doesn't have to be because you have everything in the browser, even gamepad support and fullscreen. That's great. Or at least in some browsers. ;)

If you just want to make a HTML5 Browser Game then you could use three.js as extern class and don't need to port it to haxe. The WebGL stuff is running near 80% to the native performance. Of course the CPU stuff is a different story.

Or you could even use a cpp opengl 3d rendering engine and port it to JS with emscripten. I'm experimenting a little with that, but I can't find a really small cpp 3d engine and now i finally just want to make a game from beginning to end, so I just stick with BHx now and set me a deadline when my windows 10 test will pass (40 days left). I never really finished a game.

Ok, sorry for my bad english and I wish you good luck and creativity for your game.

vujadin commented 8 years ago

mightymarcus - you should try with the latest update, I've rewrote/optimized materials heavily (primarily for cpp but js target is now faster too). Right now I can't replicate your error

mightymarcus commented 8 years ago

Strange. I updated hxcpp too. Error still here on windows 10.

            if (fallbacks != null && fallbacks.isMoreFallbacks) {
                defines = fallbacks.reduce(defines);
                this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
                        } 
                else {
                       trace("Unable to compile effect: " + this.name);
                       trace("Defines: " + defines);
                      trace("Error: " + e);
                       this._compilationError = cast e;

                if (this.onError != null) {
                    this.onError(this, this._compilationError);
                }
            }

Error message is: þ¿