- Home /
Native Integration with OpenGL render
I am currently trying to implement an open source auxiliary renderer in OpenGL. To boil it down to a simple problem I started with scene consisting of a single quad. In my native plugin I try to render another quad exactly in front of the unity game object in order to display an overlay computed in the native plugin.
So far I am stuck to recreate the MVP transformation matrix in OpenGL. The OpenGL Quad gets rendered in a similar position to the Unity Quad, but is wrongly rotated. Please have a look at the following screenshot, the green part of the computed texture corresponds to the visible part of the Unity Quad. Ideally the white and green Quad should be positioned exactly at the same position as the textured Unity Quad.
To render the quad I used the following OpenGL code, where "model" corresponds to the Quad's localToWorldMatrix, and view to the camera's worldToCameraMatrix Matrix, while projection was generated using Unity's camera settings.
glm::mat4 projection = glm::perspective(42.0, 1.0, 0.1, 10.0);
glm::mat4 mvp = projection * view * model;
glUniformMatrix4fv(mvpMatrixUniformIndex, 1, GL_FALSE, glm::value_ptr(mvp));
The quads vertices where rendered with the following vertex shader
attribute highp vec4 position;
attribute highp vec2 texCoord;
uniform highp mat4 mvpMatrix;
varying highp vec2 uv;
void main()
{
gl_Position = mvpMatrix * position;
uv = texCoord;
}
I could not find further resources on how to recreate Unity's rendering and would be glad to receive more pointers on how to progress with this.
Your answer
![](https://koobas.hobune.stream/wayback/20220613175103im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Issue with glDrawArrays in plugin 2 Answers
drawing a line following an object 3 Answers
can not enable OpenGl ES 2.0 in Edit>Graphics emulation 0 Answers
Execute native ios code in unity 1 Answer