Texture lagging

edited February 2014 in How To...

Hello, I would like to make an application which allows you to walk into a building like an FPS game with the models imported by 3ds max. But i have a big problem with the textures, if is only one is okay, but if I have more than one is lagging so damn bad. I was thinking this occurs because the app try to access at each frame the files from data, is it a possibility to load all the texture in the app only once and then link them with the .obj file? (Making only a texture for everything isn't for me a solution) Thank you very much.


  • Define your texture variable (probably a PImage) globally. Set it's value once inside setup(), by loading from the file. Use the texture all you want in draw() without loading it again.

    If you're calling loadImage() inside draw() YOU ARE DOING IT WRONG.

  • i`m not loading the textures at all, the textures are loaded automatically because of the .obj files from 3ds max, i was thinking of loading them with PImage but then how i load them into .obj files, how i link the textures with the PShape? I saw that you can somehow with the startShape() and endShape() functions but those are if you want to create a shape with processing not when you load something from 3dsMax

  • If you load the .obj files in setup() then all the textures referenced by the shapes should be loaded just once as well.

    You can set the texture of a PShape by calling setTexture(PImage), but when a PShape loaded from an obj has material textures, it internally handles them as PImages, so there shouldn't be a difference with setting manually.

  • Thank you, it looks that it works, but if i want to add more textures it stills lagging :(... can't i have more textures in an .obj file?

  • how many different textures you have in each .obj model?

  • like 6-10 texture, how can i put all in a single texture and reference them?(for example from 0,0 to 100,100 is 1st texture from 100,0 to 200,100 is the 2nd texture so on)

  • 6-10 textures shouldn't slow down things significantly. Are you drawing several copies of the same obj? If you can upload your .obj somewhere, I will take a look to check if there is something unusual going on.

    You could using a single texture to wrap the entire obj model, see the rocket texture in the Basics|Shape|LoadDisplayOBJ example. The tricky part is to define the texture coordinates so that the different areas in the texture are applied correctly onto the model.

  • yes it seems to be what i am looking for, can you please give me the url of that example i can't find it, thank you very much

  • The example is included in Processing, go to Open, Examples... and then navigate into Basics->Shape->LoadDisplayOBJ

  • Found it, but this has only one texture, I have multiple texture. I have a building and in that building I added 10 desks, 5 chairs, 13 shelves, etc... the desk has a texture, the chair has another texture and the shelves has another texture. I added all of them within 3ds max and made a whole object(called building.obj) and i have 4 texture at it(building.png, desk.png, chair.png and shelve.png). I want to make a big picture with all the textures within only one texture, how i reference them which part of the image is which texture?

  • Sorry for wasting your time, i found out how to do it. Actually is not a Processing problem, it was a 3ds max problem, i just took all the UVW mappings and put them all in one texture and the problem is solved. Thank you again for your suggestions, I appreciate.

  • @DevilShadow

    I'm totally curious about the whole thing.

    I mean, did you create the chairs and so on in 3ds max?

    Which lib are you using for loading and displaying obj?

    I tried 3D stuff in processing and when I mode close to a wall I always get unwanted results, like I am in the wall etc.

    Did you solve this?

    Can you post your sketch? Or the parts of the obj?

    Thank you!

    Chrisir ;-)

Sign In or Register to comment.