Jump to content

Issue with bumpTexture rendering


Origami
 Share

Recommended Posts

Hey all!

I'm fairly new to the babylon framework (and this is my first forum post--hey again!), but after coding in it nonstop for a few weeks, I have a decent handle on it. Or so I thought.

I'm trying to give my objects textures, and while it works on babylon-created meshes, I get no love from my own imported OBJs or .Babylon files.

I'm sure I'm just doing something incorrectly/missing a setting, but for the life of me, I can't figure it out.

And of course, obligatory playground demonstrating this issue: http://www.babylonjs-playground.com/#XTJQS#1

//EDIT: And now I can't get my .babylon or .obj files to load from my server. I swear they were working before. Does anyone have any samples so we can replicate the issue?

Thanks!

testDog.babylon

teddy.obj

Link to comment
Share on other sites

Hiya @Origami, welcome to the forum!  I don't know much about .obj importing, but I DO know that your .babylon file has no UVs in it.  I see only positions and indices.  And, I'm not a modeling expert, either, so I can't remember why Blender/Max/Unity/whatever... would not export UVs by default.  It is likely because it is un-textured in your modeling software.

.babylon files are really .json files, and you can use online .json viewers to "tree-ify" or "pretty-fy" the contents of your .babylon files.  I suggest you keep doing experiments and keep trying various exports... until you see UV's in your .babylon file.  After that, applying textures SHOULD be a much more tolerable task.

 

Link to comment
Share on other sites

Hey Wingnut! After reading through so many of your forum posts, I feel like I'm speaking with a celebrity! Niccccce.

Do you have a sample .babylon file with the UVS in it (I see that it's 'just' float-formatted data for the vertexes)? I'd love to throw it into my app and see if that fixes the issue.

Link to comment
Share on other sites

:) Thanks, but I'm really just a local blowhard.  Good to have you with us.  I already like your personality and spirit.

I made my previous post a bit longer.  I had to do an early save, because I somehow lost my cursor.  Goofy forum software.  Checking for decent demo... stby.

Link to comment
Share on other sites

Right on, right on!

I'll see what i can do about applying a vanilla texture in Blender and exporting that, then overwriting it in my JS with the bumpTexture. If that ends up working, and it really is just the existence/lack of this attr within the .babylon's JSON structure, I'll probably end up writing a script that trawls through a folder of OBJs and inserts dummy texture floats. My team is getting a crapton of OBJs from modelers and it would be a tedious process to open each and every model, apply textures, and then export, to say the least.

Thanks for the quick reply here, I'll get cracking and report back!

Link to comment
Share on other sites

My pleasure and a good game plan, O!  Be patient, though, as more experts might have better ideas.  Although big, THIS PG uses a .babylon file with 'uvs' within it.

Its .babylon file... https://cdn.rawgit.com/Wingnutt/misc/master/Perplexus_Components.babylon

Hope this helps!  Again, welcome aboard, and thanks for helping us with BJS, by driving BJS.  Know where all your searchers are, right?  Playground search, forum search, docs search?  Holler if ya need urls.  :)

Addenda:   Here's an obj loader demo... but don't ask me what the playground author was doing AFTER loading the .obj.  .hdr... phew.  Over my head.  :)

Link to comment
Share on other sites

@Origami:

48 minutes ago, Origami said:

My team is getting a crapton of OBJs from modelers and it would be a tedious process to open each and every model, apply textures, and then export, to say the least.

Welcome to the forum :) @Wingnut is correct about the "teddy" file - it has no UVs and as it has no accompanying .mtl file it has no materials of any type.

Not sure quite what you are doing, but you may have to insist that any model submitted to you is UVMapped and has materials/textures.

Other possible issues are the size - the "teddy" is  30-40x the BJS standard cube, and the "origin" - the "teddy" is OK (origin 0,0,0 - between head and body)  but I have seen 3d meshes where the origin is completely outside the mesh which would make rotating and scaling the mesh tricky.

My work flow for creating textured 3D objects/meshes in Blender is typically this:

Model Mesh ->Create UVs ->Create Textures(diffuse, normal, etc.). As you can see, the final textures I create are based on the UVMaps - not the other way around.

cheers, gryff :)

Link to comment
Share on other sites

Hey Babyl-allstars!

So I've quashed some other bugs in the app and I've started trying to work through this issue, but I can't even seem to load any OBJ files into the scene at all. I keep getting the error:

"o._addPendingData is not a function",

which is being thrown in: "[email protected]:15".

I've tried using both methods that look applicable:

var loader = new BABYLON.AssetsManager(scene); var batman = loader.addMeshTask("batman", "", "assets/", "batman.obj");

and

BABYLON.SceneLoader.ImportMesh("batmanface", "batman.obj", scene, function (meshes) { // ... });

Hell, I'm even trying to load the batman models, but I still get this error. And the only thread I've found on this gives creating a scene as a fix. But I definitely already have a scene, since the obj loading occurs on a click, while the rest of the scene is loaded before the click occurs. The syntax is identical to the playground, but it's not throwing the error.

So I'm stuck with not being able to even test all these great suggestions for applying a texture to an OBJ, since I can't even get an OBJ to load. I guess I'll try tweaking the .babylon files and working on it from there, but I really would prefer to be able to use OBJs. Hmmmm...

Link to comment
Share on other sites

:)  Wasn't intuition.  Was an examination of the .babylon file.... told the story. 

Ok, moving on.  http://urbanproductions.com/wingy/babylon/khaled/objload01.htm

Whack that.  When its loaded, click the little gray box in the lower right.  A filepicker should open.  When it does, choose one of your many .obj files... on your computer.  See if it loads-in.  It might be small, so mousewheel-in to check.  This still loads .obj files on my computer... but its an old style loader.  It uses a separate objloader.js.

Don't volunteer me for knowledge I don't have, Nabs.  :)  How about YOU tell us all where " you try to add data to a function that already has data in it. " is happening.  Get specific.

Link to comment
Share on other sites

So I can load my obj in your site, that works fine. So I guess Nabroski is correct that the code is incorrect somehow? I'm just confused, because it loads .babylon files just fine and the syntax of sceneLoader.ImportMesh() is the same for both of them. As far as I can guess, I think the prototype chain for whatever 'o' isn't connected to the babylon prototype chain properly to get that method. Is it something about how the initialization for the mesh in the .obj file starts with 'o'? Hmmph. More digging & testing.

I'm using babylon 2.4.0 & babylon.objFileLoader I picked up from the github repo. Is there still something I'm missing?

Also, in case any of you guys are curious, I'm looking to use this method for auto-generating the UV mapping from the face normals to avoid blender's seam creation mini-game for what will likely be dozens (and growing) OBJs/.babylon files.

Link to comment
Share on other sites

@Nabroski I'm using your example and it looks like I missed a comma in the filename in my jumping back and forth between git branches. I feel embarrassed, but there's nothing for it but to move on.

So now it clears the initial o._addPendingData error, but it still kicks into the onFailure callback after loading the first mesh (my OBJ only has one mesh). My code looks like:

BABYLON.SceneLoader.ImportMesh(
  "",
  serverPath,
  filename,
  scene,
  function(meshes)   { console.log("success!"); /*...followed by doing stuff with the meshes... */ },
  function(evt)      { console.log(evt, "is loaded") },
  function(errorEvt) { console.log("error:", errorEvt) }
)

And I don't get to "success!". All I see is the log for "is loaded" for the only mesh of the object and then the errorEvt is logged. And the errorEvt looks to just be the scene object itself. Is there a particular attribute in here I should be looking for to debug through this?

Link to comment
Share on other sites

@Nabroski, you don't know how very right you are. In my jumping around from git branch to branch like the nascent code monkey I am, the ObjLoader script inclusion was dropped from my index.html.

After spotting that this afternoon, I've been able to make great progress. Your help with creating progress/failure functions was key in my narrowing the lurking variables here.

Thank you guys for such a great community (and library!)

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...