【UnityShader】学习笔记 灯光

官网教程地址:https://docs.unity3d.com/Manual/SL-Material.html

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 color漫反射: The diffuse color component. This is an object’s base color.

Ambient color环境光: The ambient color component. This is the color the object has when it’s hit by the ambient light set in the Lighting Window.

Specular color镜面反射: The color of the object’s specular highlight.

Shininess number: The 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 color自发光: The color of the object when it is not hit by any light.

The full color of lights hitting the object is:

Ambient * Lighting Window’s Ambient Intensity setting + (Light Color * Diffuse + Light Color * Specular) + Emission

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

Typically you want to keep the Diffuse and Ambient colors the same (all built-in Unity shaders do this).

 漫反射:对应的是镜面反射,表面光滑的物体在反射的时候会有光斑,是镜面反射;表面粗糙的物体反射的时候角度是不固定的,会出现漫反射的效果。

 镜面反射和漫反射的最大区别是:镜面反射的物体表面比较光滑,有一个高光效果


Shader "Custom/NewSurfaceShader" {
	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
	}
	}
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值