Properly take into consideration that VERTEX must be written to in opaque pre pass, does some speed up to scenes using triplanar.
This commit is contained in:
parent
d81c5004b1
commit
0243803117
@ -2238,11 +2238,11 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
|
||||
if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
|
||||
//shader does not use discard and does not write a vertex position, use generic material
|
||||
if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
|
||||
p_material = storage->material_owner.getptr(default_material_twosided);
|
||||
p_material = storage->material_owner.getptr( p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
|
||||
no_cull = true;
|
||||
mirror = false;
|
||||
} else {
|
||||
p_material = storage->material_owner.getptr(default_material);
|
||||
p_material = storage->material_owner.getptr( p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2280,15 +2280,19 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
|
||||
}
|
||||
|
||||
e->sort_key |= uint64_t(e->material->index) << RenderList::SORT_KEY_MATERIAL_INDEX_SHIFT;
|
||||
e->sort_key |= uint64_t(e->instance->depth_layer) << RenderList::SORT_KEY_OPAQUE_DEPTH_LAYER_SHIFT;
|
||||
|
||||
if (e->instance->gi_probe_instances.size()) {
|
||||
e->sort_key |= SORT_KEY_GI_PROBES_FLAG;
|
||||
}
|
||||
|
||||
e->sort_key |= uint64_t(p_material->render_priority + 128) << RenderList::SORT_KEY_PRIORITY_SHIFT;
|
||||
} else {
|
||||
e->sort_key |= uint64_t(e->instance->depth_layer) << RenderList::SORT_KEY_OPAQUE_DEPTH_LAYER_SHIFT;
|
||||
e->sort_key |= uint64_t(e->material->index) << RenderList::SORT_KEY_MATERIAL_INDEX_SHIFT;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (e->geometry->type==RasterizerStorageGLES3::Geometry::GEOMETRY_MULTISURFACE)
|
||||
e->sort_flags|=RenderList::SORT_FLAG_INSTANCING;
|
||||
@ -4056,7 +4060,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
||||
|
||||
render_list.clear();
|
||||
_fill_render_list(p_cull_result, p_cull_count, true);
|
||||
render_list.sort_by_depth(false);
|
||||
render_list.sort_by_key(false);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH, true);
|
||||
_render_list(render_list.elements, render_list.element_count, p_cam_transform, p_cam_projection, 0, false, false, true, false, false);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH, false);
|
||||
@ -4086,10 +4090,10 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
||||
_setup_lights(p_light_cull_result, p_light_cull_count, p_cam_transform.affine_inverse(), p_cam_projection, p_shadow_atlas);
|
||||
_setup_reflections(p_reflection_probe_cull_result, p_reflection_probe_cull_count, p_cam_transform.affine_inverse(), p_cam_projection, p_reflection_atlas, env);
|
||||
|
||||
render_list.clear();
|
||||
|
||||
bool use_mrt = false;
|
||||
|
||||
render_list.clear();
|
||||
_fill_render_list(p_cull_result, p_cull_count, false);
|
||||
//
|
||||
|
||||
@ -4760,6 +4764,19 @@ void RasterizerSceneGLES3::initialize() {
|
||||
default_material_twosided = storage->material_create();
|
||||
storage->shader_set_code(default_shader_twosided, "shader_type spatial; render_mode cull_disabled;\n");
|
||||
storage->material_set_shader(default_material_twosided, default_shader_twosided);
|
||||
|
||||
//default for shaders using world coordinates (typical for triplanar)
|
||||
|
||||
default_worldcoord_shader = storage->shader_create();
|
||||
storage->shader_set_code(default_worldcoord_shader, "shader_type spatial; render_mode world_vertex_coords;\n");
|
||||
default_worldcoord_material = storage->material_create();
|
||||
storage->material_set_shader(default_worldcoord_material, default_worldcoord_shader);
|
||||
|
||||
default_worldcoord_shader_twosided = storage->shader_create();
|
||||
default_worldcoord_material_twosided = storage->material_create();
|
||||
storage->shader_set_code(default_worldcoord_shader_twosided, "shader_type spatial; render_mode cull_disabled,world_vertex_coords;\n");
|
||||
storage->material_set_shader(default_worldcoord_material_twosided, default_worldcoord_shader_twosided);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -78,6 +78,11 @@ public:
|
||||
RID default_shader;
|
||||
RID default_shader_twosided;
|
||||
|
||||
RID default_worldcoord_material;
|
||||
RID default_worldcoord_material_twosided;
|
||||
RID default_worldcoord_shader;
|
||||
RID default_worldcoord_shader_twosided;
|
||||
|
||||
RID default_overdraw_material;
|
||||
RID default_overdraw_shader;
|
||||
|
||||
|
@ -1601,6 +1601,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
|
||||
p_shader->spatial.uses_screen_texture = false;
|
||||
p_shader->spatial.uses_vertex = false;
|
||||
p_shader->spatial.writes_modelview_or_projection = false;
|
||||
p_shader->spatial.uses_world_coordinates = false;
|
||||
|
||||
shaders.actions_scene.render_mode_values["blend_add"] = Pair<int *, int>(&p_shader->spatial.blend_mode, Shader::Spatial::BLEND_MODE_ADD);
|
||||
shaders.actions_scene.render_mode_values["blend_mix"] = Pair<int *, int>(&p_shader->spatial.blend_mode, Shader::Spatial::BLEND_MODE_MIX);
|
||||
@ -1616,14 +1617,16 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
|
||||
shaders.actions_scene.render_mode_values["cull_back"] = Pair<int *, int>(&p_shader->spatial.cull_mode, Shader::Spatial::CULL_MODE_BACK);
|
||||
shaders.actions_scene.render_mode_values["cull_disabled"] = Pair<int *, int>(&p_shader->spatial.cull_mode, Shader::Spatial::CULL_MODE_DISABLED);
|
||||
|
||||
|
||||
shaders.actions_scene.render_mode_flags["unshaded"] = &p_shader->spatial.unshaded;
|
||||
shaders.actions_scene.render_mode_flags["depth_test_disable"] = &p_shader->spatial.no_depth_test;
|
||||
|
||||
shaders.actions_scene.render_mode_flags["vertex_lighting"] = &p_shader->spatial.uses_vertex_lighting;
|
||||
|
||||
shaders.actions_scene.render_mode_flags["world_vertex_coords"] = &p_shader->spatial.uses_world_coordinates;
|
||||
|
||||
shaders.actions_scene.usage_flag_pointers["ALPHA"] = &p_shader->spatial.uses_alpha;
|
||||
shaders.actions_scene.usage_flag_pointers["ALPHA_SCISSOR"] = &p_shader->spatial.uses_alpha_scissor;
|
||||
shaders.actions_scene.usage_flag_pointers["VERTEX"] = &p_shader->spatial.uses_vertex;
|
||||
|
||||
shaders.actions_scene.usage_flag_pointers["SSS_STRENGTH"] = &p_shader->spatial.uses_sss;
|
||||
shaders.actions_scene.usage_flag_pointers["DISCARD"] = &p_shader->spatial.uses_discard;
|
||||
@ -1632,6 +1635,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
|
||||
|
||||
shaders.actions_scene.write_flag_pointers["MODELVIEW_MATRIX"] = &p_shader->spatial.writes_modelview_or_projection;
|
||||
shaders.actions_scene.write_flag_pointers["PROJECTION_MATRIX"] = &p_shader->spatial.writes_modelview_or_projection;
|
||||
shaders.actions_scene.write_flag_pointers["VERTEX"] = &p_shader->spatial.uses_vertex;
|
||||
|
||||
actions = &shaders.actions_scene;
|
||||
actions->uniforms = &p_shader->uniforms;
|
||||
|
@ -453,6 +453,7 @@ public:
|
||||
bool uses_time;
|
||||
bool writes_modelview_or_projection;
|
||||
bool uses_vertex_lighting;
|
||||
bool uses_world_coordinates;
|
||||
|
||||
} spatial;
|
||||
|
||||
|
@ -263,6 +263,8 @@ uniform highp sampler2D skeleton_texture; //texunit:-1
|
||||
|
||||
out highp vec4 position_interp;
|
||||
|
||||
invariant gl_Position;
|
||||
|
||||
void main() {
|
||||
|
||||
highp vec4 vertex = vertex_attrib; // vec4(vertex_attrib.xyz * data_attrib.x,1.0);
|
||||
|
@ -69,8 +69,26 @@ __attribute__((visibility("default"))) DWORD NvOptimusEnablement = 0x00000001;
|
||||
#define WM_TOUCH 576
|
||||
#endif
|
||||
|
||||
static String format_error_message(DWORD id) {
|
||||
|
||||
LPWSTR messageBuffer = NULL;
|
||||
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL);
|
||||
|
||||
String msg = "Error "+itos(id)+": "+String(messageBuffer,size);
|
||||
|
||||
LocalFree(messageBuffer);
|
||||
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern HINSTANCE godot_hinstance;
|
||||
|
||||
|
||||
|
||||
void RedirectIOToConsole() {
|
||||
|
||||
int hConHandle;
|
||||
@ -1604,7 +1622,7 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han
|
||||
}
|
||||
|
||||
if (!p_library_handle) {
|
||||
ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + String::num(GetLastError()));
|
||||
ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + format_error_message(GetLastError()));
|
||||
ERR_FAIL_V(ERR_CANT_OPEN);
|
||||
}
|
||||
return OK;
|
||||
|
Loading…
Reference in New Issue
Block a user