Home › Forums › Programming › Changing base color using HTML color code
Tagged: color picker html puzzle
- This topic has 22 replies, 6 voices, and was last updated 5 years, 4 months ago by
Yuri Kovelenov.
-
AuthorPosts
-
2018-09-28 at 2:46 pm #7732
dragosburian
CustomerHi everybody,
Is there any way in which you can get the base color of a material changed by using an HTML color code using puzzles? If not, which would be the way to go with this issue? Thank you!
2018-09-28 at 3:17 pm #7733Mikhail Luzyanin
StaffIs there any way in which you can get the base color of a material changed by using an HTML color code using puzzles? If not, which would be the way to go with this issue? Thank you!
It’s not possible.
Co-founder and lead graphics specialist at Soft8Soft.
2018-09-28 at 3:35 pm #7734Yorick
CustomerHi Mikhail, since we are paying for priority support, can you suggest another way to do this?
We discussed with Yuri via video conference beforehand that changing colour of a 3D element based on input from our application is something that we need. Chancing colour seems to more straightforward than scaling/stretching to us.
Do you have any ideas that could help us, or or you planning on adding this development?
2018-09-28 at 3:44 pm #7738Mikhail Luzyanin
StaffWe discussed with Yuri via video conference beforehand that changing colour of a 3D element based on input from our application is something that we need. Chancing colour seems to more straightforward than scaling/stretching to us.
For now I think it’s can be only implemented using javascript. You can ask Yuri do add this feature: you will need to things: first is node to Get color from HTML object and second is node that can change RGB color in RGB color node in a material, this two are not presented now in puzzle. If you decide to do it via JavaScript it’s better to write in programming sub-forum.
Co-founder and lead graphics specialist at Soft8Soft.
2018-09-28 at 4:08 pm #7740Yuri Kovelenov
StaffHi,
It is possible to change a material’s color via JavaScript API.
For node based materials use the following approach:var object = app.scene.getObjectByName("MyObj"); var mat = object.material; var index = mat.nodeRGBMap['RGB.001']; // 'RGB.001' is the name of an RGB node mat.nodeRGB[index] = new v3d.Vector4(1, 0, 0, 1); // new color in RGBA format
If you are using standard or Verge3D PBR materials, simply update its color property:
var object = app.scene.getObjectByName("MyObj"); var mat = object.material; mat.color = new v3d.Color(1, 0, 0);
2018-10-03 at 7:27 pm #7837dragosburian
CustomerHi,
By RGB node, do you refer to the name of that node in Blender(e.g. Base Color in case of the Principled BSDF) or is there an index I can find?
Also, By using the second approach using Principled shader, it just won’t change the colors alothough I have no error and the mat.color gets updated with the values but does nothing. Am I mising anything?2018-10-04 at 9:01 am #7849Yuri Kovelenov
StaffBy RGB node, do you refer to the name of that node in Blender
Yes, you can check for the name in Blender node editor.
By using the second approach using Principled shader
This approach only valid for standard or glTF-compliant PBR shaders. Principled shader is considered to be a generic node-based shader so the first approach should be used in this case.
2018-10-04 at 1:33 pm #7864dragosburian
CustomerAnd in the case of me having a hex color (e.g. #20ca24). How do I apply that color to the Principled BSDF shader?
2018-10-04 at 1:42 pm #7865Yuri Kovelenov
Staff2018-10-04 at 1:59 pm #7868dragosburian
CustomerDone that, still no effect in the player
2018-10-04 at 2:08 pm #7870Yuri Kovelenov
Staff2018-10-04 at 2:32 pm #7871dragosburian
CustomerPrincipled
2018-10-04 at 2:38 pm #7873Yuri Kovelenov
Staff2018-10-04 at 3:04 pm #7875dragosburian
CustomerAnd the code remains the same?
2018-10-04 at 3:15 pm #7876Yuri Kovelenov
Staff -
AuthorPosts
- You must be logged in to reply to this topic.