@@ -1,31 +0,0 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec3 fragPosition;
|
||||
|
||||
// Input uniform values
|
||||
uniform samplerCube environmentMap;
|
||||
uniform bool vflipped;
|
||||
uniform bool doGamma;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Fetch color from texture map
|
||||
vec4 texelColor = vec4(0.0);
|
||||
|
||||
if (vflipped) texelColor = textureCube(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z));
|
||||
else texelColor = textureCube(environmentMap, fragPosition);
|
||||
|
||||
vec3 color = vec3(texelColor.x, texelColor.y, texelColor.z);
|
||||
|
||||
if (doGamma) // Apply gamma correction
|
||||
{
|
||||
color = color/(color + vec3(1.0));
|
||||
color = pow(color, vec3(1.0/2.2));
|
||||
}
|
||||
|
||||
// Calculate final fragment color
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#version 100
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 matProjection;
|
||||
uniform mat4 matView;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec3 fragPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate fragment position based on model transformations
|
||||
fragPosition = vertexPosition;
|
||||
|
||||
// Remove translation from the view matrix
|
||||
mat4 rotView = mat4(mat3(matView));
|
||||
vec4 clipPos = matProjection*rotView*vec4(vertexPosition, 1.0);
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = clipPos;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ int config_load_ref(lua_State *L, int idx, Config *out)
|
||||
|
||||
// ======== DEFAULTS ========
|
||||
out->space.offset = (Vector3) { 0, 0, 0 };
|
||||
out->space.initial_center = (Vector3) { 0, 1, 0 };
|
||||
out->space.initial_center = (Vector3) { 0, 0, 0 };
|
||||
out->space.radius = 1.0f;
|
||||
out->space.window_scale = 0.001f;
|
||||
out->displays.hud.size = 720;
|
||||
|
||||
@@ -1508,7 +1508,7 @@ static bool init_xr(LunarWM *this)
|
||||
XrReferenceSpaceCreateInfo const ci = {
|
||||
.type = XR_TYPE_REFERENCE_SPACE_CREATE_INFO,
|
||||
.next = nullptr,
|
||||
.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_STAGE,
|
||||
.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL,
|
||||
.poseInReferenceSpace = { .orientation = { 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
.position = { 0.0f, 0.0f, 0.0f } },
|
||||
};
|
||||
@@ -1815,8 +1815,6 @@ static void cleanup_xr(LunarWM *this)
|
||||
}
|
||||
|
||||
if (this->xr.session != XR_NULL_HANDLE) {
|
||||
if (this->xr.session_running)
|
||||
xrEndSession(this->xr.session);
|
||||
xrDestroySession(this->xr.session);
|
||||
this->xr.session = XR_NULL_HANDLE;
|
||||
this->xr.session_running = false;
|
||||
@@ -1841,6 +1839,16 @@ static void cleanup_wayland(LunarWM *this)
|
||||
}
|
||||
|
||||
if (this->wayland.xwayland) {
|
||||
if (this->wayland.xwayland_new_surface.link.prev
|
||||
|| this->wayland.xwayland_new_surface.link.next) {
|
||||
wl_list_remove(&this->wayland.xwayland_new_surface.link);
|
||||
this->wayland.xwayland_new_surface.notify = NULL;
|
||||
}
|
||||
if (this->wayland.xwayland_ready.link.prev
|
||||
|| this->wayland.xwayland_ready.link.next) {
|
||||
wl_list_remove(&this->wayland.xwayland_ready.link);
|
||||
this->wayland.xwayland_ready.notify = NULL;
|
||||
}
|
||||
wlr_xwayland_destroy(this->wayland.xwayland);
|
||||
this->wayland.xwayland = NULL;
|
||||
}
|
||||
@@ -2193,17 +2201,17 @@ void render_hud(LunarWM *this, float /*dt*/, int hud_size)
|
||||
|
||||
void render_3d(LunarWM *this, float /*dt*/)
|
||||
{
|
||||
Skybox_draw(this->renderer.skybox, (Vector3) { 0, 0, 0 });
|
||||
Skybox_draw(this->renderer.skybox, this->renderer.center);
|
||||
|
||||
rlDisableBackfaceCulling();
|
||||
// rlDisableBackfaceCulling();
|
||||
for (size_t i = 0; i < vector_size(this->wayland.v_toplevels); i++) {
|
||||
auto *tl = this->wayland.v_toplevels[i];
|
||||
|
||||
if (!tl || !tl->surface)
|
||||
continue;
|
||||
|
||||
if (!LunarWM_Toplevel_update(tl))
|
||||
continue;
|
||||
// if (!LunarWM_Toplevel_update(tl))
|
||||
// continue;
|
||||
|
||||
DrawTexture3D(tl->rl_texture,
|
||||
Vector3Add(this->renderer.center,
|
||||
@@ -2211,7 +2219,7 @@ void render_3d(LunarWM *this, float /*dt*/)
|
||||
0, 0, this->cman->cfg.space.radius - 0.01 * (float)i }),
|
||||
this->renderer.center, this->cman->cfg.space.window_scale, false);
|
||||
}
|
||||
rlEnableBackfaceCulling();
|
||||
// rlEnableBackfaceCulling();
|
||||
|
||||
for (int h = 0; h < 2; ++h) {
|
||||
auto *hand_info = &this->xr.hands[h];
|
||||
@@ -2356,7 +2364,8 @@ static bool render_layer(LunarWM *this, LunarWM_RenderLayerInfo *info, float dt)
|
||||
rlSetMatrixViewOffsetStereo(view_off_r, view_off_l);
|
||||
|
||||
glViewport(0, 0, (GLsizei)eye_w * view_count, (GLsizei)eye_h);
|
||||
ClearBackground((Color) { 0, 0, 10, 255 });
|
||||
rlClearColor(0, 0, 10, 255);
|
||||
rlClearScreenBuffers();
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
XrTime const time = info->predicted_display_time;
|
||||
@@ -2406,6 +2415,8 @@ static bool render_layer(LunarWM *this, LunarWM_RenderLayerInfo *info, float dt)
|
||||
}
|
||||
|
||||
BeginTextureMode(this->renderer.tmp_rt);
|
||||
rlDisableColorBlend();
|
||||
ClearBackground(BLACK);
|
||||
BeginShaderMode(this->renderer.linear_srgb);
|
||||
DrawTexturePro(this->renderer.main_rt.texture,
|
||||
(Rectangle) {
|
||||
@@ -2423,6 +2434,7 @@ static bool render_layer(LunarWM *this, LunarWM_RenderLayerInfo *info, float dt)
|
||||
(Vector2) { 0, 0 }, 0, WHITE);
|
||||
EndShaderMode();
|
||||
EndTextureMode();
|
||||
rlEnableColorBlend();
|
||||
|
||||
// release swapchain images
|
||||
XrSwapchainImageReleaseInfo const ri
|
||||
|
||||
23
src/RayExt.c
23
src/RayExt.c
@@ -12,13 +12,14 @@ static char const *SKYBOX_VS = "#version 300 es\n"
|
||||
"out vec3 vDir;\n"
|
||||
"void main(){ vDir=vertexPosition; "
|
||||
"gl_Position=mvp*vec4(vertexPosition,1.0); }\n";
|
||||
static char const *SKYBOX_FS = "#version 300 es\n"
|
||||
"precision highp float;\n"
|
||||
"in vec3 vDir;\n"
|
||||
"uniform samplerCube environmentMap;\n"
|
||||
"out vec4 finalColor;\n"
|
||||
"void main(){ vec3 dir=normalize(vDir); "
|
||||
"finalColor=texture(environmentMap, dir); }\n";
|
||||
static char const *SKYBOX_FS
|
||||
= "#version 300 es\n"
|
||||
"precision highp float;\n"
|
||||
"in vec3 vDir;\n"
|
||||
"uniform samplerCube environmentMap;\n"
|
||||
"out vec4 finalColor;\n"
|
||||
"void main(){ vec3 dir=normalize(vDir); "
|
||||
"finalColor=vec4(texture(environmentMap, normalize(vDir)).rgb, 1.0); }\n";
|
||||
#endif
|
||||
|
||||
void Skybox_init(Skybox *skybox, char const *fp)
|
||||
@@ -96,14 +97,14 @@ void Skybox_draw(Skybox const skybox, Vector3 position)
|
||||
|
||||
// Render behind everything without writing depth; cull disabled so we see
|
||||
// inside faces
|
||||
rlDisableColorBlend();
|
||||
rlDisableBackfaceCulling();
|
||||
rlDisableDepthMask();
|
||||
rlDisableColorBlend();
|
||||
|
||||
DrawModel(skybox.cube, position, 60.0f, (Color) { 255, 255, 255, 255 });
|
||||
|
||||
DrawModel(skybox.cube, position, 500.0f, (Color) { 255, 255, 255, 255 });
|
||||
rlDrawRenderBatchActive();
|
||||
|
||||
rlEnableColorBlend();
|
||||
rlEnableDepthMask();
|
||||
rlEnableBackfaceCulling();
|
||||
rlEnableColorBlend();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user