Is it possible to easily switch between the in-scene texture with the Utility api?

api

(Sismique) #1

I have been using the Utility api for a couple days now and I have to say, it works really well for editing materials and programing translations and such. However, I have been having issues with the way it manages textures.

TLDR: I’d like to be able to change textures easily with the already in-scene textures, just like the OptionOption api, (so being able to switch to any number of textures and then switch back) is this possible? Am I missing something? (I’ve poured over the material channel texture on the website, did not really work out for me as it has to do with online textures.)


(Shaderbytes) #2

Hey there, this is something i overlooked as it was not possible before to have unused textures stored in a scene before. I will do some testing and see if this is possible to access and then provide a fix to work with unused scene textures.

chat soon


(Shaderbytes) #3

mm i just tried out uploading a single plane and uploading 5 textures, you could switch between the textures in the editor just fine. Once I exited the editor and went back into edit mode , all the textures except the one currently assigned were not there so nothing has changed here?

Do you want to exchange the scene textures of different materials between each other?


(Sismique) #4

Thanks for the quick reply and your devotion! I will be waiting for your news in anticipation.
Talk to you soon


#5

We do not include unused editor textures in the viewer for performance / download size reasons.


(Sismique) #6

Sorry I couldn’t respond earlier, I could not cannot reply to my own topic because of an trust level issue (btw, thx for the fix James)
Anyways, to answer your question, yes, I do want to exchange the scene textures of different materials between each other. The idea is you would take the texture from an invisible object (either from opacity or from the visibility options) and apply it to the selected material. However without losing the current material’s original parameters (like how your current cashing system work, so you can reset it to its original state).


(Shaderbytes) #7

im busy building a solution to grab a scene textures and fill the cache with them using their texture names as the cachekey ( i renamed this now to UIDKey ) it is still in development but i have it working locally already, i will keep you updated


(Klaasnienhuis) #8

Thought I’d chime in as the author of the optionsoptions script for 3dsMax. I use a trick to get all textures in the scene: for each texture I create a small plane and add it in 3dsMax to the scene before uploading. When the sketchfab scene is opened in the webpage generated by optionsoptions, these sample planes are hidden, but their textures are now available.
afaik, and James confirms this, it’s the only way to make textures available but hidden. But I’m very curious to hear how you solve this @shaderbytes by grabbing the textures in another way.


(Shaderbytes) #9

hey there @klaasnienhuis

I never solved a manner to make unused textures persist like you have because my tool is a viewer run time tool , but I did edit my utility to cache all scene textures that are already in the scene and loaded. My edits are not live yet , still in dev mode locally as there are some usability issues i discovered with removing textures from objects loaded with the scene.

Anyway before I only factored in new uploaded textures into the caching system i have running. Now I made it so the scene textures that are loaded with the scene are pushed into the cache as well, they just use the texture name minus the extension as the object key. For runtime uploaded image usage I actually avoid using the texture url as the key as it could be some super long base 64 dataurl or svg url etc, so I promote user created keys as an argument when adding/ using textures via the utility. So its only for scene textures that the key is automatically assigned.

So now it is possible to target those textures and assign them to other materials , I explained to the user that unused textures get stripped , they understood that and were happy with your hidden system ( very crafty by the way :wink: ), just that my utility did not factor scene textures into its usage at all , something i overlooked as the need never arose personally, now it does do this so all is sorted.

For the bug , I found out you cant remove a texture from a scene object that loaded with one already assigned because the scene graph api strips the color property when there is a texture , and if you remove the texture then it has no color or texture info and bombs out. To get around this i just created a hack to set the create the color before removing the texture. This works ( although there are still unwanted warnings in the console ) but since I dont like the hack im waiting for some fix from sketchfab and then I can remove the hack and I will make my changes for scene texture usage live.

keep well


(Klaasnienhuis) #10

I’ve just accepted that a color and texture property on a material channel are mutually exclusive. I believe there’s an exception with the subsurface channel.


(Shaderbytes) #11

i see no reason why the colorr data can not persist. Just if a texture is assigned then it take precedence. If the texture is removed then it should just automatically fall back on the color, so the color is default and not optional , the texture is.