Vulkan is a low-overhead, cross-platform 3D graphics and compute API.
Vulkan targets high-performance realtime 3D graphics applications such as games and interactive media across multiple platforms providing higher performance and lower CPU usage.
// Compute frag pos in view space | |
vec3 fragPos; | |
{ | |
float depth = gl_FragCoord.z; | |
fragPos.z = u_lightingUniforms.projectionParams.z | |
/ (u_lightingUniforms.projectionParams.w + depth); | |
vec2 screenSize = 1.0 / RENDERER_SIZE; | |
vec2 ndc = gl_FragCoord.xy * screenSize * 2.0 - 1.0; |
// Fast SSE pow for range [0, 1] | |
// Adapted from C. Schlick with one more iteration each for exp(x) and ln(x) | |
// 8 muls, 5 adds, 1 rcp | |
inline __m128 _mm_fastpow_0_1_ps(__m128 x, __m128 y) | |
{ | |
static const __m128 fourOne = _mm_set1_ps(1.0f); | |
static const __m128 fourHalf = _mm_set1_ps(0.5f); | |
__m128 a = _mm_sub_ps(fourOne, y); | |
__m128 b = _mm_sub_ps(x, fourOne); |
// Tests each segment for a hit. All calculations are done in screen space pixel coordinates | |
bool CollisionPath::hitTest(const ViewportPosition &selection_position) const | |
{ | |
const Vector2 &mouse_pixel_pos = selection_position.getPixelPosition(); | |
const Viewport &viewport = selection_position.getViewport(); | |
const Camera &camera = viewport.getCamera(); | |
const WorldLayer &layer = *getLayer(); | |
for(auto iter = anchors.begin(); iter != anchors.end()-1; ++iter) { | |
const Vector2 &segment_begin = |
// Reconstruct worldspace depth value from z/w depth buffer | |
float depth = -(z_near * z_far) / (zbuffer_depth * (z_far - z_near) - z_far); | |
// Compute screenspace coordinate of pixel | |
float2 screenspace = (float2(pixel.xy) / float2(viewport_size.xy)) * 2.0f - 1.0f; | |
// Get direction of ray from camera through pixel | |
float3 ray_direction = normalize(camera_forward + camera_right * screenspace.x - camera_up * screenspace.y); | |
// Reconstruct world position from depth: depth in z buffer is distance to picture plane, not camera |
/* | |
* Copyright 2011 Jesper de Jong | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
https://www.opengl.org/discussion_boards/showthread.php/166942-Multi-threaded-loading-screen | |
http://omarriott.com/aux/async-glktextureloader-ios/ | |
http://genericgamedev.com/general/using-multi-threading-to-animate-and-speed-up-loading-screens/ |
/* | |
* An implementation of C11 stdatomic.h directly borrowed from FreeBSD | |
* (original copyright follows), with minor modifications for | |
* portability to other systems. Works for recent Clang (that | |
* implement the feature c_atomic) and GCC 4.7+; includes | |
* compatibility for GCC below 4.7 but I wouldn't recommend it. | |
* | |
* Caveats and limitations: | |
* - Only the ``_Atomic parentheses'' notation is implemented, while | |
* the ``_Atomic space'' one is not. |
#include <Lua.hh> | |
extern "C" { | |
#include <lualib.h> | |
#include <lauxlib.h> | |
}; | |
using namespace util; | |
int Lua::call(lua_State *vm) { |
#include <Lua.hh> | |
extern "C" { | |
#include <lualib.h> | |
#include <lauxlib.h> | |
}; | |
using namespace util; | |
int Lua::call(lua_State *vm) { |