, 그것이 :) 아니에요 프로세서에서 더 쉬워졌습니다. 또한 유니폼의 값만 변경하면됩니다. 그러나 사전 처리로 인해 응용 프로그램을 여는 데 약간의 시간이 걸릴 수 있습니다.
쉐이더를 컴파일하는 uniform 변수를 얻으십시오. animationPos는 전역이어야합니다.
Gluint animationPos = glGetUniformLocation(shaderProgram, "nameoftheuniform");
귀하의 메인 루프는 셰이더 animationPos 값을 전달한다 : 주요
uniform int animationPos;
조각 쉐이더 :
float texCoordY = texCoord.y; //texture coordinates should be passed from vertex shader
float texCoordX = texCoord.x/20.0f; //we are dividing it with 20 since it is the amount of textures that we have and if we use it directly it would try to use all the texture. Whereas the texture stores at 20 different textures.
float textureIndex = 1.0f*animationPos/20.0f; //Pointer to the start of the animation texture.
gl_fragColor = texture2D (yourTexture, vec2(textureIndex + texCoordX, texCoordY));
Gluniform1i (animationPos, curentAnimationIndex);
이 당신의 조각 셰이더 변수를 추가 위의 코드는 가정합니다. 텍스쳐를 x 방향으로 확장했다면 매트릭스처럼 확장하려고 시도 할 수 있습니다. 그런 다음 texCoord 계산 부분을 변경해야합니다. 또한 우리는 20 개의 텍스처를 사용하고 있습니다.
옵션 a)는 프로세서에서 더 무거 우므로 매번 텍스처를 변경하므로 pci를 조금 더 사용하지만 메모리는 더 사용합니다. 질문은 디자인 결정과 더 비슷하지만 20 개의 이미지를 처리 할 수 있으므로 옵션 b)를 선택해야합니다.
편집 : 코드가 추가되었습니다.
다음 ModelInstance에 하나의 자료가 있다면,
또는 :
을 또는 당신은 더 일반적인 접근 방식을 원하는 경우 가장 최근에 1.4.1을 의미합니까? 아니면 밤에 뭔가? 그 방법은 분명해 보이지만 TextureAttribute에 "Set"메서드가없는 것 같습니다. – darkflame
TextureAttribute 속성 = instance3.materials.get (0) .get (TextureAttribute.class, TextureAttribute.Diffuse); "속성"에는 "설정"방법이 없습니다. – darkflame
최신 릴리스는 TextureAttribute # set (TextureRegion)이있는 1.4.1입니다. 참조 : https://github.com/libgdx/libgdx/blob/1.4.1/gdx/src/com/badlogic/gdx/graphics/g3d/attributes/TextureAttribute.java#L122 – Xoppa