Unity里面为Sprite添加边框写的的shader

小boss让我写个shader加到sprite上,然后发现了一个神奇的问题,

Sprite的vertex在哪?现在考虑一种Sprite,它的内容没有占满整个

sprite的rect(就是你能拖动的rect),其他地方是透明的。这种sprite

的顶点既不是rect的四个顶点,也不在图像内容的边界上,而是系统

自动生成的一个多边形,这个多边形比图像内容大,把图像内容包括

在其中。

那么我现在想弄一个效果,原sprite的背后弄个影子,对于新创建的

sprite,他的shader是内置的。只能自己新建一个material,然后把做

sprite的png图像拖到material的tex里。

主要是怎么排除多边形内部的透明部分,其实就是用 Blend One One让

该部分与当前屏幕的颜色混合就行,具体看代码。另外我又发现一个问题,

可能是个偶然会出现的bug还是什么,两个自定义的shader内容完全一致(除了

文件名字和第一行的shader“XXX”),竟然有一个会得出异常结果。

Shader "Custom/Fragment extend" {
    Properties {
        _Color ("Surround Color"Color) = (0.2,0.2,0.2,0.7)
        _MainTex ("Base (RGB)"2D) = "white" {}
        _Range("Range",Range(0.1,0.3)) = 0.15
        //_Range2("Range",Range(0.1,10))=0.5
    }
    SubShader {
    //Tags{"RenderType"="Transparent"}
        //Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
        LOD 100
    Pass{
        Blend One One
        CGPROGRAM
            #pragma vertex vert

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Shadero Sprite is a real time node-based shader tool for Unity 5, 2017 and 2018 NEW! Forum : https://forum.vetasoft.store/ Discuss with us about Shadero Sprite and more ! Description Shadero Sprite is a real time node-based shader editor. Shadero was made to be a real production time saver. Beautiful and fast, it creates many astonishing effects with the several premade and fully optimized node effects. Shadero will increase the number of the premade effects in every update. No code required. Features - Ultimate tools for 2D Shader Editor - Node based editor - Real time preview - Source code included - Load/Save project - Optimised shader - Fog Support - HDR Support - Visual selection node preview - Light Support - Blend Mode support - Normalmap with light Support - Preview directly the scene - Works with Unity UI - Many premade effects (+100) - Help Tutorial in editor - Project examples - Unity 5 and 2017 and 2018 compatible - Support Anima 2D - Support Render Texture - Support Mesh Renderer - Generate a Sprite - Create Morphing - And much much more ! http://www.shadero.com New version 1.7.0 see version history Version 1.1 - Add Node: UV > FX (UV) > Sprite Sheet Animation - Add Node: UV > FX (UV) > Pixel - Add Node: UV > FX (UV) > Fish Eye - Add Node: UV > FX (UV) > Pinch - Add Node: UV > FX (UV) > Kaleiodoscope - Add Node: Generate > Shape > XRay - Add Node: Generate > Shape > Donuts - Add Node: Generate > Shape > Lines - Add Node: Generate > Shape > Noise - Add Node: RGBA > Color > Turn Metal - Add Node: RGBA > Color > Turn Gold - Add Node: RGBA > Color > Turn Transparent - Add Node: RGBA > Color > HDR Control Value - Add Node: RGBA > Color > HDR Create - Add Force Change Parameters to the Build Shader Node (Experimental) - Add Lightning Support - Fix Node: UV > FX (UV) > Pixel XY precision - Fix new Shader Project that keep the preview material issue - Fix Auto variable order issue when you add the same node Any Feedback, error reports, questions or suggestions, please contact us at support@vetasoft.com If you like Shadero Sprite you can rate it on the asset store, it would be very helpful. Any idea or suggestions to improve Shadero Sprite? Feel free to contact us at : support@vetasoft.com

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值