Skip to content

Commit

Permalink
made shader abstract and simplified the static shader
Browse files Browse the repository at this point in the history
Former-commit-id: 655e3d2
  • Loading branch information
da1nerd committed Apr 23, 2020
1 parent b3a31d2 commit e3bf1e6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/prism/common/component/light/ambient_light.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Prism::Common::Light
# This is a special type of light that provides a minimum amount of light to the entire scene.
# For now you always need to have an ambient light otherwise no other light sources will work.
# That may be a bug that get's fixed later on.
# DEPRECATED we'll add ambient lighting in the other lights.
class AmbientLight < Core::AmbientLight
getter color

Expand Down
4 changes: 2 additions & 2 deletions src/prism/common/component/light/base_light.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Prism::Common::Light
struct BaseLight
include Core::Shader::Serializable

@[Core::Shader::Field("color")]
@[Core::Shader::Field(name: "color")]
@color : Vector3f

@[Core::Shader::Field("intensity")]
@[Core::Shader::Field(name: "intensity")]
@intensity : Float32

getter color, intensity
Expand Down
3 changes: 2 additions & 1 deletion src/prism/core/shader/program.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Prism::Core::Shader
# This `ShaderProgram` contains all of the shader implementation.
#
# I probably need to rename these two classes
class Program
abstract class Program
# A map of shader programs that have been created.
# This allows us to re-use programs.
@@programs = {} of String => CompiledProgram
Expand Down Expand Up @@ -106,6 +106,7 @@ module Prism::Core::Shader
#
# TODO: let this take in a path to the vertex shader and fragment shader for more flexibility.
def initialize(@file_name : String, &shader_reader : String -> String)
@@programs = {} of String => CompiledProgram
if @@programs.has_key?(@file_name)
# Re-use a compiled program so we don't need to compile a new one.
@resource = @@programs[@file_name]
Expand Down
2 changes: 0 additions & 2 deletions src/prism/core/shader/static_shader.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module Prism::Core::Shader
class StaticShader < Program
@@programs = {} of String => CompiledProgram

inline_uniform material, Material
uniform transformation_matrix, Matrix4f
uniform projection_matrix, Matrix4f
Expand Down

0 comments on commit e3bf1e6

Please sign in to comment.