Creating Cubemaps in Unity3D
    
            
摘要:【Creating Cubemaps in Unity3D】1、在Editor目录下生成GenerateStaticCubemap.cs。 2、编写代码,生成一个继承于ScriptableWizard类。 wizard包含以下成员: Wizard入口设置如下: 3、Wizard回调函...
        
阅读全文
摘要:【Anisotropic Specular】 Anisotropic Specular(各向异性反射)模拟表面凹槽的方向性。就像CD表面一样。CD的表面凹槽是有方向的。 BlinnPhong中Specular强度的由N*H得计算得到,如下: 在Anisotropic的简单实现中,需要Ani...
        
阅读全文
摘要:【Failed to install *.apk on device *: timeout】 如果Android项目太大,则Eclipse在安装调试时可能会超时。 错误出现:连接真机调试的时候如果连接太久没响应就会出现timeout 解决方法:将timeout时间调长,默认是5000ms。 ...
        
阅读全文
摘要:【logcat】 The Android logging system provides a mechanism for collecting and viewing system debug output. Logs from various applications and portions o
        
阅读全文
摘要:【Android Debug Bridge】 ADB lets you communicate with an emulator instance or connected Android-powered device. ADB is a client-server program that inc
        
阅读全文
摘要:【DVI与VGA有什么区别】 DVI接口的传输信号采用全数字格式,与之对应的是采用模拟信号的VGA接口。 VGA和DVI的区别,首先VGA模拟信号的传输比较麻烦,首先是将电脑内的数字信号转换为模拟信号,将信号发送到LCD显示器,而显示器再将该模拟信号转换为数字信号,形成画面展示在大家面前,正因为...
        
阅读全文
摘要:【Solo and Mute】 Muting means a transition will be disabled. Soloed transtions are enabled and with respect to other transitions originating from the ...
        
阅读全文
摘要:【法线贴图原理】 如果法线处于世界坐标中的(world space),那称为world space normal。如果是处于物体本身局部坐标中的,那称为object space normal。 很容易想象,world space normal一旦从贴图里解压出来后,就可以直接用了,效率很高。但是...
        
阅读全文
摘要:【RimLight(轮廓光) - Shader】 RimLight指的是物体的轮廓光。效果如下: 轮廓光的强度通过 1.0 - dot(normal, eye_vector)来计算。使用这个公式,则指向camera的轮廓光强度会是0,垂直到camera的轮廓光强度是1,而背离的强度会是2。G...
        
阅读全文
摘要:【AttributeUsage】 System.AttributeUsage声明一个Attribute的使用范围与使用原则。 AllowMultiple和Inherited参数是可选的,所以此代码具有相同的效果: AttributeTarget的值可以参考1。部分可取值如下: 如...
        
阅读全文
摘要:【System.Diagnostics.Conditional】 指示编译器当特定的宏定义了时,才生成此方法的相应代码。只能应用于AttributeClass、Method。 参考:http://msdn.microsoft.com/zh-cn/library/system.diagnost...
        
阅读全文
摘要:【MonoDevelop Assembly Browser】 View -> Assembly Browser,通过此窗口可以查看Dll的反编译后的代码。 还有几款免费的替代产品可以使用, 虽然不及 .Net Reflector 成熟, 但是已经可以使用了, 它们是:dotPeekJetBr...
        
阅读全文
摘要:【年薪50万美金的工程师到底牛在哪里?-- 转】 年薪 50 万美金的工程师他们究竟做哪些事情,或是拥有哪些技术,让他们如此值钱?这些东西有办法“学”吗? 之前 Business Insider 出了一篇某个 Google 工程师拒绝年薪 50 万工作,因为 Google 每年附他 300 万美金的
        
阅读全文
摘要:【Binormal - 副法线】 Binormal是垂直于Normal、Tangent平面的直线。Normal、Binormal、Tangent三条线构成一个坐标系。参考:http://202.113.29.3/nankaisource/graphics/differential%20geomet...
        
阅读全文
摘要:【Fresnel Reflection】 One of the most used types of reflections is the Fresnel reflection.One of the most used surfaces of this type of effect is the ...
        
阅读全文
摘要:【Fresnel Reflection - 菲涅尔反射】 “菲涅尔”是一个人的名字,因为他发现了一个有关反射的光学现象,这个现象就用这个人的名字命名了。那么,是什么现象呢? 这就是反射/折射与视点角度之间的关系。 如果你站在湖边,低头看脚下的水,你会发现水是透明的,反射不是特别强烈;如果你看远处的湖
        
阅读全文
摘要:【NormalMap & CubeMap】 有时候我们需要CubeMap的环境反射也需要有凹凸信息,此时需要装将NormalMap与CubeMap结合。 因为要使用NormalMap,使用Property定义中必须有定义NormalMap: By using the INTERNAL_DA...
        
阅读全文
摘要:【Simple Cubemap Reflection】 Cubemap加在MainTex上,所以Property需要按如下定义: 注意_Cubemap的类型是CUBE。 使用Cubemap,需要计算反射向量,Unity内置的worldRefl是一个可以直接使用的反射向量。 反射向量的...
        
阅读全文
摘要:【求Half向量】 给定入射向量与视角向量。把入射向量与视角向量相加即可,如下: 前提是 lightDir、ViewDir 都是单位向量。
        
阅读全文
摘要:【Specular Mask Texture】 Specular Texture是一个Mask纹理,通过Mask纹理的texel可以控制每个像素的纹理。 在属性中添加Specular Mask Texture纹理。 在Surf函数中修改Mask: 下图是最后的结果:
        
阅读全文
摘要:【Phong Specular Shader】 如果物体离摄像机很远,或者不需要高精度镜面反射,则Phong模型适用。 Phong模型如下: 使用前必须指定使用自定义Phong。 【BlinnPhong Specular Shader】 前一篇博文中记录了Unity自带的BlinnPh...
        
阅读全文
摘要:【built-in SpecularType of Unity】1、声明变量。 注意并没有在Shader中声明_SpecColor,因为Lighting.cginc中已经帮我们声明。2、声明使用BlinnPhong光照模型。 3、最后将_SpecPower和Gloss给赋值。 Sp...
        
阅读全文
摘要:【Creating Procedural Textures】 由程序主生贴图,然后设置给Material。首先定义需要的数据: 在Start方法中完成初始化,注意设置的是_MainTex。 实现GenerateParabola方法,算的是到中点的距离除以半径的百分比: 【How it...
        
阅读全文
摘要:【NormalMapping】 法线贴图内的数据是法线,高度贴图内的数据是高度,不是一个东西。在ShaderLab中,UnpackNormal()分析的是法线贴图(注意不是高度贴图)。 可以看到,在GLES环境下及Mobile环境下,normal中存储的只是0-1的值。而UnpackNorm...
        
阅读全文
摘要:【使用BlendingTexture实现简单的Terrain】 BlendingTexture,就是一张纹理,纹理内存储的数据用于其它去处的Alpha通道value。例如以下四张图需要混合在Terrain表面: 我们可以将四张alpha灰度图组织成一张RGBA图: 为了完成混合纹理功能...
        
阅读全文
摘要:【UV-Sprite动画】 下文以单行Sprite纹理作为动画贴图。首先需要输入纹理宽度、Sprint数量、速度: 计算每个Sprite的像素宽与UV宽: 根据_Time,计算当前显示第几个Sprite: 最后,就是根据上述信息修改原有UV了。 UV-Sprite动画把计算完全...
        
阅读全文
摘要:【UV动画】 UV-Animatinoallows you to create effects such as waterfalls, rivers, lava flows, and so on. 首先,添加x、y速度属性。 还需要引用_MainTex的uv,如下: 使用内置的_...
        
阅读全文
摘要:【使用RampTexture实现BRDF效果】 BRDF stands for bidirectional reflectance distribution function. While that is a mouthful, it simply means the way in which l...
        
阅读全文
摘要:【RampTexture】 RampTexture(渐变纹理),可以是1D/2D纹理. This allows you to accentuate the surface's colors to fake the effects of more bounce light or a more ad...
        
阅读全文
摘要:【Half Lambert】 Half Lambert was a technique created by Valve as a way of getting the lighting to show the surface of an object in low-light areas. It 
        
阅读全文
摘要:【SurfaceShader自定义光照】1、在pragma中添加自定义光照函数名: #pragma surface surf BasicDiffuse2、实现自定义光照函数。下面就是Lambert光照模型。也是Lambert算法。 _LightColor0是Unity提供的变量。使用该算法的...
        
阅读全文
摘要:【What is _MainTex_ST ?】 在Unity自带的Unlit/Texture中,有引用到float4 _MainTex_ST,如下:// Unlit shader. Simplest possible textured shader.// - no lighting// - no ...
        
阅读全文
摘要:【C# Enum,Int,String的互相转换】1、Enum-->String(1)利用Object.ToString()方法:如Colors.Green.ToString()的值是"Green"字符串;(2)利用Enum的静态方法GetName与GetNames: public static...
        
阅读全文
摘要:【Plugins in Unity】 In Unity, you normally use scripts to create functionality but you can also include code created outside Unity in the form of aPlug
        
阅读全文
摘要:【Mono在Full AOT模式下的限制】 调试时遇到一个Mono运行时异常:ExecutionEngineException: Attempting to JIT compile method '...' while running with --aot-only. 最后发现原因是使用了泛型接...
        
阅读全文
摘要:【雾化】 雾浓度在[0,1]间取值,控制雾化程度。 和光的衰减一样,通过把雾分为3段进行处理,当距离小于D_min时,雾系数为0,当距离大于D_max时,雾系数为1,在2者中间时,则进行插值。 雾的浓度即是插值得到的这个系数[0,1]。公式如下: C_fogged = C_lit + f...
        
阅读全文
摘要:【Matrix】 通常像下面这样定义Matrix:int1x1 iMatrix; // integer matrix with 1 row, 1 columnint4x1 iMatrix; // integer matrix with 4 rows, 1 columnint1...
        
阅读全文