mac os patch

This commit is contained in:
Tanasart 2023-12-06 19:51:22 +07:00
parent 5ab5c94ca8
commit 96ba8d4ac9
10 changed files with 61 additions and 31 deletions

View file

@ -4,8 +4,6 @@ draw_clear(COLORS.bg);
#region windows init
if(OS == os_windows && winMan_isMinimized())
exit;
else if(OS == os_macosx)
mac_window_step();
#endregion
#region widget scroll

View file

@ -60,6 +60,7 @@ function __3dLightDirectional() : __3dLight() constructor {
surface_set_target(shadow_map);
draw_clear(c_black);
shader_set(shadow_mapper);
shader_set_i("use_8bit", OS == os_macosx);
gpu_set_ztestenable(true);
camera_set_view_mat(shadow_map_camera, shadow_map_view);

View file

@ -62,6 +62,8 @@ function __3dLightPoint() : __3dLight() constructor {
draw_clear(c_black);
shader_set(shadow_mapper);
shader_set_i("use_8bit", OS == os_macosx);
gpu_set_ztestenable(true);
camera_set_view_mat(shadow_map_camera, shadow_map_views[index]);
@ -80,7 +82,7 @@ function __3dLightPoint() : __3dLight() constructor {
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, surface_r32float);
shadow_maps[i] = surface_verify(shadow_maps[i], shadow_map_size, shadow_map_size, OS == os_macosx? surface_rgba8unorm : surface_r32float);
var position = transform.position;
@ -101,7 +103,7 @@ function __3dLightPoint() : __3dLight() constructor {
shadowProjectEnd();
}
shadow_map = surface_verify(shadow_map, shadow_map_size * 2, shadow_map_size, surface_rgba32float);
shadow_map = surface_verify(shadow_map, shadow_map_size * 2, shadow_map_size, OS == os_macosx? surface_rgba8unorm : surface_rgba32float);
surface_set_target(shadow_map);
draw_clear(c_black);

View file

@ -129,9 +129,9 @@ function __3dScene(camera, name = "New scene") constructor {
} #endregion
static geometryPass = function(deferData, object, w = 512, h = 512) { #region
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);
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);
surface_set_target_ext(0, deferData.geometry_data[0]);
surface_set_target_ext(1, deferData.geometry_data[1]);
@ -149,6 +149,7 @@ function __3dScene(camera, name = "New scene") constructor {
shader_set(sh_d3d_geometry);
shader_set_f("planeNear", camera.view_near);
shader_set_f("planeFar", camera.view_far);
shader_set_i("use_8bit", OS == os_macosx);
submit(object, sh_d3d_geometry);
@ -158,10 +159,12 @@ function __3dScene(camera, name = "New scene") constructor {
surface_reset_target();
if(defer_normal_radius) {
var _normal_blurred = surface_create_size(deferData.geometry_data[2], surface_rgba32float);
var _normal_blurred = surface_create_size(deferData.geometry_data[2], OS == os_macosx? surface_rgba8unorm : 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]);
surface_reset_shader();
@ -202,6 +205,8 @@ function __3dScene(camera, name = "New scene") constructor {
static apply = function(deferData = noone) { #region
shader_set(sh_d3d_default);
shader_set_i("use_8bit", OS == os_macosx);
#region ---- background ----
shader_set_f("light_ambient", colToVec4(lightAmbient));
shader_set_i("env_use_mapping", is_surface(enviroment_map) );

View file

@ -835,25 +835,27 @@ function Panel_Preview() : PanelContent() constructor {
d3_view_camera.applyCamera();
gpu_set_cullmode(cull_noculling);
gpu_set_ztestenable(true);
gpu_set_zwriteenable(false);
if(OS != os_macosx) {
gpu_set_cullmode(cull_noculling);
gpu_set_ztestenable(true);
gpu_set_zwriteenable(false);
shader_set(sh_d3d_grid_view);
var _dist = round(d3_view_camera.focus.distance(d3_view_camera.position));
var _tx = round(d3_view_camera.focus.x);
var _ty = round(d3_view_camera.focus.y);
shader_set(sh_d3d_grid_view);
var _dist = round(d3_view_camera.focus.distance(d3_view_camera.position));
var _tx = round(d3_view_camera.focus.x);
var _ty = round(d3_view_camera.focus.y);
var _scale = _dist * 2;
while(_scale > 32) _scale /= 2;
var _scale = _dist * 2;
while(_scale > 32) _scale /= 2;
shader_set_f("axisBlend", _blend);
shader_set_f("scale", _scale);
shader_set_f("shift", _tx / _dist / 2, _ty / _dist / 2);
draw_sprite_stretched(s_fx_pixel, 0, _tx - _dist, _ty - _dist, _dist * 2, _dist * 2);
shader_reset();
shader_set_f("axisBlend", _blend);
shader_set_f("scale", _scale);
shader_set_f("shift", _tx / _dist / 2, _ty / _dist / 2);
draw_sprite_stretched(s_fx_pixel, 0, _tx - _dist, _ty - _dist, _dist * 2, _dist * 2);
shader_reset();
gpu_set_zwriteenable(true);
gpu_set_zwriteenable(true);
}
#endregion
#region draw

View file

@ -21,6 +21,10 @@
function winMan_getData(curr = true) { #region
INLINE
var _monitors = display_measure_all();
if(!is_array(_monitors) || array_empty(_monitors))
return [ 0, 0, display_get_width(), display_get_height(),
0, 0, display_get_width(), display_get_height(), ];
var _x = window_get_x();
var _y = window_get_y();
@ -38,9 +42,6 @@ function winMan_getData(curr = true) { #region
)) return _monitor;
}
if(!is_array(_monitor) || array_length(_monitor) < 8)
return [ 0, 0, display_get_width(), display_get_height(),
0, 0, display_get_width(), display_get_height(), ];
return _monitors[0];
} #endregion

View file

@ -11,6 +11,8 @@ varying float v_cameraDistance;
#define PI 3.14159265359
#define TAU 6.28318530718
uniform int use_8bit;
#region ---- light ----
uniform vec4 light_ambient;
uniform float shadowBias;
@ -145,6 +147,10 @@ varying float v_cameraDistance;
vec3 n = normalize(dir);
return vec2((atan(n.x, n.y) / TAU) + 0.5, 1. - acos(n.z) / PI);
}
vec4 unormToFloat(vec4 vec) {
return vec - 1. * 65536.;
}
#endregion
void main() {
@ -164,8 +170,11 @@ void main() {
#region ++++ normal ++++
vec3 _norm = v_vNormal;
if(mat_defer_normal == 1)
if(mat_defer_normal == 1) {
_norm = texture2D(mat_normal_map, viewProjPos.xy).rgb;
if(use_8bit == 1)
_norm = unormToFloat(_norm);
}
vec3 normal = normalize(_norm);
#endregion

View file

@ -5,6 +5,7 @@ varying vec3 v_vNormal;
uniform int mat_flip;
uniform int use_normal;
uniform int use_8bit;
uniform float normal_strength;
uniform sampler2D normal_map;
@ -14,11 +15,16 @@ void main() {
vec4 mat_baseColor = texture2D( gm_BaseTexture, uv_coord );
if(mat_baseColor.a < 0.1) discard;
gl_FragData[0] = vec4(v_worldPosition.xyz, mat_baseColor.a);
gl_FragData[1] = vec4(v_viewPosition, mat_baseColor.a);
vec3 normal = v_vNormal;
if(use_normal == 1) normal += (texture2D(normal_map, uv_coord).rgb * 2. - 1.) * normal_strength;
gl_FragData[0] = vec4(v_worldPosition.xyz, mat_baseColor.a);
gl_FragData[1] = vec4(v_viewPosition, mat_baseColor.a);
gl_FragData[2] = vec4(normalize(normal), mat_baseColor.a);
if(use_8bit == 1) {
gl_FragData[0] = gl_FragData[0] / 65536. + 1.;
gl_FragData[1] = gl_FragData[1] / 65536. + 1.;
gl_FragData[2] = gl_FragData[2] / 65536. + 1.;
}
}

View file

@ -4,8 +4,9 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 dimension;
uniform float radius;
uniform int use_8bit;
void main() {
vec3 current = texture2D( gm_BaseTexture, v_vTexcoord ).rgb;
@ -36,4 +37,8 @@ void main() {
}
gl_FragColor = vec4(sampled / weight, 1.);
if(use_8bit == 1) {
gl_FragColor = gl_FragColor / 65536. + 1.;
}
}

View file

@ -1,4 +1,5 @@
varying float v_LightDepth;
uniform int use_8bit;
void main() {
gl_FragColor = vec4(v_LightDepth, v_LightDepth, v_LightDepth, 1.);