Fixed display menu visualizations.

This commit is contained in:
Juan Linietsky 2019-10-03 22:59:14 -03:00
parent 965185c765
commit fb739f9da7
4 changed files with 53 additions and 9 deletions

View File

@ -2775,6 +2775,7 @@ void SpatialEditorViewport::_menu_option(int p_option) {
VIEW_DISPLAY_OVERDRAW,
VIEW_DISPLAY_SHADELESS,
VIEW_DISPLAY_LIGHTING,
VIEW_DISPLAY_WIREFRAME,
VIEW_DISPLAY_DEBUG_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS,
VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO,
@ -2790,8 +2791,8 @@ void SpatialEditorViewport::_menu_option(int p_option) {
Viewport::DEBUG_DRAW_WIREFRAME,
Viewport::DEBUG_DRAW_SHADOW_ATLAS,
Viewport::DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
Viewport::DEBUG_DRAW_GI_PROBE_LIGHTING,
Viewport::DEBUG_DRAW_GI_PROBE_ALBEDO
Viewport::DEBUG_DRAW_GI_PROBE_ALBEDO,
Viewport::DEBUG_DRAW_GI_PROBE_LIGHTING
};
int idx = 0;
@ -3626,6 +3627,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_normal", TTR("Display Normal")), VIEW_DISPLAY_NORMAL);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_wireframe", TTR("Display Wireframe")), VIEW_DISPLAY_WIREFRAME);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_overdraw", TTR("Display Overdraw")), VIEW_DISPLAY_OVERDRAW);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_lighting", TTR("Display Lighting")), VIEW_DISPLAY_LIGHTING);
view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_unshaded", TTR("Display Unshaded")), VIEW_DISPLAY_SHADELESS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), true);
display_submenu->add_radio_check_item(TTR("Shadow Atlas"), VIEW_DISPLAY_DEBUG_SHADOW_ATLAS);

View File

@ -104,7 +104,6 @@ public:
SHADOW_ATLAS_QUADRANT_SUBDIV_256,
SHADOW_ATLAS_QUADRANT_SUBDIV_1024,
SHADOW_ATLAS_QUADRANT_SUBDIV_MAX,
};
enum MSAA {

View File

@ -969,7 +969,17 @@ void RasterizerSceneForwardRD::_setup_environment(RID p_render_target, RID p_env
//time global variables
scene_state.ubo.time = time;
if (is_environment(p_environment)) {
if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
scene_state.ubo.use_ambient_light = true;
scene_state.ubo.ambient_light_color_energy[0] = 1;
scene_state.ubo.ambient_light_color_energy[1] = 1;
scene_state.ubo.ambient_light_color_energy[2] = 1;
scene_state.ubo.ambient_light_color_energy[3] = 1.0;
scene_state.ubo.use_ambient_cubemap = false;
scene_state.ubo.use_reflection_cubemap = false;
} else if (is_environment(p_environment)) {
VS::EnvironmentBG env_bg = environment_get_background(p_environment);
VS::EnvironmentAmbientSource ambient_src = environment_get_ambient_light_ambient_source(p_environment);
@ -1155,11 +1165,19 @@ void RasterizerSceneForwardRD::_setup_environment(RID p_render_target, RID p_env
void RasterizerSceneForwardRD::_add_geometry(InstanceBase *p_instance, uint32_t p_surface, RID p_material, PassMode p_pass_mode, uint32_t p_geometry_index) {
RID m_src = p_instance->material_override.is_valid() ? p_instance->material_override : p_material;
RID m_src;
/*if (state.debug_draw == VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
m_src = default_overdraw_material;
}*/
m_src = p_instance->material_override.is_valid() ? p_instance->material_override : p_material;
if (unlikely(debug_draw != VS::VIEWPORT_DEBUG_DRAW_DISABLED)) {
if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
m_src = overdraw_material;
} else if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_WIREFRAME) {
m_src = wireframe_material;
} else if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_LIGHTING) {
m_src = default_material;
}
}
MaterialData *material = NULL;
@ -1756,6 +1774,12 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co
RENDER_TIMESTAMP("Setup 3D Scene");
if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
p_light_cull_count = 0;
p_reflection_probe_cull_count = 0;
p_gi_probe_cull_count = 0;
}
_update_render_base_uniform_set();
bool using_shadows = true;
@ -1824,7 +1848,9 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co
Color clear_color;
bool keep_color = false;
if (is_environment(p_environment)) {
if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) {
clear_color = Color(0, 0, 0, 1); //in overdraw mode, BG should always be black
} else if (is_environment(p_environment)) {
VS::EnvironmentBG bg_mode = environment_get_background(p_environment);
float bg_energy = environment_get_bg_energy(p_environment);
switch (bg_mode) {
@ -2568,6 +2594,19 @@ RasterizerSceneForwardRD::RasterizerSceneForwardRD(RasterizerStorageRD *p_storag
default_shader_rd = shader.scene_shader.version_get_shader(md->shader_data->version, SHADER_VERSION_COLOR_PASS);
}
{
overdraw_material_shader = storage->shader_create();
storage->shader_set_code(overdraw_material_shader, "shader_type spatial;\nrender_mode blend_add,unshaded;\n void fragment() { ALBEDO=vec3(0.4,0.8,0.8); ALPHA=0.2; }");
overdraw_material = storage->material_create();
storage->material_set_shader(overdraw_material, overdraw_material_shader);
wireframe_material_shader = storage->shader_create();
storage->shader_set_code(wireframe_material_shader, "shader_type spatial;\nrender_mode wireframe,unshaded;\n void fragment() { ALBEDO=vec3(0.0,0.0,0.0); }");
wireframe_material = storage->material_create();
storage->material_set_shader(wireframe_material, wireframe_material_shader);
}
{
default_vec4_xform_buffer = RD::get_singleton()->storage_buffer_create(256);
Vector<RD::Uniform> uniforms;

View File

@ -501,6 +501,10 @@ class RasterizerSceneForwardRD : public RasterizerSceneRD {
double time;
RID default_shader;
RID default_material;
RID overdraw_material_shader;
RID overdraw_material;
RID wireframe_material_shader;
RID wireframe_material;
RID default_shader_rd;
RID default_vec4_xform_buffer;