precision mediump float; uniform sampler2D uTexture; uniform sampler2D refractTexture; varying vec2 vTexCoordinate; varying vec2 vRefTexCoordinate; void main() { vec2 scaleVec = vec2(0.05, 0.05); vec4 bumpTex = 2.0 * texture2D(refractTexture, vRefTexCoordinate) - 1.0; vec2 refCoords = vTexCoordinate.xy + bumpTex.xy * scaleVec; gl_FragColor = texture2D(uTexture, refCoords); }
vec4 bumpTex = 2.0 * texture2D(refractTexture, vRefTexCoordinate) - 1.0;
mTextureUniformHandle = GLES20.glGetUniformLocation(mProgram, "uTexture"); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataHandle); GLES20.glUniform1i(mTextureUniformHandle, 0); if (refractNormal && textureRefBuffer != null) { mTextureRefUniHandle = GLES20.glGetUniformLocation(mProgram, "refractTexture"); GLES20.glActiveTexture(GLES20.GL_TEXTURE1); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureRefDataHandle); GLES20.glUniform1i(mTextureRefUniHandle, 1); mTextureRefCoordinateHandle = GLES20.glGetAttribLocation(mProgram, "aRefTexCoordinate"); GLES20.glVertexAttribPointer(mTextureRefCoordinateHandle, mTextureCoordinateDataSize, GLES20.GL_FLOAT, false, 0, textureRefBuffer); GLES20.glEnableVertexAttribArray(mTextureRefCoordinateHandle); } mTextureCoordinateHandle = GLES20.glGetAttribLocation(mProgram, "aTexCoordinate"); GLES20.glVertexAttribPointer(mTextureCoordinateHandle, mTextureCoordinateDataSize, GLES20.GL_FLOAT, false, 0, textureBuffer); GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
precision mediump float; uniform vec4 vColor; uniform sampler2D uTexture; varying vec2 vTexCoordinate; void main() { gl_FragColor = vColor * texture2D(uTexture, vTexCoordinate); }
vec4 bumpTex = 2.0 * texture2D(refractTexture, vRefTexCoordinate) - 1.0; vec2 refCoords = vTexCoordinate.xy + bumpTex.xy * scaleVec;