🧵#Plastic SCM

marwi123

Hello, yes we've done projects with Plastic SCM - but we usually use git.

You just need to modify the .gitignore that comes with your web project to the ignore file that plastic uses.

ilja3406

sure, thanks for the advice 😉

I’m trying to switch from MeshStandardMaterial + onBeforeCompile to a pure ShaderMaterial with lights: true so I can use the Three lighting/shadow.

As soon as the material is assigned the renderer crashes with TypeError: Cannot set properties of undefined (setting 'value') at getProgram → setProgram → renderBufferDirect (Needle Engine 4.8.8 / three.module.js).

What’s the correct way in Needle to use ShaderMaterial { lights: true } (with shadows)?

marwi123

Ok well there's no 'Needle' way in this scenario, this is pure three.js. It sounds like your ShaderMaterial isn't constructed correctly, without more info I can't help here - but again just to be clear: This is just like in any three.js based app and there's nothing special we do here to make it work/not work.

marwi123

Sounds to me like a unifrom that is necessary to work with the lights setting is unassigned.

Setting lights: true in a Three.js ShaderMaterial tells the renderer to automatically populate your shader's uniforms with the current scene's light data. To make this work, your ShaderMaterial's uniforms object must include the necessary light uniforms, such as those found in the THREE.UniformsLib['lights']. Without these specific light uniforms in your uniforms object, the lights: true setting will have no effect on your shader. 
marwi123
// Example of setting up uniforms with light data
const uniforms = THREE.UniformsUtils.merge([
    THREE.UniformsLib['lights'], // Include the standard light uniforms
    {
        // Your custom uniforms here
        // map: { value: new THREE.Texture(...) }
    }
]);

const shaderMaterial = new THREE.ShaderMaterial({
    uniforms: uniforms,
    vertexShader,
    fragmentShader,
    lights: true // This tells the renderer to populate the lights uniforms
});

// You can then access these uniforms in your shaders like:
// uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
// uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
ilja3406

Hey needlz, I’ve got a question about loading an additional .glb into my Main Scene.

Let’s say I have a Main Scene that starts with a loading progress bar. The Needle Engine GameObject is attached to the Main Scene. The bar reflects the load progress of another file, content.glb (project > Content.scene > right-click > Needle Engine > Export to GLB). After the GLB is loaded, everything only works if the Needle Engine GO is present in the Content scene. If I remove the Engine GO, shaders don’t load and the animation doesn’t play (the scene looks quite dead).

My question: Is there any concern with having two Needle Engine GOs loaded in one iframe (one in the Main Scene and one in the Content Scene)? ChatGPT suggests that two Engine components in one iframe might interfere with each other and hurt performance. Is that true? Any best practices here?

Thanks!

marwi123

Hi, im not 100% sure i understand it exactly right: by "Needle Engine GO" you mean an object that has the Needle Engine component?

Loading multiple glbs into one scene should work fine. It depends on what components those additional file have tho regarding the effect so without more details i cant say much.

You might want to checkout the multi scene sample (e.g. via the Needle Engine menu item/Explore Samples or on https://samples.needle.tools)

The chatgpt suggestion sounds like it misunderstood something because having two components would just render two separate webgl canvases.

ilja3406

Hey, it’s me again with another question. Is it okay to continue this thread, or should I start a new one? Anyway, when I export a scene as a .glb, my timelines don’t play at all. Are there any limitations I should consider? Scenario: I have a bootScene that loads the MainContent scene (exported as .glb). The MainContent scene contains a Timeline that works when I test the scene directly, but the timeline doesn’t play after I load it from bootScene. Thnks for your support!