UE 极坐标、旋转、溶解、燃烧、查找边缘、浮雕、去色、抖动材质
极坐标
float polar_coordinates(float2 uvs) {struct SF {static float remap_value_range(float input, float input_low, float input_high, float target_low, float target_high) {return (input - input_low) / (input_high - input_low) * (target_high - target_low) + target_low;}};float pi = acos(-1);float2 uv = float2(SF::remap_value_range(uvs.x, 0, 1, -1, 1), SF::remap_value_range(uvs.y, 0, 1, -1, 1));return SF::remap_value_range(atan2(uv.x, uv.y) / pi, -1, 1, 0, 1);
}
旋转
/**
* 旋转
* rotation_center - 旋转点
* rotation_angle - 旋转角度
*/
float2 rotate(float2 uvs, float2 rotation_center, float rotation_angle) {float pi = acos(-1);rotation_angle *= 2 * pi;// 逆时针旋转float2x2 mt = float2x2(cos(rotation_angle), sin(rotation_angle),-sin(rotation_angle), cos(rotation_angle));/** 顺时针旋转float2x2 mt = float2x2(cos(rotation_angle), -sin(rotation_angle),sin(rotation_angle), cos(rotation_angle));*/return mul(uvs + rotation_center * -1, mt) + rotation_center;
}
也可以使用 UE 自带的 CustomRotator 材质函数。
溶解
/**
* 溶解
* texture2d - 纹理
* texture2d_noise - 噪点纹理
* value - 溶解程度
* edge - 溶解边缘
* xyz - 溶解边缘颜色
* w - 溶解边缘宽度
*/
float4 dissolve(float2 uvs, Texture2D texture2d, float2 uvs_noise Texture2D texture2d_noise, float value, float4 edge) {float3 texture_color = Texture2DSampleLevel(texture2d, texture2dSampler, uvs, 0).xyz;// float3 texture_color = Texture2DSample(texture2d, Material.Texture2D_0Sampler, uvs).xyz;float noise_value = Texture2DSampleLevel(texture2d_noise, texture2d_noiseSampler, uvs_noise, 1).x;// float noise_value = Texture2DSample(texture2d_noise, Material.Texture2D_1Sampler, uvs_noise).x;value = saturate(value) * 2 - 1 + noise_value;float dissolve_value = value * step(value, 1) * step(saturate(1 - edge.w), value);float3 dissolve_color = edge.xyz * dissolve_value;value = saturate(value);float alpha = 1 - floor(value);texture_color = lerp(texture_color, 0, value);float3 color = saturate(texture_color + dissolve_color);return float4(color, alpha);
}
燃烧
/**
* 燃烧
* texture2d - 纹理
* texture2d_noise - 噪点纹理
* noise_scale - 噪点尺寸
* value - 燃烧程度
* edge - 燃烧边缘
* xyz - 燃烧边缘颜色
* w - 燃烧边缘宽度
*/
float4 burn(float2 uvs, Texture2D texture2d, Texture2D texture2d_noise, float noise_scale, float value, float4 edge) {float3 texture_color = Texture2DSampleLevel(texture2d, texture2dSampler, uvs, 0).xyz;// float3 texture_color = Texture2DSample(texture2d, Material.Texture2D_0Sampler, uvs).xyz;float noise_value = Texture2DSampleLevel(texture2d_noise, texture2d_noiseSampler, uvs, 1).x * noise_scale;// float noise_value = Texture2DSample(texture2d_noise, Material.Texture2D_1Sampler, uvs).x * noise_scale;float progress = uvs.x + noise_value;value *= 1 + noise_scale + edge.w;float react_1 = step(value, progress);float react_2 = step(value - edge.w, progress);float react_3 = react_2 - react_1;float3 color = edge.xyz * react_3 + texture_color * react_1;return float4(color, react_2);
}
查找边缘
float3 find_edges(float2 uvs, Texture2D texture2d, float2 texture_size) {float GX[3][3] = {{-1, -2, -1},{0, 0, 0},{1, 2, 1}};float GY[3][3] = {{-1, 0, 1},{-2, 0, 2},{-1, 0, 1}};float ex = 0.f;float ey = 0.f;for(int x = -1; x <= 1; x++) {for (int y = -1; y <= 1; y++) {float2 uvs_offset = float2(uvs.x + x * texture_size.x, uvs.y + y * texture_size.y);float3 pixel_color = Texture2DSampleLevel(texture2d, texture2dSampler, uvs_offset, 0);ex += pixel_color * GX[x + 1][y + 1];ey += pixel_color * GY[x + 1][y + 1];}}return saturate(1 - (abs(ex) + abs(ey)));
}
浮雕
float3 emboss(float2 uvs, Texture2D texture2d, float2 texture_size, float value) {float GX[3][3] = {{-1, -2, -1},{0, 0, 0},{1, 2, 1}};float GY[3][3] = {{-1, 0, 1},{-2, 0, 2},{-1, 0, 1}};float ex = 0.f;float ey = 0.f;for(int x = -1; x <= 1; x++) {for (int y = -1; y <= 1; y++) {float2 uvs_offset = float2(uvs.x + x * texture_size.x, uvs.y + y * texture_size.y);float3 pixel_color = Texture2DSampleLevel(texture2d, texture2dSampler, uvs_offset, 0);ex += pixel_color * GX[x + 1][y + 1];ey += pixel_color * GY[x + 1][y + 1];}}return value + ex + ey;
}
去色
float3 desaturation(float3 color) {float3 factor = float3(0.299, 0.587, 0.114);return dot(color, factor);
}
也可以使用 UE 自带的 Desaturation 表达式。
抖动
float3 shake(float2 uvs, Texture2D texture2d, Texture2D texture2d_noise, float range, float value) {float noise_value = Texture2DSampleLevel(texture2d_noise, texture2d_noiseSampler, float2(sin(value), cos(value)), 0).x;noise_value *= range;// 采样红色,右移float texture_color_r = Texture2DSampleLevel(texture2d, texture2dSampler, float2(uvs.x + noise_value, uvs.y), 1).x;// 采样绿色,不变float texture_color_g = Texture2DSampleLevel(texture2d, texture2dSampler, uvs, 1).y;// 采样蓝色,左移float texture_color_b = Texture2DSampleLevel(texture2d, texture2dSampler, float2(uvs.x - noise_value, uvs.y), 1).z;return float3(texture_color_r, texture_color_g, texture_color_b);
}
UE 极坐标、旋转、溶解、燃烧、查找边缘、浮雕、去色、抖动材质相关推荐
- Mentor Expedition如何极坐标旋转添加器件?
Mentor Expedition(EE)如何极坐标旋转添加器件? 我们在使用EDA工具画PCB时,常常会出现一些器件使用极坐标方式摆放器件,对于我们常见的AD.PADS.allergeo相信大家都能 ...
- webview img照片旋转_Python图像处理,照片去色、翻转、模糊、缩略图统统搞定
Python提到图像处理第一个想到的库就是PIL,全称Python Imaging Library Python,图像处理类库,它提供了大量的图像操作,比如图像缩放,裁剪,贴图,模糊等等. 今天小编就 ...
- UE风格化Day7-maya的AO烘焙和SP绘制材质
做了瓦片之后其他部分好像也只能直接在SP画了 SP教程: CG马锤锤-[SP教程]Substance Painter2021零基础教程 (油管)Learning The Basics of 3D Ha ...
- iOS传感器:实现一个随屏幕旋转的图片
作者 非典型技术宅 关注 2017.05.24 17:22* 字数 1568 阅读 351评论 7喜欢 14 在写上一个动画系列的时候学到了非常多的知识,也认识了很多人.例如受邀进入了某个神秘的动效组 ...
- 使用自定义材质球,实现NGUI屏幕溶解和灰显
UITexture实现的溶解: 重设UITeture的材质球实现上述效果,把当前屏幕渲染的Texture2D丢给UITexture,即可实现UI屏幕特效,背景模糊等都可以. 难点主要是实时刷新问题 解 ...
- UE风格化Day16-风格化云雾材质/风格化的探讨
今天学一下云雾的创建:虽然UE自带也有云雾生成的功能,效果并不理想,风格化的效果可能还是要自己做 教程: (油管)游戏中云雾实现的几种方式 :虽然没有具体的做法教程,但是从原理上分析了生成 在虚幻商城 ...
- UE风格化Day5-Rizom展UV的一些问题
终于把模型建完了,因为附楼是复制主楼的结构,所以有些细节没有按原画,后面的小楼原画只能一部分,而且应该结构上有点问题,最后建成了重檐庑殿顶感觉比较接近 小小评论一下建筑形制:重檐庑殿顶应该比歇山顶等级 ...
- AE506 320多个专业无缝过渡毛刺转场全景旋转光效形状缩放等效果ae模板
AE506 320多个专业无缝过渡毛刺转场全景旋转飞行偏移光效形状缩放等效果ae模板 [ae模板介绍] 模板用途:广播.电影.失真.史诗级幻灯片放映.电影制作人.故障.无缝过渡.igtv.运动.全景. ...
- 十五. 单线激光雷达和视觉信息融合
单线激光雷达和视觉信息融合案例 很多智能应用场景涉及到激光雷达和相机视觉信息融合,一般都是指多线激光雷达,至少也得16线激光吧;但多线激光雷达动不动数万的价格,让很多技术人员无法尝试.我尝试使用微型机 ...
最新文章
- python【数据结构与算法】Floyd算法模拟
- 基于AES加解密的图像加解密算法
- java gif_使用Java来处理GIF图片
- 伪集群zookeeper模式下codis的部署安装
- java未知对象调用其某个方法_引用一个类的属性或调用其方法,必须以这个类的对象为前缀。...
- 10 个步骤让你成为高效的 Web 开发者
- VC++调用大漠插件
- 三器六垢_本初行者劉暢友居士浅谈如何学佛(三)
- android AP热点(wifi热点)开发
- 贴息政策打出“组合拳”,院校实验室建设攻略来了(二)!
- ERROR: Failed building wheel for box2d-py 解决方法
- 2021学习前端开发有前途吗?(建议收藏)
- MATLAB算术运算符和常用函数
- Kanzi学习之路(3):Kanzi的树形结构和常用控件介绍
- 分压电路+运放电路(OPA2350UA)放大电位器分压信号
- 九龙证券|全球央行增持提振黄金交易活跃度
- udp端口不可达 icmp
- 基于vue实现假分页
- 观影网站影评信息管理系统
- 硕士生如何选择三维扫描研究课题? 实例一:将多层扫描服装模型“穿”到人体模型上