Forum Replies Created
-
AuthorPosts
-
Xen Wildman
CustomerNo, just the color picker in the top left. The RGB on the spheres was before I built the html with color picker.
Xen Wildman
CustomerHere’s the link.
Xen Wildman
CustomerThis is the code that ended up working for me:
function hex2rgb(hex, opacity) { var h=hex.replace('#', ''); h = h.match(new RegExp('(.{'+h.length/3+'})', 'g')); for(var i=0; i<h.length; i++) h = parseInt(h.length==1? h+h:h, 16); if (typeof opacity != 'undefined') h.push(opacity); return 'rgba('+h.join(',')+')'; }
Xen Wildman
CustomerI found a shorter snippet that works perfectly:
app.ExternalInterface.hexToRgb = function(hex) { return ['0x' + hex[1] + hex[2] | 0, '0x' + hex[3] + hex[4] | 0, '0x' + hex[5] + hex[6] | 0]; }
Edit: Need to check more.
Xen Wildman
CustomerI put in 181 38 124 and it works fine. Yours didn’t work since it is expecting 255 255 255.
Xen Wildman
CustomerGood catch thank you I missed that. Usually the case for normal maps as well. Yeah I have a list of things I’d like to do including an actual UI.
It seems like the moment I put a math node into the equation to try to convert to linear, it all goes grey whether in Blender or puzzles.
Xen Wildman
CustomerIt’s not all perfect yet as I have to account for the fact that the environment color and spot light is going to influence the result. I’m totally open to playing with your solution as well and appreciate you sharing.
Xen Wildman
CustomerReplied there. Big thanks for your input.
Xen Wildman
CustomerHere’s a link to the current working project:
Edit: Click on the sphere’s to set the values, then click the keys to change them.
Xen Wildman
CustomerThanks for the reply Gliftek. No offense taken, I’ve been doing computer graphics for many years but you’re right this (WebGL) is new to me. I did solve the RGB thing, I’m not sure how efficient it is but it works.
I am using vertex color to drive color so that the user can choose to color each element separately. I don’t think that would be very efficient with materials.
Edit: In Blender that was Gamma 2.2. Changed here to test.
Xen Wildman
CustomerThanks so much for the project that I can dissect. Based on your conversation with Gliftek, this is as far as I got but the objects were turning black. I think I understand now.
app.ExternalInterface.setKeyCol = function(changeObject, changeColor) { var myObj = app.scene.getObjectByName(changeObject); var setcolor = changeColor; var attrName = myObj.material.nodeVCAliases['Keys']; if (attrName !== undefined) { var vertColor = myObj.geometry.attributes[attrName]; } for (var i = 0; i < vertColor.count; i++) { vertColor.setXYZ(i, 'setColor'); } vertColor.needsUpdate = true; }
Xen Wildman
CustomerWhat would the whole script look like if you were setting a vertex colour for a picked object in a vertex colour index called KeyCol? Say I want to do another and call it something else?
Edit: I’d also like user to specify a colour to change to.
Edit2: Would this puzzle work or is it better to set variable and the external js will pick it up? There are two vertex colors: KeyCol and Legend
Xen Wildman
CustomerThanks! It works kinda but doesn’t reflect what I’m seeing in Blender or using the same values in separate shaders.
Xen Wildman
CustomerThe moment I add this to my js file it kills the app and it won’t load anymore. Can someone provide an updated example of a video material?
Verge3d devs, it would be prudent to have this as an example project included with Verge3d or a puzzle to plug videos in to the application.
-
AuthorPosts