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.
//Convert to 24bit | |
const float3 depthFactor = float3(65536.0f/16777215.0f, 256.0f/16777215.0f, 1.0f/16777215.0f ); | |
float GetDepth( float4 raw_depth ) | |
{ | |
return dot( round( raw_depth.xyz * 255.0f.xxx ), depthFactor.xyz); | |
} | |
float2 texcoord = in.vpos/g_Resolution; | |
pos.xy = in.vpo; | |
pos.z = GetDepth( tex2D(g_Depthmap,texcoord).rgba ); |
// 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 |
/* | |
* 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) { |
// Creating a node graph editor for ImGui | |
// Quick demo, not production code! This is more of a demo of how to use ImGui to create custom stuff. | |
// Better version by @daniel_collin here https://gist.github.com/emoon/b8ff4b4ce4f1b43e79f2 | |
// See https://github.com/ocornut/imgui/issues/306 | |
// v0.02 | |
// Animated gif: https://cloud.githubusercontent.com/assets/8225057/9472357/c0263c04-4b4c-11e5-9fdf-2cd4f33f6582.gif | |
// NB: You can use math functions/operators on ImVec2 if you #define IMGUI_DEFINE_MATH_OPERATORS and #include "imgui_internal.h" | |
// Here we only declare simple +/- operators so others don't leak into the demo code. | |
static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); } |