Skip to content

Instantly share code, notes, and snippets.

View galek's full-sized avatar
🧭
I'm ready for new discoveries

Nikolay Galko galek

🧭
I'm ready for new discoveries
View GitHub Profile
@galek
galek / child.cpp
Last active June 27, 2017 21:33
CHILD_FINISHED_SENDED
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <pvm3.h>
#include <unistd.h>
#include <math.h>
# define SIZE 1000
# define NPROCS 5
@galek
galek / clock.h
Created April 4, 2017 13:50
Clocks
static inline uint64_t cf_getms()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ((uint64_t)ts.tv_nsec / 1000000) + ((uint64_t)ts.tv_sec * 1000);
}
static inline uint64_t cf_getus()
{
struct timespec ts;
@galek
galek / BitwiseOperations.glsl
Created February 21, 2017 03:39 — forked from mattatz/BitwiseOperations.glsl
Bitwise operations without operators for glsl.
// BitwiseOperations.glsl
const int BIT_COUNT = 8;
int modi(int x, int y) {
return x - y * (x / y);
}
int or(int a, int b) {
int result = 0;
@galek
galek / q.glsl
Created January 26, 2017 21:48
#ifndef PHONG_LIGHTING_INC
#define PHONG_LIGHTING_INC 1
#define USE_OPTIMIZATION 1
#include "BRDF.h"
float GetAngleAttenuation(vec3 _l, vec3 _lightDir, float _angleScale, float _angleOffset)
{
float cosa = -dot(_l, _lightDir);
#include "shared/glslversion.h"
#include "glslcommon.inc"
#include "uniforms.inc"
in
#include "VertexData.h"
#include "LightData.h"
layout(location = 0) out vec4 my_FragColor0;
@galek
galek / 26.cs
Created January 17, 2017 00:23
using System;
namespace Rextester
{
public class ArrayHelper
{
int[] _result;
public int[] result
{
@galek
galek / depth_to_position.glsl
Created November 22, 2016 07:41 — forked from jimmiebergmann/depth_to_position.glsl
PS3 GLSL Depth to position
//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 );
[GLSL_VERTEX_SHADER]
#include "shared/glslversion.h"
#include "glslcommon.inc"
#include "uniforms.inc"
layout(location = 0) in vec4 vposition;
layout(location = 5) in vec2 vtexcoord;
out vec2 ftexcoord;
@galek
galek / Reconstructing Position From Depth Buffer
Created May 30, 2016 04:11
Reconstructing Position From Depth Buffer
float3 vFrustumCornersWS[8] =
{
float3(-1.0, 1.0, 0.0), // near top left
float3( 1.0, 1.0, 0.0), // near top right
float3(-1.0, -1.0, 0.0), // near bottom left
float3( 1.0, -1.0, 0.0), // near bottom right
float3(-1.0, 1.0, 1.0), // far top left
float3( 1.0, 1.0, 1.0), // far top right
float3(-1.0, -1.0, 1.0), // far bottom left
float3( 1.0, -1.0, 1.0) // far bottom right
ViewDir = normalize(vCameraPos.xyz - vWorldPos.xyz);