Home › Forums › Graphics / Blender › OSL script not working
- This topic has 12 replies, 4 voices, and was last updated 1 month, 1 week ago by
Ignacio Díaz.
-
AuthorPosts
-
2024-06-01 at 10:37 pm #74493
Ignacio Díaz
CustomerHi everyone,
I need some help with visualizing an OSL shader in Verge3D. The shader works perfectly in Blender, but I can’t seem to get it to work in Verge3D. Here is the code I’m using:
float pingPong(float x, float period) { float twicePeriod = period * 2.0; float modX = mod(x, twicePeriod); return period - abs(modX - period); } float frac(float x) { return x - floor(x); } point hadamardFraction(point v) { return point(frac(v[0]), frac(v[1]), frac(v[2])); } shader tejido( point Vector = P, int CantidadFilas = 60, int CantidadColumnas = 46, color Color1 = color(1, 0, 0), color Color2 = color(0, 1, 0), color Color3 = color(0, 0, 1), output color Col = 0, output point VectorOut = 0 ) { float columna = Vector[0] * CantidadColumnas; float fila = Vector[1] * CantidadFilas; float pingPongCol = pingPong(columna, 1.0); fila += pingPongCol; VectorOut = hadamardFraction(point(columna, fila, 0)); VectorOut -= point(0.5, 0.5, 0.5); }
This is the shader in blender:
And the node setup
Any suggestions or advice would be greatly appreciated!
2024-06-01 at 10:40 pm #74494Ignacio Díaz
CustomerNode Setup*
2024-06-03 at 12:16 am #74499kdv
ParticipantShow how you are trying to use the code above in your app. And keep in mind that this code is not a JS code…
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2024-06-03 at 1:19 am #74500Ignacio Díaz
CustomerI’m attempting to visualize a procedural texture created with an OSL script in Verge3D, but it’s invisible. At one point, I was able to preview it. I’m currently not using puzzles; instead, I’m using the app manager or sneak peek to check if it’s working. According to the Verge3D documentation, OSL shaders are supposed to be compatible with Verge3D… I hope there is a fix to this.
2024-06-03 at 5:35 am #74505Yuri Kovelenov
Staff2024-06-04 at 8:18 pm #74554Ignacio Díaz
Customer2024-06-05 at 5:03 am #74557Yuri Kovelenov
Staff2024-06-05 at 7:58 pm #74584Ignacio Díaz
CustomerHere is the .blend file and the .osl file.
Attachments:
You must be logged in to view attached files.2024-06-06 at 7:32 am #74587Alexander Kovelenov
StaffHi,
Thanks for the scene, it helped a lot!It appears that the OSL node inputs are not corresponding to the inputs in the shader itself. Maybe it’s a bug or a feature of Blender, but it causes crash in Verge3D. You can easily fix this by creating a new node with the same shader code so Blender assigns inputs in correct order:
-
This reply was modified 3 months ago by
Alexander Kovelenov.
Attachments:
You must be logged in to view attached files.2024-06-07 at 12:00 am #74596Ignacio Díaz
CustomerIt worked like a charm! thanks for the help
2024-06-07 at 2:40 am #74597Ignacio Díaz
CustomerI first tried creating the same procedural texture using shader nodes, but it didn’t work well in Verge3D. Is OSL fully supported by Verge3D?
2024-06-07 at 5:14 am #74598Alexander Kovelenov
StaffI first tried creating the same procedural texture using shader nodes, but it didn’t work well in Verge3D. Is OSL fully supported by Verge3D?
Glad it helped! Most OSL shaders should work just fine, however we only support procedural textures, e.g. it’s not possible to compose a complex BSDF shader.
2024-07-28 at 4:05 am #76224Ignacio Díaz
CustomerHello again,
I’m having trouble getting the new version of my OSL shader to work. I followed the same procedure to create a new script node, but it didn’t work as expected this time either. Any suggestions on what might be going wrong?
Thanks in advance!
PS: Is it possible to use GLSL scripts with Verge3D? Because there aren’t many learning resources available for OSL.
Attachments:
You must be logged in to view attached files. -
This reply was modified 3 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.