Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Corona like UV randomization

2 REPLIES 2
Reply
Message 1 of 3
geppeto
525 Views, 2 Replies

Corona like UV randomization

Greetings,

Is there a standard way to replicate Corona’s very handy UV randomization shader when a material is tiled with Arnold in C4D? Per object randomization is easy but what about material repetition at the same object eg. a marble checkerboard floor plane where each tile should be different .

Tags (1)
Labels (1)
2 REPLIES 2
Message 2 of 3
lee_griggs
in reply to: geppeto

There is this OSL shader.

Lee Griggs
Arnold rendering specialist
AUTODESK
Message 3 of 3
RichardMoss
in reply to: geppeto

I just came up against this problem recently, I couldn't seem to get the original 3dsmax osl shader to work but this one modified and written for redshift worked

RedshiftOSLShaders/TextureNoTile.osl at main · redshift3d/RedshiftOSLShaders (github.com)

// Non-Tiling Texture Shader
// TextureNoTile.osl, by Zap Andersson
// Modified: 2020-03-28
// Copyright 2020 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license
// https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt
// Modified by Saul Espinosa for Redshift OSL Support 2020-12-28

float sum( color col ) { return col[0]+col[1]+col[2]; }


color textureNoTile( string FileName, point UV, float GradientScale, float Offset, float Rescale, float Rotate, int LevelCount, int Debug, int Seed )
{
    float k = noise("uperlin", UV / GradientScale, Seed);
    float l = k*LevelCount + UV[1] / GradientScale;
    float i = floor( l );
    float f = l - i;
    vector offa = cellnoise(i + 0.0, Seed) * vector(Offset, Offset, 1.0);
    vector offb = cellnoise(i + 1.0, Seed) * vector(Offset, Offset, 1.0);
    float  sca = 1.0 / (1.0 + (offa[2] - 0.5) * Rescale);
    float  scb = 1.0 / (1.0 + (offb[2] - 0.5) * Rescale);

    float  rota = offa[2] * Rotate;
    float  rotb = offb[2] * Rotate;

    point rotA = rotate(UV, rota, vector(0.5,0.5,0), vector(0.5,0.5,1.0));
    point rotB = rotate(UV, rotb, vector(0.5,0.5,0), vector(0.5,0.5,1.0));

    color cola = texture(FileName, rotA[0] * sca + offa[0], 1.0 - (rotA[1] * sca + offa[1]), "wrap", "periodic" );
    color colb = texture(FileName, rotB[0] * scb + offb[0], 1.0 - (rotB[1] * scb + offb[1]), "wrap", "periodic" );

    if (Debug)
    {
        cola = offa;
        colb = offb;
    }

    return mix( cola, colb, smoothstep(0.1,0.9,f-0.1*sum(cola-colb)) );
}

shader NoTile
[[ string help  = "Non-Tiling Bitmap Lookup, based on an OpenGL Technique",
   string label = "Non-Tiling Bitmap Lookup",
   string URL   = "http://www.iquilezles.org/www/articles/texturerepetition/texturerepetition.htm" ]]
(

// Texture Input
point  uvw   = point(u,v,0)
                [[  string label= "UV Coordinate",
                        string help = "The 2D coordiante at which the texture is looked up." ]],
        string Filename = "" [[ string widget="filename", string page = "Image" ]],

string fromSpace = "" 
[[  string label = "Input Space", string widget = "colorspace", string page = "Image"]],

string toSpace = "" 
[[  string label = "Output Space", string widget = "colorspace", string page = "Image"]],

float gainMul = 1
[[  string label = "Gain",
    string page = "Image",
float softmin = 0,
float softmax = 10,
float slidermin = 0,
float slidermax = 10,
float sensitivity = 0.001 ]],

// Noise Options
        float  GradientScale = 2.0
            [[  float min = 0,
                float max = 25,
string page = "Noise"
            ]],
        float  Offset = 1.0
            [[  float min = 0,
                float max = 25,
string page = "Noise"
            ]],
        float  Rescale = 0.0
            [[  float min = 0,
                float max = 25,
string page = "Noise"
            ]],
        float  Rotate  = 0.0
            [[  float min = -180,
                float max = 180,
string page = "Noise"
            ]],
        int    LevelCount = 8
            [[  int min = 0,
                int max = 25,
string page = "Noise"
            ]],
        int    Seed = 0
            [[  int min = 0,
                int max = 100,
string page = "Noise"
            ]],
        int    Debug   = 0
                [[  string widget = "checkBox",
                        string help = "Shows the regions that are being mixed", string page = "Utility" ]],
        int    Bypass = 0
                [[  string widget = "checkBox",
                        string help = "Turns the effect off, to compare", string page = "Utility" ]],

        output color outColor = 0
)
{
        int s = Seed;


        point Pos = select(vector(u,v,0), uvw, isconnected(uvw));

        if (Bypass)
                color Col = texture(Filename, Pos[0], 1.0 - Pos[1], "wrap", "periodic");
        else
                Col = textureNoTile( Filename, Pos, GradientScale, Offset, Rescale, Rotate, LevelCount, Debug, s );

outColor = transformc( fromSpace, toSpace, Col) * gainMul;
}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report