自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(152)
  • 资源 (1)
  • 收藏
  • 关注

原创 在Unity3d中创建一个简单的Mesh

假如我们要创建如下一个网格,该怎么做呢?这是个4x4的网格,一共有25个顶点,16x2个三角形。建个坐标系如下图:1.创建顶点:如坐标系所示,我们的25个顶点为:(0,4)(1,4)(2,4)(3,4)(4,4)(0,3)(1,3)(2,3)(3,3)(4,3)(0,2)(1,2)(2,2)(3,2)(4,2)(0,1)(1,1)(2,1)(3,1)(4,1...

2018-07-28 18:08:26 5151

原创 Unity中写GLSL(二十一)—— Cook-Torrance— Fresnel

参考:http://www.codinglabs.net/article_physically_based_rendering_cook_torrance.aspx下面是效果: 其实之前的文章就写过菲涅尔反射了。 下面是代码:Shader "Custom/FresnalShader"{ Properties { _DiffuseColor ("Diffuse C

2018-02-01 20:09:15 411

原创 Unity中写GLSL(二十)—— Cook-Torrance—Geometry

参考:http://www.codinglabs.net/article_physically_based_rendering_cook_torrance.aspx这个函数是关于microfacet方面的。roughness为0时如图: roughness为0.2时如图: roughness为0.5时如图: roughness为0.8时如图: roughness为1时如图: 最后是代码:

2018-02-01 17:05:33 448

原创 Unity中写GLSL(十九)—— Cook-Torrance—Distribution

参考http://www.codinglabs.net/article_physically_based_rendering_cook_torrance.aspx这个分布函数其实就是靠roughness来改变高光分布的意思。roughness为0.01时如图: roughness为0.2时如图: roughness为0.6时如图: roughness为1时如图: 下面是代码: 这代码只是拿

2018-02-01 16:10:44 559

原创 Unity中写GLSL(十八)—— 创建Diffuse环境贴图和Specular环境贴图

参考了WIKI:https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Many_Light_Sources 具体的可以到这个wiki上面去看,我这里只给结果。(写太多东西太麻烦。。。) 这是生成的Diffuse环境贴图: 这是生成的Specular环境贴图: 下面是代码:using System.Collections;using Sys

2018-01-31 17:02:01 2679

原创 Unity中写GLSL(十七)—— 半球光照

参考wiki:https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Diffuse_Reflection_of_Skylight先上图: 然后是代码:Shader "Custom/ShaderExample18"{ Properties { _Color ("Diffuse Material Color", Co

2018-01-29 16:42:07 679 1

原创 Unity中写GLSL(十六)—— 菲涅尔反射

参考了wiki:https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Specular_Highlights_at_Silhouettes先上图:不过看不太出什么区别 然后是代码:Shader "Custom/ShaderExample17"{ Properties { _Color ("Diffuse Mate

2018-01-29 16:38:23 724

原创 Unity中写GLSL(十五)—— 折射

先上图: 因为天空盒的问题,所以黑色那部分看上去不太对,但是大概就是这个样子。 然后是代码:Shader "Custom/ShaderExample14"{ Properties { _Cube ("Environment Map", Cube) = "" {} } SubShader { Pass {

2018-01-25 13:08:59 410

原创 Unity中写GLSL(十四)—— Unity中的Projector

上图: 和之前的cookie差不多,是种投影仪的感觉,阴影也可以靠这个实现。下面是代码:Shader "Custom/ShaderExample13"{ Properties { _ShadowTex ("Projected Image", 2D) = "white" {} } SubShader { Pass

2018-01-24 12:55:09 570

原创 Unity中写GLSL(十三)—— light cookie

参考WIKI:https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Cookies light cookie其实是这么个效果: 首先在PhotoShop里画了一张有透明部分的图,储存成PNG格式: 把cookie.png拖进unity3d,然后需要设置一下光源的cookie和cookie size, 然后效果如图: 最后是代码:Shade

2018-01-22 14:27:25 2688 2

转载 Unity中写GLSL(十二)—— layer texture

参考了WIKI:https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Layers_of_Textures 先上图: 两张图片是根据lightDir与normal的夹角来确定混合权重的,所以放两张图: 下面是代码:Shader "Custom/ShaderExample10"{ Properties { _D

2018-01-21 17:19:48 659

原创 Unity中写GLSL(十一)—— 双面材质

先上图:左边是背面,右边是正面 然后是代码:Shader "Custom/ShaderExample9"{ Properties { _Color ("Front Material Diffuse Color", Color) = (1,1,1,1) _SpecColor ("Front Material Specular Color", Colo

2018-01-21 14:19:42 492

原创 Unity中写GLSL(十)—— Specular + Diffuse

先上图: 这光照是在顶点着色器里计算的,如果在片元着色器中计算效果会好一些。然后是代码:Shader "Custom/ShaderExample8"{ Properties { _Color ("Diffuse Material Color", Color) = (1, 1, 1, 1) _SpecColor ("Specular Material

2018-01-20 20:31:50 497

原创 Unity中写GLSL(九)—— 渲染简单的透明物体

参照了wiki:https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Transparency先上图: 下面是代码:Shader "Custom/ShaderExample6"{ Properties { } SubShader { Tags { "Queue" = "Transparent

2018-01-14 19:30:40 964

原创 Unity中写GLSL(八)—— 方向光 + Normal Map + Diffuse Map + AO Map

先上图: 下面是代码Shader "Custom/ShaderExample5"{ Properties { _MainTex ("Texture", 2D) = "white" {} //diffuse _BumpMap("Normal Map", 2D) = "bump" {} //normal _OcclusionMap

2018-01-14 18:53:31 1191

原创 Unity中写GLSL(七)—— 程序式纹理:棋盘格

先上图:原理:在顶点着色器中先把uv乘以density,这样uv的range就从0 - 1变成了0 - density。 然后在片元着色器中把uv值取整再除以2,这样uv值就变成了0, 0.5, 1, 1.5, 2, 2.5 。。。 接着把x,y相加,值为0, 0.5, 1, 1.5 。。。 再取小数,值为0或者0.5 再乘以2,值为0或者1 最后取颜色。然后是代码:

2018-01-14 16:32:10 1473

原创 Unity中写GLSL(六)—— 环境skybox反射 + Normal Map + Diffuse Map + AO Map

先上图:再来是代码:Shader "Custom/ShaderExample3"{ Properties { _MainTex ("Texture", 2D) = "white" {} //duffuse _BumpMap("Normal Map", 2D) = "bump" {} //normal _Occl

2018-01-14 15:53:38 334

原创 Unity中写GLSL(五)—— 环境skybox反射 + Normal Map

先上图: 这normal map是从3dsmax里面导出的。注意:normal map在Unity3d中的texture type要保持默认default才行。下面是代码:Shader "Custom/ShaderExample2"{ Properties { _BumpMap("Normal Map", 2D) = "bump" {}

2018-01-13 20:09:16 458

原创 Unity中写GLSL(四)—— 环境skybox反射

先上图: 看着不太对是因为skybox的问题,skybox没底部图片,所以用了top图片。下面是代码:Shader "Custom/ShaderExample2"{ Properties { _Cube("Reflection Map", Cube) = "" {} } SubShader { Pass

2018-01-13 16:31:24 594

原创 Unity中写GLSL —— 常用的一些内置变量

本页的内容参考了Wiki:https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Shading_in_World_Space首先是一些顶点相关的:gl_Vertex //模型坐标gl_Position //projection过后顶点坐标gl_MultiTexCoord0 //uv坐标gl_Normal //法线gl_FragCo

2018-01-13 14:09:59 981

原创 Unity中写GLSL(三)—— 试试法线Normal

这里只是把法线当做color来用。法线的range是-1 - 1所以要转换range到0 - 1。下面上图:下面是代码:Shader "Custom/ShaderExample1"{ Properties { _MainTex ("Texture", 2D) = "white" {} } SubShader { Pass

2018-01-13 13:50:48 675

原创 Unity中写GLSL(二)—— Unlit着色器,无光照,只从纹理采样

GLSL语法用的330之后的语法。先上图: 棋盘格纹理是我百度随便找的。 下面是代码:Shader "Unlit/UnlitShader_GL"{ Properties { _MainTex ("Texture", 2D) = "white" {} //纹理 } SubShader { Pass {

2018-01-12 21:34:50 798

原创 GameEntity(十一)—— Iplayer

目录为:Assets/Scripts/GameEntity/目录下 Iplayer.csplayer接口using UnityEngine;using System.Collections;using System.Collections.Generic;using System;//继承Ientitypublic class Iplayer: Ientity{ //吸附特效

2017-11-06 20:17:13 363

原创 GameEntity(十)—— Mail

目录为:Assets/Scripts/GameEntity/目录下 Mail.csusing System;using System.Collections.Generic;//邮件状态public enum EMailCurtState{ eMailState_None = 0, eMailState_New = 1, eMailState_LookedButNot

2017-11-02 16:11:49 303

原创 GameEntity(九)—— InviteOtherPlayer

目录为:Assets/Scripts/GameEntity/目录下 InviteOtherPlayer.cs邀请好友类using UnityEngine;using System.Collections;using System;using System.Collections.Generic;//邀请好友public class InviteOtherPlayer{ //sta

2017-11-02 15:56:41 167

原创 GameEntity(八)—— FriendManager

目录为:Assets/Scripts/GameEntity/目录下 FriendManager.cs好友管理类using UnityEngine;using System.Collections;using System.Collections.Generic;using System;//好友管理类public class FriendManager{ //static

2017-11-01 16:57:57 181

原创 GameEntity(七)—— Friend

目录为:Assets/Scripts/GameEntity/目录下 Friend.cs看来是好友类using System;using System.Collections.Generic;//好友public class Friend{ public UInt64 SGUID { private set; get; } //是否

2017-11-01 15:55:45 160

原创 GameEntity(六)—— IChat

目录为:Assets/Scripts/GameEntity/目录下 IChat.cs聊天的接口类using UnityEngine;using System.Collections;using System.Collections.Generic;using System;//看来是聊天相关的接口public class IChat{ public UInt64 SGUID

2017-11-01 15:25:08 306

原创 GameEntity(五)—— INpc

目录为:Assets/Scripts/GameEntity/目录下 INpc.cs这是Npc的接口类using UnityEngine;using System.Collections;using System;//Npc的接口public class INpc: Ientity{ //调用Ientity的构造函数 public INpc(UInt64 sGUID, Ent

2017-11-01 15:13:20 216

原创 Unity中写GLSL(一)—— 简单的diffuse color

写这篇文章主要是为了记录一下需要用到的Unity提供的变量等等。 参考了WiKi:GLSL Programming/Unity/Diffuse Reflection注意要给Unity添加启动项才行,像这样 强制使用opengl,这样才能测试shader下面是shader代码,Wiki上的不好用了,改了一下的Shader "GLSL per-vertex diffuse lighting" {

2017-11-01 13:50:11 2237

原创 GameEntity(四)—— Ientity

目录为:Assets/Scripts/GameEntity/目录下 Ientity.cs这是Entity的接口using System;using System.Collections;using System.Collections.Generic;using UnityEngine;//最主要的游戏实体//整个Entity的接口public class Ientity{ /

2017-10-31 21:44:55 886

原创 GameEntity(三)—— EntityStrategyHelper

目录为:Assets/Scripts/GameEntity/目录下 EntityStrategyHelper.csusing UnityEngine;using System.Collections;public static class EntityStrategyHelper{ public const float MoveCheckBlockTick = 1.0f; pu

2017-10-30 14:03:58 227

原创 GameEntity(二)—— EntityType

目录为:Assets/Scripts/GameEntity/目录下 EntityType.csusing UnityEngine;using System.Collections;public enum EntityType{ Monster = 1, Soldier, Buiding, Player, AltarSoldier}public enum

2017-10-29 17:13:59 350

原创 GameEntity(一) —— CampType

目录为:Assets/Scripts/GameEntity/目录下 CampType.cs这次先从Entity入手,好多地方都涉及到这一部分。using UnityEngine;using System.Collections;public enum EntityCampType{ CampTypeNull = -2, CampTypeBad, //全敌对 Cam

2017-10-29 16:56:59 307

原创 Effect(二十二)—— SM_UVScroller

目录为:Assets/Media/Effect/Scripts/目录下 SM_UVScroller.csusing UnityEngine;using System.Collections;//UV滚动public class SM_UVScroller: MonoBehaviour{ public int targetMaterialSlot = 0; public Mat

2017-10-28 16:11:42 212

原创 Effect(二十一)—— SM_TransRimShaderIrisator

目录为:Assets/Media/Effect/Script/目录下 SM_TransRimShaderIrisator.csusing UnityEngine;using System.Collections;public class SM_TransRimShaderIrisator: MonoBehaviour{ public float topStr = 2.0f; p

2017-10-28 16:00:16 231

原创 Effect(二十)—— SM_TransRimShaderFader

目录为:Assets/Media/Effect/Script/目录下 SM_TransRimShaderFader.cs没找到在哪用。using UnityEngine;using System.Collections;public class SM_TransRimShaderFader: MonoBehaviour{ public float startStr = 2.0f;

2017-10-28 15:49:15 174

原创 Effect(十九)—— SM_TrailFade

目录为:Assets/Media/Effect/Script/目录下 SM_TrailFade.csusing UnityEngine;using System.Collections;public class SM_TrailFade: MonoBehaviour{ public float fadeInTime = 0.1f; public float stayTime =

2017-10-27 16:47:30 164

原创 Effect(十八)—— SM_RotateThis

目录为:Assets/Media/Effect/Script/目录下 SM_RotateThis.csusing UnityEngine;using System.Collections;//rotatepublic class SM_rotateThis: MonoBehaviour{ public float rotationSpeedX = 90; public flo

2017-10-27 16:32:27 204

原创 Effect(十七)—— SM_MoveThis

目录为:Assets/Media/Effect/Script/目录下 SM_MoveThis.csusing UnityEngine;using System.Collections;//就只是不停移动而已public class SM_MoveThis: MonoBehaviour{ public float translationSpeedX = 0; public fl

2017-10-27 16:15:49 210

opengl第一个示例

opengl第八版的第一个示例triangles

2016-11-08

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除