OSL Shaders support
#1
I ran a test feeding a float to a scale map, changing an amplifier on the osl map does not trigger the scale.
A legacy noise map works.

The legacy maps are unattractive, outdated and very much not in same league as OSL when it comes to flexibility.
  Reply
#2
Shader I am seeding from

shader f(float i = 0, output float F =0) { F = i; }

Just try compile it and hook to anything, no dice.

I got a signal going, RGB to vector.
So I guess its working. I fail to pipe some generic noise.

Dug further.
Animated float values are not caught.

So I animate Time, scrubbing time line does not sync the scale of the particles to the OSL shader.
Changing the float value directly on the OSL shader with the spinner updates perfect.

vector fract ( vector x ){
return x - floor (x);}
vector Rotate(vector V,  float angle) {
    float c = cos(angle);
    float s = sin(angle);
    matrix mat2 = matrix (c,-s,0,0,s,c,0,0,0,0,0,0,0,0,0,0);
    return transform(mat2,V);
}

vector coordToHex(vector coord, float scale, float angle) {
    vector c = Rotate(coord, angle);
    float q = (1.0 / 3.0 * sqrt(3.0) * c[0] - 1.0 / 3.0 * c[1]) * scale;
    float r = 2.0 / 3.0 * c[1] * scale;
    return vector(q, r, -q - r);
}

vector hexToCell(vector hex, float m) {
    return fract(hex / m) * 2.0 - 1.0;
}

float absMax(vector V) {
    return max(max(abs(V[0]), abs(V[1])), abs(V[2]));
}

float nsin( float value) {
    return sin(value * M_PI*2) * 0.5 + 0.5;
}

float hexToFloat(vector hex, float amt) {
    return mix(absMax(hex), 1.0 - length(hex) / sqrt(3.0), amt);
}

float calc(vector tx, float Time) {
    float angle = M_PI * nsin(Time * 0.1) + M_PI / 6.0;
    float len = 1.0 - length(tx) * nsin(Time);
    float value = 0.0;
    float gridSize = 20.0;
    float wave = 5.0;
    vector hex = coordToHex(tx, gridSize * nsin(Time * 0.1), angle);

    for (int i = 0; i < 3; i++) {
        float offset = float(i) / 3.0;
        vector cell = hexToCell(hex, 1.0 + float(i));
        value += nsin(hexToFloat(cell,nsin(len + Time + offset)) * 
                  wave * nsin(Time * 0.5 + offset) + len + Time);
    }

    return value / 3.0;
}


shader gugu(

point Po = P,
float Time = 0,
output vector Out = 0,

) {
float brightness = 1.5;
float timeScale = 0.2;
float Displace = 0.01;
    point tx = (Po) - 0.5;
 
    float Timer = Time * timeScale;
    vector rgb = vector(0.0, 0.0, 0.0);
    for (int i = 0; i < 3; i++) {
        float time2 = Timer + float(i) * Displace;
        rgb[i] += pow(calc(tx, time2), 2.0);
    }
    Out = vector(rgb * brightness);
}

[Image: 001.gif]
  Reply
#3
Actually, 2020 file attached here.
Try scrub time line while material editor is open, you will see the procedural update and the particles are idle.
Now, try change the float spinner on my shader and see the particles update.
Note the float value changes as you scrub line, so the shader does update.

This should run 60FPS fluid.


Attached Files
.max   OSL.max (Size: 1.21 MB / Downloads: 295)
  Reply
#4
Thanks MadsD, currently I haven't done any direct OSL testing. I simply use max's pre-existing update texture methods, each frame. If that's not updating the OSL for whatever reason, then I'll have to figure out why.
  Reply
#5
Textures are parsed as strings.
Look at fileName node.
  Reply


Forum Jump: