Shader Anisotropic 各项异性
来源:互联网 发布:怎么手机修改淘宝评价 编辑:程序博客网 时间:2024/04/30 17:12
在金属管,CD光碟上常看到这样的效果。水波纹也能形成这样的Specular 反射。
实际上就是因为物体上有水波纹这样的高低起伏的表面,让本来该平滑延展的Specular反射,也变得褶皱。
这是要改变光照模型。
用法线贴图来采样褶皱方向。
Properties{_MainTint("Diffuse Tint", Color) = (1,1,1,1)_MainTex("Base (RGB)", 2D) = "white" {}_SpecularColor("specular Color", Color) = (1,1,1,1)_Specular("Specular Amount", Range(0,1)) = 0.5_SpecPower("Specular Power", Range(0,1)) = 0.5_AnisoDir("Anisotropic Direction", 2D) = "" {}_AnisoOffset("Anisotropic Offset", Range(-1,1)) = -0.2}SubShader{Tags{ "RenderType" = "Opaque" }LOD 200CGPROGRAM#pragma surface surf Anisotropic#pragma target 3.0sampler2D _MainTex;sampler2D _AnisoDir;float4 _MainTint;float4 _SpecularColor;float _AnisoOffset;float _Specular;float _SpecPower;struct SurfaceAnisoOutput{fixed3 Albedo;fixed3 Normal;fixed3 Emission;fixed3 AnisoDirection;half Specular;fixed Gloss;fixed Alpha;};inline fixed4 LightingAnisotropic(SurfaceAnisoOutput s, fixed3 lightDir, half3 viewDir, fixed atten){fixed3 halfVector = normalize(normalize(lightDir) + normalize(viewDir));float NdotL = saturate(dot(s.Normal, lightDir));fixed HdotA = dot(normalize(s.Normal + s.AnisoDirection), halfVector);float aniso = max(0, sin(radians((HdotA + _AnisoOffset) * 180)));float spec = saturate(pow(aniso, s.Gloss * 128) * s.Specular);fixed4 c;c.rgb = ((s.Albedo * _LightColor0.rgb * NdotL) + (_LightColor0.rgb * _SpecularColor.rgb * spec)) * (atten);c.a = 1.0;return c;}struct Input{float2 uv_MainTex;float2 uv_AnisoDir;};void surf(Input IN, inout SurfaceAnisoOutput o){half4 c = tex2D(_MainTex, IN.uv_MainTex) * _MainTint;float3 anisoTex = UnpackNormal(tex2D(_AnisoDir, IN.uv_AnisoDir));o.AnisoDirection = anisoTex;o.Specular = _Specular;o.Gloss = _SpecPower;o.Albedo = c.rgb;o.Alpha = c.a;}ENDCG}FallBack "Diffuse"
阅读全文
0 0
- Shader Anisotropic 各项异性
- 各项异性滤波简介Anisotropic Filtering(AF)
- 各项异性扩散(Anisotropic diffusion)
- 各项异性扩散(Anisotropic diffusion)
- 各项异性过滤
- 各项异性扩散滤波 -- OpenCV实现
- anisotropic diffusion
- Anisotropic stretching
- 各向异性扩散 Anisotropic diffusion
- 最近做了个并行的计算各项异性地震波的有限元程序(cuda+mpi),可以计算超大规模问题,网格点个数可以几百亿都没有问题.
- OpenGL蓝宝书源码学习(十)第五章——纹理的应用、Mip贴图、各项异性过滤和纹理压缩基础
- 异性效应
- 关于异性
- Cg anisotropic per-pixel lighting
- 渴望异性合租
- 结交异性招数大全
- 关于异性知己
- 异性钨钢材质制作
- C++实现单链表
- defer和async的原理与区别
- 【LeetCode】537. Complex Number Multiplication
- Java实现乘法口诀
- ios开发过程遇到问题总结
- Shader Anisotropic 各项异性
- Hdu 1251-统计难题(字典树模板题)
- 对扫描出的图片进行纠偏
- EditText 只能限制输入中文
- window+Jenkins+Maven+SVN+tomcat持续集成
- javassist 常用方法整理
- iOS 使用字典NSMutableDictionary保存数据到文件(持久化)~ Swift
- Detect Cycle in a linked list (Floyd’s Cycle Detection Algorithm)
- nhmicro微服务框架开发技术说明