We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

OSL script not working

Home Forums Graphics / Blender OSL script not working

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #74493
    Ignacio Díaz
    Customer

    Hi 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:
    Shader Image
    And the node setup
    Node Setup

    Any suggestions or advice would be greatly appreciated! :-)

    #74494
    Ignacio Díaz
    Customer
    #74499
    kdv
    Participant

    Show 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.

    #74500
    Ignacio Díaz
    Customer

    I’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.

    #74505

    Hi Ignacio,

    Can you share this material assigned to a plane model with us?

    Chief 3D Verger | LinkedIn | Twitter

    #74554
    Ignacio Díaz
    Customer

    Here is the preview in cycles.

    #74557

    Can you attach some simple .blend file that shows this issue?

    Chief 3D Verger | LinkedIn | Twitter

    #74584
    Ignacio Díaz
    Customer

    Here is the .blend file and the .osl file.

    Attachments:
    You must be logged in to view attached files.
    #74587

    Hi,
    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:

    Attachments:
    You must be logged in to view attached files.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #74596
    Ignacio Díaz
    Customer

    It worked like a charm! thanks for the help :good:

    #74597
    Ignacio Díaz
    Customer

    I first tried creating the same procedural texture using shader nodes, but it didn’t work well in Verge3D. Is OSL fully supported by Verge3D?

    #74598

    I 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.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #76224
    Ignacio Díaz
    Customer

    Hello 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.
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.