Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.19.1 #2

Merged
merged 2 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lessons/lesson01.elm → lessons/Lesson01.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson01 exposing (main)

-- Create a mesh with a triangle and a square

Expand Down
2 changes: 1 addition & 1 deletion lessons/lesson02.elm → lessons/Lesson02.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson02 exposing (main)

-- Create a mesh with a triangle and a square
-- Uses varyings to interpolate colors
Expand Down
2 changes: 1 addition & 1 deletion lessons/lesson03.elm → lessons/Lesson03.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson03 exposing (main)

-- Create a mesh with a triangle and a square
-- Uses varyings to interpolate colors
Expand Down
2 changes: 1 addition & 1 deletion lessons/lesson04.elm → lessons/Lesson04.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson04 exposing (main)

-- Create a pyramid and a cube meshes

Expand Down
2 changes: 1 addition & 1 deletion lessons/lesson05.elm → lessons/Lesson05.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson05 exposing (main)

-- Rotating cube mesh with texture

Expand Down
2 changes: 1 addition & 1 deletion lessons/lesson06.elm → lessons/Lesson06.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson06 exposing (main)

import Browser
import Browser.Events exposing (onAnimationFrameDelta, onKeyDown, onKeyUp)
Expand Down
19 changes: 13 additions & 6 deletions lessons/lesson07.elm → lessons/Lesson07.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson07 exposing (main)

import Browser
import Browser.Events exposing (onAnimationFrameDelta, onKeyDown, onKeyUp)
Expand Down Expand Up @@ -441,7 +441,7 @@ renderEntity mesh thetaX thetaY texture position lighting directionalColour dire
[ WebGL.entity vertexShader fragmentShader mesh (uniformsCube thetaX thetaY tex position lighting directionalColour directional ambientColour) ]


uniformsCube : Float -> Float -> Texture -> Vec3 -> Bool -> Vec3 -> Vec3 -> Vec3 -> { texture : Texture, worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Bool, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 }
uniformsCube : Float -> Float -> Texture -> Vec3 -> Bool -> Vec3 -> Vec3 -> Vec3 -> { texture : Texture, worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Int, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 }
uniformsCube tx ty texture displacement lighting directionalColour directional ambientColour =
let
worldSpace =
Expand All @@ -452,13 +452,20 @@ uniformsCube tx ty texture displacement lighting directionalColour directional a

perspective =
makePerspective 45 1 0.1 100

boolToInt bool =
if bool then
1

else
0
in
{ texture = texture
, worldSpace = worldSpace
, perspective = perspective
, camera = camera
, normalMatrix = transpose (inverseOrthonormal worldSpace)
, lighting = lighting
, lighting = boolToInt lighting
, directionalColour = directionalColour
, ambientColour = ambientColour
, directional = directional
Expand All @@ -469,7 +476,7 @@ uniformsCube tx ty texture displacement lighting directionalColour directional a
-- SHADERS


vertexShader : Shader { attr | position : Vec3, coord : Vec3, norm : Vec3 } { unif | worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Bool, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 } { vcoord : Vec2, lightWeighting : Vec3 }
vertexShader : Shader { attr | position : Vec3, coord : Vec3, norm : Vec3 } { unif | worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Int, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 } { vcoord : Vec2, lightWeighting : Vec3 }
vertexShader =
[glsl|

Expand All @@ -483,7 +490,7 @@ vertexShader =
uniform mat4 perspective;
uniform mat4 normalMatrix;
uniform mat4 camera;
uniform bool lighting;
uniform int lighting;
uniform vec3 directionalColour;
uniform vec3 directional;
uniform vec3 ambientColour;
Expand All @@ -495,7 +502,7 @@ vertexShader =
gl_Position = perspective * camera * worldSpace * vec4(position, 1.0);
vcoord = coord.xy;

if (!lighting) {
if (lighting == 0) {
lightWeighting = vec3(1.0, 1.0, 1.0);
} else {
vec4 transformedNormal = normalMatrix * vec4(norm, 0.0);
Expand Down
19 changes: 13 additions & 6 deletions lessons/lesson08.elm → lessons/Lesson08.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson08 exposing (main)

import Browser
import Browser.Events exposing (onAnimationFrameDelta, onKeyDown, onKeyUp)
Expand Down Expand Up @@ -480,7 +480,7 @@ renderEntity mesh thetaX thetaY texture position lighting blending alpha directi
[ WebGL.entityWith settings vertexShader fragmentShader mesh (uniformsCube thetaX thetaY tex position lighting alpha directionalColour directional ambientColour) ]


uniformsCube : Float -> Float -> Texture -> Vec3 -> Bool -> Float -> Vec3 -> Vec3 -> Vec3 -> { texture : Texture, worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Bool, alpha : Float, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 }
uniformsCube : Float -> Float -> Texture -> Vec3 -> Bool -> Float -> Vec3 -> Vec3 -> Vec3 -> { texture : Texture, worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Int, alpha : Float, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 }
uniformsCube tx ty texture displacement lighting alpha directionalColour directional ambientColour =
let
worldSpace =
Expand All @@ -491,13 +491,20 @@ uniformsCube tx ty texture displacement lighting alpha directionalColour directi

perspective =
makePerspective 45 1 0.1 100

boolToInt bool =
if bool then
1

else
0
in
{ texture = texture
, worldSpace = worldSpace
, perspective = perspective
, camera = camera
, normalMatrix = transpose (inverseOrthonormal (mul worldSpace camera))
, lighting = lighting
, lighting = boolToInt lighting
, alpha = alpha
, directionalColour = directionalColour
, ambientColour = ambientColour
Expand All @@ -509,7 +516,7 @@ uniformsCube tx ty texture displacement lighting alpha directionalColour directi
-- SHADERS


vertexShader : Shader { attr | position : Vec3, coord : Vec3, norm : Vec3 } { unif | worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Bool, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 } { vcoord : Vec2, lightWeighting : Vec3 }
vertexShader : Shader { attr | position : Vec3, coord : Vec3, norm : Vec3 } { unif | worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Int, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 } { vcoord : Vec2, lightWeighting : Vec3 }
vertexShader =
[glsl|

Expand All @@ -523,7 +530,7 @@ vertexShader =
uniform mat4 perspective;
uniform mat4 normalMatrix;
uniform mat4 camera;
uniform bool lighting;
uniform int lighting;
uniform vec3 directionalColour;
uniform vec3 directional;
uniform vec3 ambientColour;
Expand All @@ -535,7 +542,7 @@ vertexShader =
gl_Position = perspective * camera * worldSpace * vec4(position, 1.0);
vcoord = coord.xy;

if (!lighting) {
if (lighting == 0) {
lightWeighting = vec3(1.0, 1.0, 1.0);
} else {
vec4 transformedNormal = normalMatrix * vec4(norm, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion lessons/lesson09.elm → lessons/Lesson09.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson09 exposing (main)

import Array
import Browser
Expand Down
2 changes: 1 addition & 1 deletion lessons/lesson10.elm → lessons/Lesson10.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson10 exposing (main)

import Array
import Browser
Expand Down
19 changes: 13 additions & 6 deletions lessons/lesson11.elm → lessons/Lesson11.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson11 exposing (main)

import Browser
import Browser.Events exposing (onMouseDown, onMouseMove, onMouseUp)
Expand Down Expand Up @@ -388,7 +388,7 @@ renderEntity mesh thetaX thetaY texture position lighting directionalColour dire
[ WebGL.entity vertexShader fragmentShader mesh (uniformsShpere thetaX thetaY tex position lighting directionalColour directional ambientColour) ]


uniformsShpere : Float -> Float -> Texture -> Vec3 -> Bool -> Vec3 -> Vec3 -> Vec3 -> { texture : Texture, worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Bool, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 }
uniformsShpere : Float -> Float -> Texture -> Vec3 -> Bool -> Vec3 -> Vec3 -> Vec3 -> { texture : Texture, worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Int, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 }
uniformsShpere tx ty texture displacement lighting directionalColour directional ambientColour =
let
worldSpace =
Expand All @@ -399,13 +399,20 @@ uniformsShpere tx ty texture displacement lighting directionalColour directional

perspective =
makePerspective 45 1 0.1 100

boolToInt bool =
if bool then
1

else
0
in
{ texture = texture
, worldSpace = worldSpace
, perspective = perspective
, camera = camera
, normalMatrix = transpose (inverseOrthonormal (mul worldSpace camera))
, lighting = lighting
, lighting = boolToInt lighting
, directionalColour = directionalColour
, ambientColour = ambientColour
, directional = directional
Expand All @@ -416,7 +423,7 @@ uniformsShpere tx ty texture displacement lighting directionalColour directional
-- SHADERS


vertexShader : Shader { attr | position : Vec3, coord : Vec3, norm : Vec3 } { unif | worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Bool, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 } { vcoord : Vec2, lightWeighting : Vec3 }
vertexShader : Shader { attr | position : Vec3, coord : Vec3, norm : Vec3 } { unif | worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Int, directionalColour : Vec3, ambientColour : Vec3, directional : Vec3 } { vcoord : Vec2, lightWeighting : Vec3 }
vertexShader =
[glsl|

Expand All @@ -430,7 +437,7 @@ vertexShader =
uniform mat4 perspective;
uniform mat4 normalMatrix;
uniform mat4 camera;
uniform bool lighting;
uniform int lighting;
uniform vec3 directionalColour;
uniform vec3 directional;
uniform vec3 ambientColour;
Expand All @@ -442,7 +449,7 @@ vertexShader =
gl_Position = perspective * camera * worldSpace * vec4(position, 1.0);
vcoord = coord.xy;

if (!lighting) {
if (lighting == 0) {
lightWeighting = vec3(1.0, 1.0, 1.0);
} else {
vec4 transformedNormal = normalMatrix * vec4(norm, 0.0);
Expand Down
19 changes: 13 additions & 6 deletions lessons/lesson12.elm → lessons/Lesson12.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Main exposing (main)
module Lesson12 exposing (main)

import Browser
import Browser.Events exposing (onAnimationFrameDelta)
Expand Down Expand Up @@ -384,7 +384,7 @@ renderEntity mesh theta texture position lighting pointColour point ambientColou
[ WebGL.entity vertexShader fragmentShader mesh (uniformsShpere theta texture position lighting pointColour point ambientColour) ]


uniformsShpere : Float -> Texture -> Vec3 -> Bool -> Vec3 -> Vec3 -> Vec3 -> { texture : Texture, worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Bool, pointColour : Vec3, ambientColour : Vec3, point : Vec3 }
uniformsShpere : Float -> Texture -> Vec3 -> Bool -> Vec3 -> Vec3 -> Vec3 -> { texture : Texture, worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Int, pointColour : Vec3, ambientColour : Vec3, point : Vec3 }
uniformsShpere tx texture displacement lighting pointColour point ambientColour =
let
worldSpace =
Expand All @@ -395,13 +395,20 @@ uniformsShpere tx texture displacement lighting pointColour point ambientColour

perspective =
makePerspective 45 1 0.1 100

boolToInt bool =
if bool then
1

else
0
in
{ texture = texture
, worldSpace = worldSpace
, perspective = perspective
, camera = camera
, normalMatrix = transpose (inverseOrthonormal worldSpace)
, lighting = lighting
, lighting = boolToInt lighting
, pointColour = pointColour
, ambientColour = ambientColour
, point = point
Expand All @@ -412,7 +419,7 @@ uniformsShpere tx texture displacement lighting pointColour point ambientColour
-- SHADERS


vertexShader : Shader { attr | position : Vec3, coord : Vec3, norm : Vec3 } { unif | worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Bool, pointColour : Vec3, ambientColour : Vec3, point : Vec3 } { vcoord : Vec2, lightWeighting : Vec3 }
vertexShader : Shader { attr | position : Vec3, coord : Vec3, norm : Vec3 } { unif | worldSpace : Mat4, perspective : Mat4, camera : Mat4, normalMatrix : Mat4, lighting : Int, pointColour : Vec3, ambientColour : Vec3, point : Vec3 } { vcoord : Vec2, lightWeighting : Vec3 }
vertexShader =
[glsl|

Expand All @@ -426,7 +433,7 @@ vertexShader =
uniform mat4 perspective;
uniform mat4 normalMatrix;
uniform mat4 camera;
uniform bool lighting;
uniform int lighting;
uniform vec3 pointColour;
uniform vec3 point;
uniform vec3 ambientColour;
Expand All @@ -439,7 +446,7 @@ vertexShader =
gl_Position = perspective * camera * mvPosition;
vcoord = coord.xy;

if (!lighting) {
if (lighting == 0) {
lightWeighting = vec3(1.0, 1.0, 1.0);
} else {
//vec4 directional = vec4(normalize(point), 0.0);
Expand Down
Loading