Jump to content

Texture question


Kita
 Share

Recommended Posts

Hi,

 

i'm new to babylon.js and i have some trouble.

 

I generate some plane meshes 25x25 with the same textures. Then the FPS go down to 30, but i think thats not a big 3d-Scene, the Examples on babylonjs.com are more complex and run in 60 FPS.

 

I try it with runRenderLoop and with window.setTimeout both max 30 FPS.

 

Here is my code:

var createScene = function () {    var scene = new BABYLON.Scene(engine);    //Create a light    var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(-60, 60, 80), scene);        var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene);    light0.diffuse = new BABYLON.Color3(1, 1, 1);    light0.specular = new BABYLON.Color3(1, 1, 1);    light0.groundColor = new BABYLON.Color3(0, 0, 0);    var camera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(0, 0, -40), scene);    scene.activeCamera = camera;    scene.activeCamera.attachControl(canvas);    var materialPlane = new BABYLON.StandardMaterial("texturePlane", scene);    materialPlane.diffuseTexture = new BABYLON.Texture("textures/grass.jpg", scene);    materialPlane.diffuseTexture.uScale = 1.0;//Repeat 5 times on the Vertical Axes    materialPlane.diffuseTexture.vScale = 1.0;//Repeat 5 times on the Horizontal Axes    materialPlane.backFaceCulling = false;//Allways show the front and the back of an element    var x,y;    var width = 25;    var height = 25;    var startx = -(width*1.1)/2;    var starty = -(height*1.1)/2;    for(x=0;x<width;++x) {        for(y=0;y<height;++y) {            var plane = BABYLON.Mesh.CreatePlane("plane", "1", scene);            plane.position.x = startx+x*1.1;            plane.position.y = starty+y*1.1;            plane.material = materialPlane;        }    }    return scene;}

Its that ok, when i use the same material on different meshes?

 

How can i create a texture with a Subimage, uOffset and vOffset doesn't work?

 

best regards,

   Kita

Link to comment
Share on other sites

To achieve far greater performance, it could be interesting to merge your meshes into one single mesh. SOmething like this:

        var globalVertexData = new BABYLON.VertexData();        for (var i = 0; i < count; i++) {            var planeVertexData = BABYLON.VertexData.CreatePlane(128);            delete planeVertexData.normals; // We do not need normals            // Transform            var randomScaling = Math.random() * Math.random() * 1.5 + 0.5;            var transformMatrix = BABYLON.Matrix.Scaling(randomScaling, randomScaling, 1.0);            transformMatrix = transformMatrix.multiply(BABYLON.Matrix.RotationZ(Math.random() * Math.PI));            transformMatrix = transformMatrix.multiply(BABYLON.Matrix.Translation(Math.random() * 1000 - 500, -Math.random() * Math.random() * 100, count - i));            planeVertexData.transform(transformMatrix);            // Merge            globalVertexData.merge(planeVertexData);        }        var clouds = new BABYLON.Mesh("Clouds", scene);        globalVertexData.applyToMesh(clouds);

Live example here:

http://www.babylonjs.com/scenes/clouds/

Link to comment
Share on other sites

Thanks for the answers, i will try the merging.

 

but how can i create multible planes with different textures?

 

And the other question, how can i create a texture with a Subimage, uOffset and vOffset doesn't work?

The SpriteManager can use different Subimages in Sprite.playAnimation.

 

Best regards,

   Kita

Link to comment
Share on other sites

Hey Kita (and others)... what FPS do you get for this particles demo... http://www.babylonjs.com/playground/?12   ?  I'm around 52 FPS on it.

 

 

http://www.babylonjs...yground/#2HO8HK ...is so much slower.  hmmm.  There has to be a logical explanation for this.  When I first arrive at the page, my FPS is at 60.  Five seconds later... boom, 10 FPS.  *scratch scratch* 

 

One would think that the particles demo would be much more "heavy" than Kita's thing.  But my FPS says noooo... Kita's thing appears 5 times heavier.  :o  I am perplexed.

Link to comment
Share on other sites

Hi dk!  Same results for my auto-updating IE11.  (insignificant performance differences from FF). 

 

Win 7 - Google Chrome... I can't get it to do webGL.  When the Chrome browser launches, I get 5 little popups (opening all at once) with only an "ok" button on each.  They are all blank, or white text on white backdrop... and text (if its there) is un-highlight-able.  They can be closed.  Browser window looks fine, but can't do webGL. 

 

I've tried the web-suggested ways of making Chrome's webGL work, but all webGL demos claim "not webGL ready".  Personal problem.  :)  Those 5 popups are indicating SOMETHING, but without text on them, it is difficult to determine what they indicate.

Link to comment
Share on other sites

Ok, I'll see what can be done, but last I checked, I have the newest driver available for this on-MB video.

 

Not sure if its pertinent, but in both my browsers... if I turn the camera until the planes are out of view, the fps is back to 60+.

 

Ok, thanks for the info... I'm off on a driver updating mission.  :)   But I think I will fail.  I went down this path before, back when we struggled to get the mirrored video running.

 

Updatehttp://www.dell.com/support/home/us/en/04/product-support/servicetag/2DS0GK1/drivers?DCP=DndTag&s=DHS  No new video drivers available.  There is a BIOS upgrade there, but when attempting to install... computer reports that my current BIOS is the same or newer, already.  Still researching.

Link to comment
Share on other sites

@Deltakosh: Thanks thats what i need :)

When i use "textures/player.png", i will not use the first SubImage, but the second or third one as a Texture. Just like a tileset https://wiki.themanaworld.org/images/c/c3/Woodland_Tileset.png , sorry for my english ;)

 

 

@Wingnut: I have the same Problem if i use 25x25 Planes, and turn the camera 60+.

 

 

Best regards,

   Kita

Link to comment
Share on other sites

Thanks for the link, Dad72!  Actually, I already have one of these. It is built-into the Win7 device manager.

 

The driver details list...

 

http://urbanproductions.com/wingy/babylon/misc/driverdetails.jpg

 

The search panel...

 

http://urbanproductions.com/wingy/babylon/misc/driversearch.jpg

 

The results...

 

http://urbanproductions.com/wingy/babylon/misc/driverwork.jpg

 

I have also scoured the Dell video drivers update pages, and they report the same. (darnit)

 

(Sorry for the off-topic stuff, here, gang.  Thanks for the help.)

Link to comment
Share on other sites

Wow, that's a nice piece of software.  It found a newer (2012) driver, at Intel.  Unfortunately, after the driver installed, no changes are seen in all three browsers.  But thanks again for the link, software, and good advice (and a fresher GFX driver).  I am going to continue the investigation, of course. 

 

I'm sure glad Ma-Config allowed English language.  :)  I was scared, at first.

 

Maybe it's time for this 6 year old desktop to retire to media server status.  :)

Link to comment
Share on other sites

I think thats not a Graphic Propblem, its a the CPU Problem, when i use IE / Chrome with useing only one CPU 100%.

If I turn the camera until the planes are out of view, the fps is back to 60+ and CPU go down to 10%.

 

Is my Browser using CPU insteat of GPU?

 

I have an i5-460M CPU and NVIDIA GT 420M.

 

How can i detect if my Browser use the CPU or the GPU?

 

In Chrome i have opened the url "chrome://gpu/" they show me all "Hardware accelerated" only Rasterization "Software only".

 

Best regards,

   Kita

Edited by Kita
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...