diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 4208e6706..3d80567aa 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -1471,6 +1471,7 @@ {"name":"sh_channel_R2A","order":13,"path":"shaders/sh_channel_R2A/sh_channel_R2A.yy",}, {"name":"sh_channel_R2B","order":12,"path":"shaders/sh_channel_R2B/sh_channel_R2B.yy",}, {"name":"sh_channel_R2G","order":11,"path":"shaders/sh_channel_R2G/sh_channel_R2G.yy",}, + {"name":"sh_channel_R2R","order":14,"path":"shaders/sh_channel_R2R/sh_channel_R2R.yy",}, {"name":"sh_channel_S","order":5,"path":"shaders/sh_channel_S/sh_channel_S.yy",}, {"name":"sh_channel_V","order":6,"path":"shaders/sh_channel_V/sh_channel_V.yy",}, {"name":"sh_checkerboard","order":3,"path":"shaders/sh_checkerboard/sh_checkerboard.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 578fdf938..31e281144 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -2125,6 +2125,7 @@ {"id":{"name":"sh_channel_R2A","path":"shaders/sh_channel_R2A/sh_channel_R2A.yy",},}, {"id":{"name":"sh_channel_R2B","path":"shaders/sh_channel_R2B/sh_channel_R2B.yy",},}, {"id":{"name":"sh_channel_R2G","path":"shaders/sh_channel_R2G/sh_channel_R2G.yy",},}, + {"id":{"name":"sh_channel_R2R","path":"shaders/sh_channel_R2R/sh_channel_R2R.yy",},}, {"id":{"name":"sh_channel_S","path":"shaders/sh_channel_S/sh_channel_S.yy",},}, {"id":{"name":"sh_channel_V","path":"shaders/sh_channel_V/sh_channel_V.yy",},}, {"id":{"name":"sh_checkerboard","path":"shaders/sh_checkerboard/sh_checkerboard.yy",},}, diff --git a/scripts/d3d_light/d3d_light.gml b/scripts/d3d_light/d3d_light.gml index 048641727..e2225a534 100644 --- a/scripts/d3d_light/d3d_light.gml +++ b/scripts/d3d_light/d3d_light.gml @@ -22,23 +22,23 @@ function __3dLight() : __3dObject() constructor { static submit = function(scene = {}, shader = noone) {} - static setShadow = function(active, shadowMapSize, shadowMapScale = shadow_map_scale) { #region + static setShadow = function(active, shadowMapSize, shadowMapScale = shadow_map_scale) { shadow_active = active; shadow_map_size = shadowMapSize; shadow_map_scale = shadowMapScale; return self; - } #endregion + } static shadowProjectBegin = function() {} static shadowProjectEnd = function() {} - static submitShadow = function(scene, objects) { #region + static submitShadow = function(scene, objects) { if(!shadow_active) return; shadowProjectBegin(); objects.submit(scene, shadow_mapper); shadowProjectEnd(); - } #endregion + } } \ No newline at end of file diff --git a/scripts/d3d_light_directional/d3d_light_directional.gml b/scripts/d3d_light_directional/d3d_light_directional.gml index 25d60f8a1..96e8440d3 100644 --- a/scripts/d3d_light_directional/d3d_light_directional.gml +++ b/scripts/d3d_light_directional/d3d_light_directional.gml @@ -11,17 +11,17 @@ function __3dLightDirectional() : __3dLight() constructor { shadow_mapper = sh_d3d_shadow_depth; - static submitSel = function(params = {}) { #region + static submitSel = function(params = {}) { shader_set(sh_d3d_wireframe); shader_set_color("blend", color); preSubmitVertex(params); shader_reset(); - } #endregion + } static submitShader = function(params = {}) { params.addLightDirectional(self); } - static preSubmitVertex = function(params = {}) { #region + static preSubmitVertex = function(params = {}) { var _rot = new __rot3(0, 0, 0).lookAt(transform.position, params.camera.position); var rot = matrix_build(0, 0, 0, @@ -49,9 +49,9 @@ function __3dLightDirectional() : __3dLight() constructor { matrix_stack_pop(); matrix_set(matrix_world, matrix_build_identity()); - } #endregion + } - static shadowProjectBegin = function() { #region + static shadowProjectBegin = function() { shadow_map = surface_verify(shadow_map, shadow_map_size, shadow_map_size, OS == os_macosx? surface_rgba8unorm : surface_r32float); shadow_map_view = matrix_build_lookat(transform.position.x, transform.position.y, transform.position.z, 0, 0, 0, 0, 0, -1); @@ -63,17 +63,18 @@ function __3dLightDirectional() : __3dLight() constructor { shader_set_i("use_8bit", OS == os_macosx); gpu_set_ztestenable(true); + gpu_set_cullmode(cull_counterclockwise); camera_set_view_mat(shadow_map_camera, shadow_map_view); camera_set_proj_mat(shadow_map_camera, shadow_map_proj); camera_apply(shadow_map_camera); - } #endregion + } - static shadowProjectEnd = function() { #region + static shadowProjectEnd = function() { shader_reset(); surface_reset_target(); camera_apply(0); gpu_set_ztestenable(false); - } #endregion + } } \ No newline at end of file diff --git a/scripts/d3d_light_point/d3d_light_point.gml b/scripts/d3d_light_point/d3d_light_point.gml index 20360d819..32896b956 100644 --- a/scripts/d3d_light_point/d3d_light_point.gml +++ b/scripts/d3d_light_point/d3d_light_point.gml @@ -18,7 +18,7 @@ function __3dLightPoint() : __3dLight() constructor { static submitShader = function(params = {}) { params.addLightPoint(self); } - static preSubmitVertex = function(params = {}) { #region + static preSubmitVertex = function(params = {}) { var _rot = new __rot3(0, 0, 0).lookAt(transform.position, params.camera.position); var rot = matrix_build(0, 0, 0, @@ -54,9 +54,9 @@ function __3dLightPoint() : __3dLight() constructor { matrix_stack_pop(); matrix_set(matrix_world, matrix_build_identity()); - } #endregion + } - static shadowProjectBegin = function(index = 0) { #region + static shadowProjectBegin = function(index = 0) { //print($"Projecting cube face {index} to {shadow_maps[index]} with view {shadow_map_views[index]}") surface_set_target(shadow_maps[index]); @@ -65,65 +65,73 @@ function __3dLightPoint() : __3dLight() constructor { shader_set_i("use_8bit", OS == os_macosx); gpu_set_ztestenable(true); + gpu_set_cullmode(cull_counterclockwise); camera_set_view_mat(shadow_map_camera, shadow_map_views[index]); camera_set_proj_mat(shadow_map_camera, shadow_map_proj); camera_apply(shadow_map_camera); - } #endregion + BLEND_OVERRIDE + } - static shadowProjectEnd = function() { #region + static shadowProjectEnd = function() { + BLEND_NORMAL + camera_apply(0); shader_reset(); surface_reset_target(); - camera_apply(0); gpu_set_ztestenable(false); - } #endregion + } - static submitShadow = function(scene, objects) { #region + static submitShadow = function(scene, objects) { if(!shadow_active) return; for( var i = 0; i < 6; i++ ) - shadow_maps[i] = surface_verify(shadow_maps[i], shadow_map_size, shadow_map_size, OS == os_macosx? surface_rgba8unorm : surface_r32float); + shadow_maps[i] = surface_verify(shadow_maps[i], shadow_map_size, shadow_map_size, surface_r32float); var position = transform.position; + var _x = position.x; + var _y = position.y; + var _z = position.z; - shadow_map_views = array_create(6); - shadow_map_views[0] = matrix_build_lookat(position.x, position.y, position.z, position.x + 1, position.y, position.z, 0, 0, -1); - shadow_map_views[1] = matrix_build_lookat(position.x, position.y, position.z, position.x - 1, position.y, position.z, 0, 0, -1); - shadow_map_views[2] = matrix_build_lookat(position.x, position.y, position.z, position.x, position.y + 1, position.z, 0, 0, -1); - shadow_map_views[3] = matrix_build_lookat(position.x, position.y, position.z, position.x, position.y - 1, position.z, 0, 0, -1); - shadow_map_views[4] = matrix_build_lookat(position.x, position.y, position.z, position.x, position.y, position.z + 1, 0, -1, 0); - shadow_map_views[5] = matrix_build_lookat(position.x, position.y, position.z, position.x, position.y, position.z - 1, 0, 1, 0); + shadow_map_views = array_verify(shadow_map_views, 6); + shadow_map_views[0] = matrix_build_lookat(_x, _y, _z, _x + 1, _y, _z, 0, 0, -1); + shadow_map_views[1] = matrix_build_lookat(_x, _y, _z, _x - 1, _y, _z, 0, 0, -1); + shadow_map_views[2] = matrix_build_lookat(_x, _y, _z, _x, _y + 1, _z, 0, 0, -1); + shadow_map_views[3] = matrix_build_lookat(_x, _y, _z, _x, _y - 1, _z, 0, 0, -1); + shadow_map_views[4] = matrix_build_lookat(_x, _y, _z, _x, _y, _z + 1, 0, 1, 0); + shadow_map_views[5] = matrix_build_lookat(_x, _y, _z, _x, _y, _z - 1, 0, -1, 0); shadow_map_view = array_merge( shadow_map_views[0], shadow_map_views[1], shadow_map_views[2], shadow_map_views[3], shadow_map_views[4], shadow_map_views[5] ); shadow_map_proj = matrix_build_projection_perspective_fov(90, 1, .01, radius); - for( var j = 0; j < 6; j++ ) { ///FUCK There's gotta be a better way to do this in GameMaker + for( var j = 0; j < 6; j++ ) { shadowProjectBegin(j); objects.submit(scene, shadow_mapper); shadowProjectEnd(); } - shadow_map = surface_verify(shadow_map, shadow_map_size * 2, shadow_map_size, OS == os_macosx? surface_rgba8unorm : surface_rgba32float); + shadow_map = surface_verify(shadow_map, shadow_map_size * 2, shadow_map_size, surface_rgba32float); surface_set_target(shadow_map); - draw_clear(c_black); + draw_clear_alpha(c_black, 1.); gpu_set_blendmode_ext(bm_one, bm_one); - draw_surface_safe(shadow_maps[0]); + shader_set(sh_channel_R2R); + draw_surface(shadow_maps[0], 0, 0); draw_surface(shadow_maps[3], shadow_map_size, 0); + shader_reset(); shader_set(sh_channel_R2G); - draw_surface_safe(shadow_maps[1]); + draw_surface(shadow_maps[1], 0, 0); draw_surface(shadow_maps[4], shadow_map_size, 0); shader_reset(); shader_set(sh_channel_R2B); - draw_surface_safe(shadow_maps[2]); + draw_surface(shadow_maps[2], 0, 0); draw_surface(shadow_maps[5], shadow_map_size, 0); shader_reset(); - gpu_set_blendmode(bm_normal); - surface_reset_target(); - } #endregion + BLEND_NORMAL + __surface_reset_target(); + } } \ No newline at end of file diff --git a/scripts/d3d_object/d3d_object.gml b/scripts/d3d_object/d3d_object.gml index f76d1fbbc..12ebc0544 100644 --- a/scripts/d3d_object/d3d_object.gml +++ b/scripts/d3d_object/d3d_object.gml @@ -152,52 +152,47 @@ function __3dObject() constructor { if(custom_shader != noone) _shader = custom_shader; if(shader != noone) _shader = shader; - - shader_set(_shader); + + if(!is_undefined(shader)) shader_set(_shader); preSubmitVertex(scene); - transform.submitMatrix(); - matrix_set(matrix_world, matrix_stack_top()); - #region ++++ Submit & Material ++++ - gpu_set_tex_repeat(true); + gpu_set_tex_repeat(true); + + for( var i = 0, n = array_length(VB); i < n; i++ ) { + var _ind = array_safe_get_fast(material_index, i, i); + var _mat = array_safe_get_fast(materials, _ind, noone); + var _useMat = is_instanceof(_mat, __d3dMaterial); - for( var i = 0, n = array_length(VB); i < n; i++ ) { - var _ind = array_safe_get_fast(material_index, i, i); - var _mat = array_safe_get_fast(materials, _ind, noone); - var _useMat = is_instanceof(_mat, __d3dMaterial); + shader_set_i("mat_flip", texture_flip); + var _tex = _useMat? _mat.getTexture() : -1; + + if(_shader == sh_d3d_default) { + if(_useMat) { + _mat.submitShader(); + } else { + shader_set_f("mat_diffuse", 1); + shader_set_f("mat_specular", 0); + shader_set_f("mat_shine", 1); + shader_set_i("mat_metalic", 0); + shader_set_f("mat_reflective", 0); + shader_set_f("mat_texScale", [ 1, 1 ] ); + } + + } else if(_shader == sh_d3d_geometry) { + if(_useMat) _mat.submitGeometry(); + else shader_set_i("use_normal", 0); - shader_set_i("mat_flip", texture_flip); - var _tex = _useMat? _mat.getTexture() : -1; - - if(_shader == sh_d3d_default) { - if(_useMat) { - _mat.submitShader(); - } else { - shader_set_f("mat_diffuse", 1); - shader_set_f("mat_specular", 0); - shader_set_f("mat_shine", 1); - shader_set_i("mat_metalic", 0); - shader_set_f("mat_reflective", 0); - shader_set_f("mat_texScale", [ 1, 1 ] ); - } - - vertex_submit(VB[i], render_type, _tex); - } else if(_shader == sh_d3d_geometry) { - if(_useMat) _mat.submitGeometry(); - else shader_set_i("use_normal", 0); - - vertex_submit(VB[i], render_type, _tex); - } else - vertex_submit(VB[i], render_type, _tex); } - gpu_set_tex_repeat(false); - #endregion + vertex_submit(VB[i], render_type, _tex); + } - shader_reset(); + gpu_set_tex_repeat(false); + + if(!is_undefined(shader)) shader_reset(); if(scene.show_normal) { if(NVB == noone) generateNormal(); @@ -213,7 +208,6 @@ function __3dObject() constructor { transform.clearMatrix(); matrix_set(matrix_world, matrix_build_identity()); - postSubmitVertex(scene); } diff --git a/scripts/d3d_scene/d3d_scene.gml b/scripts/d3d_scene/d3d_scene.gml index 1d5cbbe18..424543bd4 100644 --- a/scripts/d3d_scene/d3d_scene.gml +++ b/scripts/d3d_scene/d3d_scene.gml @@ -61,7 +61,7 @@ function __3dScene(camera, name = "New scene") constructor { ssao_bias = 0.1; ssao_strength = 1.; - static reset = function() { #region + static reset = function() { lightDir_count = 0; lightDir_direction = []; lightDir_color = []; @@ -86,14 +86,14 @@ function __3dScene(camera, name = "New scene") constructor { lightPnt_viewMat = []; lightPnt_projMat = []; lightPnt_shadowBias = []; - } reset(); #endregion + } reset(); static submit = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submit (self, shader); D3DSCENE_POSTSUBMIT } static submitUI = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitUI (self, shader); D3DSCENE_POSTSUBMIT } static submitSel = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitSel (self, shader); D3DSCENE_POSTSUBMIT } static submitShader = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitShader (self, shader); D3DSCENE_POSTSUBMIT } - static deferPass = function(object, w, h, deferData = noone) { #region + static deferPass = function(object, w, h, deferData = noone) { if(deferData == noone) deferData = { geometry_data: [ noone, noone, noone ], ssao : noone, @@ -103,9 +103,9 @@ function __3dScene(camera, name = "New scene") constructor { ssaoPass(deferData); return deferData; - } #endregion + } - static renderBackground = function(w, h, surf = noone) { #region + static renderBackground = function(w, h, surf = noone) { surf = surface_verify(surf, w, h); surface_set_shader(surf, sh_d3d_background); shader_set_color("light_ambient", lightAmbient); @@ -126,12 +126,12 @@ function __3dScene(camera, name = "New scene") constructor { surface_reset_shader(); return surf; - } #endregion + } - static geometryPass = function(deferData, object, w = 512, h = 512) { #region - deferData.geometry_data[0] = surface_verify(deferData.geometry_data[0], w, h, OS == os_macosx? surface_rgba8unorm : surface_rgba32float); - deferData.geometry_data[1] = surface_verify(deferData.geometry_data[1], w, h, OS == os_macosx? surface_rgba8unorm : surface_rgba32float); - deferData.geometry_data[2] = surface_verify(deferData.geometry_data[2], w, h, OS == os_macosx? surface_rgba8unorm : surface_rgba32float); + static geometryPass = function(deferData, object, w = 512, h = 512) { + deferData.geometry_data[0] = surface_verify(deferData.geometry_data[0], w, h, surface_rgba32float); + deferData.geometry_data[1] = surface_verify(deferData.geometry_data[1], w, h, surface_rgba32float); + deferData.geometry_data[2] = surface_verify(deferData.geometry_data[2], w, h, surface_rgba32float); surface_set_target_ext(0, deferData.geometry_data[0]); surface_set_target_ext(1, deferData.geometry_data[1]); @@ -162,21 +162,21 @@ function __3dScene(camera, name = "New scene") constructor { surface_reset_target(); if(defer_normal_radius) { - var _normal_blurred = surface_create_size(deferData.geometry_data[2], OS == os_macosx? surface_rgba8unorm : surface_rgba32float); + var _normal_blurred = surface_create_size(deferData.geometry_data[2], surface_rgba32float); surface_set_shader(_normal_blurred, sh_d3d_normal_blur); shader_set_f("radius", defer_normal_radius); shader_set_i("use_8bit", OS == os_macosx); shader_set_dim("dimension", deferData.geometry_data[2]); - draw_surface_safe(deferData.geometry_data[2]); + draw_surface(deferData.geometry_data[2], 0, 0); surface_reset_shader(); surface_free(deferData.geometry_data[2]); deferData.geometry_data[2] = _normal_blurred; } - } #endregion + } - static ssaoPass = function(deferData) { #region + static ssaoPass = function(deferData) { if(!ssao_enabled) { surface_free(deferData.ssao); return; @@ -204,13 +204,13 @@ function __3dScene(camera, name = "New scene") constructor { shader_set_f("dimension", _sw, _sh); shader_set_surface("vNormal", deferData.geometry_data[2]); - draw_surface_safe(_ssao_surf); + draw_surface(_ssao_surf, 0, 0); surface_reset_shader(); surface_free(_ssao_surf); - } #endregion + } - static apply = function(deferData = noone) { #region + static apply = function(deferData = noone) { shader_set(sh_d3d_default); shader_set_i("use_8bit", OS == os_macosx); @@ -222,22 +222,21 @@ function __3dScene(camera, name = "New scene") constructor { if(deferData != noone) shader_set_surface("ao_map", deferData.ssao ); #endregion - shader_set_i("light_dir_count", lightDir_count); #region + shader_set_i("light_dir_count", lightDir_count); if(lightDir_count) { shader_set_f("light_dir_direction", lightDir_direction); shader_set_f("light_dir_color", lightDir_color); shader_set_f("light_dir_intensity", lightDir_intensity); shader_set_i("light_dir_shadow_active", lightDir_shadow); - for( var i = 0, n = array_length(lightDir_shadowMap); i < n; i++ ) { + for( var i = 0, n = array_length(lightDir_shadowMap); i < n; i++ ) var _sid = shader_set_surface($"light_dir_shadowmap_{i}", lightDir_shadowMap[i], true); - gpu_set_tex_repeat_ext(_sid, false); - } + shader_set_f("light_dir_view", lightDir_viewMat); shader_set_f("light_dir_proj", lightDir_projMat); shader_set_f("light_dir_shadow_bias", lightDir_shadowBias); - } #endregion + } - shader_set_i("light_pnt_count", lightPnt_count); #region + shader_set_i("light_pnt_count", lightPnt_count); if(lightPnt_count) { shader_set_f("light_pnt_position", lightPnt_position); shader_set_f("light_pnt_color", lightPnt_color); @@ -246,16 +245,13 @@ function __3dScene(camera, name = "New scene") constructor { shader_set_i("light_pnt_shadow_active", lightPnt_shadow); - if(OS == os_windows) { - for( var i = 0, n = array_length(lightPnt_shadowMap); i < n; i++ ) { - var _sid = shader_set_surface($"light_pnt_shadowmap_{i}", lightPnt_shadowMap[i], true, true); - gpu_set_tex_repeat_ext(_sid, false); - } - shader_set_f("light_pnt_view", lightPnt_viewMat); - shader_set_f("light_pnt_proj", lightPnt_projMat); - shader_set_f("light_pnt_shadow_bias", lightPnt_shadowBias); - } - } #endregion + for( var i = 0, n = array_length(lightPnt_shadowMap); i < n; i++ ) + var _sid = shader_set_surface($"light_pnt_shadowmap_{i}", lightPnt_shadowMap[i], true, false); + + shader_set_f("light_pnt_view", lightPnt_viewMat); + shader_set_f("light_pnt_proj", lightPnt_projMat); + shader_set_f("light_pnt_shadow_bias", lightPnt_shadowBias); + } if(OS == os_windows && defer_normal && deferData != noone && array_length(deferData.geometry_data) > 2) { shader_set_i("mat_defer_normal", 1); @@ -274,9 +270,9 @@ function __3dScene(camera, name = "New scene") constructor { //print($"Submitting scene with {lightDir_count} dir, {lightPnt_count} pnt lights."); shader_reset(); - } #endregion + } - static addLightDirectional = function(light) { #region + static addLightDirectional = function(light) { if(lightDir_count >= lightDir_max) { noti_warning("Direction light limit exceeded"); return self; @@ -301,9 +297,9 @@ function __3dScene(camera, name = "New scene") constructor { lightDir_count++; return self; - } #endregion + } - static addLightPoint = function(light) { #region + static addLightPoint = function(light) { if(lightPnt_count >= lightPnt_max) { noti_warning("Point light limit exceeded"); return self; @@ -314,7 +310,7 @@ function __3dScene(camera, name = "New scene") constructor { array_push(lightPnt_intensity, light.intensity); array_push(lightPnt_radius, light.radius); - array_push(lightPnt_shadow, OS == os_windows && light.shadow_active); + array_push(lightPnt_shadow, light.shadow_active); if(light.shadow_active) { if(lightPnt_shadow_count < lightPnt_shadow_max) { @@ -329,9 +325,7 @@ function __3dScene(camera, name = "New scene") constructor { lightPnt_count++; return self; - } #endregion + } - static toString = function() { #region - return $"[3D Scene] {name}"; - } #endregion + static toString = function() { return $"[3D Scene] {name}"; } } \ No newline at end of file diff --git a/scripts/node_3d_light_directional/node_3d_light_directional.gml b/scripts/node_3d_light_directional/node_3d_light_directional.gml index 4d75b8b16..9ed6457e7 100644 --- a/scripts/node_3d_light_directional/node_3d_light_directional.gml +++ b/scripts/node_3d_light_directional/node_3d_light_directional.gml @@ -7,9 +7,9 @@ function Node_3D_Light_Directional(_x, _y, _group = noone) : Node_3D_Light(_x, _ newInput(in_light + 1, nodeValue_Int("Shadow Map Size", self, 1024)); - newInput(in_light + 2, nodeValue_Int("Shadow Map Scale", self, 4)); + newInput(in_light + 2, nodeValue_Int("Shadow Map Scale", self, 16)); - newInput(in_light + 3, nodeValue_Float("Shadow Bias", self, .001)); + newInput(in_light + 3, nodeValue_Float("Shadow Bias", self, 0.01)); input_display_list = [ ["Transform", false], 0, diff --git a/scripts/node_3d_light_point/node_3d_light_point.gml b/scripts/node_3d_light_point/node_3d_light_point.gml index d8764f4c3..b57e8eb5f 100644 --- a/scripts/node_3d_light_point/node_3d_light_point.gml +++ b/scripts/node_3d_light_point/node_3d_light_point.gml @@ -11,7 +11,7 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr newInput(in_light + 2, nodeValue_Int("Shadow Map Size", self, 1024)) .setWindows(); - newInput(in_light + 3, nodeValue_Float("Shadow Bias", self, .001)) + newInput(in_light + 3, nodeValue_Float("Shadow Bias", self, 0.01)) .setWindows(); input_display_list = [ @@ -24,7 +24,7 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr tool_settings = []; tool_attribute.context = 1; - static processData = function(_output, _data, _output_index, _array_index = 0) { #region + static processData = function(_output, _data, _output_index, _array_index = 0) { var _active = _data[in_d3d + 0]; if(!_active) return noone; @@ -33,14 +33,24 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr var _shadow_map_size = _data[in_light + 2]; var _shadow_bias = _data[in_light + 3]; - var object = getObject(_array_index); + var _object = getObject(_array_index); - setTransform(object, _data); - setLight(object, _data); - object.setShadow(_shadow_active, _shadow_map_size); - object.radius = _radius; - object.shadow_bias = _shadow_bias; + setTransform(_object, _data); + setLight(_object, _data); + _object.setShadow(_shadow_active, _shadow_map_size); + _object.radius = _radius; + _object.shadow_bias = _shadow_bias * 100; - return object; - } #endregion + return _object; + } + + // static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + // var bbox = drawGetBbox(xx, yy, _s); + // var _object = getObject(0); + + // if(_object == noone) return; + + // var __smap = _object.shadow_map; + // draw_surface_ext_safe(__smap, bbox.x0, bbox.y0, .5 * _s, .5 * _s); + // } } \ No newline at end of file diff --git a/scripts/node_shape/node_shape.gml b/scripts/node_shape/node_shape.gml index dbedeb922..382756a74 100644 --- a/scripts/node_shape/node_shape.gml +++ b/scripts/node_shape/node_shape.gml @@ -1,7 +1,8 @@ global.node_shape_keys = [ - "rectangle", "ellipse", "regular polygon", "star", "arc", "teardrop", "cross", "leaf", "crescent", "donut", - "square", "circle", "triangle", "pentagon", "hexagon", "ring", "diamond", "trapezoid", "parallelogram", "heart", - "arrow", "gear", "squircle", + "rectangle", "square", "diamond", "trapezoid", "parallelogram", + "circle", "ellipse", "arc", "donut", "crescent", "ring", "squircle", + "regular polygon", "triangle", "pentagon", "hexagon", "star", "cross", + "teardrop", "leaf", "heart", "arrow", "gear", ]; function Node_create_Shape(_x, _y, _group = noone, _param = {}) { diff --git a/shaders/sh_channel_R2R/sh_channel_R2R.fsh b/shaders/sh_channel_R2R/sh_channel_R2R.fsh new file mode 100644 index 000000000..8d56cccc3 --- /dev/null +++ b/shaders/sh_channel_R2R/sh_channel_R2R.fsh @@ -0,0 +1,10 @@ +// +// Simple passthrough fragment shader +// +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() { + vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); + gl_FragColor = vec4(col.r, 0., 0., 0.); +} diff --git a/shaders/sh_channel_R2R/sh_channel_R2R.vsh b/shaders/sh_channel_R2R/sh_channel_R2R.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_channel_R2R/sh_channel_R2R.vsh @@ -0,0 +1,19 @@ +// +// Simple passthrough vertex shader +// +attribute vec3 in_Position; // (x,y,z) +//attribute vec3 in_Normal; // (x,y,z) unused in this shader. +attribute vec4 in_Colour; // (r,g,b,a) +attribute vec2 in_TextureCoord; // (u,v) + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() +{ + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; +} diff --git a/shaders/sh_channel_R2R/sh_channel_R2R.yy b/shaders/sh_channel_R2R/sh_channel_R2R.yy new file mode 100644 index 000000000..e6b7f533d --- /dev/null +++ b/shaders/sh_channel_R2R/sh_channel_R2R.yy @@ -0,0 +1,12 @@ +{ + "$GMShader":"", + "%Name":"sh_channel_R2R", + "name":"sh_channel_R2R", + "parent":{ + "name":"channels", + "path":"folders/shader/filter/channels.yy", + }, + "resourceType":"GMShader", + "resourceVersion":"2.0", + "type":1, +} \ No newline at end of file diff --git a/shaders/sh_d3d_default/sh_d3d_default.fsh b/shaders/sh_d3d_default/sh_d3d_default.fsh index ea041555a..2e58e87b1 100644 --- a/shaders/sh_d3d_default/sh_d3d_default.fsh +++ b/shaders/sh_d3d_default/sh_d3d_default.fsh @@ -126,12 +126,14 @@ uniform int use_8bit; //else if(index == 2) d = texture2D(light_dir_shadowmap_2, position); //else if(index == 3) d = texture2D(light_dir_shadowmap_3, position); - if(use_8bit == 1) - return unormToFloat(d.rgb); + if(use_8bit == 1) return unormToFloat(d.rgb); return d.r; } float samplePntShadowMap(int index, vec2 position, int side) { + // -x, x, -y, y, -z, z + // r0, b0, g0, r1, g1, b1 + float d = 0.; position.x /= 2.; @@ -241,24 +243,22 @@ void main() { vec3 lightVector = normalize(light_dir_direction[i]); if(light_dir_shadow_active[i] == 1) { //use shadow - vec4 cameraSpace = light_dir_view[i] * v_worldPosition; - vec4 screenSpace = light_dir_proj[i] * cameraSpace; + vec4 l_cameraSpace = light_dir_view[i] * v_worldPosition; + vec4 l_screenSpace = light_dir_proj[i] * l_cameraSpace; + float l_lightDistance = l_screenSpace.z; + vec2 lightMapUV = (l_screenSpace.xy / l_screenSpace.w * 0.5) + 0.5; - float v_lightDistance = screenSpace.z / screenSpace.w; - vec2 lightMapPosition = (screenSpace.xy / screenSpace.w * 0.5) + 0.5; - - if(lightMapPosition.x >= 0. && lightMapPosition.x <= 1. && lightMapPosition.y >= 0. && lightMapPosition.y <= 1.) { - light_map_depth = sampleDirShadowMap(shadow_map_index, lightMapPosition); + if(lightMapUV.x >= 0. && lightMapUV.x <= 1. && lightMapUV.y >= 0. && lightMapUV.y <= 1.) { + light_map_depth = sampleDirShadowMap(shadow_map_index, lightMapUV); - //gl_FragData[0] = texture2D(light_dir_shadowmap_0, lightMapPosition); + //gl_FragData[0] = texture2D(light_dir_shadowmap_0, lightMapUV); //return; shadow_map_index++; - lightDistance = v_lightDistance; float shadowFactor = dot(normal, lightVector); float bias = mix(light_dir_shadow_bias[i], 0., shadowFactor); - if(lightDistance > light_map_depth + bias) + if(l_lightDistance > light_map_depth + bias) continue; } } @@ -275,41 +275,47 @@ void main() { shadow_map_index = 0; for(int i = 0; i < light_pnt_count; i++) { - vec3 lightVector = normalize(light_pnt_position[i] - v_worldPosition.xyz); + vec3 lightVector = light_pnt_position[i] - v_worldPosition.xyz; light_distance = length(lightVector); - if(light_distance > light_pnt_radius[i]) - continue; - + if(light_distance > light_pnt_radius[i]) { + gl_FragData[0] = vec4(1., 0., 0., .5); + return; + // continue; + } + + lightVector = normalize(lightVector); + if(light_pnt_shadow_active[i] == 1) { //use shadow vec3 dirAbs = abs(lightVector); - int side = dirAbs.x > dirAbs.y ? - (dirAbs.x > dirAbs.z ? 0 : 2) : - (dirAbs.y > dirAbs.z ? 1 : 2); + int side = dirAbs.x > dirAbs.y ? (dirAbs.x > dirAbs.z ? 0 : 2) : (dirAbs.y > dirAbs.z ? 1 : 2); side *= 2; if(side == 0 && lightVector.x > 0.) side += 1; else if(side == 2 && lightVector.y > 0.) side += 1; else if(side == 4 && lightVector.z > 0.) side += 1; - vec4 cameraSpace = light_pnt_view[i * 6 + side] * v_worldPosition; - vec4 screenSpace = light_pnt_proj[i] * cameraSpace; - float v_lightDistance = screenSpace.z / screenSpace.w; - vec2 lightMapPosition = (screenSpace.xy / screenSpace.w * 0.5) + 0.5; + vec4 l_cameraSpace = light_pnt_view[i * 6 + side] * v_worldPosition; + vec4 l_screenSpace = light_pnt_proj[i] * l_cameraSpace; + float l_lightDistance = l_screenSpace.z; + vec2 lightMapUV = (l_screenSpace.xy / l_screenSpace.w * 0.5) + 0.5; - if(lightMapPosition.x >= 0. && lightMapPosition.x <= 1. && lightMapPosition.y >= 0. && lightMapPosition.y <= 1.) { + if(lightMapUV.x >= 0. && lightMapUV.x <= 1. && lightMapUV.y >= 0. && lightMapUV.y <= 1.) { + float shadowFactor = dot(normal, lightVector); float bias = mix(light_pnt_shadow_bias[i], 0., shadowFactor); - light_map_depth = samplePntShadowMap(shadow_map_index, lightMapPosition, side); + light_map_depth = samplePntShadowMap(shadow_map_index, lightMapUV, side); shadow_map_index++; - - if(v_lightDistance > light_map_depth + bias) + + // gl_FragData[0] = vec4((l_lightDistance - (light_map_depth + bias)) * 10., ((light_map_depth + bias) - l_lightDistance) * 10., 0., 1.); + // return; + + if(l_lightDistance > light_map_depth + bias) continue; } } light_attenuation = 1. - pow(light_distance / light_pnt_radius[i], 2.); - vec3 light_phong = phongLight(normal, lightVector, viewDirection, light_pnt_color[i].rgb * light_attenuation); light_effect += light_phong * light_pnt_intensity[i]; diff --git a/shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.fsh b/shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.fsh index 7e21d4f8e..edb503ac4 100644 --- a/shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.fsh +++ b/shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.fsh @@ -15,5 +15,5 @@ void main() { float d = v_LightDepth; if(use_8bit == 1) gl_FragColor = vec4(floatToUnorm(d), 1.); - else gl_FragColor = vec4(vec3(d), 1.); + else gl_FragColor = vec4(d, 0., 0., 1.); } diff --git a/shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.vsh b/shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.vsh index 0a495022e..fb5eab6bc 100644 --- a/shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.vsh +++ b/shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.vsh @@ -9,5 +9,5 @@ void main() { vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; - v_LightDepth = gl_Position.z / gl_Position.w; + v_LightDepth = gl_Position.z; }