想要使用代码直接修改材质的tilingOffset,代码运行后直接整个物体直接变成白色的了
下面是代码相关代码
const material = this.node.children[0].children[0].getComponent(cc.ModelComponent).material ;
material .setProperty(‘tilingOffset’, [info.s.x, info.s.z, 0, 0]);
想要使用代码直接修改材质的tilingOffset,代码运行后直接整个物体直接变成白色的了
下面是代码相关代码
const material = this.node.children[0].children[0].getComponent(cc.ModelComponent).material ;
material .setProperty(‘tilingOffset’, [info.s.x, info.s.z, 0, 0]);
tilingOffset 的 info.s.x 和 info.s.z 值分别是多少?想要的平铺效果是什么样的?可能是需要修改贴图的 clamp 设置。
1.info.s.x 和 info.s.z 值在10~20之间,
2.就是个地板砖的贴图,要放大地板,让贴图平铺,直接在编辑器里更改是有效果的
这个是想要的效果,
这个是图片资源
tilingOffset.xyzw 的取值是 0 - 1,tilingOffset.xy 是缩放,tilingOffset.zw 是偏移。
另外,需要将贴图的 wrap mode 改为 REPEAT 才会有重复平铺的效果
使用setProperty设置tilingOffset后,整个变白的问题我也遇到了,请问楼主怎么解决的。
material .setProperty(‘tilingOffset’, [0.5, 0.5, 0, 0]);
没解决,功能还没做完,项目就被砍了
这也是一种不错的解决方案
解决方法
this.materCom.setProperty(“tilingOffset”,new Vec4(1,1,0,0));