Skip to content
/ gnm Public

GNM is a lightweight mathematics library which is C++ implementation followed GLSL Spec.

Notifications You must be signed in to change notification settings

jerrywwl/gnm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GNM (GLSL Native Mathematics)

GNM is a lightweight mathematics library which is C++ implementation followed GLSL Specifications.

Features:

  • Header only library
  • Usages are in complete accord with GLSL
  • Supports all types and operations for mathematics part of GLSL
  • Supports swizzle operation as GLSL
  • Supports Intel instruction (SSE2/SSE4/AVX...)
  • Supports quaternion
  • Any C++11 compiler
  • Other features are in progress...

Example Code:

#include "gnm.h"

GNM_USING_NAMESPACE

int main() {
  
  vec3 camera_pos(10.0f, 10.0f, 10.0f);
  vec3 view_pos(0.0f);
  vec3 normal(1.0f, 1.0f, 1.0f);

  vec3 albedo = vec3(0.75f);
  vec3 metallic = vec3(0.25f);

  vec3 f0 = vec3(0.04);
  vec3 diffuse = albedo * 0.96 * (1.0 - metallic);
  vec3 specular = mix(f0, albedo, metallic);

  vec3 v = normalize(camera_pos.xyz - view_pos.xyz);

  float n_dot_v = clamp(abs(dot(normal, v)), 0.001f, 1.0f);

  return 0;
}

Building

Prerequisites

Windows

  • Run build.bat, choose the selection to generate .sln
  • Open .sln with Visual Studio, and building.

About

GNM is a lightweight mathematics library which is C++ implementation followed GLSL Spec.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published