要实现双面透明无光照只有纹理色的surface shader。

错误的写法:(导致带有曝光)

Shader "Custom/doubleFaceTranspTexColor" {
  Properties {
    _Color ("Color", Color) = (1,1,1,1)
    _MainTex ("Albedo (RGB)", 2D) = "white" {}
  }
  SubShader {
    Tags { "RenderType"="Transparent" }
    LOD 200

    Cull Off

    Blend SrcAlpha OneMinusSrcAlpha // Alpha blending

    CGPROGRAM
    // Physically based Standard lighting model, and enable shadows on all light types
    #pragma surface surf MyTexColor alpha:fade

    half4 LightingMyTexColor(SurfaceOutput s, half3 lightDir, half atten){
      half4 c;
      c.rgb=s.Albedo;
      c.a=s.Alpha;
      return c;

    }
    // Use shader model 3.0 target, to get nicer looking lighting
    #pragma target 3.0

    sampler2D _MainTex;

    struct Input {
      float2 uv_MainTex;
    };

    fixed4 _Color;

    void surf (Input IN, inout SurfaceOutput o) {
      // Albedo comes from a texture tinted by color
      fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
      o.Albedo = c.rgb;
      o.Alpha = c.a;
    }
    ENDCG
  }
  FallBack "Diffuse"
}

正确的写法:

Shader "Custom/doubleFaceTranspTexColor" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
    }
    SubShader {
        Tags { "RenderType"="Transparent" "RenderQueue"="Transparent"}
        LOD 200
        
        Cull Off
        Lighting Off
        Blend SrcAlpha OneMinusSrcAlpha // Alpha blending
        
        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf MyTexColor alpha:fade
        
        half4 LightingMyTexColor(SurfaceOutput s, half3 lightDir, half atten){
            half4 c;
            c.rgb=half3(0,0,0);
            c.a=s.Alpha;
            return c;
        
        }
        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

sampler2D _MainTex;

struct Input {
            float2 uv_MainTex;
        };

fixed4 _Color;

void surf (Input IN, inout SurfaceOutput o) {
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Emission = c.rgb;
            o.Albedo = fixed3(0,0,0);
            o.Alpha = c.a;
        }
        ENDCG
    } 
    FallBack "Diffuse"
}

参考:http://answers.unity3d.com/questions/272749/how-to-write-unlit-surface-shader.html

unity, unlit surface shader (texColor only surface shader)的更多相关文章

  1. 【Unity Shaders】Diffuse Shading——在Surface Shader中使用properties

    本系列主要参考<Unity Shaders and Effects Cookbook>一书(感谢原书作者),同时会加上一点个人理解或拓展. 这里是本书所有的插图.这里是本书所需的代码和资源 ...

  2. unity, multi pass shader中的surface pass

    今天尝试写一个multi pass shader,但其中有一个Pass是surface pass,总是莫名奇妙地报错.后来看到下面帖子: http://forum.unity3d.com/thread ...

  3. Unity 的“Vertex Lit Rendering path“中 shader Pass 的注意事项

    "MADFINGER/Environment/Unlit (Supports Lightmap)"是 ShadowGun 示例中最简单的 shader 了,如下: // Unlit ...

  4. Unity加载模块深度解析(Shader)

    作者:张鑫链接:https://zhuanlan.zhihu.com/p/21949663来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 接上一篇 加载模块深度解析(二 ...

  5. 今天写shader流光效果,shader代码少了个括号,unity shader compiler卡死且不提示原因

    今天写shader流光效果,shader代码少了个括号,unity shader compiler卡死且不提示原因 好在找到了原因,shader 代码如下,原理是提高经过的颜色亮度 void surf ...

  6. UnityShader之Shader格式篇【Shader资料1】

    关于Shader,在Unity里面我们一般叫做ShaderLab,只要你的职业是与渲染搭边,Unity就与ShaderLab有着直接的关联,你都应该试着去学会它,其实我们在新手未有入门的时候,我们总是 ...

  7. cocos2d-js Shader系列4:Shader、GLProgram在jsb(native、手机)和html5之间的兼容问题。cocos2d-js框架各种坑。

    为了让jsb也能顺利跑起滤镜效果,在手机侧折腾了2天,因为每次在真机上运行总要耗那么半分钟,而且偶尔还遇到apk文件无法删除导致运行失败的情况. 这个调试起来,实在让人烦躁加沮丧. 还好,测试上百轮, ...

  8. Android中surface,surfaceview,sufaceholder以及surface客户端的关系

    这里以照相机camera功能的实现来解释surface,surfaceview,sufaceholder以及surface客户端(本例子中指的是camera)的关系,surface及其client(客 ...

  9. Surface Pro 4 和 Surface Book 使用名为 Surface UEFI(统一可扩展固件接口)的新固件接口

    Surface Pro 4 和 Surface Book 使用名为 Surface UEFI(统一可扩展固件接口)的新固件接口.Surface UEFI 提供新功能,如启动更快速.安全性更高.可替换 ...

随机推荐

  1. http://www.pass.org

    http://www.pass.org/Learning/Recordings/Listing.aspx?category=conferences

  2. winform WebBrowser如何修改使用默认的IE浏览器版本

    在搜了一些相关资料原来WebBrowser使用的是IE的兼容模式进行浏览(IE7模式). 建议:先添加注册表中,然后使用注册表编辑器导出功能,产生reg注册文件:方便日后使用. Winform  We ...

  3. gridview展开嵌套显示

    最近实在是太忙了,好几个月没有更新博客了,近来项目需要用到GRIDVIEW嵌套的,在这里跟大家分享一下,大家如有更好的解决方案,请不吝贴出.在ASP.NET中,GridView嵌套可以显示当前选定的父 ...

  4. Log4j 日志级别

    转自:http://michales003.iteye.com/blog/1160605 日志记录器(Logger)是日志处理的核心组件.log4j具有5种正常级别(Level).: 1.static ...

  5. 解决Centos运行yum 报错:坏的解释器

    # ll /usr/bin/python python python2 python2.6 python2.7 python.bak 1,这里先备份原来的/usr/bin/python 为python ...

  6. JS的join方法

    join() 方法用于把数组中的所有元素放入一个字符串. 元素是通过指定的分隔符进行分隔的. 例子 1 在本例中,我们将创建一个数组,然后把它的所有元素放入一个字符串: <script type ...

  7. Linux下的基础命令

    在容器环境中很多时候要确定底层操作系统是什么和什么版本,网上找了一把,发现了一些比较有用的命令,从其他地方转过来,参考 # uname -a # 查看内核/操作系统/CPU信息 # head -n / ...

  8. third-maximum-number

    https://leetcode.com/problems/third-maximum-number/ // 开始我以为相同的也占一位,比如5,3,3,2,得出3,但是答案是需要2 public cl ...

  9. android sdk下载SDK Platform失败记录

    在使用android sdk manager下载的时候会遇到 下载完毕后,你可能会出现如下图一样的错误,就算重复尝试多次依然无法正常安装 Downloading SDK Platform Androi ...

  10. es服务

    #!/bin/bash #chkconfig:2345 20 90 #description: elastic service #processname: elastic ROOT_PATH=/es5 ...