简体   繁体   English

选择纹理的一部分并绘制GPU

[英]Select portions of a texture, and draw, GPU

I have a few days looking for how to do this, but I'm stuck, if someone can tell me some resource that can be useful for me, I do what I look for, I do not want to write all the code for my only guide me how to do it, "because I think it is possible " 我有几天的时间在寻找如何执行此操作的方法,但我遇到了麻烦,如果有人可以告诉我一些对我有用的资源,我会按照我的意愿去做,我不想为我编写所有代码只指导我该怎么做,“因为我认为这是可能的”

My intention is to host a texture on the GPU, and take, selections, parts of that texture, passing the size you want to take, and draw in "quad" or "mesh" in libgdx. 我的意图是在GPU上托管一个纹理,并获取,选择该纹理的一部分,传递要获取的大小,并在libgdx中绘制“ quad”或“ mesh”。

I can create a multitexture, using vertex and shader, but not like taking parts of a texture to them in another texture, and change the parts that should be drawn. 我可以使用顶点和着色器创建多纹理,但是不喜欢将纹理的一部分带入另一个纹理中,然后更改应绘制的部分。

But maybe this is not the right way to do what I want. 但这也许不是我想要做的正确方法。

Below, I show an image to understand me better: 下面,我显示一张图片以更好地了解我:

在此处输入图片说明

  1. is the texture on the GPU, original 是GPU上的纹理,原始
  2. the image, which would be drawn depending on the coordinates that are passed 图像,将根据传递的坐标进行绘制
  3. the result would be shown 结果将显示

If I understood your intent correctly, I think what you want is simply texture coordinate or UV mapping. 如果我正确理解了您的意图,我想您想要的只是纹理坐标或UV贴图。 Assuming you have the texture (1), you would then draw four quads, each of them using different texture coordinates to access the multitexture. 假定您具有纹理(1),然后绘制四个四边形,每个四边形使用不同的纹理坐标来访问多纹理。 For example, looking at the top image of (3), 例如,查看(3)的顶部图像,

  • the top-left and top-right quads would use texture coordinates from [0.0, 0.0] to [0.5, 0.5] to access the black area, 左上角和右上角四边形将使用从[0.0,0.0]到[0.5,0.5]的纹理坐标来访问黑色区域,
  • the bottom-left quad would use texture coordinates from [0.5, 0.5] to [1.0, 1.0] to access the red area, and 左下角的四边形将使用从[0.5,0.5]到[1.0,1.0]的纹理坐标来访问红色区域,并且
  • the bottom-right quad would use texture coordinates from [0.5, 0.0] to [1.0, 0.5] to access the blue area. 右下角的四边形将使用从[0.5,0.0]到[1.0,0.5]的纹理坐标来访问蓝色区域。

If you want, you can create a function that maps the "atlas frame index" 1, 2, 3 or 4 to the correct texture coordinates to make drawing easier. 如果需要,可以创建一个将“图集框架索引” 1​​、2、3或4映射到正确的纹理坐标的函数,以使绘制更加容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM