Unity中实现半球照明技术.pdfVIP

  • 1
  • 0
  • 约2.63千字
  • 约 6页
  • 2026-02-07 发布于北京
  • 举报

Unity3D中实现HemisphereLighting

发布于2013年02月16日由U3d/Unity3D脚本/插件/浏览186次

Unity3D中实现半球照明代码如下:

_

ShaderCustom/HemisphereLighting{

__

Properties{MainTex(纹理,2D)=白色{}

SkyColor(天空颜色,Color)=(1,1,1,1)_

GroundColor(地面颜色,Color)=(0,0,0,1)}

SubShader{Pass{CGPROGRAM#pragma

vertexvert#pragmafragmentfrag#include

UnityCG.cgincfloat4_SkyColor;float4_

_

GroundColor;sampler2DMainTex;

Unity3D中实现HemisphereLighting

Postedon2013年02月16日byU3d/Unity3D脚本/插件/被围观186次

Unity3D中实现HemisphereLighting代码如下:

ShaderCustom/Hemisphere_Lighting{

Properties{

_MainTex(Texture,2D)=white{}

_SkyColor(SkyColor,Color)=(1,1,1,1)

_GroundColor(GroundColor,Color)=(0,0,0,1)

}

SubShader{

Pass{

CGPROGRAM

#pragmavertexvert

#pragmafragmentfrag

#includeUnityCG.cginc

float4_SkyColor;

float4_GroundColor;

sampler2D_MainTex;

_

structv2f{float4pos:SVPOSITION;float2uv:

_

TEXCOORD0;fixed4color:COLOR0;};float4_MainTexST;

__

v2fvert(appdatabasev){v2fo;o.pos=mul(UNITY

__

MATRIXMVP,v.vertex);o.uv=TRANSFORMTEX

_

(v.texcoord,MainTex);fixed3tnorm=

__

mul(fixed4(v.normal,1),UNITYMATRIXMVP);floatcostheta

=dot(tnorm,fixed3(0,1,0));floata=0.5+0.5*costheta;

_returno;}half4

o.color=_SkyColor*a+(1‑a)*GroundColor;

frag(v2fi):COLOR{

structv2f{

float4pos:SV_POSITION;

float2uv:TEXCOORD0;

fixed4color:COLOR0;

};

float4_MainTex_ST;

v2fvert(appdata_basev)

{

v2fo;

o.pos=mul(UNITY_MATRIX_MVP,v.vertex);

o.uv=TRANSFORM_TEX

文档评论(0)

1亿VIP精品文档

相关文档