利用者:DingTo/OpenShadingLanguage/Tutorial

提供: wiki
< 利用者:DingTo‎ | OpenShadingLanguage
2018年6月29日 (金) 05:51時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Introduction Tutorial

Some basic information for getting started with OSL in Blender.

First things first

  • Read the Language Specification (PDF) first, at least the basic chapters to get familiar with the syntax of the language and the data types.
  • The Script Node can be found inside the Add Node Menu (SHIFT+A) in the "Scripts" category.
  • You can write OSL shaders in Blenders own text editor or in any external text editor as well. After adding the Script Node, you can select your .osl source, an ID Text Block from within Blender (Intern) or an .osl file on your harddrive (Extern).

The basic structure of a shader

#include "stdosl.h"

shader-type shader-name ( optional-parameters )
{
    statements
}

A first working example

This simple shader will create one input and one output node socket, and simply pass the input to the output color.

#include "stdosl.h"

shader node_test(
	color ColIn = color(0.8, 0.6, 0.4),
        output color ColOut = color(0.8))
{
        ColOut = ColIn;
}