Categories
Journals

NB: Watch this at the full 720p. YouTube’s compression is making this look a bit ghastly.. or check out still versions here.

After a full day of rendering, here are some abstract multicoloured waves.

The base geometry is a boring ordinary plane. It hasn’t even been modified by a subdiv surface – it’s that boring.

This is the OSL script in its material:

#include “stdosl.h”

// source: http://glsl.heroku.com/e#12485.1

shader circlees(

    float FTime = 1.0,

    float Speed = 1.0,

    point Po = P,

    output color Col = (0.8),

    output float Fac = 0.0

)

{

    point position = Po;

    float SafeSpeed = Speed;

    if (SafeSpeed == 0) {

        SafeSpeed = 0.000000001;

    }

    float Time = FTime * SafeSpeed;

     float Tcolor = 0.0;

Tcolor += sin( position[0] * cos( Time / 15.0 ) * 80.0 ) + cos( position[1] * cos( Time / 15.0 ) * 10.0 );

Tcolor += sin( position[1] * sin( Time / 10.0 ) * 40.0 ) + cos( position[0] * sin( Time / 25.0 ) * 40.0 );

Tcolor += sin( position[0] * sin( Time / 5.0 ) * 10.0 ) + sin( position[1] * sin( Time / 35.0 ) * 80.0 );

Tcolor *= sin( Time / 10.0 ) * 0.5;

Col = color( Tcolor, Tcolor * 0.5, sin( Tcolor + Time / 3.0 ) * 0.75 );

float red = (position[0] – 0.5)*(position[0] – 0.5) + (position[1] – 0.5)*(position[1] – 0.5) + sin(Time/100.0);

float green = (position[0] – 0.5)*(position[0] – 0.5) + (position[1] – 0.5)*(position[1] – 0.5) + cos(Time/100.0);

float blue = (position[0] – 0.5)*(position[0] – 0.5) + (position[1] – 0.5)*(position[1] – 0.5) + tan(Time/100.0);

Col += color( sin(red*100.0), sin(green * 200.0) , sin(blue * 300.0) );

    Fac = (Col[0] + Col[1] + Col[2]) / 3;

}

That OSL shader is fed into a Diffuse and an Emission shader, mixed at 0.5 and fed into the Surface output. The OSL shader is also divided by 0.5 and fed to Displacement. The Experimental mesh Displacement feature was set to True. Subdivision is switched on, Dicing rate is set to 0.002

Speed is set to 0.1, FTime is set to increase by 1 every frame using an FCurve modifier, press render, and 409 frames later, this happens. 🙂

Categories
Journals

After finding this excellent guide to converting GLSL shader routines to OSL, I thought I’d dig up a couple of the simpler but still spiffy-looking ones on GLSL Sandbox for conversion practice.

The successes and failures have both been pretty great. I don’t know what I’m doing, I’m fairly sure I found a bug but I will need to test a bit more to be sure. But yeah. Shaders. Cool stuff. 🙂

Haven’t really got many tips on how to convert, suffice it to say it helps to know how vectors and scalars behave. Also worth knowing is the following.

In GLSL, vec2 pos = (gl_FragCoord.xy / resolution.xy) means that pos contains members pos.x and pos.y with ranges from from 0.0 to 1.1

In OSL: there’s a global point P which you can put into the shader signature as point Po = P. Po will then contains three read-only indices – P[0], P[1] and P[2]. These are floats of X Y and Z respectively containing values from 0.0 to 1.0 or close enough.

You can factor in time by putting float FTime = 1.0 in the shader signature. Once you’ve compiled the shader, hover mouse over FTime and hit i to insert a keyframe. Then hit up the F-Curves Editor, add a Generator and you’ll have time as frames. If you the time to be fed in as seconds instead of frames, set the first order co-efficient (aka.the parameter next to the X) as 1/24 or 1/yourframerate. (Drivers do not appear work for OSL node parameters.)

Think I might render out a video or two for tomorrow. This stuff is cool in motion.

Originals: http://glsl.heroku.com/e#12424.0 and http://glsl.heroku.com/e#12485.1 – thanks to Stefan Hintz and the anonymous contributor of the other GLSL shader.