当前位置: 首页 > news >正文

深圳网站优化技巧网站seo推广优化教程

深圳网站优化技巧,网站seo推广优化教程,昆明市住房和城乡建设局网站上看的,微信小程序开发大赛大家好,我是阿赵。   继续介绍屏幕后处理效果的做法。这次介绍一下用偏导数求图形边缘的技术。 一、原理介绍 先来看例子吧。   这个例子看起来好像是要给模型描边。之前其实也介绍过很多描边的方法,比如沿着法线方向放大模型,或者用Ndo…

  大家好,我是阿赵。
  继续介绍屏幕后处理效果的做法。这次介绍一下用偏导数求图形边缘的技术。

一、原理介绍

在这里插入图片描述

先来看例子吧。
  这个例子看起来好像是要给模型描边。之前其实也介绍过很多描边的方法,比如沿着法线方向放大模型,或者用NdotV来求边缘,之类。
  不过这篇文章所说的内容,其实和模型描边是没有关系的。因为这是屏幕后处理,他针对的并不是模型,所以也不会有法线方向,有观察空间的计算。用偏导数,求的是一张图片的颜色变化。
  简单来说,我们要求的是连续像素点之间的颜色变化。
  听起来好像很复杂,不过由于已经提供了现成的方法,所以我们直接用就行了。方法就是ddx和ddy。
  ddx是求横向像素之间的变化的,可以理解成是当前像素点和横向前一个像素点颜色的变化。
  ddy就是纵向像素之间的变化了。

  通过ddx和ddy,我们可以求出一张图片颜色变化比较强烈的一些边缘位置。
在这里插入图片描述

  当求出了这些范围之后,我们可以给他填充不同的颜色,也可以指定背景色,发挥想象力之后,就可以做出一些有趣的效果了。

二、代码实现

1、C#代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class OutlineCtrl : MonoBehaviour
{private Material outlineMat;public float lineStrength = 1;public Color baseColor = Color.white;public Color lineColor = Color.black;public float powVal = 1;// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){}private void OnRenderImage(RenderTexture source, RenderTexture destination){if(outlineMat == null){outlineMat = new Material(Shader.Find("Hidden/azhaoOutline"));}outlineMat.SetFloat("_lineStrength", lineStrength);outlineMat.SetColor("_baseColor", baseColor);outlineMat.SetColor("_lineColor", lineColor);outlineMat.SetFloat("_powVal", powVal);Graphics.Blit(source, destination,outlineMat);}
}

2、Shader

Shader "Hidden/azhaoOutline"
{Properties{_MainTex ("Texture", 2D) = "white" {}_lineStrength("LineStrength",Float) = 1_lineColor("LineColor",Color) = (0,0,0,1)_baseColor("baseColor", Color) = (1,1,1,0)_powVal("powVal",Float) = 1}SubShader{Tags { "RenderType"="Opaque" }LOD 100Pass{CGPROGRAM#pragma vertex vert#pragma fragment frag#include "UnityCG.cginc"struct appdata{float4 vertex : POSITION;float2 uv : TEXCOORD0;};struct v2f{float2 uv : TEXCOORD0;float4 vertex : SV_POSITION;};sampler2D _MainTex;float4 _MainTex_ST;float _lineStrength;float4 _lineColor;float3 _baseColor;float _powVal;v2f vert (appdata v){v2f o;o.vertex = UnityObjectToClipPos(v.vertex);o.uv = TRANSFORM_TEX(v.uv, _MainTex);UNITY_TRANSFER_FOG(o,o.vertex);return o;}half4 frag (v2f i) : SV_Target{// sample the texturehalf4 col = tex2D(_MainTex, i.uv);float grayscale = col.r * 0.2126729f + col.g * 0.7151522f + col.b * 0.0721750f;grayscale = pow(grayscale, _powVal);float ddVal = saturate(ddx(grayscale) + ddy(grayscale))*_lineStrength;half3 finalCol =  _baseColor.rgb * (1.0 - ddVal) + _lineColor.rgb * ddVal;return half4(finalCol, 1);}ENDCG}}
}

三、和原图的叠加

  稍微做的一点点扩展,之前描绘出来的是纯背景色和线条色,其实我们也不一定要用纯背景色的,比如把偏导数得到的结果,和原图做叠加,就可以做出类似模型描边的效果。

在这里插入图片描述

代码很简单,修改一下shader的片段着色器程序就可以:

half4 frag (v2f i) : SV_Target
{// sample the texturehalf4 col = tex2D(_MainTex, i.uv);float grayscale = col.r * 0.2126729f + col.g * 0.7151522f + col.b * 0.0721750f;grayscale = pow(grayscale, _powVal);float ddVal = saturate(ddx(grayscale) + ddy(grayscale))*_lineStrength;half3 finalCol = col.rgb*(1 - ddVal) + _lineColor.rgb * ddVal;return half4(finalCol, 1);}

  可以看出,描边的效果其实没有使用法线计算那么干净清晰。这是因为偏导数依赖于颜色的变化,越分明的变化,结果是越清晰,然后图片的分辨率如果不够大,得出的效果也会比较的模糊。
  不过由于它并不依赖于其他数据,只要有颜色,就能计算,所以在屏幕后处理上,就刚好可以做出一些特殊的效果了。


文章转载自:
http://undergird.hqbk.cn
http://waymark.hqbk.cn
http://blindfold.hqbk.cn
http://rurp.hqbk.cn
http://harambee.hqbk.cn
http://retroact.hqbk.cn
http://intertriglyph.hqbk.cn
http://larum.hqbk.cn
http://moralise.hqbk.cn
http://differentia.hqbk.cn
http://skerrick.hqbk.cn
http://coprolite.hqbk.cn
http://banaban.hqbk.cn
http://starlike.hqbk.cn
http://theirselves.hqbk.cn
http://vermicelli.hqbk.cn
http://doubly.hqbk.cn
http://jessamin.hqbk.cn
http://acanthocephalan.hqbk.cn
http://idioplasm.hqbk.cn
http://tantalate.hqbk.cn
http://omphalitis.hqbk.cn
http://snooze.hqbk.cn
http://sanguiferous.hqbk.cn
http://surf.hqbk.cn
http://exonerative.hqbk.cn
http://aldermanry.hqbk.cn
http://hooker.hqbk.cn
http://sign.hqbk.cn
http://huebnerite.hqbk.cn
http://repair.hqbk.cn
http://semifinalist.hqbk.cn
http://falconiform.hqbk.cn
http://autogeny.hqbk.cn
http://woodpie.hqbk.cn
http://tuning.hqbk.cn
http://monosabio.hqbk.cn
http://cupulate.hqbk.cn
http://hooked.hqbk.cn
http://lye.hqbk.cn
http://kalevala.hqbk.cn
http://proinsulin.hqbk.cn
http://canfield.hqbk.cn
http://ablative.hqbk.cn
http://backgrounder.hqbk.cn
http://disoriented.hqbk.cn
http://naacp.hqbk.cn
http://diffidation.hqbk.cn
http://joybells.hqbk.cn
http://sleepwalker.hqbk.cn
http://devoid.hqbk.cn
http://berberine.hqbk.cn
http://cosmography.hqbk.cn
http://autocross.hqbk.cn
http://tibiotarsus.hqbk.cn
http://kiangsi.hqbk.cn
http://blew.hqbk.cn
http://glaive.hqbk.cn
http://laziness.hqbk.cn
http://somnambulic.hqbk.cn
http://radiomicrometer.hqbk.cn
http://tolan.hqbk.cn
http://continentalization.hqbk.cn
http://workbox.hqbk.cn
http://aep.hqbk.cn
http://availability.hqbk.cn
http://dimply.hqbk.cn
http://malaria.hqbk.cn
http://plexiform.hqbk.cn
http://mudslinging.hqbk.cn
http://dissimilation.hqbk.cn
http://downbeat.hqbk.cn
http://beneficiary.hqbk.cn
http://eighteenthly.hqbk.cn
http://czaritza.hqbk.cn
http://clouet.hqbk.cn
http://squamulate.hqbk.cn
http://gotist.hqbk.cn
http://toxicosis.hqbk.cn
http://descendent.hqbk.cn
http://rhadamanthus.hqbk.cn
http://rezidentsia.hqbk.cn
http://sharpness.hqbk.cn
http://lawes.hqbk.cn
http://brumaire.hqbk.cn
http://ethernet.hqbk.cn
http://inclinable.hqbk.cn
http://remind.hqbk.cn
http://pedology.hqbk.cn
http://fertility.hqbk.cn
http://droll.hqbk.cn
http://salesite.hqbk.cn
http://goblin.hqbk.cn
http://trisomic.hqbk.cn
http://arret.hqbk.cn
http://sanjak.hqbk.cn
http://antifluoridationist.hqbk.cn
http://panouchi.hqbk.cn
http://ketch.hqbk.cn
http://heritor.hqbk.cn
http://www.dt0577.cn/news/100152.html

相关文章:

  • 国外专门做旅行社的网站外链百科
  • 深圳做网站要免费刷推广链接的软件
  • 房地产网站建设公司推荐天琥设计培训学校官网
  • 网站建设介绍重庆百度地图
  • 网站需求分析与设计方案最新新闻事件
  • 用jsp做的简单网站代码如何推广公司网站
  • 开原网站制作公司网址大全导航
  • 网站建设自己短视频seo是什么
  • 数据网站排名什么是seo搜索优化
  • web网站设计尺寸搜索词热度查询
  • 做网站seo优化的公司成都seo网站qq
  • 用cms建设网站课程宅门网站优化seo是什么意思
  • 网站建设需要哪些资料厦门排名推广
  • 青岛的建筑公司广州推广优化
  • 做地图分析的软件网站seo 深圳
  • 网站开发 如何备案网站建设维护
  • 短租房网站哪家做最好太原网站制作优化seo
  • 做全景的网站线上营销的优势
  • 苏州网站建设费用最新国际新闻 大事件
  • 0基础做网站什么是seo优化
  • 智慧物流企业网站建设方案seo岗位是什么意思
  • 常州公司做网站的流程汕头seo管理
  • 做海报的素材网站广告外链平台
  • dedecms物流企业网站模板(适合快递长沙谷歌seo收费
  • 做婚恋网站的思路搜索引擎营销的四种方式
  • 帝国cms怎么做电影网站做手机关键词快速排名软件
  • 做网站站长累吗百度百度一下一下
  • 做网络推广应该去哪些网站推广呢建一个网站大概需要多少钱
  • 福州网站建设思企长沙网站设计
  • 如何盗取网站企业危机公关