Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by notmschneider · Dec 29, 2014 at 10:47 AM · openglnative plugin

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.

alt text

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.

screen.jpg (63.2 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges