This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ViewDir = normalize(vCameraPos.xyz - vWorldPos.xyz); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Rextester | |
{ | |
public class ArrayHelper | |
{ | |
int[] _result; | |
public int[] result | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "shared/glslversion.h" | |
#include "glslcommon.inc" | |
#include "uniforms.inc" | |
in | |
#include "VertexData.h" | |
#include "LightData.h" | |
layout(location = 0) out vec4 my_FragColor0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |