CausticsPattern_Advanced.osl

A forum where development builds are posted for testing by the community.
Forum rules
NOTE: The software in this forum is not %100 reliable, they are development builds and are meant for testing by experienced octane users. If you are a new octane user, we recommend to use the current stable release from the 'Commercial Product News & Releases' forum.
Post Reply
User avatar
Elvissuperstar007
Licensed Customer
Posts: 2506
Joined: Thu May 20, 2010 8:20 am
Location: Ukraine/Russia
Contact:

I tried to create an OSL procedural, but there are errors, here is the code itself, if you manage to fix it, then I will ask you to integrate this procedural into Octane Render as a procedural map

Here is an example of what a procedure map does.
https://www.dualheights.se/caustics/

_______________________________________________________________________________________________________________________________________________________________________________________

shader CausticsPattern_Advanced(
float Time = 0.0 [[ string label = "Time", string widget = "float" ]],
float Speed = 1.0 [[ string label = "Animation Speed" ]],
float Scale = 10.0 [[ string label = "Pattern Scale" ]],
float Intensity = 2.0 [[ string label = "Brightness" ]],
color Tint = color(1.0, 1.0, 1.0) [[ string label = "Color Tint" ]],
float Distortion = 0.5 [[ string label = "Distortion Strength", min = 0.0, max = 2.0 ]],
float Rotation = 0.0 [[ string label = "UV Rotation (Degrees)", min = 0.0, max = 360.0 ]],
point UV_Offset = point(0.0, 0.0, 0.0) [[ string label = "UV Offset (X,Y)" ]],
float Contrast = 1.0 [[ string label = "Contrast", min = 0.1, max = 5.0 ]],
output color result = 0
)
{
point pos = transform("common", P);

// Apply scaling
pos *= Scale;

// Apply offset
pos += UV_Offset;

// Apply rotation
float rad = radians(Rotation);
float cos_r = cos(rad);
float sin_r = sin(rad);
float x_rot = pos[0] * cos_r - pos[1] * sin_r;
float y_rot = pos[0] * sin_r + pos[1] * cos_r;
point uv = point(x_rot, y_rot, 0);

// Animate noise
float t = Time * Speed;
float n1 = noise("perlin", point(uv[0] + sin(t), uv[1] + cos(t), 0));
float n2 = noise("perlin", point(uv[0] + cos(t), uv[1] + sin(t), 0));
float mixed = n1 * n2;

// Add distortion
mixed += Distortion * (noise("perlin", uv + point(sin(t*0.3), cos(t*0.2), 0)) - 0.5);

// Apply contrast
mixed = pow(clamp(mixed, 0.0, 1.0), Contrast);

// Final caustic pattern
float caustic = smoothstep(0.3, 1.0, mixed);
result = Tint * caustic * Intensity;
}


______________________________________________________________________________________________________________________________________________________________________________________


shader FakeCausticsLoop(
float Time = 0.0 [[ string label = "Time", string widget = "float" ]],
float Speed = 1.0 [[ string label = "Loop Speed" ]],
float Scale = 8.0 [[ string label = "Wave Scale" ]],
float Intensity = 3.0 [[ string label = "Light Intensity" ]],
float Contrast = 1.5 [[ string label = "Contrast", min = 0.1, max = 5.0 ]],
float AnimationPhase = 1.0 [[ string label = "Loop Phase (0.1–2)" ]],
color Tint = color(1.0, 1.0, 1.0) [[ string label = "Light Tint" ]],
output color result = 0
)
{
point uv = transform("common", P);
uv *= Scale;

float t = Time * Speed;

// Cyclic moving noise
float angle1 = t * AnimationPhase;
float angle2 = t * (AnimationPhase * 1.3);

point offset1 = point(sin(angle1), cos(angle1), 0);
point offset2 = point(cos(angle2), sin(angle2), 0);

float noise1 = noise("perlin", uv + offset1);
float noise2 = noise("perlin", uv + offset2);

float combined = noise1 * noise2;

combined = pow(clamp(combined, 0.0, 1.0), Contrast);

float caustics = smoothstep(0.3, 1.0, combined);

result = Tint * caustics * Intensity;
}


_______________________________________________________________________________________________________________________________________________________________________________________
CausticsPattern_Advanced.osl – Shader Overview
This custom OSL shader generates animated, procedural caustics patterns, simulating the effect of light being focused through water or glass. It’s designed to be tileable, loopable, and customizable for use with emissive materials or surface patterns in render engines like Octane Render within 3ds Max.

What Each Part Does
Input Parameters:
Time: Controls the animation phase. You animate this over time (e.g., keyframe it from 0 to 10 over a timeline).

Speed: Multiplies the animation speed. Higher = faster caustics movement.

Scale: Zooms in or out of the caustics pattern. Larger scale = finer detail.

Intensity: Controls the brightness (multiplicative factor).

Tint: Adds a color tint to the caustic pattern (e.g., blue or white).

Distortion: Adds procedural distortion to make the pattern more organic and "wavy".

Rotation: Rotates the pattern around the UV space in degrees.

UV_Offset: Moves the pattern in X and Y directions. Good for offsetting duplicates or looping.

Contrast: Sharpens or softens the caustics effect. Higher contrast = more pronounced light-dark areas.

Internal Processing:
Positioning & Transformation:

Transforms the current surface point (P) into UV-like space.

Applies scale, offset, and rotation to simulate movement and orientation.

Noise Generation:

Uses Perlin noise to create an organic pattern.

Two noise values (n1, n2) are multiplied for visual complexity.

Animation is driven by sine/cosine functions of time.

Distortion Layer:

Adds extra animated distortion to prevent repetitive patterns.

Contrast and Output:

Applies contrast curve using pow() function.

The final result is a grayscale or colored intensity map.

Output is multiplied by Intensity and Tint.

Use Cases:
Connect to an emission shader (e.g., light projector with caustic map).

Apply as a surface texture (wet surfaces, pools, underwater).

Use in displacement or bump mapping (with tweaks).
win 7 /64x C2Quad 6600 2.4/ Nvidia 9800 GX2 1gb 512 bit + Asus 480 GTX/ DDR2 8Gb / NVIDIA 460 GTX 2GB/2x NVIDIA 580 GTX 3GB
Page octane render " В Контакте " http://vkontakte.ru/club17913093
Post Reply

Return to “Development Build Releases”