spark的纹理索引方式是左下为最小值0 右上为最大值k ,遍历顺序为横向即:

 

  3  4  5

 

  0  1  2

 

而常规的纹理帧序列是这样的:

 

  0  1  2

 

  3  4  5

 

所以,为了让spark的纹理遍历顺序能按照常规的纹理遍历顺序,需要改spark的源码;

在SPARK核心工程的SPK_QuadRenderBehavior.h头文件中

247行:完成如下修改即可:

	inline void QuadRenderBehavior::computeAtlasCoordinates(const Particle& particle) const
	{
		//edit by 南水之源: for UV 从左上为 00, 右下为最大
		//之前的UV是左下为00,右上最大
		int textureIndex = static_cast<int>(particle.getParamNC(PARAM_TEXTURE_INDEX));
		atlasU0 = atlasU1 = static_cast<float>(textureIndex % textureAtlasNbX) / textureAtlasNbX;
		//atlasV0 = atlasV1 = static_cast<float>(textureIndex / textureAtlasNbX) / textureAtlasNbY;
		atlasV0 = atlasV1 = 1.0 - static_cast<float>(textureIndex / textureAtlasNbX) / textureAtlasNbY;//edit
		atlasU1 += textureAtlasW;
		//atlasV1 += textureAtlasH;
		atlasV1 -= textureAtlasH;//edit
	}

  

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-02-10
  • 2021-11-13
  • 2022-02-27
猜你喜欢
  • 2021-04-10
  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
相关资源
相似解决方案