diff --git a/src/assets/bubble_reflection.scn b/src/assets/bubble_reflection.scn new file mode 100644 index 0000000..3ac8623 --- /dev/null +++ b/src/assets/bubble_reflection.scn @@ -0,0 +1,214 @@ +{ + "canvas": { + "clear_color": true, + "clear_z": true, + "color": [ + 60, + 85, + 91, + 255 + ] + }, + "environment": { + "ambient": [ + 0, + 0, + 0, + 255 + ], + "brdf_map": "core/pbr/brdf.dds", + "current_camera": null, + "fog_color": [ + 255, + 255, + 255, + 255 + ], + "fog_far": 0.0, + "fog_near": 0.0, + "probe": { + "irradiance_map": "probes/scenery.hdr.irradiance", + "parallax": 0.0, + "pos": [ + 0.0, + 0.0, + 0.0 + ], + "radiance_map": "probes/scenery.hdr.radiance", + "rot": [ + 0.0, + 0.0, + 0.0 + ], + "scl": [ + 1.0, + 1.0, + 1.0 + ], + "type": "sphere" + } + }, + "key_values": null, + "lights": [ + { + "diffuse": [ + 255, + 213, + 133, + 255 + ], + "diffuse_intensity": 5.0, + "inner_angle": 9.999999747378752e-05, + "outer_angle": 0.6108652353286743, + "priority": 0.0, + "pssm_split": [ + 10.0, + 50.0, + 100.0, + 500.0 + ], + "radius": 0.0, + "shadow_bias": 9.999999747378752e-06, + "shadow_type": "map", + "specular": [ + 255, + 180, + 0, + 255 + ], + "specular_intensity": 5.0, + "type": "spot" + } + ], + "nodes": [ + { + "components": [ + 0, + 4294967295, + 0, + 4294967295, + 4294967295 + ], + "disabled": false, + "idx": 0, + "name": "sphere_chrome" + }, + { + "components": [ + 1, + 4294967295, + 4294967295, + 0, + 4294967295 + ], + "disabled": true, + "idx": 1, + "name": "Light" + } + ], + "objects": [ + { + "bones": [], + "material_infos": [ + { + "name": "default" + } + ], + "materials": [ + { + "blend_mode": "add", + "depth_test": "less", + "face_culling": "disabled", + "flags": [], + "program": "core/shader/pbr.hps", + "values": [ + { + "name": "uBaseOpacityColor", + "type": "vec4", + "value": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "name": "uOcclusionRoughnessMetalnessColor", + "type": "vec4", + "value": [ + 0.3580000102519989, + 0.15199999511241913, + 0.9639999866485596, + 1.0 + ] + }, + { + "name": "uSelfColor", + "type": "vec4", + "value": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + { + "name": "uSpecBooster", + "type": "vec4", + "value": [ + 1.0, + 2000.0, + 2000.0, + 1.0 + ] + } + ], + "write_a": true, + "write_b": true, + "write_g": true, + "write_r": true, + "write_z": false + } + ], + "name": "primitives/sphere.geo" + } + ], + "transforms": [ + { + "parent": null, + "pos": [ + 0.0, + 1.604031718520287e-16, + 0.0 + ], + "rot": [ + 0.0, + 0.0, + 0.0 + ], + "scl": [ + 1.0, + 1.0, + 1.0 + ] + }, + { + "parent": null, + "pos": [ + 0.0, + 55.3507080078125, + 22.0 + ], + "rot": [ + 89.99994659423828, + 0.0, + 0.0 + ], + "scl": [ + 1.0, + 0.9999999403953552, + 0.9999999403953552 + ] + } + ] +} \ No newline at end of file diff --git a/src/assets/bubble_reflection.scn.aaa b/src/assets/bubble_reflection.scn.aaa new file mode 100644 index 0000000..03b674f --- /dev/null +++ b/src/assets/bubble_reflection.scn.aaa @@ -0,0 +1,12 @@ +{ + "bloom_bias": 0.5, + "bloom_intensity": 0.10000000149011612, + "bloom_threshold": 5.0, + "exposure": 1.0, + "gamma": 2.200000047683716, + "max_distance": 100.0, + "motion_blur": 1.0, + "sample_count": 2, + "taa_weight": 0.10000000149011612, + "z_thickness": 0.10000000149011612 +} \ No newline at end of file diff --git a/src/assets/bubble_reflection.scn.editor b/src/assets/bubble_reflection.scn.editor new file mode 100644 index 0000000..25590a8 --- /dev/null +++ b/src/assets/bubble_reflection.scn.editor @@ -0,0 +1,178 @@ +{ + "editor": { + "animeditor_plugin": { + "quantize_time": true, + "show_trajectories": null, + "trajectories_tick_seconds": 1.0, + "trajectories_tick_size": 0.10000000149011612 + }, + "explorer": { + "node_custom_order": { + "refs": null, + "roots": [ + 0, + 1 + ] + }, + "node_sort_method": "custom", + "show_node_uid": false + }, + "grid_plugin": { + "enabled": true, + "grid_color_b": 1.0, + "grid_color_g": 1.0, + "grid_color_r": 1.0, + "n_subdivs": 10, + "offset": 0.0, + "opacity": 0.5, + "subdiv_size": 1.0 + }, + "navigation_plugin": { + "orbit_distance": 2.632981538772583, + "speed": 0.10000000149011612, + "turbo": 1.0 + }, + "transform_gizmo_plugin": { + "mode": "local", + "snap": "none", + "snap_rotation": 5.0, + "snap_rotation_fine": 1.0, + "snap_scale": 10.0, + "snap_scale_fine": 1.0, + "snap_translation": 1.0, + "snap_translation_fine": 0.10000000149011612, + "tool": "move" + }, + "view_plugin": { + "show_cameras": true, + "show_collisions": false, + "show_lights": true, + "show_nodes": true, + "show_probe": true + }, + "views": { + "back": [ + -0.9999999403953552, + 0.0, + -8.742277657347586e-08, + 0.0, + 0.0, + 1.0, + -0.0, + 0.0, + 8.742277657347586e-08, + -0.0, + -0.9999999403953552, + 0.0 + ], + "bottom": [ + 1.0, + -0.0, + -0.0, + 0.0, + -0.0, + -8.742277657347586e-08, + 1.0, + 0.0, + -0.0, + -1.0, + -8.742277657347586e-08, + 0.0 + ], + "bottom_zrange": { + "zfar": 1000.0, + "znear": -1000.0 + }, + "current_camera": 0, + "front": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + -0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0 + ], + "left": [ + -8.742277657347586e-08, + 0.0, + 1.0, + 0.0, + 0.0, + 1.0, + -0.0, + 0.0, + -1.0, + 0.0, + -8.742277657347586e-08, + 0.0 + ], + "left_zrange": { + "zfar": 1000.0, + "znear": -1000.0 + }, + "orthographic_size": 1.0, + "perspective": [ + -0.7115512490272522, + -0.1653103530406952, + -0.6829080581665039, + 1.7980844974517822, + 0.0, + 0.9719282388687134, + -0.23527324199676514, + 0.6194703578948975, + 0.7026358842849731, + -0.16740863025188446, + -0.6915751695632935, + 1.8209043741226196 + ], + "perspective_fov": 0.6361725330352783, + "perspective_zrange": { + "zfar": 1000.0, + "znear": 0.009999999776482582 + }, + "right": [ + -8.742277657347586e-08, + 0.0, + -1.0, + 0.0, + 0.0, + 1.0, + -0.0, + 0.0, + 1.0, + -0.0, + -8.742277657347586e-08, + 0.0 + ], + "right_zrange": { + "zfar": 1000.0, + "znear": -1000.0 + }, + "scale": 0.05000000074505806, + "top": [ + 1.0, + 0.0, + -0.0, + 0.0, + -0.0, + -8.742277657347586e-08, + -1.0, + 0.0, + 0.0, + 1.0, + -8.742277657347586e-08, + 0.0 + ], + "top_zrange": { + "zfar": 1000.0, + "znear": -1000.0 + } + } + } +} \ No newline at end of file diff --git a/src/assets/core/shader/pbr.hps b/src/assets/core/shader/pbr.hps index 884a1a3..abb3be2 100644 --- a/src/assets/core/shader/pbr.hps +++ b/src/assets/core/shader/pbr.hps @@ -1,5 +1,6 @@ { "features": ["OptionalBaseColorOpacityMap", "OptionalOcclusionRoughnessMetalnessMap", "OptionalNormalMap", "OptionalSelfMap", "_OptionalSkinning"], "uniforms": [ - {"name": "uSelfCtrl", "type": "Vec4", "value": [3.0, 1.0, 1.0, 1.0]} + {"name": "uSelfCtrl", "type": "Vec4", "value": [3.0, 1.0, 1.0, 1.0]}, + {"name": "uSpecBooster", "type": "Vec4", "value": [1.0, 1.0, 1.0, 1.0]} ]} diff --git a/src/assets/core/shader/pbr_fs.sc b/src/assets/core/shader/pbr_fs.sc index 23270ec..df3fc72 100644 --- a/src/assets/core/shader/pbr_fs.sc +++ b/src/assets/core/shader/pbr_fs.sc @@ -9,6 +9,7 @@ uniform vec4 uBaseOpacityColor; uniform vec4 uOcclusionRoughnessMetalnessColor; uniform vec4 uSelfColor; uniform vec4 uSelfCtrl; +uniform vec4 uSpecBooster; // Texture slots SAMPLER2D(uBaseOpacityMap, 0); @@ -40,6 +41,7 @@ float SampleShadowPCF(sampler2DShadow map, vec4 coord, float inv_pixel_size, flo float k = 0.0; #if FORWARD_PIPELINE_AAA +#if !BGFX_SHADER_LANGUAGE_GLSL #define PCF_SAMPLE_COUNT 2 // 3x3 ARRAY_BEGIN(float, weights, 9) 0.011147, 0.083286, 0.011147, 0.083286, 0.622269, 0.083286, 0.011147, 0.083286, 0.011147 ARRAY_END(); @@ -51,6 +53,15 @@ float SampleShadowPCF(sampler2DShadow map, vec4 coord, float inv_pixel_size, flo k += SampleHardShadow(map, coord + vec4(vec2(u, v) * k_pixel_size, 0.0, 0.0), bias) * weights[j * 3 + i]; } } +#else + // 2x2 + k += SampleHardShadow(map, coord + vec4(vec2(-0.5, -0.5) * k_pixel_size, 0.0, 0.0), bias); + k += SampleHardShadow(map, coord + vec4(vec2( 0.5, -0.5) * k_pixel_size, 0.0, 0.0), bias); + k += SampleHardShadow(map, coord + vec4(vec2(-0.5, 0.5) * k_pixel_size, 0.0, 0.0), bias); + k += SampleHardShadow(map, coord + vec4(vec2( 0.5, 0.5) * k_pixel_size, 0.0, 0.0), bias); + + k /= 4.0; +#endif #else // FORWARD_PIPELINE_AAA // 2x2 k += SampleHardShadow(map, coord + vec4(vec2(-0.5, -0.5) * k_pixel_size, 0.0, 0.0), bias); @@ -204,7 +215,7 @@ void main() { #endif // FORWARD_PIPELINE_AAA } #endif // SLOT0_SHADOWS - color += GGX(V, N, NdotV, uLightDir[0].xyz, base_opacity.xyz, occ_rough_metal.g, occ_rough_metal.b, F0, uLightDiffuse[0].xyz * k_shadow, uLightSpecular[0].xyz * k_shadow); + color += GGX(V, N, NdotV, uLightDir[0].xyz, base_opacity.xyz, occ_rough_metal.g, occ_rough_metal.b, F0, uLightDiffuse[0].xyz * k_shadow, uLightSpecular[0].xyz * k_shadow * uSpecBooster.x); } // SLOT 1: point/spot light (with optional shadows) { @@ -218,7 +229,7 @@ void main() { shadow_atten = SampleShadowPCF(uSpotShadowMap, vSpotShadowCoord, uShadowState.y, uShadowState.w, jitter); attenuation *= shadow_atten; #endif // SLOT1_SHADOWS - color += GGX(V, N, NdotV, L, base_opacity.xyz, occ_rough_metal.g, occ_rough_metal.b, F0, uLightDiffuse[1].xyz * attenuation, uLightSpecular[1].xyz * attenuation); + color += GGX(V, N, NdotV, L, base_opacity.xyz, occ_rough_metal.g, occ_rough_metal.b, F0, uLightDiffuse[1].xyz * attenuation, uLightSpecular[1].xyz * attenuation * uSpecBooster.y); vec3 wave_caustics = WaterCaustics(P, N, uClock.x); float shadow_mix = 1.0 - clamp(pow(cone_attenuation, 0.5), 0.0, 1.0); color += mix(wave_caustics * shadow_atten * 4.0, wave_caustics * 0.25, shadow_mix) * occ_rough_metal.x; @@ -232,7 +243,7 @@ void main() { L /= max(distance, 1e-8); float attenuation = LightAttenuation(L, uLightDir[i].xyz, distance, uLightPos[i].w, uLightDir[i].w, uLightDiffuse[i].w); - color += GGX(V, N, NdotV, L, base_opacity.xyz, occ_rough_metal.g, occ_rough_metal.b, F0, uLightDiffuse[i].xyz * attenuation, uLightSpecular[i].xyz * attenuation); + color += GGX(V, N, NdotV, L, base_opacity.xyz, occ_rough_metal.g, occ_rough_metal.b, F0, uLightDiffuse[i].xyz * attenuation, uLightSpecular[i].xyz * attenuation * uSpecBooster.z); } } diff --git a/src/assets/shaders/compositer_fs.sc b/src/assets/shaders/compositer_fs.sc index df6d426..e7d63b0 100644 --- a/src/assets/shaders/compositer_fs.sc +++ b/src/assets/shaders/compositer_fs.sc @@ -16,9 +16,11 @@ uniform vec4 fade; uniform vec4 uClock; uniform vec4 uZFrustum; // z_near, z_far, fov, ___ SAMPLER2D(s_tex, 0); // main framebuffer +#if !BGFX_SHADER_LANGUAGE_GLSL SAMPLER2D(s_depth, 1); SAMPLER2D(b_tex, 2); // framebuffer for "bubbles fx" SAMPLER2D(b_depth, 3); +#endif #define WAV_FREQ_X 15.0 #define WAV_FREQ_Y 6.0 @@ -57,8 +59,11 @@ void main() { vignette *= mix(clamp(map(UV0.y, 0.75, 1.0, 1.0, 0.0), 0.75, 1.0), clamp(map(UV0.y, 0.75, 1.0, 1.0, 0.0), 0.0, 1.0), UV0.x); float inv_vignette = ((1.0 - vignette) * 5.0) + 1.0; + float zb = 0.0; + float i, j; +#if !BGFX_SHADER_LANGUAGE_GLSL // get bubble masked by landscape - float i, j, z; + float z; vec2 o; // float z_bg = 0.0, z_bubbles = 0.0; for(j = 0; j < MAX_BLUR_SAMPLE; j++) @@ -74,8 +79,13 @@ void main() { z /= (MAX_BLUR_SAMPLE * MAX_BLUR_SAMPLE); // 0.0 to 1.0 factor to exclude the walkman from the blur - float zb = clamp(1.0 - (get_zFromDepth(texture2D(s_depth, UV0).x) * 0.001), 0.0, 1.0); + zb = clamp(1.0 - (get_zFromDepth(texture2D(s_depth, UV0).x) * 0.001), 0.0, 1.0); zb = clamp(map(zb, 0.97, 0.97225, 0.0, 1.0), 0.0, 1.0); +#else + vec2 UV0r = vec2(clamp(UV0.x + 0.09 - UV0.y * 0.1, 0.0, 1.0), UV0.y + UV0.x * 0.4); + zb = pow(clamp(UV0r.x * 8.0, 0.0, 1.0), 4.0) * pow(clamp((0.4 - UV0r.x) * 8.0, 0.0, 1.0), 0.75); + zb *= pow(min(UV0r.y * 6.0, 1.0), 2.0) * pow(clamp((0.4 - UV0r.y) * 12.0, 0.0, 1.0), 0.75); +#endif vignette = clamp(vignette + zb, 0.0, 1.0); @@ -101,11 +111,10 @@ void main() { overscan *= clamp(map(UV0.y, 0.9, 1.0, 1.0, 0.0), 0.0, 1.0); waveUV0 = waveUV0 * vec2(0.01 * overscan * uClock.y, 0.01 * overscan * uClock.y); - // distort buffer along the bubbles -#if 0 - vec3 bubble_rgb = texture2D(b_tex, UV0).xyz; -#else + vec2 bubbleUV0 = vec2(0.0, 0.0); vec3 bubble_rgb = vec3(0.0, 0.0, 0.0); +#if !BGFX_SHADER_LANGUAGE_GLSL + // distort buffer along the bubbles for(j = 0; j < MAX_BLUR_SAMPLE; j++) { for(i = 0; i < MAX_BLUR_SAMPLE; i++) @@ -115,9 +124,9 @@ void main() { } } bubble_rgb /= (MAX_BLUR_SAMPLE * MAX_BLUR_SAMPLE); + + bubbleUV0 = (vec2(bubble_rgb.x, bubble_rgb.y) - vec2(0.5, 0.5)) * 2.0 * 0.015 * z; #endif - vec2 bubbleUV0 = (vec2(bubble_rgb.x, bubble_rgb.y) - vec2(0.5, 0.5)) * 2.0 * 0.015 * z; - // vec2 bubbleUV0 = (vec2(bubble_rgb.x, bubble_rgb.y)) * 2.0 * 0.015 * z; // poorman's color dispersion float dispersion = mix(clamp(map(UV0.x, 0.0, 0.5, 0.0, 1.0), 0.0, 1.0), clamp(map(UV0.x, 0.0, 0.5, 0.5, 1.0), 0.0, 1.0), UV0.y); @@ -152,6 +161,7 @@ void main() { g *= (1.0 / (MAX_BLUR_SAMPLE * MAX_BLUR_SAMPLE)); b *= (1.0 / (MAX_BLUR_SAMPLE * MAX_BLUR_SAMPLE)); +#if !BGFX_SHADER_LANGUAGE_GLSL // Bubble (fake fresnel) edges float bubble_edges = pow(bubble_rgb.z, 4.0) * 0.75 * z; // * vignette; @@ -166,6 +176,7 @@ void main() { r += refl.x; g += refl.y; b += refl.z; + #endif r = r * fade.x; g = g * fade.x; @@ -187,6 +198,7 @@ void main() { // gl_FragColor = texture2D(b_tex, UV0); // gl_FragColor = vec4(z, z, z, 1.0); // gl_FragColor = vec4(zb, zb, zb, 1.0); + // gl_FragColor = vec4(r, g, b, 1.0) + vec4(zb, zb, zb, 0.0); // gl_FragColor = vec4(bubble_rgb.x, bubble_rgb.y, bubble_rgb.z, 1.0); // gl_FragColor = vec4(bubbleUV0 * 200.0, 0.0, 1.0); } diff --git a/src/config_gui.lua b/src/config_gui.lua index 2e575ce..1af376a 100644 --- a/src/config_gui.lua +++ b/src/config_gui.lua @@ -1,5 +1,6 @@ -function config_gui() +function config_gui(is_opengl) + is_opengl = is_opengl or false -- resolution selection local res_list = {{640, 360}, {768, 432}, {896, 504}, {1024, 576}, {1152, 648}, {1280, 720}, {1920, 1080}, {1920, 1200}, {2560, 1440}, {3840, 2160}, {5120, 2880}} local res_list_str = {} @@ -26,7 +27,11 @@ function config_gui() local config_done = 0 -- 0 = stay, 1 = play demo, 2 = exit without playing the demo local win = hg.NewWindow("Marine Melodies - Config", res_x, res_y, 32) - hg.RenderInit(win) -- , hg.RT_OpenGL) + if is_opengl == false then + hg.RenderInit(win) + else + hg.RenderInit(win, hg.RT_OpenGL) + end local imgui_prg = hg.LoadProgramFromAssets('core/shader/imgui') local imgui_img_prg = hg.LoadProgramFromAssets('core/shader/imgui_image') diff --git a/src/main.lua b/src/main.lua index 069e5cc..7582890 100644 --- a/src/main.lua +++ b/src/main.lua @@ -24,9 +24,13 @@ function draw_line(pos_a, pos_b, line_color, vid, vtx_line_layout, line_shader) end function main(cmd_arg) - local config = {enable_aaa=true, low_aaa=false, skip_intro=false} + local config = {enable_aaa=true, low_aaa=false, skip_intro=true, is_opengl=true} local i + if package.config:sub(1,1) == '/' then + is_opengl=true + end + -- hg.SetLogLevel(hg.LL_Normal) hg.InputInit() @@ -50,7 +54,7 @@ function main(cmd_arg) local no_aa hg.ShowCursor() - config_done, default_res_x, default_res_y, default_fullscreen, full_aaa, low_aaa, no_aaa = config_gui() + config_done, default_res_x, default_res_y, default_fullscreen, full_aaa, low_aaa, no_aaa = config_gui(config.is_opengl) -- set config res_x, res_y = default_res_x, default_res_y @@ -74,7 +78,11 @@ function main(cmd_arg) -- local win = hg.RenderInit('Minisub Escape', res_x, res_y, hg.RF_VSync | hg.RF_MSAA4X) win = hg.NewWindow("Marine Melodies^Resistance(2022)", res_x, res_y, 32, default_fullscreen) --, hg.WV_Fullscreen) - hg.RenderInit(win) --, hg.RT_OpenGL) + if config.is_opengl == false then + hg.RenderInit(win) + else + hg.RenderInit(win, hg.RT_OpenGL) + end hg.RenderReset(res_x, res_y, hg.RF_MSAA4X | hg.RF_MaxAnisotropy) -- create pipeline @@ -104,16 +112,23 @@ function main(cmd_arg) local scene_clocks = hg.SceneClocks() -- specific scene to render the bubbles - local bubble_scene = hg.Scene() + local bubble_scene + if config.is_opengl == false then + bubble_scene = hg.Scene() + else + bubble_scene = scene + end -- create a frame buffer to draw the scene to local color = hg.CreateTexture(res_x, res_y, "color texture", hg.TF_RenderTarget, hg.TF_RGBA8) - local depth = hg.CreateTexture(res_x, res_y, "depth texture", hg.TF_RenderTarget, hg.TF_D32F) + local depth = hg.CreateTexture(res_x, res_y, "depth texture", hg.TF_RenderTarget, hg.TF_D24F) local frame_buffer = hg.CreateFrameBuffer(color, depth, "framebuffer") - local bubble_color = hg.CreateTexture(res_x, res_y, "color texture", hg.TF_RenderTarget, hg.TF_RGBA8) - local bubble_depth = hg.CreateTexture(res_x, res_y, "depth texture", hg.TF_RenderTarget, hg.TF_D32F) - local bubble_frame_buffer = hg.CreateFrameBuffer(bubble_color, bubble_depth, "bubble_framebuffer") + if config.is_opengl == false then + local bubble_color = hg.CreateTexture(res_x, res_y, "color texture", hg.TF_RenderTarget, hg.TF_RGBA8) + local bubble_depth = hg.CreateTexture(res_x, res_y, "depth texture", hg.TF_RenderTarget, hg.TF_D24F) + local bubble_frame_buffer = hg.CreateFrameBuffer(bubble_color, bubble_depth, "bubble_framebuffer") + end -- create a plane model for the final rendering stage local vtx_layout = hg.VertexLayoutPosFloatNormUInt8TexCoord0UInt8() @@ -160,8 +175,10 @@ function main(cmd_arg) local z_far = cam:GetCamera():GetZFar() local fov = cam:GetCamera():GetFov() - local bubble_cam = hg.CreateCamera(bubble_scene, cam:GetTransform():GetWorld(), z_near, z_far, fov) - bubble_scene:SetCurrentCamera(bubble_cam) + if config.is_opengl == false then + local bubble_cam = hg.CreateCamera(bubble_scene, cam:GetTransform():GetWorld(), z_near, z_far, fov) + bubble_scene:SetCurrentCamera(bubble_cam) + end -- intro particles init local intro_particles = {} @@ -189,7 +206,12 @@ function main(cmd_arg) -- bubbles init local bubble_particles = {emitter={spawn_timeout=hg.time_from_sec_f(0.0)}, particles={}} - local blank_bubble = hg.CreateInstanceFromAssets(bubble_scene, hg.TranslationMat4(hg.Vec3(0,0,0)), "bubble.scn", res, hg.GetForwardPipelineInfo()) -- , hg.LSSF_Nodes | hg.LSSF_Scene | hg.LSSF_DoNotChangeCurrentCameraIfValid) + local blank_bubble + if config.is_opengl == false then + blank_bubble = hg.CreateInstanceFromAssets(bubble_scene, hg.TranslationMat4(hg.Vec3(0,0,0)), "bubble.scn", res, hg.GetForwardPipelineInfo()) -- , hg.LSSF_Nodes | hg.LSSF_Scene | hg.LSSF_DoNotChangeCurrentCameraIfValid) + else + blank_bubble = hg.CreateInstanceFromAssets(bubble_scene, hg.TranslationMat4(hg.Vec3(0,0,0)), "bubble_reflection.scn", res, hg.GetForwardPipelineInfo()) -- , hg.LSSF_Nodes | hg.LSSF_Scene | hg.LSSF_DoNotChangeCurrentCameraIfValid) + end blank_bubble:Disable() -- fish boids init @@ -490,7 +512,9 @@ function main(cmd_arg) hg.SceneUpdateSystems(scene, scene_clocks, dt, physics, hg.time_from_sec_f(1 / 60), 4) -- physics:SyncTransformsToScene(scene) -- scene:Update(dt) - bubble_scene:Update(dt) + if config.is_opengl == false then + bubble_scene:Update(dt) + end -- main framebuffer local view_id = 0 @@ -500,7 +524,7 @@ function main(cmd_arg) else view_id, pass_ids = hg.SubmitSceneToPipeline(view_id, scene, hg.IntRect(0, 0, res_x, res_y), true, pipeline, res, frame_buffer.handle) end - + -- view_id, pass_ids = hg.SubmitSceneToPipeline(view_id, scene, hg.IntRect(0, 0, res_x, res_y), true, pipeline, res) -- debug draw lines @@ -523,7 +547,9 @@ function main(cmd_arg) fish_boids = boids_update_draw(opaque_view_id, vtx_line_layout, dt, fish_boids, boids_min_max, scene, physics, shader_for_line, scene:GetNode("sphere")) -- bubble framebuffer - view_id, pass_ids = hg.SubmitSceneToPipeline(view_id, bubble_scene, hg.IntRect(0, 0, res_x, res_y), true, pipeline, res, bubble_frame_buffer.handle) + if config.is_opengl == false then + view_id, pass_ids = hg.SubmitSceneToPipeline(view_id, bubble_scene, hg.IntRect(0, 0, res_x, res_y), true, pipeline, res, bubble_frame_buffer.handle) + end -- draw the render texture on a quad hg.SetViewPerspective(view_id, 0, 0, res_x, res_y, hg.TranslationMat4(hg.Vec3(0, 0, -0.5))) @@ -538,8 +564,13 @@ function main(cmd_arg) hg.MakeUniformSetValue('uClock', hg.Vec4(hg.time_to_sec_f(clock), 0.1, 0.0, 0.0)), hg.MakeUniformSetValue('uZFrustum', hg.Vec4(z_near, z_far, fov, 0)) } - tex_uniforms = {hg.MakeUniformSetTexture('s_tex', color, 0), hg.MakeUniformSetTexture('s_depth', depth, 1), + if config.is_opengl == false then + tex_uniforms = {hg.MakeUniformSetTexture('s_tex', color, 0), hg.MakeUniformSetTexture('s_depth', depth, 1), hg.MakeUniformSetTexture('b_tex', bubble_color, 2), hg.MakeUniformSetTexture('b_depth', bubble_depth, 3)} + else + tex_uniforms = {hg.MakeUniformSetTexture('s_tex', color, 0)} + end + hg.DrawModel(view_id, screen_mdl, screen_prg, val_uniforms, tex_uniforms, hg.TransformationMat4(hg.Vec3(0, 0, 0), hg.Vec3(math.pi / 2, math.pi, 0)))