unity如何unity改变颜色材质贴图的UV

如何在unity3d中分别修改cube每个面的贴图uv_百度知道
如何在unity3d中分别修改cube每个面的贴图uv
我有更好的答案
写一个shader,单独指定给cube每个面使用贴图UV
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。本游戏资料是个关于从相机视角产生UV贴图相机脚本Unity素材资源,大小:62.5 MB,格式:unitypackage,使用软件:Unity,供广大设计师学习使用,语言:英语。Unity3D是一个让你轻松创作的多平台的游戏开发工具,是一个全面整合的专业游戏引擎。Unity代表了一个质的飞跃——内置的光照贴图(lightmapping)、遮挡剔除(occlusion culling)和调试器。编辑器经过彻底革新,让你可以获得卓越的性能体验。不可思议、无法阻挡的产品已经看到了曙光。Unity是一款跨平台的游戏开发工具,从一开始就被设计成易于使用的产品。作为一个完全集成的专业级应用,Unity还包含了价值数百万美元的功能强大的游戏引擎。Unity 4作为一个游戏开发工具,它的设计主旨就是让你能够创建令人惊讶的游戏。如果你之前尝试过Unity,请查看Unity 3都做了哪些更新。如果你是第一次尝试,那就好好看看吧,看Unity都能为你带来什么。Unity作为一种开发环境,可让你脱离传统的游戏开发方式,以一种更简单的方式专注于你的游戏开发。开发网络游戏、移动游戏、单机游戏,Unity都能完全胜任。本帖隐藏的内容Project UV from Camera Scripting CameraCecil IsnardRequires Unity 5.3.4 or higher.Want to map a texture dynamically in game exactly how you want it to be from the camera point of view ? This asset is for you.Create camera mapping in Unity ! Project easily and accurately your gameObjects' UVs from camera screen space while in editor or dynamicaly in game. No specific shader, no change needed to your materials. Just plug it...Some video demos :video 1video 2Spherical projection** NEW : Full source code included** NEW : SkinMesh support** NEW : UV1 to UV4 projection supportCompatible Unity 5.3.4+ (Pro and Free)Works on mobile (Android & iOs)Features :- Planar and spherical projection.- Project with one button the UVs from camera to the object(s)- Realtime or manual projection- UV tiling- Display GUI watermark to preview the projection over the object(s)- Keep the watermark texture aspect ratio or fill the entire screen- Set up watermark opacity- Project UVs on single gameObject or multiple sub-objects- Restore original set of UVs with a single button or by deleting component- Instantiate gameObjects- Full script API support- Works with orthographic or perspective camera- layer filter- mirror UVs- uv channel choice to project- cpu optimization tuning (nth frame projection, minimum update mode)- compatible Oculus Rift.- SkinMesh supportDocumentation and demos included, nevertheless, if you're facing issue do not hesitate to contact me.视频预览:
-----------------------------------------------------------------
资源名称: 从相机视角产生UV贴图相机脚本Unity素材资源
本站编号:&&ZH3087
百度网盘5:城通网盘:
解压密码:&&
更多的信息: 待补充
如果下载地址失效,请发邮件到三大爱好:游戏、动漫、姑娘
【Unity Shaders】学习笔记之通过修改UV坐标实现纹理贴图的滚动(八)
纹理贴图可以使我们的着色器更有生命力,而且可以快速地实现非常逼真的效果。然而略显遗憾的是,你需要小心翼翼地控制用于着色器地纹理贴图的数目,因为如果添加的纹理图片过多,会非常影响游戏的性能。于是我们可以通过修改UV坐标实现纹理贴图的滚动,使用这种技术实现如瀑布,河流,熔岩流等效果
二、准备工作
创建一个新的着色器文件和一个新的材质。这样,我们就创建一个简介漂亮的着色器,我们可以使用它来研究滚动效果。
三、如何操作
首先,打开刚才创建的着色器文件,然后输入下面提到的代码
1.该着色器需要两个新的属性,我们可以用来控制纹理滚动的速度。因此,我们将添加x方向的速度属性和y方向的速度属性,如下代码所示:
Properties
_MainTint ("Diffuse Tint", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_ScrollXSpeed ("X Scroll Speed", Range(0, 10)) = 2
_ScrollYSpeed ("Y Scroll Speed", Range(0, 10)) = 2
2.修改位于CGPROGRAM部分的CG属性,添加两个新的属性变量便于以后访问
fixed4 _MainT
fixed _ScrollXS
fixed _ScrollYS
sampler2D _MainT
3.修改surf()函数,通过tex2D()函数来改变UV坐标。然后使用内置的_Time变量来实现动态纹理,当我们点击Unity播放按钮时纹理会随时间动起来
void surf (Input IN, inout SurfaceOutput o)
fixed2 scrolledUV = IN.uv_MainT
fixed xScrollValue = _ScrollXSpeed * _T
fixed yScrollValue = _ScrollYSpeed * _T
scrolledUV += fixed2(xScrollValue, yScrollValue);
half4 c = tex2D (_MainTex, scrolledUV);
o.Albedo = c.rgb * _MainT
o.Alpha = c.a;
下图展示了使用滚动UV系统为你的环境创建一个简单河流运动的效果图
四、实现原理
这套纹理滚动系统首先需要声明两个属性,使着色器的使用者能够提高或降低纹理的滚动速度。它的作用在于我们可以从材质Inspector面板中获取浮点值,然后传递给着色器里的surf函数。在程序的开始,我们首先将UV值存储在scrolledUV变量中。这个变量必须是一个float2或fixed2类型的变量,因为UV值是通过Input结构体传入的:
struct Input
float2 uv_MainT
这样,当访问网格的UV时,我们可以使用滚动速度变量和内置的_Time变量对纹理进行便宜。该内置变量返回的是float4类型的值,这意味着当我们进入游戏时,变量的每个组成部分都包含不同的时间值。
_Time变量为我们提供一个基于Unity游戏时钟的递增型浮点值。因此,我们可以使用该事件值在UV方向上移动我们的UV值,也可以通过滚动速度变量来加快或减慢时间。
fixed xScrollValue = _ScrollXSpeed * _T
fixed yScrollValue = _ScrollYSpeed * _T
使用时间计算出正确的偏移量后,我们就可以添加新的偏移值到原有UV值上。这也是我们在下一行使用+=运算符的原因。我们要把原来的UV值,加上新的偏移量,然后传递给tex2D()函数作为新的UV纹理。这样我们就创建了一个物体表面的纹理运动效果。由于我们只对UV坐标进行修改,所以这些是模拟的纹理运动效果。
scrolledUV += fixed2(xScrollValue, yScrollValue);
half4 c = tex2D (_MainTex, scrolledUV);
五、全部代码
Shader "liulongling/ScrollingUVs" {
Properties
_MainTint ("Diffuse Tint", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_ScrollXSpeed ("X Scroll Speed", Range(0, 10)) = 2
_ScrollYSpeed ("Y Scroll Speed", Range(0, 10)) = 2
Tags { "RenderType"="Opaque" }
#pragma surface surf Lambert
fixed4 _MainT
fixed _ScrollXS
fixed _ScrollYS
sampler2D _MainT
struct Input
float2 uv_MainT
void surf (Input IN, inout SurfaceOutput o)
fixed2 scrolledUV = IN.uv_MainT
fixed xScrollValue = _ScrollXSpeed * _T
fixed yScrollValue = _ScrollYSpeed * _T
scrolledUV += fixed2(xScrollValue, yScrollValue);
half4 c = tex2D (_MainTex, scrolledUV);
o.Albedo = c.rgb * _MainT
o.Alpha = c.a;
FallBack "Diffuse"
本文参考了一书,感谢原书作者提供的学习资料
没有更多推荐了,

我要回帖

更多关于 unity 改变体型 的文章

 

随机推荐