vr | HackLAB https://www.geeks3d.com/hacklab 3D Programming, Prototyping and Gamedev with GeeXLab Thu, 14 Jun 2018 07:09:35 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 Introduction to VR Programming with GeeXLab https://www.geeks3d.com/hacklab/20170331/introduction-to-vr-programming-with-geexlab/ https://www.geeks3d.com/hacklab/20170331/introduction-to-vr-programming-with-geexlab/#respond Fri, 31 Mar 2017 15:25:26 +0000 http://www.geeks3d.com/hacklab/?p=1252 GeeXLab 0.14+ comes with a very cool feature: the support of Virtual Reality (or VR for the impatient!) via the use of the OpenVR library. OpenVR functionalities are accessible in Lua and Python via the OpenVR plugin of GeeXLab (plugin_gxc_openvr_x32.dll or plugin_gxc_openvr_x64.dll on Windows platforms). Currently only Windows platforms are supported, but I can build the Linux 64-bit version if necessary (and I will certainly … Continue reading Introduction to VR Programming with GeeXLab »

The post Introduction to VR Programming with GeeXLab first appeared on HackLAB.]]>

How to program the HTC Vive in GeeXLab

GeeXLab 0.14+ comes with a very cool feature: the support of Virtual Reality (or VR for the impatient!) via the use of the OpenVR library. OpenVR functionalities are accessible in Lua and Python via the OpenVR plugin of GeeXLab (plugin_gxc_openvr_x32.dll or plugin_gxc_openvr_x64.dll on Windows platforms). Currently only Windows platforms are supported, but I can build the Linux 64-bit version if necessary (and I will certainly build it in the future). I tested the OpenVR plugin with the HTC Vive headset. I don’t know if it will work with the Oculus Rift but according to what I read on the Net, it should work.

Virtual reality… VR is very cool, especially for a graphics programmer. Why? Because for the first time, the graphics programmer can visit the 3D world that he’s programming. Even the simplest 3D object, the triangle, is an amazing spectacle the first time you see it through the VR headset. The RGB triangle (RGB because it’s nicer) is there, in front of you, and you can walk around it, you can almost touch it… like it was really there. You are in the matrix!

Here’s the hello world of VR programming: the RGB triangle:


VR demo in GeeXLab

 
and just for fun, here is a close-up of the right eye of the HTC Vive headset:


VR demo in GeeXLab

 
Programming VR in GeeXLab is quite simple. Basically, you need for each eye:
– one perspective camera
– one render target

You also need functions of the gh_vr library that is available in Lua and Python.

The size of the render target for each eye can be get with gh_vr.get_recommended_render_target_size(). For the HTC Vive, the size of a render target is 1512×1680 pixels.

Here are the 4 steps to render a scene in VR:
1/ update the left and right cameras with gh_vr.update_cameras()
2/ render the world from the point of view of the left camera into the render target of the left eye.
3/ render the world from the point of view of the right camera into the render target of the right eye.
4/ send both render targets to the HMD (Head Mounted Display) using gh_vr.submit().

The principle is simple. The practice with GeeXLab too. Here is the INIT code (Lua) for the RGB triangle demo:

---------------------------------
-- Create 2 render targets
--
vr_rt_w, vr_rt_h = gh_vr.get_recommended_render_target_size()    
rt_left_eye = gh_render_target.create(vr_rt_w, vr_rt_h)
rt_right_eye = gh_render_target.create(vr_rt_w, vr_rt_h)


---------------------------------
-- Create 2 cameras
--
aspect = vr_rt_w / vr_rt_h
camera_left_eye = gh_camera.create_persp(60, aspect, 0.1, 100.0)
Camera_right_eye = gh_camera.create_persp(60, aspect, 0.1, 100.0)


---------------------------------
-- Create a triangle and a ground plane
--
triangle = gh_mesh.create_triangle()
ground = gh_mesh.create_plane(10, 10, 20, 20)

 
Now the FRAME script, still in Lua:

---------------------------------
-- Update left and right cameras
--
gh_vr.update_cameras(camera_left_eye, camera_right_eye)



---------------------------------
-- Render the world (triangle and ground plane) for the left eye.
--
gh_render_target.bind(rt_left_eye)
  
gh_camera.bind(camera_left_eye)
gh_renderer.clear_color_depth_buffers(0.0, 0.0, 0.0, 1.0, 1.0)

gh_gpu_program.bind(vertex_color_prog)

gh_renderer.wireframe()
gh_object.render(ground)
gh_renderer.solid()

gh_object.set_euler_angles(triangle, 0, 0, 0)
gh_object.set_position(triangle, 0, 0.5, -1.0)
gh_object.render(triangle)

gh_render_target.unbind(rt_left_eye)



---------------------------------
-- Render the world for the right eye.
--
gh_render_target.bind(rt_right_eye)
  
gh_camera.bind(camera_right_eye)
gh_renderer.clear_color_depth_buffers(0.0, 0.0, 0.0, 1.0, 1.0)

gh_gpu_program.bind(vertex_color_prog)

gh_renderer.wireframe()
gh_object.render(ground)
gh_renderer.solid()

gh_object.set_euler_angles(triangle, 0, 0, 0)
gh_object.set_position(triangle, 0, 0.5, -1.0)
gh_object.render(triangle)

gh_render_target.unbind(rt_right_eye)



---------------------------------
-- Send render target to the HMD
--
gh_vr.submit(rt_left_eye, rt_right_eye)
  

 
I put in bold the functions of the OpenVR plugin. Very limited.

The RGB triangle demo can be found in the gl-32/vr/demo01/ folder of the code sample pack.

The post Introduction to VR Programming with GeeXLab first appeared on HackLAB.]]>
https://www.geeks3d.com/hacklab/20170331/introduction-to-vr-programming-with-geexlab/feed/ 0
GeeXLab 0.14.1 released with Virtual Reality (VR) Support https://www.geeks3d.com/hacklab/20170331/geexlab-0-14-1-released-with-virtual-reality-vr-support/ https://www.geeks3d.com/hacklab/20170331/geexlab-0-14-1-released-with-virtual-reality-vr-support/#respond Fri, 31 Mar 2017 14:35:09 +0000 http://www.geeks3d.com/hacklab/?p=1251 After few months without new version, a new update of GeeXLab is available for Windows (32/64-bit), Linux (64-bit) and Raspberry Pi (32-bit). And the macOS version? The macOS version is still alive and I will simply build it later… The main new feature of the branch 0.14.x.x is the support of Virtual Reality (VR) headsets via the OpenVR library. Like many other features in GeeXLab, … Continue reading GeeXLab 0.14.1 released with Virtual Reality (VR) Support »

The post GeeXLab 0.14.1 released with Virtual Reality (VR) Support first appeared on HackLAB.]]>

GeeXLab

After few months without new version, a new update of GeeXLab is available for Windows (32/64-bit), Linux (64-bit) and Raspberry Pi (32-bit). And the macOS version? The macOS version is still alive and I will simply build it later…

The main new feature of the branch 0.14.x.x is the support of Virtual Reality (VR) headsets via the OpenVR library. Like many other features in GeeXLab, the functionalities of OpenVR are available via a plugin (in the {GeeXLab_Home}/plugins/ folder). The OpenVR plugin is currently available for Windows platforms only but can be compiled on Linux too if necessary (to be honest I was too lazy to build the plugin on Linux…). I only tested the OpenVR plugin with the HTC VIVE headset and it’s a really cool experience! So if you have a VR headset, you will find some VR demos in the full code sample pack (in the gl-32/vr/ folder). I will explain how to code a VR demo in GeeXLab in a next post. As you will see, it’s easy!


HTC Vive headset

GeeXLab - VR demo

 
I also improved a bit the error handling (syntax and runtime errors in scripting) and on Windows, GeeXLab displays an error scene. From GeeXLab 0.14+, a new log file is available for all scripting traces. This log file called _scripting_log.txt contains only scripting-related information. That allows to remove noise present in the main log file.

Other minor improvement is the support of Open True Type fonts (OTF) by the gh_font lib (lua / python). The Lua engine has been updated to the latest 5.3.4 version.

GeeXLab 0.14.1.x as well as the code sample pack can be downloaded from THIS PAGE.

The changelog for the branch 0.14 of GeeXLab is available right here. The full changelog can be found HERE.

Version 0.14.1.1 - 2017.04.01
! [WINDOWS] ! improves the detection of AMD Radeon GPUs in some systems 
  that include Intel iGPU + AMD Radeon GPU.
! updated GPU Shark 0.9.11.2


Version 0.14.1.0 - 2017.03.28
+ [WINDOWS] a preview of scripting errors is now displayed in a new built-in error scene
  instead of being simply displayed in a log file. The log file is still available with complete
  information.
+ added a new log file for scripting: _scripting_log.txt. All traces related to scripting
  are writtren in this log file.
! updated the default startup scene.
! [WINDOWS, LINUX] Vulkan plugin recompiled with latest Vulkan API headers (v1.0.45).
! [WINDOWS, LINUX] updated the GPU monitoring plugin with NVIDIA GeForce GTX 1080 Ti, 
  AMD Radeon RX 580, RX 570 and RX 560.
* [WINDOWS] fixed minor bugs in the OpenVR plugin.
+ [WINDOWS] added gh_openvr lib (OpenVR) to the Python plugin.
+ [WINDOWS] added milliseconds in every trace of the log file.
+ added get_absolute_orientation() to gh_object lib (lua / python).
! updated the GPU monitoring plugin with AMD Radeon Pro WX 7100, WX 5100, WX4100,
  WX 4150 and WX 4130.


Version 0.14.0.0 - 2017.03.08
+ [WINDOWS] added OpenVR support (openvr plugin) + gh_openvr lib (lua).
! updated Lua scripting plugin with latest Lua 5.3.4.
+ added update_plane_size() to gh_mesh (lua / python).
+ added update_box_face_uv_tiling() to gh_mesh lib (lua / python).
+ added get_euler_angles() to gh_camera lib (lua / python).
+ added get_num_vertices_v2() and get_num_faces_v2() to gh_object lib (lua / python).
! [WINDOWS] Vulkan plugin recompiled with latest Vulkan API headers (v1.0.42).
* fixed a bug in the Vulkan plugin that led to a crash with recent NVIDIA and AMD drivers.
! [WINDOWS] updated the GPU monitoring plugin with AMD Radeon R7 M360, R7 M340,
  R7 M260, R7 M460 and R7 M440. 
+ added support of open true type fonts (OTF) in gh_font lib (lua/python).


GeeXLab

The post GeeXLab 0.14.1 released with Virtual Reality (VR) Support first appeared on HackLAB.]]>
https://www.geeks3d.com/hacklab/20170331/geexlab-0-14-1-released-with-virtual-reality-vr-support/feed/ 0