Vuforia SDK를 사용하여 휴대 전화 카메라의 비디오 스트림을 화면에 렌더링합니다. 왜이 오버레이를 렌더링 할 때 오프셋이 있습니까?
은 그래서 질감이 날은 Vuforia 라이브러리에 의해 생성되지 않습니다. 이러한 배경을 렌더링하는 데 사용쉐이더는 다음과 같습니다
내가 원하는하지 않습니다
// Vertex Shader
attribute vec4 a_position;
attribute vec2 a_textureCoords;
varying vec2 v_textureCoords;
uniform mat4 u_projectionMatrix;
void main()
{
gl_Position = u_projectionMatrix * a_position;
v_textureCoords = a_textureCoords;
}
// Fragment Shader
varying highp vec2 v_textureCoords;
uniform sampler2D u_currentTexture;
void main()
{
vec4 currentColor = texture2D(u_currentTexture, v_textureCoords);
gl_FragColor = currentColor;
}
지금, 나는 화면의 왼쪽 상단 모서리에 오버레이를 원하는 이 오버레이는 분홍색 질감 인 만 표시하지만 분홍색 질감과 배경 질감은 multiply blend입니다. 텍스처는 이 아니며은 같은 좌표를가집니다.
하지만 지금은, 이의이 혼합 잊고 그냥 분홍색 질감의 쉐이더 프로그램에서 배경 질감 을 렌더링 할 수 있도록. 그래서 결국, 예, 하나는 배경 전용 버전과 오버레이 버전이있는 배경이 다르지 않아야합니다. 당신이 볼 수 있듯이
... 작은이 오프셋이 , (그림과 의자의 상단에 보면)
오버레이를 렌더링하는 데 사용되는 셰이더
은 다음과 같습니다// Vertex Shader
attribute vec4 a_position;
attribute vec2 a_currentTextureCoords;
varying vec2 v_currentTextureCoords;
void main()
{
gl_Position = a_position;
v_currentTextureCoords = a_currentTextureCoords;
}
// Fragment Shader
varying highp vec2 v_currentTextureCoords;
uniform sampler2D u_currentTexture;
uniform sampler2D u_backgroundTexture;
void main()
{
vec2 screenSize = vec2(1080.0, 1920.0);
vec2 cameraResolution = vec2(720.0, 1280.0);
vec2 texelSize = vec2(1.0/screenSize.x, 1.0/screenSize.y);
vec2 scaleFactor = vec2(cameraResolution.x/screenSize.x, cameraResolution.y/screenSize.y);
vec2 uv = gl_FragCoord.xy * texelSize * scaleFactor;
uv = vec2(scaleFactor.y - uv.y, scaleFactor.x - uv.x);
vec4 backgroundColor = texture2D(u_backgroundTexture, uv);
gl_FragColor = backgroundColor;
}
계산이 잘못 되었습니까?