짧은 대답은 "쉐이더"접근 방식에 대해 자세한 내용 "그것은 renderscript를 통해 OpenGL을 쉐이더를 통해 직접 할 수는 없습니다 만, 가능"입니다. 그것은 컴파일 또는 런타임 오류없이 작동
FloatBuffer texBuffer = ByteBuffer.allocateDirect(array.length * Float.SIZE).order(ByteOrder.nativeOrder()).asFloatBuffer();
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, iAxisSize, iAxisSize, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, texBuffer);
하지만 결과적으로 당신은 검은 화면이 나타납니다 : 1 개 라인이
#extension GL_OES_texture_3D : enable
precision mediump float;
uniform sampler2D u_texture0;
uniform vec4 uColor;
varying vec4 v_vertex;
uniform sampler3D u_lut;
void main() {
vec2 texcoord0 = v_vertex.xy;
vec4 rawColor=texture2D(u_texture0, texcoord0);
vec4 outColor = texture3D(u_lut, rawColor.rgb);
gl_FragColor = outColor; //rawColor;
}
자바 코드 (듯이) Texture3D
를 사용하여 정의해야합니다주의를 기울이십시오. 물론 glTexImage2D 함수 대신 glTexImage2D 함수를 사용해야하지만 안드로이드 SDK17에서는 구현되지 않았으므로 아무 것도 할 수 없습니다.
좋은 소식 : Android SDK17에서는 ScriptIntrinsicLUT을 구현하여 소스 이미지에 1D LUT를 적용 할 수 있습니다. 자바 코드가 우는 소리입니다 : 약
private RenderScript mRS;
private Allocation mInAllocation;
private Allocation mOutAllocation;
private ScriptC_mono mScript;
private ScriptIntrinsicLUT mIntrinsic;
...
mRS = RenderScript.create(this);
mIntrinsic = ScriptIntrinsicLUT.create(mRS, Element.U8_4(mRS));
createLUT();
mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
mOutAllocation = Allocation.createTyped(mRS, mInAllocation.getType());
mIntrinsic.forEach(mInAllocation, mOutAllocation);
mOutAllocation.copyTo(mBitmapOut);
...
private void createLUT() {
for (int ct=0; ct < 256; ct++) {
float f = ((float)ct)/255.f;
float r = f;
if (r < 0.5f) {
r = 4.0f * r * r * r;
} else {
r = 1.0f - r;
r = 1.0f - (4.0f * r * r * r);
}
mIntrinsic.setRed(ct, (int)(r * 255.f + 0.5f));
float g = f;
if (g < 0.5f) {
g = 2.0f * g * g;
} else {
g = 1.0f - g;
g = 1.0f - (2.0f * g * g);
}
mIntrinsic.setGreen(ct, (int)(g * 255.f + 0.5f));
float b = f * 0.5f + 0.25f;
mIntrinsic.setBlue(ct, (int)(b * 255.f + 0.5f));
}
}
자세한 내용 : http://developer.android.com/reference/android/renderscript/ScriptIntrinsicLUT.html http://my.fit.edu/~vkepuska/ece5570/adt-bundle-windows-x86_64/sdk/sources/android-17/com/android/rs/image/CrossProcess.java
어떻게'INT []'에서의 int로 수레를 저장 (동일한 비트 패턴을 사용하여, 즉,하지 절단)에 대해, 해당 배열에서'createBitmap'을하고 RGBA 텍스처로 업로드합니까? 또는'glUniform1fv'를 사용할 수도 있습니다. – Michael