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

How to make triangles map floor with OSL

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
pproestos
326 Views, 6 Replies

How to make triangles map floor with OSL

I want to archive a triangles texture on a floor and

give to each triangle a different color.

I know how to model it and then apply random materials with OSL, but

I wonder if can I make it directly only with an OSL or arnold map....

I try to usw the shapes.osl but with no success..

thx gurus...

(Sorry I use wetransfer but when I try to upload something

it says "error parsing file" )

https://we.tl/t-zpRs5BOeoX

6 REPLIES 6
Message 2 of 7
madsd
in reply to: pproestos

You cant use that shader for floor tiles directly.
You need some, pr tile change, a float is enough, it can control all aspects of UV.
Try write off this triangle shader and build this hirachy.
I added the triangles as displacement as well, textures rotate pr tile, it can be bound to anything.

https://i.imgur.com/TFx6zMO.jpg

https://i.imgur.com/Lua6kGk.jpg

Message 3 of 7
pproestos
in reply to: pproestos

@Mads I have to start to learn OSL in my free time.... it's really magic what this language do... thx always for opening our eyes and thx for making this osl for me, I will recreate it... Cheers dev.

Message 4 of 7
pproestos
in reply to: pproestos

@Mads I compiled your shader, in the viewport shows ok but in the render window shows nothing...

4497-image4.jpg

Message 5 of 7
pproestos
in reply to: pproestos

@Mads any clue how to make your shader work? I used all kind of float combinations, none is showed on render window...

Message 6 of 7
madsd
in reply to: pproestos

Fixed up a version that utilizes a 3 point vector.
The thing is, the shader you send over works, perfect - however --->

I am calling an external .h file for the vector2 struct.
Arnold needs the pathing to be explicit and that the refferenced files are actually there.
This is semi optimal - more over, if people from other hosts use this shader, they would need the additional .h file and correct explicit refference to location in the shader.
Not very friendly.

Ideally:
All shipping Arnold builds should have a solid vector2.h and vector4.h hook in one of the stdosl files, so we can just refference them with no pathing since pathing is setup behind the curtain to simplify errors from users and make it more robuste as well.
Besides, the 2 vector types are nice to carry data around in for the sake of logic in reading and somethings for conveniency.

So I just removed the 2 point construct and parse everything through the generic vector.
Now renders with Arnold GPU.

4555-qwe.jpg

float fract  ( float x ) 
{
	return x-floor(x);
}
float r(float n, float Shuffle)
{
    return fract(abs(sin(n*Shuffle)*367.34));
}
float r(vector n, float Shuffle)
{
    return r(dot(n,vector(2.46,-1.21,0)),Shuffle);
}
float cycle(float n)
{
    return cos(fract(n)*2.0*3.141592653)*0.5+0.5;
}
shader Triangles(
 point Po = P,
 float Time = 0,
 float Shuffle = 1.0,
 output float Float_Out = 0,
    )
{
    float a = (radians(60.0));
    float zoom = 96.0;
    vector c = (vector(Po[0],Po[1],0)+vector(Time*zoom,0.0,0))*vector(sin(a),1.0,0);
    c = ((c+vector(c[1],0.0,0)*cos(a))/zoom)+vector(floor(4.*(c[0]-c[1]*cos(a))/zoom),0.0,0);
    float n = cycle(r(floor(c*4.0),Shuffle)*0.2+r(floor(c*2.0),Shuffle)*0.3+r(floor(c),Shuffle)*0.5+Time*0.125); 
    color Out = vector(n*2.0,pow(n,2.0),0.0);
    Float_Out = Out[0];
}
Message 7 of 7
pproestos
in reply to: pproestos

Even it these are hieroglyphs for me, you do a holy work @Mads...

Thanks one million time again master dev...

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

Post to forums  

Autodesk Design & Make Report