Only use envmap for lighting
This commit is contained in:
@@ -49,7 +49,6 @@ function camera_update() {
|
||||
operator_shortcut(map_get(config_keymap, "action_zoom"), shortcut_type_t.STARTED) ||
|
||||
operator_shortcut(map_get(config_keymap, "action_pan"), shortcut_type_t.STARTED) ||
|
||||
operator_shortcut(map_get(config_keymap, "rotate_envmap"), shortcut_type_t.STARTED) ||
|
||||
operator_shortcut(map_get(config_keymap, "rotate_light"), shortcut_type_t.STARTED) ||
|
||||
(mouse_started("right") && !modif) ||
|
||||
(mouse_started("middle") && !modif) ||
|
||||
(mouse_wheel_delta != 0 && !modif_key)) {
|
||||
@@ -59,7 +58,6 @@ function camera_update() {
|
||||
!operator_shortcut(map_get(config_keymap, "action_zoom"), shortcut_type_t.DOWN) &&
|
||||
!operator_shortcut(map_get(config_keymap, "action_pan"), shortcut_type_t.DOWN) &&
|
||||
!operator_shortcut(map_get(config_keymap, "rotate_envmap"), shortcut_type_t.DOWN) &&
|
||||
!operator_shortcut(map_get(config_keymap, "rotate_light"), shortcut_type_t.DOWN) &&
|
||||
!(mouse_down("right") && !modif) &&
|
||||
!(mouse_down("middle") && !modif) &&
|
||||
(mouse_wheel_delta == 0 && !modif_key)) {
|
||||
@@ -174,15 +172,6 @@ function camera_update() {
|
||||
transform_rotate(camera.base.transform, camera_object_right(camera), -mouse_movement_y / 200 * config_raw.camera_rotation_speed);
|
||||
}
|
||||
|
||||
if (operator_shortcut(map_get(config_keymap, "rotate_light"), shortcut_type_t.DOWN)) {
|
||||
camera_redraws = 2;
|
||||
let pi2: f32 = math_pi() * 2.0;
|
||||
let mx: f32 = mouse_movement_x / 100;
|
||||
context_raw.light_angle = math_fmod(context_raw.light_angle + math_fmod(mx, pi2) + pi2, pi2);
|
||||
let m: mat4_t = mat4_rot_z(mx);
|
||||
uniforms_light_world = mat4_mult_mat(uniforms_light_world, m);
|
||||
}
|
||||
|
||||
if (operator_shortcut(map_get(config_keymap, "rotate_envmap"), shortcut_type_t.DOWN)) {
|
||||
camera_redraws = 2;
|
||||
context_raw.envmap_angle -= mouse_movement_x / 100;
|
||||
|
||||
@@ -33,7 +33,6 @@ function keymap_get_default(): map_t<string, string> {
|
||||
map_set(keymap, "action_rotate", "alt+left");
|
||||
map_set(keymap, "action_pan", "alt+middle");
|
||||
map_set(keymap, "action_zoom", "alt+right");
|
||||
map_set(keymap, "rotate_light", "shift+middle");
|
||||
map_set(keymap, "rotate_envmap", "ctrl+middle");
|
||||
map_set(keymap, "set_clone_source", "alt");
|
||||
map_set(keymap, "stencil_transform", "ctrl");
|
||||
|
||||
@@ -367,116 +367,6 @@ vec2 envmap_equirect(const vec3 normal, const float angle) { \
|
||||
} \
|
||||
";
|
||||
|
||||
// Linearly Transformed Cosines
|
||||
// https://eheitzresearch.wordpress.com/415-2/
|
||||
let str_ltc_evaluate: string = " \
|
||||
float integrate_edge(vec3 v1, vec3 v2) { \
|
||||
float cos_theta = dot(v1, v2); \
|
||||
float theta = acos(cos_theta); \
|
||||
float res = cross(v1, v2).z * ((theta > 0.001) ? theta / sin(theta) : 1.0); \
|
||||
return res; \
|
||||
} \
|
||||
float ltc_evaluate(vec3 N, vec3 V, float dotnv, vec3 P, mat3 Minv, vec3 points0, vec3 points1, vec3 points2, vec3 points3) { \
|
||||
vec3 T1 = normalize(V - N * dotnv); \
|
||||
vec3 T2 = cross(N, T1); \
|
||||
Minv = mul(transpose(mat3(T1, T2, N)), Minv); \
|
||||
vec3 L0 = mul((points0 - P), Minv); \
|
||||
vec3 L1 = mul((points1 - P), Minv); \
|
||||
vec3 L2 = mul((points2 - P), Minv); \
|
||||
vec3 L3 = mul((points3 - P), Minv); \
|
||||
vec3 L4 = vec3(0.0, 0.0, 0.0); \
|
||||
int n = 0; \
|
||||
int config = 0; \
|
||||
if (L0.z > 0.0) config += 1; \
|
||||
if (L1.z > 0.0) config += 2; \
|
||||
if (L2.z > 0.0) config += 4; \
|
||||
if (L3.z > 0.0) config += 8; \
|
||||
if (config == 0) {} \
|
||||
else if (config == 1) { \
|
||||
n = 3; \
|
||||
L1 = -L1.z * L0 + L0.z * L1; \
|
||||
L2 = -L3.z * L0 + L0.z * L3; \
|
||||
} \
|
||||
else if (config == 2) { \
|
||||
n = 3; \
|
||||
L0 = -L0.z * L1 + L1.z * L0; \
|
||||
L2 = -L2.z * L1 + L1.z * L2; \
|
||||
} \
|
||||
else if (config == 3) { \
|
||||
n = 4; \
|
||||
L2 = -L2.z * L1 + L1.z * L2; \
|
||||
L3 = -L3.z * L0 + L0.z * L3; \
|
||||
} \
|
||||
else if (config == 4) { \
|
||||
n = 3; \
|
||||
L0 = -L3.z * L2 + L2.z * L3; \
|
||||
L1 = -L1.z * L2 + L2.z * L1; \
|
||||
} \
|
||||
else if (config == 5) { n = 0; } \
|
||||
else if (config == 6) { \
|
||||
n = 4; \
|
||||
L0 = -L0.z * L1 + L1.z * L0; \
|
||||
L3 = -L3.z * L2 + L2.z * L3; \
|
||||
} \
|
||||
else if (config == 7) { \
|
||||
n = 5; \
|
||||
L4 = -L3.z * L0 + L0.z * L3; \
|
||||
L3 = -L3.z * L2 + L2.z * L3; \
|
||||
} \
|
||||
else if (config == 8) { \
|
||||
n = 3; \
|
||||
L0 = -L0.z * L3 + L3.z * L0; \
|
||||
L1 = -L2.z * L3 + L3.z * L2; \
|
||||
L2 = L3; \
|
||||
} \
|
||||
else if (config == 9) { \
|
||||
n = 4; \
|
||||
L1 = -L1.z * L0 + L0.z * L1; \
|
||||
L2 = -L2.z * L3 + L3.z * L2; \
|
||||
} \
|
||||
else if (config == 10) { n = 0; } \
|
||||
else if (config == 11) { \
|
||||
n = 5; \
|
||||
L4 = L3; \
|
||||
L3 = -L2.z * L3 + L3.z * L2; \
|
||||
L2 = -L2.z * L1 + L1.z * L2; \
|
||||
} \
|
||||
else if (config == 12) { \
|
||||
n = 4; \
|
||||
L1 = -L1.z * L2 + L2.z * L1; \
|
||||
L0 = -L0.z * L3 + L3.z * L0; \
|
||||
} \
|
||||
else if (config == 13) { \
|
||||
n = 5; \
|
||||
L4 = L3; \
|
||||
L3 = L2; \
|
||||
L2 = -L1.z * L2 + L2.z * L1; \
|
||||
L1 = -L1.z * L0 + L0.z * L1; \
|
||||
} \
|
||||
else if (config == 14) { \
|
||||
n = 5; \
|
||||
L4 = -L0.z * L3 + L3.z * L0; \
|
||||
L0 = -L0.z * L1 + L1.z * L0; \
|
||||
} \
|
||||
else if (config == 15) { n = 4; } \
|
||||
if (n == 0) return 0.0; \
|
||||
if (n == 3) L3 = L0; \
|
||||
if (n == 4) L4 = L0; \
|
||||
L0 = normalize(L0); \
|
||||
L1 = normalize(L1); \
|
||||
L2 = normalize(L2); \
|
||||
L3 = normalize(L3); \
|
||||
L4 = normalize(L4); \
|
||||
float sum = 0.0; \
|
||||
sum += integrate_edge(L0, L1); \
|
||||
sum += integrate_edge(L1, L2); \
|
||||
sum += integrate_edge(L2, L3); \
|
||||
if (n >= 4) sum += integrate_edge(L3, L4); \
|
||||
if (n == 5) sum += integrate_edge(L4, L0); \
|
||||
return max(0.0, -sum); \
|
||||
} \
|
||||
";
|
||||
|
||||
let str_get_pos_nor_from_depth: string = " \
|
||||
vec3 get_pos_from_depth(vec2 uv, mat4 invVP, textureArg(gbufferD)) { \n\
|
||||
#ifdef GLSL \n\
|
||||
|
||||
@@ -196,46 +196,6 @@ function ui_menu_render() {
|
||||
context_raw.ddirty = 2;
|
||||
}
|
||||
|
||||
let lhandle: ui_handle_t = ui_handle(__ID__);
|
||||
lhandle.value = uniforms_light_strength;
|
||||
lhandle.value = math_floor(lhandle.value * 100) / 100;
|
||||
ui_menu_align(ui);
|
||||
uniforms_light_strength = ui_slider(lhandle, tr("Light"), 0.0, 4.0, true);
|
||||
if (lhandle.changed) {
|
||||
context_raw.ddirty = 2;
|
||||
}
|
||||
|
||||
let lahandle: ui_handle_t = ui_handle(__ID__);
|
||||
lahandle.value = context_raw.light_angle / math_pi() * 180;
|
||||
ui_menu_align(ui);
|
||||
let new_angle: f32 = ui_slider(lahandle, tr("Light Angle"), 0.0, 360.0, true, 1) / 180 * math_pi();
|
||||
if (ui.is_hovered) {
|
||||
let vars: map_t<string, string> = map_create();
|
||||
map_set(vars, "shortcut", map_get(config_keymap, "rotate_light"));
|
||||
ui_tooltip(tr("{shortcut} and move mouse", vars));
|
||||
}
|
||||
let ldiff: f32 = new_angle - context_raw.light_angle;
|
||||
if (math_abs(ldiff) > 0.005) {
|
||||
if (new_angle < 0) {
|
||||
new_angle += (math_floor(-new_angle / (2 * math_pi())) + 1) * 2 * math_pi();
|
||||
}
|
||||
else if (new_angle > 2 * math_pi()) {
|
||||
new_angle -= math_floor(new_angle / (2 * math_pi())) * 2 * math_pi();
|
||||
}
|
||||
context_raw.light_angle = new_angle;
|
||||
let m: mat4_t = mat4_rot_z(ldiff);
|
||||
uniforms_light_world = mat4_mult_mat(uniforms_light_world, m);
|
||||
context_raw.ddirty = 2;
|
||||
}
|
||||
|
||||
let sxhandle: ui_handle_t = ui_handle(__ID__);
|
||||
sxhandle.value = uniforms_light_size_x;
|
||||
ui_menu_align(ui);
|
||||
uniforms_light_size_x = ui_slider(sxhandle, tr("Light Size"), 0.0, 4.0, true);
|
||||
if (sxhandle.changed) {
|
||||
context_raw.ddirty = 2;
|
||||
}
|
||||
|
||||
///if (is_paint || is_sculpt)
|
||||
let split_view_handle: ui_handle_t = ui_handle(__ID__);
|
||||
if (split_view_handle.init) {
|
||||
|
||||
@@ -329,18 +329,6 @@ function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: str
|
||||
let rt: render_target_t = map_get(render_path_render_targets, "texpaint_pack_undo" + i);
|
||||
return rt._image;
|
||||
}
|
||||
else if (link == "_ltc_mat") {
|
||||
if (const_data_ltc_mat_tex == null) {
|
||||
const_data_init_ltc();
|
||||
}
|
||||
return const_data_ltc_mat_tex;
|
||||
}
|
||||
else if (link == "_ltc_mag") {
|
||||
if (const_data_ltc_mag_tex == null) {
|
||||
const_data_init_ltc();
|
||||
}
|
||||
return const_data_ltc_mag_tex;
|
||||
}
|
||||
else if (link == "_texcolorid") {
|
||||
if (project_assets.length == 0) {
|
||||
let rt: render_target_t = map_get(render_path_render_targets, "empty_white");
|
||||
|
||||
@@ -31,10 +31,6 @@ function util_render_make_material_preview() {
|
||||
scene_camera.data.fov = 0.92;
|
||||
viewport_update_camera_type(camera_type_t.PERSPECTIVE);
|
||||
|
||||
|
||||
let _light_strength: f32 = uniforms_light_strength;
|
||||
uniforms_light_strength = 0;
|
||||
|
||||
let probe: world_data_t = scene_world;
|
||||
let _probe_strength: f32 = probe.strength;
|
||||
probe.strength = 7;
|
||||
@@ -73,7 +69,6 @@ function util_render_make_material_preview() {
|
||||
camera_object_build_proj(scene_camera);
|
||||
camera_object_build_mat(scene_camera);
|
||||
|
||||
uniforms_light_strength = _light_strength;
|
||||
probe.strength = _probe_strength;
|
||||
context_raw.envmap_angle = _envmap_angle;
|
||||
context_raw.brush_scale = _brush_scale;
|
||||
@@ -110,8 +105,6 @@ function util_render_make_decal_preview() {
|
||||
let saved_fov: f32 = scene_camera.data.fov;
|
||||
scene_camera.data.fov = 0.92;
|
||||
viewport_update_camera_type(camera_type_t.PERSPECTIVE);
|
||||
let _light_strength: f32 = uniforms_light_strength;
|
||||
uniforms_light_strength = 0.0;
|
||||
scene_world._.envmap = context_raw.preview_envmap;
|
||||
|
||||
// No resize
|
||||
@@ -141,8 +134,6 @@ function util_render_make_decal_preview() {
|
||||
camera_object_build_proj(scene_camera);
|
||||
camera_object_build_mat(scene_camera);
|
||||
|
||||
uniforms_light_strength = _light_strength;
|
||||
|
||||
scene_world._.envmap = context_raw.show_envmap ? context_raw.saved_envmap : context_raw.empty_envmap;
|
||||
|
||||
make_material_parse_mesh_material();
|
||||
|
||||
@@ -79,7 +79,6 @@ function viewport_update_camera_type(camera_type: i32) {
|
||||
let cam: camera_object_t = scene_cameras[0];
|
||||
if (camera_type == camera_type_t.PERSPECTIVE) {
|
||||
cam.data.ortho = null;
|
||||
uniforms_light_strength = 1.0;
|
||||
}
|
||||
else {
|
||||
let f32a: f32_array_t = f32_array_create(4);
|
||||
@@ -89,7 +88,6 @@ function viewport_update_camera_type(camera_type: i32) {
|
||||
f32a[2] = -2 * f * (app_h() / app_w());
|
||||
f32a[3] = 2 * f * (app_h() / app_w());
|
||||
cam.data.ortho = f32a;
|
||||
uniforms_light_strength = 0.0;
|
||||
}
|
||||
camera_object_build_proj(cam);
|
||||
context_raw.ddirty = 2;
|
||||
|
||||
Reference in New Issue
Block a user