Class: Rendering::SSREffect
- Inherits:
-
Object
- Object
- Rendering::SSREffect
- Includes:
- Effect
- Defined in:
- lib/engine/rendering/post_processing/ssr_effect.rb
Instance Attribute Summary
Attributes included from Effect
Instance Method Summary collapse
- #apply(input_rt, output_rt, screen_quad) ⇒ Object
-
#initialize(max_steps: 64, max_ray_distance: 50.0, thickness: 0.5, ray_offset: 2.0) ⇒ SSREffect
constructor
A new instance of SSREffect.
Constructor Details
#initialize(max_steps: 64, max_ray_distance: 50.0, thickness: 0.5, ray_offset: 2.0) ⇒ SSREffect
Returns a new instance of SSREffect.
7 8 9 10 11 12 |
# File 'lib/engine/rendering/post_processing/ssr_effect.rb', line 7 def initialize(max_steps: 64, max_ray_distance: 50.0, thickness: 0.5, ray_offset: 2.0) @max_steps = max_steps @max_ray_distance = max_ray_distance @thickness = thickness @ray_offset = ray_offset end |
Instance Method Details
#apply(input_rt, output_rt, screen_quad) ⇒ Object
14 15 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 |
# File 'lib/engine/rendering/post_processing/ssr_effect.rb', line 14 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: Render SSR at half resolution @ssr_rt.bind Engine::GL.Disable(Engine::GL::BLEND) Engine::GL.ClearColor(0.0, 0.0, 0.0, 0.0) Engine::GL.Clear(Engine::GL::COLOR_BUFFER_BIT) ssr_material.set_runtime_texture("screenTexture", input_rt.color_texture) ssr_material.set_runtime_texture("depthTexture", PostProcessingEffect.depth_texture) ssr_material.set_runtime_texture("normalTexture", PostProcessingEffect.normal_texture) ssr_material.set_mat4("inverseVP", camera.inverse_vp_matrix) ssr_material.set_mat4("viewProj", camera.matrix) ssr_material.set_vec3("cameraPos", camera.position) ssr_material.set_float("nearPlane", camera.near) ssr_material.set_float("farPlane", camera.far) cubemap = RenderPipeline.skybox_cubemap ssr_material.set_cubemap("skyboxCubemap", cubemap&.texture) screen_quad.draw_with_material(ssr_material) # Pass 2: Combine with scene at full resolution 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("ssrTexture", @ssr_rt.color_texture) screen_quad.draw_with_material(combine_material) output_rt end |