# Convert shader script to geometry?

Greetings!

I’ve created a volumetric shape using an OSL script, it has volume and a clear 3D boundary defined by white color, then immediately transitioning to transparent/black.

So my question is, how do I import that white/black data of this shader script/material into geometry nodes, and realize a decent approximation of the surface?

Alternatively, is there a way to directly plug an OSL script into geometry nodes?

I do not think that is possible. As far as I know you can send attributes from geometry nodes to shader nodes but nothing similar the other way around. (except recreating or copying math and texture nodes)

Well, all I want to do is import the black/white data. That’s it, shouldn’t be too complicated given blender’s vast array of tools, right? I just take the data that’s rendered and instance a reasonable density of points along it and realize those instances with vertices or a volume-to-surface node or something. I’ve seen stuff like this done before in volume render tutorials although not for GLSL data.

Well yes, the only way I know of to get data from shader nodes output to GN is to bake a procedural texture to an image, you can use image textures in GN.

The problem is that images are 2D, when you say

I presume you mean a 3D volumetric shape (similar to SDF).
An Image texture will not do that.

I think the only way to go about it is by doing the math in geometry nodes (no OSL). There are people who are doing SDF things in geometry nodes.

You can recreate most of the things you can do in shader nodes directly in Geometry nodes but not every node will “copy-past”, as far as I know you can not use OSL in Geometry Nodes but you could theoretically use some of the mathematical foundations.

higgsas has some node groups for SDF things.

2 Likes

Hmm, well instead, is there a way I can use blender’s lighting/render engine on the surface that is generated by the white points in OSL language? In OSL you can build a shader from scratch, but I don’t want to build blender from scratch, I just want to use the shader engine that blender already uses, but apply it to all the white stuff in the volumetric shape.