Unity3D Shader官方教程翻譯(二)
ShaderLab語法:Shader
Shader is the root command of a shader file. Each file must define one (and only one) Shader. It specifies how any objects whose material uses this shader are rendered.
Shader是一個shader的檔案的根命令。每個檔案必須定義一個(只有一個) Shader。它指定有哪些物體的材質使用這個shader進行渲染。
Syntax
語法
Shader "name" { [Properties] Subshaders [Fallback] } Defines a shader. It will appear in the material inspector listed under name. Shaders optionally can define a list of properties that show up as material settings. After this comes a list of SubShaders, and optionally a fallback.
Shader "name" { [Properties] Subshaders [Fallback] } 定義了一個著色器。它的名字將會出現在Unity3d材質檢索器中並以定義的name顯示。Shader可以為設定材質的列表有選擇地定義屬性顯示。在此之後可以定義一個SubShaders列表,及一個可選的返回值(Fallback指當該Shader無法工作時候,返回一個可以正常工作的備用渲染處理)。
Details
細節
Properties 屬性
Shaders can have a list of properties. Any properties declared in a shader are shown in the material inspector inside Unity. Typical properties are the object color, textures, or just arbitrary values to be used by the shader.
著色器可以有一個屬性列表。在著色器中宣告的任何屬性都將在Unity3D材質檢索器中顯示。典型的屬性是物件的顏色,紋理,或一個將要在渲染中使用的任意值。
SubShaders & Fallback 子著色器及備用渲染處理
Each shader is comprised of a list of sub-shaders. You must have at least one. When loading a shader, Unity will go through the list of subshaders, and pick the first one that is supported by the end user's machine. If no subshaders are supported, Unity will try to use fallback shader.
每個著色器由一系列的子著色器組成。你必須至少指定一個子著色器。當載入一個shader時候,Unity3D將通過subshaders列表,並在列表中選擇第一個可以被終端使用者機器所支援的子著色器。如果沒有一個子著色器被支援,Unity3D將嘗試使用備用的著色器進行渲染處理[Fallback]。
Different graphic cards have different capabilities. This raises an eternal issue for game developers; you want your game to look great on the latest hardware, but don't want it to be available only to those 3% of the population. This is where subshaders come in. Create one subshader that has all the fancy graphic effects you can dream of, then add more subshaders for older cards. These subshaders may implement the effect you want in a slower way, or they may choose not to implement some details.
不同的顯示卡具有不同的功能。這就給遊戲開發商提出了一個永恆的問題,你想你的遊戲,在最新的硬體上表現得十分出色,但不希望它僅僅提供給那些僅佔人口3%的人使用。這就是subshaders的意義。建立一個Subshader給那些牛B的顯示卡使用,同時建立更多的Subshader給老式顯示卡使用,讓你的遊戲相容最多的顯示卡。這些subshaders可以實現不同的效果在不同的顯示卡上。
Examples
Here is one of the simplest shaders possible:
這是1個最簡單的Shader例子
// colored vertex lighting
Shader "Simple colored lighting" {
// a single color property 只有1個顏色屬性
Properties {
_Color ("Main Color", Color) = (1,.5,.5,1)
}
// define one subshader 定義1個子著色器
SubShader {
Pass {
Material {
Diffuse [_Color]
}
Lighting On
}
}
}
This shader defines a color property _Color (that shows up in material inspector as Main Color) with a default value of (1, 0.5, 0.5, 1). Then a single subshader is defined. The subshader consists of one Pass that turns on vertex lighting and sets up basic material for it.
這個shader定義顏色屬性的預設值(1,0.5,0.5,1)_Color(將在Unity3D的材質檢索器中作為主要顏色屬性顯示)。然後一個單一的subshader定義。該subshader組成一個渲染通道,開啟頂點照明,並設定了它的基本材質屬性。
由www.J2meGame.com精心原創,轉載請說明。http://www.j2megame.com/html/xwzx/ty/3303.html
Shader is the root command of a shader file. Each file must define one (and only one) Shader. It specifies how any objects whose material uses this shader are rendered.
Shader是一個shader的檔案的根命令。每個檔案必須定義一個(只有一個) Shader。它指定有哪些物體的材質使用這個shader進行渲染。
Syntax
語法
Shader "name" { [Properties] Subshaders [Fallback] } Defines a shader. It will appear in the material inspector listed under name. Shaders optionally can define a list of properties that show up as material settings. After this comes a list of SubShaders, and optionally a fallback.
Shader "name" { [Properties] Subshaders [Fallback] } 定義了一個著色器。它的名字將會出現在Unity3d材質檢索器中並以定義的name顯示。Shader可以為設定材質的列表有選擇地定義屬性顯示。在此之後可以定義一個SubShaders列表,及一個可選的返回值(Fallback指當該Shader無法工作時候,返回一個可以正常工作的備用渲染處理)。
Details
細節
Properties 屬性
Shaders can have a list of properties. Any properties declared in a shader are shown in the material inspector inside Unity. Typical properties are the object color, textures, or just arbitrary values to be used by the shader.
著色器可以有一個屬性列表。在著色器中宣告的任何屬性都將在Unity3D材質檢索器中顯示。典型的屬性是物件的顏色,紋理,或一個將要在渲染中使用的任意值。
SubShaders & Fallback 子著色器及備用渲染處理
Each shader is comprised of a list of sub-shaders. You must have at least one. When loading a shader, Unity will go through the list of subshaders, and pick the first one that is supported by the end user's machine. If no subshaders are supported, Unity will try to use fallback shader.
每個著色器由一系列的子著色器組成。你必須至少指定一個子著色器。當載入一個shader時候,Unity3D將通過subshaders列表,並在列表中選擇第一個可以被終端使用者機器所支援的子著色器。如果沒有一個子著色器被支援,Unity3D將嘗試使用備用的著色器進行渲染處理[Fallback]。
Different graphic cards have different capabilities. This raises an eternal issue for game developers; you want your game to look great on the latest hardware, but don't want it to be available only to those 3% of the population. This is where subshaders come in. Create one subshader that has all the fancy graphic effects you can dream of, then add more subshaders for older cards. These subshaders may implement the effect you want in a slower way, or they may choose not to implement some details.
不同的顯示卡具有不同的功能。這就給遊戲開發商提出了一個永恆的問題,你想你的遊戲,在最新的硬體上表現得十分出色,但不希望它僅僅提供給那些僅佔人口3%的人使用。這就是subshaders的意義。建立一個Subshader給那些牛B的顯示卡使用,同時建立更多的Subshader給老式顯示卡使用,讓你的遊戲相容最多的顯示卡。這些subshaders可以實現不同的效果在不同的顯示卡上。
Examples
Here is one of the simplest shaders possible:
這是1個最簡單的Shader例子
// colored vertex lighting
Shader "Simple colored lighting" {
// a single color property 只有1個顏色屬性
Properties {
_Color ("Main Color", Color) = (1,.5,.5,1)
}
// define one subshader 定義1個子著色器
SubShader {
Pass {
Material {
Diffuse [_Color]
}
Lighting On
}
}
}
This shader defines a color property _Color (that shows up in material inspector as Main Color) with a default value of (1, 0.5, 0.5, 1). Then a single subshader is defined. The subshader consists of one Pass that turns on vertex lighting and sets up basic material for it.
這個shader定義顏色屬性的預設值(1,0.5,0.5,1)_Color(將在Unity3D的材質檢索器中作為主要顏色屬性顯示)。然後一個單一的subshader定義。該subshader組成一個渲染通道,開啟頂點照明,並設定了它的基本材質屬性。
由www.J2meGame.com精心原創,轉載請說明。http://www.j2megame.com/html/xwzx/ty/3303.html
相關文章
- Unity3D Shader官方教程翻譯(一)Unity3D
- Unity3D Shader官方教程翻譯(三)----Shader語法:屬性Unity3D
- Unity3D Shader官方教程翻譯(四)----Shader語法:SubShaderUnity3D
- ZooKeeper 官方教程[翻譯]
- [翻譯]CMAKE官方教程
- Pyplot tutorial,Pyplot官方教程自翻譯
- Max/MSP/Jitter 官方教程翻譯11 - 矩陣混合矩陣
- Moya官方文件翻譯
- docker官方文件翻譯3Docker
- docker官方文件翻譯4Docker
- rabbitmq 官方文件翻譯-2MQ
- docker官方文件翻譯5Docker
- docker官方文件翻譯2Docker
- docker官方文件翻譯1Docker
- Core Foundation 官方文件翻譯
- (二)Spring Boot 起步入門(翻譯自Spring Boot官方教程文件)1.5.9.RELEASESpring Boot
- TypeScript 官方手冊翻譯計劃【二】:普通型別TypeScript型別
- HTTPie 官方文件中文翻譯版HTTP
- Flutter-Cookbook 非官方翻譯Flutter
- BBNorm官方指導文件翻譯ORM
- [翻譯]ElasticSearch官方文件-簡介Elasticsearch
- Redis-py官方文件翻譯Redis
- Akka官方文件翻譯:Cluster Specification
- ReactiveCocoa 4 官方文件翻譯React
- Max/MSP/Jitter 官方教程翻譯05 - 矩陣的數學運算矩陣
- Python heapq模組官方文件翻譯Python
- Unity3D 透明物體ShaderUnity3D
- OpenCV翻譯專案總結二——Mat翻譯OpenCV
- Max/MSP/Jitter 官方教程翻譯12 - Chromakeying 視訊去背景合成
- ExoPlayer的使用與解析(官方文件翻譯)
- [翻譯]ElasticSearch官方文件-資料的修改Elasticsearch
- Matlab最新的官方文件中文翻譯Matlab
- [翻譯]ElasticSearch官方文件-查詢語言Elasticsearch
- 【Tomcat 6.0官方文件翻譯】—— 簡介Tomcat
- PendingIntent 是個啥?官方文件描述的很到位。我給翻譯翻譯Intent
- Dubbo官方入門Demo(翻譯自http://dubbo.io/主頁入門教程)HTTP
- 歡迎參與 KubeVela 官方文件翻譯活動
- 組複製官方翻譯四、MonitoringGroupReplication