Use best fit normals for storing screen space normals

This commit is contained in:
clayjohn 2023-12-18 15:35:26 -07:00
parent bf8dd73e9d
commit 43cf21cb71
19 changed files with 207 additions and 41 deletions

View file

@ -1191,6 +1191,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
// we will add logic to automatically switch between
// sampler2D and sampler2D array and vec2 UV and vec3 UV.
bool multiview_uv_needed = false;
bool is_normal_roughness_texture = false;
for (int i = 1; i < onode->arguments.size(); i++) {
if (i > 1) {
@ -1259,7 +1260,6 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
// Need to map from texture to sampler in order to sample when using Vulkan GLSL.
String sampler_name;
bool is_depth_texture = false;
bool is_normal_roughness_texture = false;
if (actions.custom_samplers.has(texture_uniform)) {
sampler_name = actions.custom_samplers[texture_uniform];
@ -1340,6 +1340,9 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
if (is_screen_texture && !texture_func_returns_data && actions.apply_luminance_multiplier) {
code = "(" + code + " * vec4(vec3(sc_luminance_multiplier), 1.0))";
}
if (is_normal_roughness_texture) {
code = "normal_roughness_compatibility(" + code + ")";
}
} break;
case SL::OP_INDEX: {
code += _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);