Class: RBGL::Engine::BaseShader

Inherits:
Object
  • Object
show all
Includes:
ShaderBuiltins
Defined in:
lib/rbgl/engine/shader/base_shader.rb

Direct Known Subclasses

FragmentShader, VertexShader

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ShaderBuiltins

#abs, #acos, #asin, #atan, #ceil, #clamp, #color_from_vec3, #color_from_vec4, #cos, #cross, #dot, #floor, #fract, #length, #max, #min, #mix, #mod, #normalize, #pow, #reflect, #refract, #rgb, #rgba, #saturate, #sign, #sin, #smoothstep, #sqrt, #step, #tan, #texture, #texture_lod, #vec2, #vec3, #vec4

Constructor Details

#initialize(&block) ⇒ BaseShader

Returns a new instance of BaseShader.



8
9
10
# File 'lib/rbgl/engine/shader/base_shader.rb', line 8

def initialize(&block)
  @process_block = block
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



22
23
24
# File 'lib/rbgl/engine/shader/base_shader.rb', line 22

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



22
23
24
# File 'lib/rbgl/engine/shader/base_shader.rb', line 22

def output
  @output
end

#uniformsObject (readonly)

Returns the value of attribute uniforms.



22
23
24
# File 'lib/rbgl/engine/shader/base_shader.rb', line 22

def uniforms
  @uniforms
end

Class Method Details

.create(&block) ⇒ Object



24
25
26
# File 'lib/rbgl/engine/shader/base_shader.rb', line 24

def self.create(&block)
  new(&block)
end

Instance Method Details

#process(input, uniforms) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/rbgl/engine/shader/base_shader.rb', line 12

def process(input, uniforms)
  output = ShaderIO.new
  @input = input
  @uniforms = uniforms
  @output = output

  instance_exec(input, uniforms, output, &@process_block)
  finalize_output(output)
end