Class: Rendering::SSAOEffect
- Inherits:
-
Object
- Object
- Rendering::SSAOEffect
- Includes:
- Effect
- Defined in:
- lib/engine/rendering/post_processing/ssao_effect.rb
Instance Attribute Summary collapse
-
#bias ⇒ Object
Returns the value of attribute bias.
-
#blur_size ⇒ Object
Returns the value of attribute blur_size.
-
#power ⇒ Object
Returns the value of attribute power.
-
#radius ⇒ Object
Returns the value of attribute radius.
Attributes included from Effect
Instance Method Summary collapse
- #apply(input_rt, output_rt, screen_quad) ⇒ Object
-
#initialize(kernel_size: 16, radius: 0.5, bias: 0.025, power: 2.0, blur_size: 2, depth_threshold: 1000.0) ⇒ SSAOEffect
constructor
A new instance of SSAOEffect.
- #update_params ⇒ Object
Constructor Details
#initialize(kernel_size: 16, radius: 0.5, bias: 0.025, power: 2.0, blur_size: 2, depth_threshold: 1000.0) ⇒ SSAOEffect
Returns a new instance of SSAOEffect.
7 8 9 10 11 12 13 14 |
# File 'lib/engine/rendering/post_processing/ssao_effect.rb', line 7 def initialize(kernel_size: 16, radius: 0.5, bias: 0.025, power: 2.0, blur_size: 2, depth_threshold: 1000.0) @kernel_size = [kernel_size, 64].min @radius = radius @bias = bias @power = power @blur_size = blur_size @depth_threshold = depth_threshold end |
Instance Attribute Details
#bias ⇒ Object
Returns the value of attribute bias.
62 63 64 |
# File 'lib/engine/rendering/post_processing/ssao_effect.rb', line 62 def bias @bias end |
#blur_size ⇒ Object
Returns the value of attribute blur_size.
62 63 64 |
# File 'lib/engine/rendering/post_processing/ssao_effect.rb', line 62 def blur_size @blur_size end |
#power ⇒ Object
Returns the value of attribute power.
62 63 64 |
# File 'lib/engine/rendering/post_processing/ssao_effect.rb', line 62 def power @power end |
#radius ⇒ Object
Returns the value of attribute radius.
62 63 64 |
# File 'lib/engine/rendering/post_processing/ssao_effect.rb', line 62 def radius @radius end |
Instance Method Details
#apply(input_rt, output_rt, screen_quad) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/engine/rendering/post_processing/ssao_effect.rb', line 16 def apply(input_rt, output_rt, screen_quad) ensure_textures(input_rt.width, input_rt.height) camera = Engine::Camera.instance Engine::GL.Disable(Engine::GL::DEPTH_TEST) # Pass 1: Generate SSAO @ssao_rt.bind Engine::GL.ClearColor(1.0, 1.0, 1.0, 1.0) Engine::GL.Clear(Engine::GL::COLOR_BUFFER_BIT) ssao_material.set_runtime_texture("depthTexture", PostProcessingEffect.depth_texture) ssao_material.set_runtime_texture("normalTexture", PostProcessingEffect.normal_texture) ssao_material.set_runtime_texture("noiseTexture", noise_texture) ssao_material.set_mat4("projection", camera.projection.transpose) ssao_material.set_mat4("view", camera.view_matrix) ssao_material.set_mat4("inverseVP", camera.inverse_vp_matrix) ssao_material.set_float("nearPlane", camera.near) ssao_material.set_float("farPlane", camera.far) noise_scale = [@ssao_rt.width / 4.0, @ssao_rt.height / 4.0] ssao_material.set_vec2("noiseScale", noise_scale) screen_quad.draw_with_material(ssao_material) # Pass 2: Blur SSAO @blur_rt.bind Engine::GL.Clear(Engine::GL::COLOR_BUFFER_BIT) blur_material.set_runtime_texture("ssaoTexture", @ssao_rt.color_texture) blur_material.set_runtime_texture("depthTexture", PostProcessingEffect.depth_texture) screen_quad.draw_with_material(blur_material) # Pass 3: Combine with scene output_rt.bind Engine::GL.Clear(Engine::GL::COLOR_BUFFER_BIT) combine_material.set_runtime_texture("screenTexture", input_rt.color_texture) combine_material.set_runtime_texture("ssaoTexture", @blur_rt.color_texture) screen_quad.draw_with_material(combine_material) output_rt end |
#update_params ⇒ Object
64 65 66 67 68 69 |
# File 'lib/engine/rendering/post_processing/ssao_effect.rb', line 64 def update_params ssao_material.set_float("radius", @radius) ssao_material.set_float("bias", @bias) ssao_material.set_float("power", @power) blur_material.set_int("blurSize", @blur_size) end |