Questions tagged [osl]

OSL (Open Shading Language) is an open source language designed for creating materials, lights, etc. The ability to add custom OSL scripts for rendering with Cycles was added to blender in 2.65

From the OSL Introduction page:

Open Shading Language (OSL) is a small but rich language for programmable shading in advanced renderers and other applications, ideal for describing materials, lights, displacement, and pattern generation.

OSL was developed by Sony Pictures Imageworks for use in its in-house renderer used for feature film animation and visual effects. The language specification was developed with input by other visual effects and animation studios who also wish to use it.

Also see:

129 questions
10
votes
2 answers

How to load an internal blender image using OSL?

OSL has the texture command that we can use to load image files and map in an object. Dfelinto made a nice video about it some years ago. https://www.youtube.com/watch?v=V5N2rnFtSlw We also have many samples of it in the source of…
VitorBalbio
  • 173
  • 1
  • 1
  • 5
10
votes
1 answer

How would I add bump mapping on an OSL shader?

diffuse_toon(N, 0.5, 0); I've found out by reading through the specifications of OSL that N is a global variable, pertaining to normals, but I'm not certain on how to use it. If I were to use a Normal Map node to get a vector from an image, how…
Poyo
  • 1,595
  • 2
  • 17
  • 28
10
votes
1 answer

What does Open Shading Language ( OSL ) mean?

I was wondering what does Open Shading Language mean? I've heard people talk about OSL this and OSL that, and I just thought that it was something they said to sound smart. I wonder if anyone actually knows what this is or does?
Owen Patterson
  • 3,257
  • 7
  • 21
  • 28
5
votes
2 answers

Location of object in OSL

I'm running Blender 2.78 Using OSL, I am trying to find the location of an object. In the Node editor, I am in Shader Nodes for World. The object I'm trying to find is a UV sphere named 'MySun' and has an emitter material using cycles. In the OSL…
4
votes
1 answer

OSL distortion effect

I have a simple math function that produce a saw-like pattern. The question is - How to apply a distortion effect to it? Here's an example of the code: shader basic_function( point Pos = P, output float f = 0) {float x = Pos[0]; float y =…
Artem
  • 373
  • 2
  • 9
4
votes
1 answer

OSL component names for points, colors? (x, y, z, r, g, b)

The Open Shading Language spec says Color variables may also have their components referenced using “named components” that look like accessing structure fields named r, g, and b, as synonyms for [0], [1], and [2], respectively: float green = C.g;…
Rob N
  • 227
  • 1
  • 3
  • 7
3
votes
1 answer

OSL Popup Option

Is it possible to create an enum for osl, like how the glass shader offers choices for the formula used to render the glass? I've been doing some research but I have been unable to find any documentation regarding what I am looking for.
RWolfe
  • 145
  • 5
3
votes
0 answers

How to create OSL Refraction shader

Is it possible to create a refraction shader using OSL with parameters to control the angle it refracts to using the normal and the angle of incidence?
Joseph Groves
  • 215
  • 3
  • 8
3
votes
1 answer

OSL wave uv distort

I'm new to OSL and trying to see an example of how someone would convert this unity shader to OSL in object space? https://andreashackel.de/tech-art/stripes-shader-1/ Shader "Unlit/Stripes" { Properties { _Color1 ("Color 1", Color) =…
simhod
  • 43
  • 2
2
votes
0 answers

Making a Gouraud OSL shader

I am trying to make a Gouraud shader, but I can't get the right result. shader gouraud( color base_color = color(1,1,1)[[ string label = "Base Color", ]], color spec_color = color(1,1,1)[[ string label = "Specular…
L0Lock
  • 15,965
  • 1
  • 20
  • 44
2
votes
0 answers

OSL EventBoolFlag/Write text file

I use Open Shading Language. I need save event (if (speed_particle > 0.5) {boolean_flag = 1}). The trouble is that the variable "flag" is reset every frame! How can i save the value of the variable "flag"? Or How can i save the value of the variable…
Alekhly
  • 101
  • 7
2
votes
1 answer

OSL shader issue, could not find include file: node_texture.h"

I am trying to (re)create an OSL shader in Blender, but I receive an error "error: could not find include file: node_texture.h" when compiling. I've Googled it up, but can find nothing. Where can I find this file, or change the search path?
Perrishnikov
  • 239
  • 1
  • 7
2
votes
1 answer

OSL trace(): Strange result in visibiliy analysis

I would like to create a osl shader that could show the visibility of the cube surface from the cursor pos (0,0,0). So I used the trace() function like this: shader Visibility( point target = (0.0, 0.0, 0.0), output int Hit = 0, …
2
votes
1 answer

Blender's "stdio.h" not found anywhere

Trying to run some OSL scripts for Blender 2.83 on mac. Never tried it before and having troubles with it. Any script I try to run gives same error ERROR: /Applications/Blender.app/Contents/Resources/2.83/scripts/addons/cycles/shader/stdcycles.h:31:…
2
votes
1 answer

check whether `trace()` collide a face at back or front side?

How to check whether trace(ray,direction,...) collides the nearest face at front OR back side? According to OSL: Anomalous normals returned by getmessage("trace"), these below codes won't work because it always return value as front-face…
cppBeginner
  • 694
  • 4
  • 16
1
2