[Unity Shader] 3D模型的简单属性
每个3D对象是由顶点和面的。这被称为一个网格(Mesh)。每个顶点有一个归一化的“normal”的向量,表示连接到该顶点的面的方向。这对于计算光照来说很重要。当计算漫反射和镜面反射的照明,normal向量用于确定所述光与3d物体的表面之间的角度。
下面是用于计算在一个物体表面上的每个点的颜色,以提供所有的值之间的关系的一个粗略的公式的一个极端的简化。这些都不是实际使用的方程式。 distance_to_object是在光源和物体与角之间的距离是在表面与光源之间的角度:
diffuse = object_diffuse * light_diffuse / (distance_to_object * angle);
ambient = object_ambient * light_ambient;
emissive = object_emissive;
specular = object_specular * light_specular;
final_color =(diffuse + ambient +emissive)* object_texture+specular;
正如你所看到的,对象的最终颜色实际上是许多不同的灯光产生的效果的混合体。
简单介绍:
diffuse:最常用的颜色分量。变暗的表面点的距离的光(阴影)。如果衰减设置你的光源,当对象远离该光漫反射值将减小。扩散是主要的颜色值的后顾之忧。为材料的漫反射颜色是可见的,则必须具有至少一个光与非黑色漫反射颜色的图像,并且光必须在对象物的摄像机的一侧。作为与环境和自发光颜色,如果存在纹理,这会通过在纹理颜色相乘,否则这是因为如果它有一个白色的纹理。
ambient:创建具有光从四面八方打你的对象同样的效果。对于材料的环境颜色是可见的,则必须具有至少一个光带中的图象的非黑色环境色。为了确保没有黑边,以你的对象,尝试在场景中设置一个光源的环境值(0.1,0.1,0.1)和你的对象的环境价值等于其漫反射值(设置“颜色”参数为方便本)。这是理想的快速建立,只有一个光源的场景。如弥漫性和自发光颜色,如果存在纹理,这会通过在纹理颜色相乘,否则这是因为如果它有一个白色的纹理。
emissive:如果你想,即使没有灯光,或者如果你只是想有一点光彩添加到您的对象,请将此值设置为可见的对象。这具有作为环境确实只是它不要求有在发射环境光的场景的光相同的效果。如弥漫性和环境的颜色,如果存在纹理,这会通过在纹理颜色相乘。发光颜色并不实际光发射到其它的目的,否则这是因为如果它有一个白色的纹理。
specular:将此值设置将使你的对象或多或少有光泽。对于一个目的是具有镜面反射,该对象及所述光(多个)必须具有此值设为非黑色。对象也有一个“电源”组件的镜面反射,影响光泽的宽度。较低的值会产生小的镜面反射,而较大的值将拓宽反映。一个非常漂亮的效果是有4个或5个灯光在场景中随意放在身边每一个不同颜色的镜面,和你的对象的高光设置为白色(1.0,1.0,1.0)。尽量在5〜100的功率值要得到充分发挥作用,你应该有你的对象绕。材质有镜面高光无影响。
texture:纹理映射到你的物体表面的图像。对于每个画面的像素表示的对象,对每个颜色分量(红,绿,蓝),我们首先计算使用漫反射,环境和自发光亮度,再乘上的纹理在该像素的颜色。镜面高,如果有任何,然后加入到所得到的颜色值。如果有质感,你通常要设置的漫反射和环境为白色。如果你想纹理展现原样,没有任何阴影,设置漫反射和环境为黑色,并设置发光为白色。
alpha:阿尔法决定物体最终颜色的透明度。它是在0.0(透明)到1.0(不透明)的值。如果材料具有纹理,纹理的alpha通道将覆盖材质的α值。
color | This is both the diffuse and ambient color of your object. It is merely a convenient way of setting both at the same time. See diffuse and ambient below for more detail. |
diffuse | This is the diffuse float_color value for a material on your object. This parameter can be set to 3 floats (red, green, blue) or 3 floats and an integer (red, green, blue, material_index). Objects can have multiple materials, one for each part of the object (cubes have six materials, one for each face). If you don't specify a material_index, you will be setting the color for all materials in the object. You can set an entire cube to blue by setting its color to (0.0, 0.0, 1.0). Color component values (red, green and blue) should be between 0.0 and 1.0, though using values greater than 1 can make the object brighter in darkly lit scenes. When calculating the color and shading of an object, we take each light source within range and cumulatively multiply their diffuse and ambient colors by the diffuse and ambient colors of the object respectively. The diffuse light is adjusted for attenuation (distance to light) and the angle between the surface and the light (on a per vertex basis using vertex normals) while ambient light is NOT adjusted for distance or angle. Emissive is then added to the diffuse and ambient values. If there is a texture, it will be adjusted by the sum of the lit diffuse, ambient and emissive values. So setting diffuse and ambient or emissive color values to (1, 0, 0) will eliminate all greens and blues from the displayed texture. Then the calculated lit specular value is added to produce the final shading for the D3D Picture Part. Black is (0.0, 0.0, 0.0). White is (1.0, 1.0, 1.0). |
ambient | This is the ambient float_color value for a material on your object. This parameter can be set to 3 floats (red, green, blue) or 3 floats and an integer (red, green, blue, material_index). Color component values (red, green and blue) should be between 0.0 and 1.0, though using values greater than 1 can make the object brighter in darkly lit scenes. When calculating the color and shading of an object, we take each light source within range and cumulatively multiply their diffuse and ambient colors by the diffuse and ambient colors of the object respectively. The diffuse light is adjusted for attenuation (distance to light) and the angle between the surface and the light (on a per vertex basis using vertex normals) while ambient light is NOT adjusted for distance or angle. Emissive is then added to the diffuse and ambient values. If there is a texture, it will be adjusted by the sum of the lit diffuse, ambient and emissive values. So setting diffuse and ambient or emissive color values to (1, 0, 0) will eliminate all greens and blues from the displayed texture. Then the calculated lit specular value is added to produce the final shading for the D3D Picture Part. Black is (0.0, 0.0, 0.0). White is (1.0, 1.0, 1.0). |
emissive | This is the emissive float_color value for a material on your object. Emissive color is similar to ambient color, except that it does not require that any light be in the picture. An object with an emissive color of white and no texture will appear pure white in your picture. This parameter can be set to 3 floats (red, green, blue) or 3 floats and an integer (red, green, blue, material_index). Color component values (red, green and blue) should be between 0.0 and 1.0. Black is (0.0, 0.0, 0.0). White is (1.0, 1.0, 1.0). |
specular | This is the specular float_color value and power for a material on your object. Specular is made up of a float_color (red, green, blue) and a Power component. The Power component of specularity adjusts the sharpness of the highlights. A larger power value creates sharper specular highlights, making the surface appear to be quite shiny. Smaller values increase the area of the effect, creating a dull reflection that makes the surface look frosty. To make an object truly matte, set the power member to zero and the color in specular to black. Powers usually range between 0 and 100 or so. Specular highlights are affected by attenuation. Specular is independent from diffuse, ambient and emissive, and requires that the light have a non-zero specular value. The specular highlights are added to the lit diffuse, ambient and emissive values to get the final displayed color. Specular is an independent system This can be either 4 floats (red, green, blue, power) or 4 floats and 1 int (red, green, blue, power, material_index). Setting specular to anything other than black will incur a slight performance hit for each call to picture.present(). |
alpha | This is the alpha value for a material on your object. Alpha is a float which should be between 0.0(transparent) and 1.0(opaque). A value of 0.5 will be half transparent, meaning that whatever is behind this object (given that what is behind is drawn BEFORE this object) will contribute to 50% of the final color. |
transparent_color | The transparent_color color is used by the load_texture() method in sdl. It is 3 ints (red, green, blue). Any texture loaded by the load_texture() method in pcl will have this color set to transparent (an alpha of 0). When loading a mesh, the textures loaded during that process will have this transparent_color applied to them. To conserve video memory, we recommended that you create Texture objects and apply them to your D3D Picture Parts manually in order to reuse the same texture in multiple places. |
mesh_texture | Texture to apply to the object. The material_index is optional. Create a named Texture object in sdl above the D3D Picture Part definition and then apply it to objects by setting this value. |
mesh_scale | Scale modifier. Takes three floats (x, y, z). Will scale an object along three axes. A scale of anything other than (1.0, 1.0, 1.0) will incur a slight performance penalty when rendering. If you object is one of the built in D3D Picture Parts (i.e. cone, cuboid, cylinder, mesh, plane, sphere), it is better to size your object beforehand to the desired size. If you are loading an 3d object from a file using the mesh picture part, it is better to use scale_factor, which applies a one time scaling to the mesh upon loading. If you plan to frequently scale your D3D Picture Part during animation, mesh_scale and the set_scale() method would be more appropriate since the scale_mesh() method can incur a slight one time hit to performance. |
description | Description of this object. |
[Unity Shader] 3D模型的简单属性的更多相关文章
- 如何修改3D模型的原子属性
Chem3D是专门用于绘制化学三维模型和进行计算化学数据的ChemOffice组件,在三维模型中每个原子都有众多属性,比如原子类型.原子符号.原子编号以及原子颜色等等.掌握Chem 3D模型的原子属性 ...
- 修改Chem 3D模型的化学键属性的方法有哪些
很多的用户在绘制化学图形过程中发现很多的图形都是立体结构的,这个时候就需要用Chem3D,它是ChemOffice的核心组件之一,在绘制立体模型和计算化学数据方面具有不可替代的作用.虽然ChemDra ...
- Unity导入3D模型的过程与方法
一.介绍 资源是游戏开发中的原材料,也就是组成游戏的模块. Unity只是一个游戏开发引擎,而并不是一个资源开发软件.这就意味着在游戏中需要的资源通常是由一些设计者使用其他软件开发出来的,然后设计者会 ...
- unity下3d模型的透明处理
1.若只是改变模型的透明度:点击模型,在Inspector中可以看到很多模型的属性.找到要改变透明度的地方,更改shader渲染的方式选中Transparent(透明度)的diffuse,之后调节Ma ...
- Unity shader 护盾shield的简单实现
先上效果图 shader所用的贴图资源 扰动 直接对uv进行变换就可以了,记得首先把六边形格子地图的Tilling调高点 先预先调成合适大小的六边形,然后repeat铺满整个护盾 // Tiles a ...
- Unity Shader 获取模型空间坐标
CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma ...
- UNITY把3D模型显示在UI层级上的思路
一般UI是处理于显示最高层级的, 因此这里的做法是 使用镜子效果,做镜子可使用renderTexture 然后启用一个摄像机对renderTexture进行数据填充, 然后在ui上使用Raw Imag ...
- 【Unity Shader】Shader基础
目录 Chapter3 Unity Shader 基础 Chapter3 Unity Shader 基础 概述 在Unity需要材质(Material)与Unity Shader配合使用来达到满意的效 ...
- QT QML 3D模型查看器
原文链接:http://amin-ahmadi.com/2018/01/28/viewing-3d-models-using-qt/ 本文使用QT Quick中的Scene3D QML类型来查看3D模 ...
随机推荐
- 转: Windows如何打开和使用事件查看器管理计算机
方法/步骤 1 右键单击"我的电脑"(win8中名称为"这台电脑.This Computer"),选择"管理",点击. 步骤阅读 2 出 ...
- gSoap工具wsdl2h及soapcpp2指令汇总
gSoap开发包的下载地址http://sourceforge.net/projects/gsoap2,在bin目录下提供了两个工具: 1:wsdl2h:The gSOAP wsdl2h tool i ...
- ubuntu12.04的NFS配置
安装nfs: #sudo apt-get install nfs-kernel-server ubuntu12.04中的已经是最新版本了,无需安装 打开/etc/exports文件,在末尾加入: /h ...
- android TextView 之探究
1:插入图片替换 //代码 mSubjectDetailView = (TextView) findViewById(R.id.subject_detail); CharSequence text = ...
- aspx基础开始
<%@ Page Language="C#" Debug="true" trace="false" validateRequest=& ...
- win10系统安装oracle11g时遇到INS-13001环境不满足最低要求
升级win10系统之后,需要重新安装Oracle,因为在安装Oralce11g时,使用64位的会出现各种不兼容问题,我每次安装都是使用32位的数据库. 在安装时点击setup.exe之后,出现了:[I ...
- springframwork历史版本下载地址
http://sourceforge.net/projects/springframework/files/springframework-2/
- Struts2 语法--异常处理
1. UsersDAO.java里产生一个例外: System.out.println(1/0); 2. 调用DAO的UsersAction1.java 的execute方法, 加抛异常: publi ...
- 参数修饰符ref,out ,params的区别
参数修饰符ref,out ,params的区别 C#中有三个关键字-ref,out ,params,可是这三个之间的区别你都明白了吗? 那么我们就来认识一下参数修饰符ref,out ,params吧, ...
- java删除文件夹 Java中实现复制文件或文件夹
删除文件夹 import java.io.File; public class DeleteDir { /** * @param args */ public static void main(Str ...