[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模 ...
随机推荐
- servlet容器开发要点
v1 是一个http服务器. v2 是一个servlet容器, 可以提供servlet的服务. => 动态load servlet字节码,并运行它( 按生命周期). servlet容器它来 ...
- 【RMQ】 区间最值查询详解
1. 概述 RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A ...
- js获取当前日期与星期
var currentDate = new Date(); var weekday = ["星期日", "星期一", "星期二", &quo ...
- dedecms 标签的基本用法
1.关键描述调用标签: <meta name="keywords" content="{:fieldname='keywords'/}"> < ...
- JSP中文编码问题
这个乱码问题是最简单的乱码问题.一般新会出现.就是页面编码不一致导致的乱码. <%@ page language="java" pageEncoding="UTF- ...
- oracle10g遇到ORA-16038日志无法归档问题
SQL> shutdown immediate ORA-01109: 数据库未打开 已经卸载数据库. ORACLE 例程已经关闭. SQL> startup ORACLE 例程已经启动. ...
- mplayer最全的命令
前段时间做过qt内嵌mplayer的一个小程序,感觉mplayer还行不过不支持打开图片感觉有点无力.话不多说上代码: QString path="d:/1.mkv"; QWidg ...
- windows2012 r2 提高网速方法
2012 升级到 r2 微软官方地址:(感谢Monkey威武)Datacenter Preview:简体中文:http://care.dlservice.microsoft.com/dl/downlo ...
- Android SharedPreferences存图片,转码解码图片
保存图片 首先创建ByteArrayStream对象,然后用BitmapFactroy把图片加载进来,然后compress压缩图片到流, 然后toByteArray()就行了 public voi ...
- java集合框架工具类Collections,集合的操作
1 import java.util.*; public class asList { public static void main(String args[]) { // int arr[] = ...