最近在学习Unity3d中的shader编程,能找到的中文资料比较少,于是,尝试翻译一下wiki Books上的资料,以方便其他跟我一样的入门学习者。由于是第一次翻译技术资料,经验不足,难免出错,请路过的大神们批评指正,共同帮助我等新手少走弯路,谢谢。

下面翻译开始:

(原文:https://en.wikibooks.org/wiki/Cg_Programming/Unity)

Cg programming in the game engine Unity is considerably easier than Cg programming for an OpenGL or Direct3D application. Import of meshes and images (i.e. textures) is supported by a graphical user interface; mipmaps and normal maps can be computed automatically; the most common vertex attributes and uniforms are predefined; OpenGL and Direct3D states can be set by very simple commands; etc.

Unity引擎中的Cg编程,要比OpenGL或者Direct3D应用中的Cg编程容易许多。网格和图片的导入是被图形用户界面所支持;mipmaps和法线贴图能被自动计算;最平常的顶点属性和规范也被预定义好了;OpenGL和Direct3D语句能被很简单的指令所设置;等等。

Preliminaries(准备)

A free version of Unity can be downloaded for Windows and MacOS at Unity's download page. All of the included tutorials work with the free version. Three points should be noted:

Unity下载页面中,可以下载到针对Windows和Mac平台的免费版本的Unity软件。下面所有的教程都可以用免费版的Unity来运行。请注意一下三点:

  • First, this part assumes that readers are somewhat familiar with Unity. If this is not the case, readers should consult the first three sections of Unity's User Guide [1] (Unity Basics, Building Scenes, Asset Import and Creation).

首先,读者们需要对Unity有了一些熟悉,否则,读者应该考虑先去学习一下Unity的用户指导的前三部分(Unity基础、建立场景、资源的导入和创建)。

  • Second, Unity doesn't distinguish between Cg (the shading language by Nvidia) and HLSL (the shading language in Direct3D) since the two languages are very similar; thus, most of these tutorials also apply to HLSL.

其次,Unity对于Cg(Nvidia开发的着色器语言)和HLSL(Direct3D的着色器语言)不进行区分,由于这两种语言太相似了;因此,这些教程中的大多数也可以适用于HLSL.

  • Furthermore, Cg is documented by Nvidia's Cg Tutorial and Nvidia's Cg Language Specification. However, these descriptions are missing the details specific to Unity. On the other hand, Unity's shader documentation [2] focuses on shaders written in Unity's own “surface shader” format, while the documentation of shaders in Cg/HLSL is very limited [3]. Thus, learning Cg programming in Unity without prior knowledge of Cg can be rather difficult. This wikibook tries to close this gap by providing an introduction to Cg programming in Unity without requiring prior knowledge of Cg.

此外,虽然Cg语言被编写在Nvidia的Cg教程Nvidia的Cg语言说明书中,然而,这些描述是没有针对Unity平台的特殊细节的。另一方面,Unity自己的着色器文档,主要关注的是Unity自己的表面着色器的写法,其中关于Cg/HLSL的说明是非常有限的。因此,如果没有对于Cg语言的预先学习,就来学习Unity中的Cg编程,是有一定难度的。本套教程试图在没有Cg语言预先学习的情况下,通过对Unity中的Cg编程的介绍,来处理这个困难。

Tutorials(教程)

Note that the tutorials assume that you read them in the order in which they are presented here, i.e. each tutorial will assume that you are familiar with the concepts and techniques introduced by previous tutorials. If you are new to Cg or Unity you should at least read through the tutorials in the “Basics” section. (Now you are warned!)

注意:本套教程建议你按照下面所写的顺序来阅读,每一节课都假设你对之前课程里介绍的概念和技术已经熟悉了。如果你是Cg或者Unity的新手,那么你一定要阅读教程中的“基础”部分。

Basics(基础)

  • Minimal Shader(about shaders, materials, and game objects)

    最小的着色器(关于着色器、材质和游戏物体)

  • RGB Cube (about vertex output parameters)

    红绿蓝盒子(关于顶点输出参数)

  • Debugging of Shaders (about vertex input parameters)

    着色器的debugging(关于顶点输入参数)

  • Shading in World Space (about uniforms)

    世界空间中的着色(关于统一)

Transparent Surfaces(透明表面)

  • Cutaways (about discarding fragments and triangle-face culling)
  • Transparency (about blending)
  • Order-Independent Transparency (about order-independent blending)
  • Silhouette Enhancement (about transforming normal vectors)

(未完待续。。。)

(译)Cg Programming/Unity(Cg编程/Unity)的更多相关文章

  1. Unity GUI编程

    脚本语言:C# 附上一张图说明Unity GUI编程中可用的控件:(可能有遗漏) 下面列出一些例子来说明: 1.Groups : 在固定Layout模式中起到组织可用项的功能,它让你在屏幕的一个区域中 ...

  2. 【Unity Shader】Unity Chan的卡通材质

    写在前面 时隔两个月我终于来更新博客了,之前一直在学东西,做一些项目,感觉没什么可以分享的就一直没写.本来之前打算写云彩渲染或是Compute Shader的,觉得时间比较长所以打算先写个简单的. 今 ...

  3. Java实战之03Spring-03Spring的核心之AOP(Aspect Oriented Programming 面向切面编程)

    三.Spring的核心之AOP(Aspect Oriented Programming 面向切面编程) 1.AOP概念及原理 1.1.什么是AOP OOP:Object Oriented Progra ...

  4. Unity学习笔记(二)——第一个Unity项目Hello Unity

    保留版权,转载请注明出处:http://blog.csdn.net/panjunbiao/article/details/9318811 在这一篇文章里,参照宣雨松的<Unity 3D游戏开发& ...

  5. Unity cg vertex and fragment shaders(二)

    着色器的一般结构: Shader "MyShader/MyShaderName" { Properties { // ... properties here ... } SubSh ...

  6. Unity cg vertex and fragment shaders(一)

    cg片段 Cg程序片段写CGPROGRAM和ENDCG之间 开始时的片段可以作为#pragma语句编译指令 Pass { // ... the usual pass state setup ... C ...

  7. 解读Unity中的CG编写Shader系列4——unity中的圆角矩形shader

    上篇文章中我们掌握了表面剔除和剪裁模式 这篇文章将利用这些知识实现一个简单的,可是又非经常常使用的样例:把一张图片做成圆角矩形 例3:圆角矩形Shader 好吧我承认在做这个样例的时候走了不少弯路,因 ...

  8. [转]解读Unity中的CG编写Shader系列4——unity中的圆角矩形shader

    上篇文章中我们掌握了表面剔除和剪裁模式这篇文章将利用这些知识实现一个简单的,但是又很常用的例子:把一张图片做成圆角矩形 例3:圆角矩形Shader好吧我承认在做这个例子的时候走了不少弯路,由于本人对矩 ...

  9. [Unity] Cg标准函数库

随机推荐

  1. BZOJ_1025_[SCOI2009]游戏_DP+置换+数学

    BZOJ_1025_[SCOI2009]游戏_DP+置换 Description windy学会了一种游戏.对于1到N这N个数字,都有唯一且不同的1到N的数字与之对应.最开始windy把数字按 顺序1 ...

  2. ACM学习历程—ZOJ3471 Most Powerful(dp && 状态压缩 && 记忆化搜索 && 位运算)

    Description Recently, researchers on Mars have discovered N powerful atoms. All of them are differen ...

  3. Jenkins持续集成环境搭建

    1部署Jenkins Jenkins部署很简单,只需建立一个新应用,将Jenkins的war包部署进去,再分配好权限就可以了. 1.1创建应用 建立一个新Nginx应用:jenkins.com 1.2 ...

  4. 批处理中格式化Date

    @Echo Off Set _Date=%date% If "%_Date%A" LSS "A" (Set _NumTok=1-3) Else (Set _Nu ...

  5. SQL Server 将查询的结果生成insert语句

    1.将查询的结果插入到一张新表(yangTest 表系统会自动生成)select Area, District, RoadName, StationName, PathDirection, Stati ...

  6. docker 学习(七) docker 容器挂载

    1:docker的默认存放位置: $ sudo su # cd /var/lib/docker # ls -F containers/ graph/ repositories volumes/     ...

  7. 三 Flask+ MySQL 数据库操作

    一: __init__.py作用: __init__.py 文件的作用是将文件夹变为一个Python模块,Python 中的每个模块的包中,都有__init__.py 文件.通常__init__.py ...

  8. win7 64位搭建Mantis 缺陷管理系统(2)

    建立Bug数据库 1. 右键Windows托盘的图标,选择“Local Web”,(或者在IE地址中输入“http://127.0.0.1/”)可看到如下页面: 2. 点击选择“mantis”,进入页 ...

  9. C#父窗体右击事件实现

    之前在博问上提问过,没人回答啊,豆太少没人权? 没注册钩子的话根本没办法弹出右键菜单啊,因为在父窗体内有一个容器,所以鼠标在右击时是无法触发窗体的mousedown事件的,即使把KeyPreview设 ...

  10. Fluuter常遇到的问题

    The ADB binary found at XX is obsolete and has seriousperformance problems with the Android Emulator ...