Shadergraph Vertex shader not applied when rendered in ThreeJS

This might help you:

If it helps the code for loading it in needle engine is in src/engine/extensions/


Thanks I will have a look! I am a bit afraid that I am in over my head in this :smile:

by user 282554301052878848

Let me know how it goes :slightly_smiling_face: maybe we can help you with it

You probably can :smile: But it’s a nice read!
In general it would be cool to be able to export individual gameobjects from Unity with the shader included. I mean the fragment part already works :smile: The fact that we already can export GLBs and use them in ThreeJS is magic!

by user 282554301052878848

Well the fragment part already works: it’s a custom shader so someone has to build the three.js shader material at runtime. Or am I missing something? Because glTF’s are not three.js specific and can not yet contain arbitrary shaders (MaterialX will hopefully change that and then what you ask for will hopefully be possible :slightly_smiling_face: )

@Blomman would be cool to learn a bit more about your usecase as well! We’ve seen a number of people now use Needle for the exporting part but not the runtime part. Personally I think that means you’re missing out :smile: as you see with custom shaders which are part of our loader/extensions. But happy to learn more!

If I run the whole project in Needle I get a Needle scene that afaik is hard to manage and manipulate in the generated project.

I have a project which I have fine grained control of but I find it super hard to create shaders and export models from Blender etc and Needle makes that part super handy for me.

Sorry on the phone atm

by user 282554301052878848

I have a React-three-fiber project (not the needle generated one) where I want to handle all update-loop related stuff with react-three-fiber / drei.

In this particular scenario my sole intention with Needle is to use it as a Unity to ThreeJS exporter for models + shaders. I don’t want to maintain my web project within Unity (generating a or w/e it is called which I can’t modify in the web project). I don’t want to script in Unity for this project.

Needle would then save me from

  • Opening Unity assets in Blender and modify / prepare them for ThreeJS as GLTF
  • Using Nodetoy for shaders (I absolutely love ShaderGraph)

by user 282554301052878848

This alone is super valuable. You’ve basically made a “Unity to ThreeJS” exporter pipeline. Right-clicking a gameobject with the associated gltfcomponent and exporting it is really impressive. If somehow the vertex shader data is exported along with it, it’s absolute gold! (Not sure how this is supposed to work)

by user 282554301052878848

Thanks for the details. What do you mean with

I get a Needle scene that afaik is hard to manage and manipulate
?

Our goal is certainly that a usecase like “I have a XYZ project and want to manage some parts of it via Needle” works - e.g. similar to how you’re using it. We may not have enough samples for that kind of workflow yet.

The shaders are exported inside the GLB, as is all component data. What our runtime part does is to add the right extension loaders and runtime code so that the data is unpacked into the three.js world again (both shaders and component data). The lifecycle parts then take care of running onEnable, update, and so on, typical things that you’d add to your code anyways for a realtime app

I mean that if I generate a Scene in Needle, my generated project does everything implicitly. It just renders a component and that’s that. All the magic happens in the background.

I am just interested in generating the pawns and orchestrate my scenes like I would a normal react three project

by user 282554301052878848

You can totally do that already - the react template is just that, a template, you can nest NeedleEngine however you want in your own project.

I think what you’re looking for is a useNeedleGltf instead of a useGltf that adds our additional stuff like shaders, lightmaps, components etc - would that be the right interpretation?

Wow, if that is actually it, it’s spot on! I will try when I get home

by user 282554301052878848

Which dependency is that hook part of? Which dependencies am I in need of in my external project?

by user 282554301052878848