// Unlit shader. Simplest possible textured shader.
// - no lighting
// - no lightmap support
// - no per-material color Shader "Unlit/Texture" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
} SubShader {
Tags { "RenderType"="Opaque" }
LOD 100 Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog #include "UnityCG.cginc" struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
}; struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
UNITY_FOG_COORDS(1)
}; sampler2D _MainTex;
float4 _MainTex_ST; v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
} fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord);
UNITY_APPLY_FOG(i.fogCoord, col);
UNITY_OPAQUE_ALPHA(col.a);
return col;
}
ENDCG
}
} }

SV_Target 与Color略有区别,大体相同,有可能是两者的位置前者是中心位置,后者不是,有0.5像素的偏移,这个以后确认下

Fog相关的几个函数

UnityCG.cginc中的解释

// multi_compile_fog Will compile fog variants.

// UNITY_FOG_COORDS(texcoordindex) Declares the fog data interpolator.

// UNITY_TRANSFER_FOG(outputStruct,clipspacePos) Outputs fog data from the vertex shader.

// UNITY_APPLY_FOG(fogData,col) Applies fog to color "col". Automatically applies black fog when in forward-additive pass.

// Can also use UNITY_APPLY_FOG_COLOR to supply your own fog color.

builtin_shaders-5.3.4f1学习-Unlit/Texture的更多相关文章

  1. builtin_shaders-5.3.4f1学习-Sprites-Default

    Shader "Sprites/Default" { Properties { [PerRendererData] _MainTex ("Sprite Texture&q ...

  2. Unity3D WebCamTexture 调用外部摄像头

    http://www.itnose.net/detail/6259004.html 一:Unity 中使用WebCamTexture 调用摄像头实现拍照和摄像. using UnityEngine; ...

  3. Unity镜子效果的实现(无需镜子Shader)

    Unity镜子效果制作教程 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分享. ...

  4. WikiBooks/Cg Programming

    https://en.wikibooks.org/wiki/Cg_Programming Basics Minimal Shader(about shaders, materials, and gam ...

  5. unity, standard shader消耗两个draw call

    假设场景中只放一个球,关掉阴影和skybox,球体使用Unlit/Texture shader,则draw call数为2(背景占一个draw call,球占一个draw call). 相同情况下若将 ...

  6. What is _MainTex_ST ?

    [What is _MainTex_ST ?] 在Unity自带的Unlit/Texture中,有引用到float4 _MainTex_ST,如下: // Unlit shader. Simplest ...

  7. Unity 官方自带的例子笔记 - Space Shooter

    首先 买过一本叫 Unity3D开发的书,开篇第一个例子就是大家经常碰见的打飞机的例子,写完后我觉得不好玩.后来买了一本 Unity 官方例子说明的书,第一个例子也是打飞机,但是写完后发现蛮酷的,首先 ...

  8. unity 内置shader

    几个有用的Unity 内置shader: (一)Standard RenderingMode:Opaque为实体渲染,更改Color的透明通道不会有影响:Cutout会把图片的透明通道显示出来,非严格 ...

  9. Unity制作出《超级马里奥》的2D和3D混合效果

    现在来做点别的东西.Nintendo Switch上刚推出的<超级马里奥>中,有一些关卡混合了2D和3D的画面,这种效果十分让人印象深刻.如何在Unity中实现这个效果呢? 正常情况下,摄 ...

随机推荐

  1. [Cocoa]深入浅出Cocoa之Bonjour网络编程

    本文转载至 http://www.cnblogs.com/kesalin/archive/2011/09/15/cocoa_bonjour.html   深入浅出Cocoa之Bonjour网络编程 罗 ...

  2. windows 打开文件夹

    @echo off rem 建立链接 net use \\192.168.2.3\share /user:username password rem 打开共享文件夹 explorer \\192.16 ...

  3. define tensorflow and run it

    import tensorflow as tf a, b, c, d, e = tf.constant(5, name='input_a'), tf.constant(6, name='input_b ...

  4. Java Message Service

    en.wikipedia.org/wiki/Java_Message_Service Messaging is a form of loosely coupled distributed commun ...

  5. STM32 ~ 如何从ST网站找到对应的固件库

    ST官方网站改版后,基本上很难搜索到固件库的地址,找了半天才找到固件库的下载地址,通过此方法可以找到其他需要的资源,故记下来方便大家. 下载的网站地址为: Home>Tools and Soft ...

  6. SVN版本控制中.a无法提交问题

    1.首先xcode是默认忽略.a文件的.改变方法如下: 1⃣️. 打开终端,  在命令行中输入: vi ~/.subversion/config  来打开配置文件.2⃣️. 然后, 在[miscell ...

  7. [usaco2008feb_gold]路面修整

      FJ打算好好修一下农场中某条凹凸不平的土路.按奶牛们的要求,修好后的路面高度应当单调上升或单调下降,也就是说,高度上升与高度下降的路段不能同时出现在修好的路中. 整条路被分成了N段,N个整数A_1 ...

  8. iOS description

    description:重写对象的这个方法,会在打印的时候显示出自定义的description中的内容debugDescription:方法是在开发者在调试器中以控制台命令打印对象时才调用的. 在NS ...

  9. 关于VLOOKUP函数的用法

    “Lookup”的汉语意思是“查找”,在Excel中与“Lookup”相关的函数有三个:VLOOKUP.HLOOKUO和LOOKUP.下面介绍VLOOKUP函数的用法. 一.功能 在表格的首列查找指定 ...

  10. iOS 两个tableview的 瀑布流

    iOS 两个tableview的 瀑布流1. [代码]Objective-C     ////  DocViewController.m//  getrightbutton////  Created ...