Color, Material, Lighting

Color, Material, Lighting

  The material and lighting parameters are used to control the built-in vertex lighting. Vertex lighting is the standard Direct3D/OpenGL lighting model that is computed for each vertex.

  material & parameters 参数用于控制vertex lighting。

   Lighting on turns it on. Lighting is affected by Material block, ColorMaterial and SeparateSpecular commands.

  Lighting on 命令开启顶点光照。Lighting受Material、ColorMaterial、SeparateSpecular命令的影响。

  Per-pixel lights are usually implemented with custom vertex/fragment programs and don‘t use vertex lighting. For these you don‘t use any of the commands described here, instead you define your own vertex and fragment programs where you do all lighting, texturing and anything else yourself.

  Per-pixel 光照通过通过vertex/fragment 程序来实现,它们不使用顶点光照。Per-pixel光照不使用上述的任何命令,你需要定义自己的vertex & fragment 程序,在那里你要做lighting、texturing等所有的事。

  

[Syntax]

  Color:ColorSets the object to a solid color. A color is either four RGBA values in parenthesis, or a color property name in square brackets.

  Material:{ Material Block }The Material block is used to define the material properties of the object.

  Lighting:On | Off。For the settings defined in the Material block to have any effect, you must enable Lighting with the Lighting On command. If lighting is off instead, the color is taken straight from the Color command.

  SeparateSpecular:On | Off。 This command makes specular lighting be added to the end of the shader pass, so specular lighting is unaffected by texturing. Only has effect when Lighting On is used.

[Material Block]

  This contains settings for how the material reacts to the light. Any of these properties can be left out, in which case they default to black (i.e. have no effect).

  Diffuse:ColorThe diffuse color component. This is an object‘s base color.

  Ambient:ColorThe ambient color component. This is the color the object has when it‘s hit by the ambient light set in the RenderSettings.

  Specular:ColorThe color of the object‘s specular highlight.

  Shininess:NumberThe sharpness of the highlight, between 0 and 1. At 0 you get a huge highlight that looks a lot like diffuse lighting, at 1 you get a tiny speck.

  Emission:ColorThe color of the object when it is not hit by any light.

  The full color of lights hitting the object is:

  

  The light parts of the equation (within parenthesis) is repeated for all lights that hit the object.

[Examples]

1、Always render object in pure red:

Shader "Solid Red" {
    SubShader {
        Pass { Color (1,0,0,0) }
    }
} 

2、Basic Shader that colors the object white and applies vertex lighting:

Shader "VertexLit White" {
    SubShader {
        Pass {
            Material {
                Diffuse (1,1,1,1)
                Ambient (1,1,1,1)
            }
            Lighting On
        }
    }
} 

3、An extended version that adds material color as a property visible in Material Inspector:

Shader "VertexLit Simple" {
    Properties {
        _Color ("Main Color", COLOR) = (1,1,1,1)
    }
    SubShader {
        Pass {
            Material {
                Diffuse [_Color]
                Ambient [_Color]
            }
            Lighting On
        }
    }
} 

4、And finally, a full fledged vertex-lit shader (see also SetTexture reference page):

Shader "VertexLit" {
    Properties {
        _Color ("Main Color", Color) = (1,1,1,0)
        _SpecColor ("Spec Color", Color) = (1,1,1,1)
        _Emission ("Emmisive Color", Color) = (0,0,0,0)
        _Shininess ("Shininess", Range (0.01, 1)) = 0.7
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }
    SubShader {
        Pass {
            Material {
                Diffuse [_Color]
                Ambient [_Color]
                Shininess [_Shininess]
                Specular [_SpecColor]
                Emission [_Emission]
            }
            Lighting On
            SeparateSpecular On
            SetTexture [_MainTex] {
                Combine texture * primary DOUBLE, texture * primary
            }
        }
    }
} 

参考:file://localhost/Applications/Unity/Unity.app/Contents/Documentation/Documentation/Components/SL-Material.html

  

Color, Material, Lighting

时间: 2024-10-05 07:35:20

Color, Material, Lighting的相关文章

MATLAB light material lighting

clf;[X,Y,Z]=sphere(40);colormap(jet)subplot(1,2,1),surf(X,Y,Z),axis off square,shading interplight('position',[0 -10 1.5],'style','infinite') material shinysubplot(1,2,2),surf(X,Y,Z,-Z),axis off square ,shading flatlight;lighting flatlight('position'

Unity3D组件参考手册

Refer to the information on these pages for details on working in-depth with various aspects of Unity. 这些页面的参考信息,是有关Unity深入工作的各个方面的详细信息. The Unity Manual Guide contains sections that apply only to certain platforms. Please select which platforms you

Vertex and FragmentShader顶点与片段着色器

一.顶点与片段着色器简介 Vertex and FragmentShader:最强大的Shader类型,也是本系列的重点,下文中简称V&FShader,属于可编程渲染管线.使用的是CG/HLSL语法.分为2个部分vertex顶点部分和Fragment像素部分.下面依然通过写几个简单的Shader来学习. 二. CG语言一些关键词和常用函数解释 1.Cg顶点程序必须在结构中传递顶点数据.几种常用的顶点结构定义在文件UnityCG.cginc中.在大部分情况下仅仅使用它们就够了.结构如下: 1.ap

Unity3d Shader

Unity3d Shader 预览Surface Shader主要用来实现光照相关处理,可能更简洁. Vertex and Fragment Shader 如果不与光照交互, 则可以用这个shader,更录活 fixed function shaders 固定shader主要用于老旧卡  ShaderLab 不管写哪种shader,最终通过shaderLab实现,其组织结构如下: Shader "MyShader" {    Properties{        _MyTexture

Cesium原理篇:Material

Shader 首先,在本文开始前,我们先普及一下材质的概念,这里推荐材质,普及材质的内容都是截取自该网站,我觉得他写的已经够好了.在开始普及概念前,推荐一首我此刻想到的歌<光---陈粒>. 在真实世界里,每个物体会对光产生不同的反应.钢看起来比陶瓷花瓶更闪闪发光,一个木头箱子不会像钢箱子一样对光产生很强的反射.每个物体对镜面高光也有不同的反应.有些物体不会散射(Scatter)很多光却会反射(Reflect)很多光,结果看起来就有一个较小的高光点(Highlight),有些物体散射了很多,它们

three.js 源码注释(五十)Material /MeshPhongMaterial.js

商域无疆 (http://blog.csdn.net/omni360/) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:商域无疆 -  本博客专注于 敏捷开发及移动和物联设备研究:数据可视化.GOLANG.Html5.WEBGL.THREE.JS,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 俺也是刚开始学,好多地儿肯定不对还请见谅. 以下代码是THREE.JS 源码文件中materials/MeshPhongMaterial.js文件的注释. 更多更新在

three.js 源码注释(五十三)Material /MeshLambertMaterial.js

商域无疆 (http://blog.csdn.net/omni360/) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:商域无疆 -  本博客专注于 敏捷开发及移动和物联设备研究:数据可视化.GOLANG.Html5.WEBGL.THREE.JS,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 俺也是刚开始学,好多地儿肯定不对还请见谅. 以下代码是THREE.JS 源码文件中materials/MeshLambertMaterial.js文件的注释. 更多更新

three.js 源码注释(五十四)Material /SpriteMaterial.js

商域无疆 (http://blog.csdn.net/omni360/) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:商域无疆 -  本博客专注于 敏捷开发及移动和物联设备研究:数据可视化.GOLANG.Html5.WEBGL.THREE.JS,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 俺也是刚开始学,好多地儿肯定不对还请见谅. 以下代码是THREE.JS 源码文件中materials/SpriteMaterial.js文件的注释. 更多更新在 : h

three.js 源码注释(五十五)Material /SpriteCanvasMaterial.js

商域无疆 (http://blog.csdn.net/omni360/) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:商域无疆 -  本博客专注于 敏捷开发及移动和物联设备研究:数据可视化.GOLANG.Html5.WEBGL.THREE.JS,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 俺也是刚开始学,好多地儿肯定不对还请见谅. 以下代码是THREE.JS 源码文件中materials/SpriteCanvasMaterial.js文件的注释. 更多更