Explorar el Código

Review VR simulator

Requires some work, distortion shader could be move out of raylib to
example code...
pull/363/head
Ray San hace 7 años
padre
commit
ddea9d68bf
Se han modificado 3 ficheros con 8 adiciones y 8 borrados
  1. +5
    -5
      src/rlgl.c
  2. +1
    -1
      src/rlgl.h
  3. +2
    -2
      src/shader_distortion.h

+ 5
- 5
src/rlgl.c Ver fichero

@ -291,7 +291,6 @@ static bool texCompASTCSupported = false; // ASTC texture compression support
#if defined(SUPPORT_VR_SIMULATOR) #if defined(SUPPORT_VR_SIMULATOR)
// VR global variables // VR global variables
static VrDeviceInfo hmd; // Current VR device info
static VrStereoConfig vrConfig; // VR stereo configuration for simulator static VrStereoConfig vrConfig; // VR stereo configuration for simulator
static bool vrSimulatorReady = false; // VR simulator ready flag static bool vrSimulatorReady = false; // VR simulator ready flag
static bool vrStereoRender = false; // VR stereo rendering enabled/disabled flag static bool vrStereoRender = false; // VR stereo rendering enabled/disabled flag
@ -1947,7 +1946,7 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
// Matrices and other values required by shader // Matrices and other values required by shader
//----------------------------------------------------- //-----------------------------------------------------
// Calculate and send to shader model matrix (used by PBR shader) // Calculate and send to shader model matrix (used by PBR shader)
SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_MODEL], transform);
k">if (material.shader.locs[LOC_MATRIX_MODEL] != -1) SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_MODEL], transform);
// Upload to shader material.colDiffuse // Upload to shader material.colDiffuse
if (material.shader.locs[LOC_COLOR_DIFFUSE] != -1) if (material.shader.locs[LOC_COLOR_DIFFUSE] != -1)
@ -2830,10 +2829,12 @@ void EndBlendMode(void)
#if defined(SUPPORT_VR_SIMULATOR) #if defined(SUPPORT_VR_SIMULATOR)
// Init VR simulator for selected device // Init VR simulator for selected device
// NOTE: It modifies the global variable: VrDeviceInfo hmd
// NOTE: It modifies the global variable: VrStereoConfig vrConfig
void InitVrSimulator(int vrDevice) void InitVrSimulator(int vrDevice)
{ {
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
VrDeviceInfo hmd; // Current VR device info
if (vrDevice == HMD_OCULUS_RIFT_DK2) if (vrDevice == HMD_OCULUS_RIFT_DK2)
{ {
// Oculus Rift DK2 parameters // Oculus Rift DK2 parameters
@ -3345,8 +3346,6 @@ static void SetShaderDefaultLocations(Shader *shader)
shader->locs[LOC_MAP_DIFFUSE] = glGetUniformLocation(shader->id, "texture0"); shader->locs[LOC_MAP_DIFFUSE] = glGetUniformLocation(shader->id, "texture0");
shader->locs[LOC_MAP_NORMAL] = glGetUniformLocation(shader->id, "texture1"); shader->locs[LOC_MAP_NORMAL] = glGetUniformLocation(shader->id, "texture1");
shader->locs[LOC_MAP_SPECULAR] = glGetUniformLocation(shader->id, "texture2"); shader->locs[LOC_MAP_SPECULAR] = glGetUniformLocation(shader->id, "texture2");
// TODO: Try to find all expected/recognized shader locations (predefined names, must be documented)
} }
// Unload default shader // Unload default shader
@ -3941,6 +3940,7 @@ static void GenDrawCube(void)
#if defined(SUPPORT_VR_SIMULATOR) #if defined(SUPPORT_VR_SIMULATOR)
// Configure stereo rendering (including distortion shader) with HMD device parameters // Configure stereo rendering (including distortion shader) with HMD device parameters
// NOTE: It modifies the global variable: VrStereoConfig vrConfig
static void SetStereoConfig(VrDeviceInfo hmd) static void SetStereoConfig(VrDeviceInfo hmd)
{ {
// Compute aspect ratio // Compute aspect ratio

+ 1
- 1
src/rlgl.h Ver fichero

@ -27,7 +27,7 @@
* #define SUPPORT_VR_SIMULATION / SUPPORT_STEREO_RENDERING * #define SUPPORT_VR_SIMULATION / SUPPORT_STEREO_RENDERING
* Support VR simulation functionality (stereo rendering) * Support VR simulation functionality (stereo rendering)
* *
* #define SUPPORT_SHADER_DISTORTION
* #define SUPPORT_DISTORTION_SHADER
* Include stereo rendering distortion shader (shader_distortion.h) * Include stereo rendering distortion shader (shader_distortion.h)
* *
* DEPENDENCIES: * DEPENDENCIES:

+ 2
- 2
src/shader_distortion.h Ver fichero

@ -20,12 +20,12 @@ static const char vDistortionShaderStr[] =
"out vec2 fragTexCoord; \n" "out vec2 fragTexCoord; \n"
"out vec4 fragColor; \n" "out vec4 fragColor; \n"
#endif #endif
"uniform mat4 mvpMatrix; \n"
"uniform mat4 mvp; \n"
"void main() \n" "void main() \n"
"{ \n" "{ \n"
" fragTexCoord = vertexTexCoord; \n" " fragTexCoord = vertexTexCoord; \n"
" fragColor = vertexColor; \n" " fragColor = vertexColor; \n"
" gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); \n"
" gl_Position = mvp*vec4(vertexPosition, 1.0); \n"
"} \n"; "} \n";
// Fragment shader definition to embed, no external file required // Fragment shader definition to embed, no external file required

Cargando…
Cancelar
Guardar