Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Using SetRenderToImage() for Higher resolution and faster VR?

Author
Message
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 4th Jun 2017 16:22 Edited at: 4th Jun 2017 16:53
Has anyone had success using CreateRenderImage() and SetRenderToImage() commands to apply
the image to an object? I know that it works when applying to a sprite. What I am trying to accomplish
is creating a faster way to render VR on a mobile device. This method is using 2 object planes that are
distorted with a barrel vertex shader. Then I need to apply the render image to the object planes.
My testing so far shows that SetRenderToImage() does not work when the imagine is on an object.
The documentation says that it is supposed to work for an object. I think this may be a bug with
SetRenderToImage() when used with objects so if any one has an example of it working on an object
please post. If it would work I could post a complete example for a faster and higher resolution for VR.

I am basing this method on this article.
https://www.imgtec.com/blog/speeding-up-gpu-barrel-distortion-correction-in-mobile-vr/


Here is just a basic layout of the code.

The coffee is lovely dark and deep,and I have code to write before I sleep.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 4th Jun 2017 17:28
have you tried :

--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 4th Jun 2017 18:08
Yes I have it still does not work.
The coffee is lovely dark and deep,and I have code to write before I sleep.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 4th Jun 2017 18:21 Edited at: 4th Jun 2017 18:22
are you sure about the UVs of your mesh ?
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 4th Jun 2017 19:50
Yes, I can get it to work with the GetImage() command but it is too slow as it not recommended to be called every frame.

Quote: "Calling GetImage is a slow command and it is not recommended that it be called every frame."

The coffee is lovely dark and deep,and I have code to write before I sleep.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 4th Jun 2017 20:45 Edited at: 4th Jun 2017 20:45
Very strange.

For my own VR experiences i prefered to use a fullscreen shader for barrel distortion on 2 rendered sprite (leftEye, RightEye) which produces some good performances :



I wanted to release a VR example with my home-made Lib but for the moment i'm on my Multiplayer Linux server
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit

Attachments

Login to view attachments
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 5th Jun 2017 20:11
Hopefully Paul will look into this since it seems to be a bug.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 5th Jun 2017 21:26
AGK comes with an example called RenderToImage that will use a rendered image on a 3D object, so it should work. It may be because the object still has the image attached when Render is called, which will try to draw the object to the image it is currently using. Something like this may work

Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 6th Jun 2017 15:28 Edited at: 6th Jun 2017 15:30
Thanks for your insight Paul, I was unaware of the demo.
I examined the demo and discovered what I was doing wrong.
The demo does not move the camera like I am so I had to move the
SetCameraPosition() call to before the Swap() and add another Render().
I can now continue with my development on this method. Now I just need to
properly deform a mesh in a modeling program to match the distortion of the
lenses in the VR headset.


The coffee is lovely dark and deep,and I have code to write before I sleep.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 8th Jun 2017 19:08
I have made some progress, I have been able to correctly distort a mesh using Wings3D.
I now have it properly rendering the image on the mesh. Unfortunately I have run into a glitch.
I need to change the aspect ratio of the camera before I render to the image and then change it back to normal afterwards.
It seems that in AppGameKit I can not change the aspect ratio in the loop. If I do not change the aspect ratio it results in a distorted
image when the camera is rotated on the roll axis. See attached images. Two solutions could solve this, more than one camera
or being able to change the aspect ratio. In my opinion AppGameKit should have more then camera especially since all the commands
actually take a camera number already. This pre distorted mesh method is better and faster than the barrel pixel shader method
or my original testing using a barrel vertex shader to distort the mesh.

I base this on my testing results and the information from this article.
http://smus.com/vr-lens-distortion/

Paul, should it be possible to change the aspect ratio like this?



The coffee is lovely dark and deep,and I have code to write before I sleep.

Attachments

Login to view attachments
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 8th Jun 2017 21:08
It seems that you can change the aspect ratio in in the loop, AppGameKit did not like these lines.


It needed to be like this.



I will post the complete demo as soon as I get it cleaned up.
I am getting very good results on an LG Stylo 3 with a Tzumi Dream Vision headset.


The coffee is lovely dark and deep,and I have code to write before I sleep.

Login to post a reply

Server time is: 2024-09-30 03:21:28
Your offset time is: 2024-09-30 03:21:28