- This topic has 14 replies, 3 voices, and was last updated 5 years, 7 months ago by Yuri Kovelenov.
-
AuthorPosts
-
2019-03-19 at 3:26 pm #12967PottsieParticipant
Hello!
I’m trying to create a wine label visualizer tool. I’ve attached my current puzzle layout along with the my app UI. Note: the only buttons I’m focusing on right now are the “Texture” and “Upload Design” buttons.
How it currently functions:
– User clicks on a “Texture” button to choose a texture. These are predetermined materials (just two currently, in Blender – tex1Diffuse and tex2Diff -I know, they should be consistently named ). Both have different normal maps, and a shared placeholder diffuse (BLANK).
– Then, the user will click on “Upload Design” to upload their own image.Next, this is where I’m having issues.
I would like the user, after they upload their own image, to be able to go back and choose another texture to see against their design (uploaded image). However, as it currently is, when you click on one of the texture buttons, it reverts back to only showing the texture material. So it discards the uploaded image, because the initial texture material is applied. I do understand why this happens. But I just don’t know if what I’m trying to program is possible with the current puzzle options.
https://cdn.soft8soft.com/AROAJSY2GOEHMOFUVPIOE:3330f49894/applications/wine_label/index.html
Check out my sketch book :) | www.instagram.com/b.potts.art/
2019-03-19 at 4:01 pm #12971elkCustomerJust had a quick look at your puzzles, so i might be reading it wrong, but It looks to me like you are trying to assign the textures(or “state”?) and not the materials when you press the texture 1 and 2 buttons, so changing tex1 and tex2 in the two top puzzles “groups” with Tex1Diffuse and Tex2Diff in the assign material puzzles should help i think. Also it looks like you are updating both materials with the new texture when using the upload button, i guess you would want to separate that out to one event for each button. Hope that makes scense … if I´m thinking correctly here …
2019-03-19 at 7:16 pm #12984PottsieParticipantelk – Thank you for checking it out. I’ll try what you suggested.
But I’m thinking I have to somehow store the “opened file” from the user, via the “send data” snippet. I just don’t know how to wrap my brain around this right now.
I don’t know if there is a way to construct a material by targeting Blender node inputs/outputs….?
Check out my sketch book :) | www.instagram.com/b.potts.art/
2019-03-19 at 8:21 pm #12986elkCustomerI think you only need to use the send data node if you actually need it to go to the web server, and the opened file would just be “cached” in your browser if not.
Don’t know how you set up the materials, but indeed you should be able to manipulate parts of it, like changing textures if there is a texture node in your material setup, which looked to me like it was working in the link you posted
So the simplest would be having a material applied to something out of sight, and them swapping that into the label object once “uploaded”.
Just experimented a little bit with the texture swapping and opened file feature so far, so I might be slightly of on some things here. But i hope this helps you out a little, and the Verge3D team can probably fill out some details if you need.
2019-03-19 at 9:52 pm #12994PottsieParticipantHmm. Now I’m wondering how to call the cached image, if it’s possible…?
Can “opened file” be assigned to a variable?
I’m just putting that question out there for anybody in general.
Check out my sketch book :) | www.instagram.com/b.potts.art/
2019-03-19 at 10:17 pm #12997elkCustomerHello again. So I just had to try this, and this is what I came up with(see attachment).
I tried to keep your setup for the most parts, just moved some things around and added some outlines to the “buttons” so you could see which “texture slot” was selected at any given time. The top group also sets the Label to the first material right away and enables the outline.
So there are 3 materials;
-One to hold the default material to start with (material0, not used in the puzzels)
-Material 1 to hold texture number 1 (material1)
-Material 2 to hold texture number 2 (material2)The three planes under the box is just to show of the three materials as you change stuff.
One thing that surprised me, but makes real sense, is that if you have the same texture in all materials, even if the materials are individual, the reffarance to the image seems to be the same, real handy if you got the same texture used multiple places and just want to change all at once, so you see the textures have an extra number at the end just to make them individual.
I hope this is useful to you, if not at least I learned a couple of things ;)
You can test the “final” project here;
https://cdn.soft8soft.com/AROAJSY2GOEHMOFUVPIOE:53632680b5/applications/test_texture_swap/test_texture_swap.htmlPush the gray boxes behind the text, I did not bother making the text itself clickable or align the text to the buttons for that matter, but i think its clear enough for a little demo :)
2019-03-19 at 10:19 pm #12999PottsieParticipantYou’re amazing. Thank you! Gonna start rebuilding.
And I’m glad it helped you a bit! :)
Check out my sketch book :) | www.instagram.com/b.potts.art/
2019-03-19 at 10:23 pm #13000elkCustomerDid not see your last post before I posted. Not sure if you could store it in a variable, my solution was to use the material to store it in a way, using a variable might be better if that would work, at least for some more complex scenarios.
2019-03-19 at 10:30 pm #13001elkCustomerhehe. No problem. Happy to help
2019-03-20 at 12:23 pm #13042PottsieParticipantHi again! One more thing. For the top piece (assign material), does that just initiate when the scene loads, I’m assuming?
Check out my sketch book :) | www.instagram.com/b.potts.art/
2019-03-20 at 2:44 pm #13061elkCustomerYes, anything that is just straight puzzles that is not in an event handler or anything should just run straight away. The event handler in a sense also gets run straight away, but that will only registrer the event handler so the javascript under the hood can call it on events in the browser.
That being said I am not sure of the order if you put more lose puzzles in a tab, that is why I have only been using one connected block of these together. The more correct thing would probably be to do that initialisation in the default init tab.
This is mostly based on my assumptions tho, and might be putting it oversimplifide but i think this is the basis of it, please correct me if I missed something here Verge3D team :)
2019-03-21 at 7:15 am #13077Yuri KovelenovStaff2019-03-21 at 10:56 am #13093elkCustomerThanks for clearifying that Yuri. So then I would not be possible to do the initialization with the materials in the init tab because the scene data is not loaded yet. But based on those constraints you might be able to do some other initialization in the init tab, other than the obveiouse initialization puzzles.
2019-03-21 at 11:05 am #13094elkCustomerYou could also then set up the first custom tab to be you own “init afte sceneload” in a sense then, assuming the tabs will always be processed from left to right … !?
2019-03-23 at 10:53 am #13165Yuri KovelenovStaff -
AuthorPosts
- You must be logged in to reply to this topic.