首页 > 编程知识 正文

unity的意思,3dmax怎么用vray贴图

时间:2023-05-06 21:28:41 阅读:10950 作者:3631

作为全景图的HDRI地图可以代替六面cubemap,传统的3D软件被广泛使用。 用于一般的反射探头、天匣子等。

但是,过大是个问题,特别是移动侧控制包裹体的大小,虽然可以用球面图置换部分环境类图,但适用范围仍然有限。

现在,通过镜像优化贴图大小,将贴图优化为原始大小的一半。

原图如下(网络收集) :

最终效果(左右上下镜像) :

github有几个类似球面坐标的Equirectangular map变换函数,带来了直接主义。

参照:

33559 github.com/tolotratlt/unityphotosphericview

33559 github.com/mapia rz/cubemaptoequirectangular

由于测试结果可以镜像x、y轴,所以首先需要修整原始的HDRI图像。 用纹理2d的Resize直接裁剪就可以了。 conv着色器是两个镜像函数的转换着色器,不再发布

材质mat=new材质(shader.find (hidden/conv shader ); varrt=render texture.get temporary (newrendertexturedescriptor (tex.width,tex.height,RenderTextureFormat.ARGB32 ) Graphics.blit(Tex,rt,mat ); varinstancetex=instantiate(tex ); instance tex.resize (instance tex.width,instanceTex.height/2 ); instance tex.read pixels (new rect (0,0,instanceTex.width,instanceTex.height ),0,0 ); instanceTex.Apply (;

主要是变换全景图的两个函数,参考了github的内容,将常数变更为内置的UNITY_PI。

float3uvtodir(float2uv ) uv*=float2) unity_two_pi,UNITY_PI ); 浮动theta=uv.y; float phi=uv.x; float3dir=float3(0,0,0 ); Dir.x=sin(phi ) sin ) theta )-1; Dir.y=cos(Theta ) * -1; Dir.z=cos(phi ) sin ) Theta )-1; 返回dir; }浮动2 dirtouv (float 3a_coords )浮动3a _ coords _ n=normalize ) a _ coords ); floatlon=Atan2(a_coords_n.z,a_coords_n.x ); 浮动lat=acos (a _ coords _ n.y; float2spherecoords=float2(lon,lat ) *(1.0/unity_pi ); 返回浮动2 (1- (sphere coords.x * 0.5-0.5 ),1 - sphereCoords.y ); //must flip x}

变换后,对显示部分进行修正,通过传递单向矢量返回全景图的UV,在其内部进行镜像图像的修复

需要注意输出x分量不是0-1区间,而是0-2,估计是由全景宽度高度2:1引起的,但这里简单地进行了修复。

y轴的接缝很明显,手动调整误差。 压缩,关闭mipmap等。 接缝的问题得到缓和。

浮动2 dirtouv (float 3a_coords ) float3a_coords_n=Normalize ) a _ coords ); floatlon=Atan2(a_coords_n.z,a_coords_n.x ); 浮动lat=acos (a _ coords _ n.y; float2spherecoords=float2(lon,lat ) *(1.0/unity_pi ); float2uv=float2(1- (sphere coords.x * 0.5-0.5 ),1 - sphereCoords.y ); //--------UV.X----=1; if(uv.x0.5 ) uv.x=0.5-) uv.x-0.5; uv.x *=2; //--------------mirrorx.--------------- -将if(uv.y1 ) uv.y *=-0.97; else uv.y *=1.03; //------------mirrory.returnuv; }

基本上如上所述,并且在许多情况下,Cubemap需要迁移到HDRI全景。 请直接参阅维基百科中的Cubemaping映射函数:

3359 en.Wikipedia.org/wiki/cube _ mapping

转载于:https://www.cn blogs.com/hont/p/9781257.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。