A collection of shader and experiments using Open Shading Language. Here you are going to find:

If you want to know more, please consider vising the repository.

1. Constant Shader

Constant shaded color and not affected by lighting. It is probably the most basic shader to produce.

Constant Color or Texture

A simple pure shaded color.

Learn more

2. Iridescence Shader

A simple iridescence effect inspired by the Goniochromism phenomenon, which varies its aspect based on the relationship between the surface normal and the camera angle. The visual beautification is due the pseudo noise function, that makes the aspect a little more appealing.

                
                  float NaiveNoise(vector freq, vector offset) {
                    // Naive noise function to make irregularity
                    return sin(2*M_PI*P[0]*freq[0]*2 + 12 + offset[0]) +
                      cos(2*M_PI*P[2]*freq[0] + 21 + offset[0]) *
                      sin(2*M_PI*P[1]*freq[1]*2 + 23 + offset[1]) +
                      cos(2*M_PI*P[1]*freq[1] + 32 + offset[1]) *
                      sin(2*M_PI*P[2]*freq[2]*2 + 34 + offset[2]) +
                      cos(2*M_PI*P[0]*freq[2] + 43 + offset[2]);
                  }
                  
                  color iridescence(
                    float orient,
                    float noiseMult,
                    vector freqA,
                    vector offsetA,
                    vector freqB,
                    vector offsetB
                  ) {
                    // This function returns a iridescence value based on orientation
                    color irid;
                    irid[0] = abs(cos(
                      2*M_PI*orient*freqA[0] + NaiveNoise(freqB, offsetB)*noiseMult + 1 + offsetA[0]
                    ));
                    irid[1] = abs(cos(
                      2*M_PI*orient*freqA[1] + NaiveNoise(freqB, offsetB)*noiseMult + 2 + offsetA[1]
                    ));
                    irid[2] = abs(cos(
                      2*M_PI*orient*freqA[2] + NaiveNoise(freqB, offsetB)*noiseMult + 3 + offsetA[2]
                    ));

                    return irid;
                  }
                
              

Iridescence Simple

A simple iridescent shader.

Learn more