Unity3D Shader官方教程翻譯(三)----Shader語法:屬性
ShaderLab syntax: Properties
ShaderLab語法:屬性
Shaders can define a list of parameters to be set by artists in Unity's material inspector. The Properties block in the shader file defines them.
著色器可以由藝術家定義一個引數列表,這個引數值可以在Unity3D的材質檢索器中檢視。著色器中屬性塊定義了這些引數。
Syntax
Properties { Property [Property ...] }
Defines the property block. Inside braces multiple properties are defined as follows.
定義了1個屬性塊。括號內的屬性定義如下:
name ("display name", Range (min, max)) = number
Defines a float property, represented as a slider from min to max in the inspector.
定義了1個float屬性,範圍是在min到max之間的值,可以利用檢索器中對應的滑塊調節他們。
name ("display name", Color) = (number,number,number,number)
Defines a color property.
定義了一個顏色
name ("display name", 2D) = "name" { options }
Defines a 2D texture property.
定義了1個2D紋理
name ("display name", Rect) = "name" { options }
Defines a rectangle (non power of 2) texture property.
定義了1個矩形紋理屬性
name ("display name", Cube) = "name" { options }
Defines a cubemap texture property.
定義了1個cubemap紋理屬性
name ("display name", Float) = number
Defines a float property.
定義了1個float
name ("display name", Vector) = (number,number,number,number)
Defines a four component vector property.
定義了1個向量,該向量由4個分量組成。
Details
細節
Each property inside the shader is referenced by name (in Unity, it's common to start shader property names with underscore). The property will show up in material inspector as display name. For each property a default value is given after equals sign:
每個在Shader中的屬性是依據屬性的名字來引用的(在Unity3d中,通常屬性名是以下劃線開頭)。屬性的名字將在材質檢索器中顯示。每一個屬性的預設值為等號後的值。
For Range and Float properties it's just a single number.
Range和Float屬性僅僅是1個數字
For Color and Vector properties it's four numbers in parentheses.
Color和Vector屬性由4個數字組成
For texture (2D, Rect, Cube) the default value is either an empty string, or one of builtin default textures: "white", "black", "gray" or "bump".
紋理屬性(2D,Rect,Cube)的預設值是1個字串,或者是預設的內建紋理:"白色","黑色","灰色","凸點"
Later on in the shader, property values are accessed using property name in square brackets: [name].
要在Shader程式設計中訪問屬性可以用屬性名加方括號來訪問如:[name];
Example
例子
Properties {
// properties for water shader
_WaveScale ("Wave scale", Range (0.02,0.15)) = 0.07 // sliders滑塊
_ReflDistort ("Reflection distort", Range (0,1.5)) = 0.5
_RefrDistort ("Refraction distort", Range (0,1.5)) = 0.4
_RefrColor ("Refraction color", Color) = (.34, .85, .92, 1) // color顏色
_ReflectionTex ("Environment Reflection", 2D) = "" {} // textures紋理
_RefractionTex ("Environment Refraction", 2D) = "" {}
_Fresnel ("Fresnel (A) ", 2D) = "" {}
_BumpMap ("Bumpmap (RGB) ", 2D) = "" {}
}
Texture property options
紋理屬性選項
The options inside curly braces of the texture property are optional. The available options are:
紋理屬性的花括號內的選項是可選的。可用的選項是:
TexGen texgenmode 紋理座標自動生成模式
Automatic texture coordinate generation mode for this texture. Can be one of ObjectLinear, EyeLinear, SphereMap, CubeReflect, CubeNormal; these correspond directly to OpenGL texgen modes. Note that TexGen is ignored if custom vertex programs are used.
紋理座標自動生成模式。可以是ObjectLinear,EyeLinear , SphereMap, CubeReflect,CubeNormal之一,這些直接對應到OpenGL texgen模式的。注意:如果使用自定義的頂點程式,TexGen被忽略。
。
LightmapMode 光照模式
If given, this texture will be affected by per-renderer lightmap parameters. That is, the texture to use can be not in the material, but taken from the settings of the Renderer instead, see Renderer scripting documentation.
如果給定的,這種紋理將受到預渲染的光照引數影響。也就是說,這種紋理的使用效果不是取決於材質,而是取決於渲染設定。詳情請參考渲染指令碼檔案。
Example
// EyeLinear texgen mode example
Shader "Texgen/Eye Linear" {
Properties {
_MainTex ("Base", 2D) = "white" { TexGen EyeLinear }
}
SubShader {
Pass {
SetTexture [_MainTex] { combine texture }
}
}
}
由www.J2meGame.com原創,轉載請說明。
ShaderLab語法:屬性
Shaders can define a list of parameters to be set by artists in Unity's material inspector. The Properties block in the shader file defines them.
著色器可以由藝術家定義一個引數列表,這個引數值可以在Unity3D的材質檢索器中檢視。著色器中屬性塊定義了這些引數。
Syntax
Properties { Property [Property ...] }
Defines the property block. Inside braces multiple properties are defined as follows.
定義了1個屬性塊。括號內的屬性定義如下:
name ("display name", Range (min, max)) = number
Defines a float property, represented as a slider from min to max in the inspector.
定義了1個float屬性,範圍是在min到max之間的值,可以利用檢索器中對應的滑塊調節他們。
name ("display name", Color) = (number,number,number,number)
Defines a color property.
定義了一個顏色
name ("display name", 2D) = "name" { options }
Defines a 2D texture property.
定義了1個2D紋理
name ("display name", Rect) = "name" { options }
Defines a rectangle (non power of 2) texture property.
定義了1個矩形紋理屬性
name ("display name", Cube) = "name" { options }
Defines a cubemap texture property.
定義了1個cubemap紋理屬性
name ("display name", Float) = number
Defines a float property.
定義了1個float
name ("display name", Vector) = (number,number,number,number)
Defines a four component vector property.
定義了1個向量,該向量由4個分量組成。
Details
細節
Each property inside the shader is referenced by name (in Unity, it's common to start shader property names with underscore). The property will show up in material inspector as display name. For each property a default value is given after equals sign:
每個在Shader中的屬性是依據屬性的名字來引用的(在Unity3d中,通常屬性名是以下劃線開頭)。屬性的名字將在材質檢索器中顯示。每一個屬性的預設值為等號後的值。
For Range and Float properties it's just a single number.
Range和Float屬性僅僅是1個數字
For Color and Vector properties it's four numbers in parentheses.
Color和Vector屬性由4個數字組成
For texture (2D, Rect, Cube) the default value is either an empty string, or one of builtin default textures: "white", "black", "gray" or "bump".
紋理屬性(2D,Rect,Cube)的預設值是1個字串,或者是預設的內建紋理:"白色","黑色","灰色","凸點"
Later on in the shader, property values are accessed using property name in square brackets: [name].
要在Shader程式設計中訪問屬性可以用屬性名加方括號來訪問如:[name];
Example
例子
Properties {
// properties for water shader
_WaveScale ("Wave scale", Range (0.02,0.15)) = 0.07 // sliders滑塊
_ReflDistort ("Reflection distort", Range (0,1.5)) = 0.5
_RefrDistort ("Refraction distort", Range (0,1.5)) = 0.4
_RefrColor ("Refraction color", Color) = (.34, .85, .92, 1) // color顏色
_ReflectionTex ("Environment Reflection", 2D) = "" {} // textures紋理
_RefractionTex ("Environment Refraction", 2D) = "" {}
_Fresnel ("Fresnel (A) ", 2D) = "" {}
_BumpMap ("Bumpmap (RGB) ", 2D) = "" {}
}
Texture property options
紋理屬性選項
The options inside curly braces of the texture property are optional. The available options are:
紋理屬性的花括號內的選項是可選的。可用的選項是:
TexGen texgenmode 紋理座標自動生成模式
Automatic texture coordinate generation mode for this texture. Can be one of ObjectLinear, EyeLinear, SphereMap, CubeReflect, CubeNormal; these correspond directly to OpenGL texgen modes. Note that TexGen is ignored if custom vertex programs are used.
紋理座標自動生成模式。可以是ObjectLinear,EyeLinear , SphereMap, CubeReflect,CubeNormal之一,這些直接對應到OpenGL texgen模式的。注意:如果使用自定義的頂點程式,TexGen被忽略。
。
LightmapMode 光照模式
If given, this texture will be affected by per-renderer lightmap parameters. That is, the texture to use can be not in the material, but taken from the settings of the Renderer instead, see Renderer scripting documentation.
如果給定的,這種紋理將受到預渲染的光照引數影響。也就是說,這種紋理的使用效果不是取決於材質,而是取決於渲染設定。詳情請參考渲染指令碼檔案。
Example
// EyeLinear texgen mode example
Shader "Texgen/Eye Linear" {
Properties {
_MainTex ("Base", 2D) = "white" { TexGen EyeLinear }
}
SubShader {
Pass {
SetTexture [_MainTex] { combine texture }
}
}
}
由www.J2meGame.com原創,轉載請說明。
相關文章
- Unity3D Shader官方教程翻譯(四)----Shader語法:SubShaderUnity3D
- Unity3D Shader官方教程翻譯(一)Unity3D
- Unity3D Shader官方教程翻譯(二)Unity3D
- Unity3D 透明物體ShaderUnity3D
- ZooKeeper 官方教程[翻譯]
- [翻譯]CMAKE官方教程
- Unity3D中的shader基礎知識Unity3D
- 【GLSL教程】(三)在OpenGL中向shader傳遞資訊
- 【Unity3D Shader程式設計】之二 雪山飛狐篇:Unity的基本Shader框架寫法&顏色、光照與材質Unity3D程式設計框架
- opengl 教程(5) shader(2) uniform變數ORM變數
- Unity Shader 00 - 梳理 Unity Shader 的基本結構Unity
- Compute Shader
- Pyplot tutorial,Pyplot官方教程自翻譯
- Unity3D學習筆記3——Unity Shader的初步使用Unity3D筆記
- D3D9 Shader例項教程3D
- Unity開發--(三)Shader程式設計:寫一個shader讓圖片的背面不被剔除Unity程式設計
- Shader中的shader_feature與multi_compileCompile
- godot shader 升級Go
- 【Unity Shaders】Mobile Shader Adjustment—— 什麼是高效的ShaderUnity
- [翻譯]ElasticSearch官方文件-查詢語言Elasticsearch
- UE4 Shader 編譯以及變種實現編譯
- Compute Shader 簡介
- WebGL Shader 環境搭建Web
- OpenGL shader 程式基礎
- Cesium渲染模組之Shader
- Shader:常用結構體結構體
- Android著色器——ShaderAndroid
- 【Shader】ComputeScreenPos 的使用
- 寫一個Geometry Shader
- Godot 字型邊框shaderGo
- Max/MSP/Jitter 官方教程翻譯11 - 矩陣混合矩陣
- lxml官方入門教程(The lxml.etree Tutorial)翻譯XML
- Moya官方文件翻譯
- unity 統一替換shaderUnity
- Shader 函式視覺化函式視覺化
- 在 SwiftUI 中使用 Metal ShaderSwiftUI
- voltDB官方文件第三章翻譯
- 理解CSS屬性值語法CSS