### Undo coding assistant setup Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/docs/dev/Agentic_Coding.md Run `.agents/setup-agent clear` to remove all tool setup, or specify a tool to remove only that tool's setup. The script is idempotent, so running it multiple times is safe. ```bash .agents/setup-agent clear # remove all tool setup .agents/setup-agent clear claude # remove setup for one tool ``` -------------------------------- ### Example shader group serialization Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/src/doc/shadergroups.md This example shows a complete shader group description using the `param`, `shader`, and `connect` statements. It sets instance values for texture maps, gamma, and wood color, declares shader instances, and connects their parameters. Note that comments are included in the source. ```none param string name "rings.tx" ; # set pending `name' param float scale 3.5 ; # set pending `scale' shader "texturemap" "tex1" ; # tex1 layer, picks up `name', `scale' param string name "grain.tx" ; shader "texturemap" "tex2" ; param float gam 2.2 ; shader "gamma" "gam1" ; param float gam 1.0 ; shader "gamma" "gam2" ; param color woodcolor 0.42 0.38 0.22 ; # example of a color param shader "wood" "wood1" ; connect tex1.Cout gam1.Cin ; # connect tex1's Cout to gam1's Cin connect tex2.Cout gam2.Cin ; connect gam1.Cout wood1.rings ; connect gam2.Cout wood1.grain ; ``` -------------------------------- ### regex_search examples Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/src/doc/stdlib.md Illustrates the regex_search function with three examples: simple substring matching, capturing a sub-expression with a results array, and capturing multiple sub-expressions. The comments show expected return values and the resulting match indices. ```cpp r = regex_search ("foobar.baz", "bar"); // = 1 r = regex_search ("foobar.baz", "bark"); // = 0 int match[2]; regex_search ("foobar.baz", match, "[Oo]{2}") = 1 (match[0] == 1, match[1] == 3) substr ("foobar.baz", match[0], match[1]-match[0]) = "oo" int match[6]; regex_search ("foobar.baz", match, "(f[Oo]{2}).*(.az)") = 1 substr ("foobar.baz", match[0], match[1]-match[0]) = "foobar.baz" substr ("foobar.baz", match[2], match[3]-match[2]) = "foo" substr ("foobar.baz", match[4], match[5]-match[4]) = "baz" ``` -------------------------------- ### Run setup script for coding assistants Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/docs/dev/Agentic_Coding.md Run `.agents/setup-agent ` after cloning to configure the specified coding assistant. The script is idempotent, so running it multiple times is safe. Use `all` to set up all supported tools. ```bash .agents/setup-agent claude # Claude Code .agents/setup-agent cursor # Cursor .agents/setup-agent codex # OpenAI Codex .agents/setup-agent opencode # Opencode .agents/setup-agent copilot # GitHub Copilot .agents/setup-agent all # all of the above ``` -------------------------------- ### Match camera-to-diffuse-to-light path Source: https://github.com/academysoftwarefoundation/openshadinglanguage/wiki/OSL-Light-Path-Expressions Example path with camera, diffuse reflection, diffuse transmission, and light events. Shows the full event notation with angle brackets. ```text ``` -------------------------------- ### Run osltoy with mandelbrot.osl Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/src/doc/osltoy.md Run osltoy with the mandelbrot.osl shader from the OSL installation directory to start an interactive shader editing session. ```cpp osltoy /shaders/mandelbrot.osl ``` -------------------------------- ### BSDL configuration header example Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/src/libbsdl/README.md Shows a BSDLConfig struct that overrides math functions with OIIO fast approximations and sets HERO_WAVELENGTH_CHANNELS to 3 for RGB-only rendering. Include this header before including anything else from BSDL. ```cpp #define BSDL_INLINE static inline OSL_HOSTDEVICE #define BSDL_INLINE_METHOD inline OSL_HOSTDEVICE #define BSDL_DECL OSL_DEVICE #define BSDL_UNROLL() // Do nothing #include #include struct BSDLConfig : public bsdl::BSDLDefaultConfig { // testrender won't do spectral render, just 3 channels covers RGB static constexpr int HERO_WAVELENGTH_CHANNELS = 3; struct Fast { static BSDL_INLINE_METHOD float cosf(float x) { return OIIO::fast_cos(x); } static BSDL_INLINE_METHOD float sinf(float x) { return OIIO::fast_sin(x); } static BSDL_INLINE_METHOD float asinf(float x) { return OIIO::fast_asin(x); } static BSDL_INLINE_METHOD float acosf(float x) { return OIIO::fast_acos(x); } static BSDL_INLINE_METHOD float atan2f(float y, float x) { return OIIO::fast_atan2(y, x); } static BSDL_INLINE_METHOD void sincosf(float x, float* s, float* c) { return OIIO::fast_sincos(x, s, c); } static BSDL_INLINE_METHOD float sinpif(float x) { return OIIO::fast_sinpi(x); } static BSDL_INLINE_METHOD float cospif(float x) { return OIIO::fast_cospi(x); } static BSDL_INLINE_METHOD float expf(float x) { return OIIO::fast_exp(x); } static BSDL_INLINE_METHOD float exp2f(float x) { return OIIO::fast_exp2(x); } static BSDL_INLINE_METHOD float logf(float x) { return OIIO::fast_log(x); } static BSDL_INLINE_METHOD float log2f(float x) { return OIIO::fast_log2(x); } static BSDL_INLINE_METHOD float log1pf(float x) { return OIIO::fast_log1p(x); } static BSDL_INLINE_METHOD float powf(float x, float y) { return OIIO::fast_safe_pow(x, y); } }; // Don't care for colorspaces/spectral static BSDL_INLINE_METHOD ColorSpaceTag current_color_space() { return ColorSpaceTag::sRGB; } static BSDL_INLINE_METHOD const JakobHanikaLut* get_jakobhanika_lut(ColorSpaceTag cs) { return nullptr; } }; ``` -------------------------------- ### Utility template naming example Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/CONTRIBUTING.md Example of a general utility class or template that follows standard library naming conventions (lowercase with underscores). ```cpp template shared_ptr; ``` -------------------------------- ### Class naming example Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/CONTRIBUTING.md Example of a class name that follows standard library conventions, using lowercase with underscores. ```cpp class scoped_mutex; ``` -------------------------------- ### Variable declarations: basic examples Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/src/doc/syntax.md Illustrates declaring variables with and without initializers, computed initializers, and declaring multiple variables of the same type in one statement. ```cpp float a; // Declare; current value is undefined float b = 1; // Declare and assign a constant initializer float c = a*b; // Computed initializer float d, e = 2, f; // Declare several variables of the same type ``` -------------------------------- ### Simple shader definition (hello.osl) Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/src/doc/testshade.md Defines a simple OSL shader that prints the sum of two parameters a and b. Used as the example for running testshade. ```cpp shader hello (float a = 0, float b = 1) { printf ("hello, a+b = %g\n", a+b); } ``` -------------------------------- ### Direct CMake build commands Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/AGENTS.md Direct CMake commands to configure, build, install, and run tests. By default, builds into `./build` and installs into `./dist`. ```bash cmake -B build -S . cmake --build build --target install ctest --test-dir build -R --output-on-failure ``` -------------------------------- ### Setup AI coding assistant Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/CONTRIBUTING.md Run after cloning to set up the AI coding assistant tool(s) you plan to use. Replace 'claude' with cursor, codex, opencode, copilot, or all. ```bash .agents/setup-agent claude # or: cursor, codex, opencode, copilot, all ``` -------------------------------- ### oslinfo: full example of using OSLQuery Source: https://github.com/academysoftwarefoundation/openshadinglanguage/blob/main/src/doc/oslquery.md Complete source of the oslinfo command-line utility, which prints a compiled shader's parameters (name, type, default values, and metadata). Includes helper functions for printing default values of string and integer-based parameters. ```cpp // Copyright Contributors to the Open Shading Language project. // SPDX-License-Identifier: BSD-3-Clause // https://github.com/AcademySoftwareFoundation/OpenShadingLanguage /* The code in this file is based somewhat on code released by NVIDIA as part of Gelato (specifically, gsoinfo.cpp). That code had the following copyright notice: Copyright 2004 NVIDIA Corporation. All Rights Reserved. and was distributed under the 3-clause BSD license. SPDX-License-Identifier: BSD-3-Clause */ /// /// /// Example program using OSLQuery /// ============================== /// /// This is the full text of `oslinfo`, a command-line utility that /// for any shader, will print out its parameters (name, type, default /// values, and metadata). /// /// ~~~~ ///