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 Jyakku · Oct 27, 2014 at 07:01 PM · renderingpluginopenglnative pluginoculusrift

Native Rendering Plugin with Oculus Rift

I'm working on a project that offloads some rendering to a native plugin I wrote for Unity, in order to make use of instancing and other advanced graphics features. I'm developing it for a cross-platform release, but I work with a Mac so testing is done primarily with OpenGL. The plugin works as expected in a blank Unity project, but as soon as I incorporate it into my Oculus project, it begins behaving erratically.

In the Rift, the plugin's geometry draws twice, one time stretching across both eyes and another time drawing only within the bounds of the right eye. Additionally, any primitive colors I apply to the geometry are lost and the geometry appears to pick up surrounding colors; on a black screen with red text, the geometry will be mostly black with some red bleeding into the lines. As soon as my green terrain is loaded, the geometry drawn by the plugin becomes green.

Below is a screenshot of the geometry being drawn in a blank Unity project with nothing else:

Blank Unity project

And here is a screenshot of the same geometry being drawn on top of my Oculus Rift application:

Native rendering on top of Oculus Rift

Here's the creation of the vertices that I'm rendering (three coordinates and color):

 Vertex verts[4] =
     {
         { -0.5f,  0.5f,  0, 0xFF0000ff },
         {  0.5f,  0.5f,  0, 0xFFff0000 },
         {  0.5f, -0.5f,  0, 0xFF00ff00 },
         { -0.5f, -0.5f,  0, 0xFFff0000 },
     };

Here's the draw function, called every frame within the plugin:

 // OpenGL case
 if (g_DeviceType == kGfxRendererOpenGL)
 {
     //initialize model view matrices
     glMatrixMode (GL_MODELVIEW);
     float modelMatrix[16] =
     {
         1,0,0,0,
         0,1,0,0,
         0,0,1,0,
         0,0,0,1,
     };
     glLoadMatrixf (modelMatrix); //assign our matrix to the current MatrixMode
 
     //initialize projection matrix
     glMatrixMode (GL_PROJECTION);
     projectionMatrix[10] = 2.0f; //tweak projection matrix to match D3D
     projectionMatrix[14] = -1.0f;
     glLoadMatrixf (projectionMatrix);
 
     // Vertex layout
     glVertexPointer (3, GL_FLOAT, sizeof(verts[0]), &verts[0].x);
     glEnableClientState (GL_VERTEX_ARRAY);
     glColorPointer (4, GL_UNSIGNED_BYTE, sizeof(verts[0]), &verts[0].color);
     glEnableClientState (GL_COLOR_ARRAY);
 
     glDrawArrays(GL_LINE_LOOP, 0, 4);
 
 }

Any insight from experienced native plugin/Rift graphics coders would be appreciated!

screen shot 2014-10-27 at 3.04.42 pm.png (17.3 kB)
screen shot 2014-10-27 at 3.02.20 pm.png (420.9 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

Native Plugin: What has to happen in the RenderEvent? 1 Answer

UnityPluginLoad never called on iOS, Is it just broken? 1 Answer

OpenGL Context from Plugin 1 Answer

Native rendering plugin OpenGL device type not being set. 2 Answers

External terrain renderer 0 Answers


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