[SOLVED] How do you set "shininess" via code?


Been looking at developer API for a while, can’t seem to find any ‘shininess’ or a setting that’s between 0-100 :thinking:

Hey, it is in standardMaterial API, the parameter is called gloss
Screenshot 2023-10-18 at 1.29.37 PM

1 Like


Left: Editor glosiness 100
Right: material.gloss = 1;

doesn’t seem like :thinking: :grinning:

or there’s something else different between default editor new material and new pc.StandardMaterial :thinking:

I would take look at materials other options maybe you need to enable or disable some rendering options to get same result as in editor?
Screenshot 2023-10-18 at 1.42.21 PM

Seems like there’s more differences than I’ve imagined :grinning:

left: default new pc.StandardMaterial
right: editor default

Wonder why new pc.StandardMaterial doesn’t inherit skybox once its created and applied :thinking:

I’m starting to think the roots of this is in the way how i load skybox

pc.app.scene.envAtlas = textureAtlas;
pc.app.scene.skyboxMip = 0;

or perhaps no…
creating a new material from editor, applying it to a box, seems to have this nice reflections even after the app was started

Trying to find solution

material.cubeMapProjectionBox = pc.CUBEPROJ_BOX; - no effect

You can first try to adjust the gloss value of an editor copy by script, to be sure that works as expected.

Let me again point you to these awesome examples - some likely do similar things to what you need here: PlayCanvas Examples

1 Like

Im sure it works as expected

Thank you but its something with materials that I dont understand, not the skybox. Once app is started - all editor materials works as expected, can create new ones, adjust. Probem is with materials created by code, misses something.

Got it working… Thanks

What was the issue @Newbie_Coder ?

To achieve same reflectivity using new pc.StandardMaterial as in default editor-material (glossiness 100, even though metalness is unchecked):

       entity.render.material.gloss = 1;
       entity.render.material.metalness = 0;
       entity.render.material.useMetalness = true;