Add FOG, RADIANCE, and IRRADIANCE shader overrides
This commit is contained in:
parent
b0ca859501
commit
f46932feab
@ -2690,6 +2690,9 @@ RasterizerSceneHighEndRD::RasterizerSceneHighEndRD(RasterizerStorageRD *p_storag
|
|||||||
actions.renames["NORMAL_ROUGHNESS_TEXTURE"] = "normal_roughness_buffer";
|
actions.renames["NORMAL_ROUGHNESS_TEXTURE"] = "normal_roughness_buffer";
|
||||||
actions.renames["DEPTH"] = "gl_FragDepth";
|
actions.renames["DEPTH"] = "gl_FragDepth";
|
||||||
actions.renames["OUTPUT_IS_SRGB"] = "true";
|
actions.renames["OUTPUT_IS_SRGB"] = "true";
|
||||||
|
actions.renames["FOG"] = "custom_fog";
|
||||||
|
actions.renames["RADIANCE"] = "custom_radiance";
|
||||||
|
actions.renames["IRRADIANCE"] = "custom_irradiance";
|
||||||
|
|
||||||
//for light
|
//for light
|
||||||
actions.renames["VIEW"] = "view";
|
actions.renames["VIEW"] = "view";
|
||||||
@ -2726,6 +2729,10 @@ RasterizerSceneHighEndRD::RasterizerSceneHighEndRD(RasterizerStorageRD *p_storag
|
|||||||
actions.usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
actions.usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||||
actions.usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
actions.usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||||
|
|
||||||
|
actions.usage_defines["FOG"] = "#define CUSTOM_FOG_USED\n";
|
||||||
|
actions.usage_defines["RADIANCE"] = "#define CUSTOM_RADIANCE_USED\n";
|
||||||
|
actions.usage_defines["IRRADIANCE"] = "#define CUSTOM_IRRADIANCE_USED\n";
|
||||||
|
|
||||||
actions.render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
|
actions.render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
|
||||||
actions.render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
|
actions.render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
|
||||||
actions.render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
|
actions.render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
|
||||||
|
@ -7971,6 +7971,7 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) {
|
|||||||
actions.renames["HALF_RES_COLOR"] = "half_res_color";
|
actions.renames["HALF_RES_COLOR"] = "half_res_color";
|
||||||
actions.renames["QUARTER_RES_COLOR"] = "quarter_res_color";
|
actions.renames["QUARTER_RES_COLOR"] = "quarter_res_color";
|
||||||
actions.renames["RADIANCE"] = "radiance";
|
actions.renames["RADIANCE"] = "radiance";
|
||||||
|
actions.renames["FOG"] = "custom_fog";
|
||||||
actions.renames["LIGHT0_ENABLED"] = "directional_lights.data[0].enabled";
|
actions.renames["LIGHT0_ENABLED"] = "directional_lights.data[0].enabled";
|
||||||
actions.renames["LIGHT0_DIRECTION"] = "directional_lights.data[0].direction_energy.xyz";
|
actions.renames["LIGHT0_DIRECTION"] = "directional_lights.data[0].direction_energy.xyz";
|
||||||
actions.renames["LIGHT0_ENERGY"] = "directional_lights.data[0].direction_energy.w";
|
actions.renames["LIGHT0_ENERGY"] = "directional_lights.data[0].direction_energy.w";
|
||||||
|
@ -1672,6 +1672,15 @@ void main() {
|
|||||||
float clearcoat_gloss = 0.0;
|
float clearcoat_gloss = 0.0;
|
||||||
float anisotropy = 0.0;
|
float anisotropy = 0.0;
|
||||||
vec2 anisotropy_flow = vec2(1.0, 0.0);
|
vec2 anisotropy_flow = vec2(1.0, 0.0);
|
||||||
|
#if defined(CUSTOM_FOG_USED)
|
||||||
|
vec4 custom_fog = vec4(0.0);
|
||||||
|
#endif
|
||||||
|
#if defined(CUSTOM_RADIANCE_USED)
|
||||||
|
vec4 custom_radiance = vec4(0.0);
|
||||||
|
#endif
|
||||||
|
#if defined(CUSTOM_IRRADIANCE_USED)
|
||||||
|
vec4 custom_irradiance = vec4(0.0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(AO_USED)
|
#if defined(AO_USED)
|
||||||
float ao = 1.0;
|
float ao = 1.0;
|
||||||
@ -1889,6 +1898,10 @@ FRAGMENT_SHADER_CODE
|
|||||||
specular_light *= scene_data.ambient_light_color_energy.a;
|
specular_light *= scene_data.ambient_light_color_energy.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CUSTOM_RADIANCE_USED)
|
||||||
|
specular_light = mix(specular_light, custom_radiance.rgb, custom_radiance.a);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef USE_LIGHTMAP
|
#ifndef USE_LIGHTMAP
|
||||||
//lightmap overrides everything
|
//lightmap overrides everything
|
||||||
if (scene_data.use_ambient_light) {
|
if (scene_data.use_ambient_light) {
|
||||||
@ -1906,7 +1919,9 @@ FRAGMENT_SHADER_CODE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_LIGHTMAP
|
#endif // USE_LIGHTMAP
|
||||||
|
#if defined(CUSTOM_IRRADIANCE_USED)
|
||||||
|
ambient_light = mix(specular_light, custom_irradiance.rgb, custom_irradiance.a);
|
||||||
|
#endif
|
||||||
#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
|
||||||
|
|
||||||
//radiance
|
//radiance
|
||||||
@ -2734,6 +2749,11 @@ FRAGMENT_SHADER_CODE
|
|||||||
specular_buffer.rgb = mix(specular_buffer.rgb, vec3(0.0), fog.a);
|
specular_buffer.rgb = mix(specular_buffer.rgb, vec3(0.0), fog.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CUSTOM_FOG_USED)
|
||||||
|
diffuse_buffer.rgb = mix(diffuse_buffer.rgb, custom_fog.rgb, custom_fog.a);
|
||||||
|
specular_buffer.rgb = mix(specular_buffer.rgb, vec3(0.0), custom_fog.a);
|
||||||
|
#endif //CUSTOM_FOG_USED
|
||||||
|
|
||||||
#else //MODE_MULTIPLE_RENDER_TARGETS
|
#else //MODE_MULTIPLE_RENDER_TARGETS
|
||||||
|
|
||||||
#ifdef MODE_UNSHADED
|
#ifdef MODE_UNSHADED
|
||||||
@ -2753,6 +2773,10 @@ FRAGMENT_SHADER_CODE
|
|||||||
frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a);
|
frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CUSTOM_FOG_USED)
|
||||||
|
frag_color.rgb = mix(frag_color.rgb, custom_fog.rgb, custom_fog.a);
|
||||||
|
#endif //CUSTOM_FOG_USED
|
||||||
|
|
||||||
#endif //MODE_MULTIPLE_RENDER_TARGETS
|
#endif //MODE_MULTIPLE_RENDER_TARGETS
|
||||||
|
|
||||||
#endif //MODE_RENDER_DEPTH
|
#endif //MODE_RENDER_DEPTH
|
||||||
|
@ -181,6 +181,7 @@ void main() {
|
|||||||
float alpha = 1.0; // Only available to subpasses
|
float alpha = 1.0; // Only available to subpasses
|
||||||
vec4 half_res_color = vec4(1.0);
|
vec4 half_res_color = vec4(1.0);
|
||||||
vec4 quarter_res_color = vec4(1.0);
|
vec4 quarter_res_color = vec4(1.0);
|
||||||
|
vec4 custom_fog = vec4(0.0);
|
||||||
|
|
||||||
#ifdef USE_CUBEMAP_PASS
|
#ifdef USE_CUBEMAP_PASS
|
||||||
vec3 inverted_cube_normal = cube_normal;
|
vec3 inverted_cube_normal = cube_normal;
|
||||||
@ -233,6 +234,10 @@ FRAGMENT_SHADER_CODE
|
|||||||
frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a);
|
frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (custom_fog.a > 0.0) {
|
||||||
|
frag_color.rgb = mix(frag_color.rgb, custom_fog.rgb, custom_fog.a);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DISABLE_FOG
|
#endif // DISABLE_FOG
|
||||||
|
|
||||||
// Blending is disabled for Sky, so alpha doesn't blend
|
// Blending is disabled for Sky, so alpha doesn't blend
|
||||||
|
@ -129,6 +129,9 @@ ShaderTypes::ShaderTypes() {
|
|||||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
|
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||||
|
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["FOG"] = ShaderLanguage::TYPE_VEC4; // TODO consider adding to light shader
|
||||||
|
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["RADIANCE"] = ShaderLanguage::TYPE_VEC4;
|
||||||
|
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["IRRADIANCE"] = ShaderLanguage::TYPE_VEC4;
|
||||||
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].can_discard = true;
|
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].can_discard = true;
|
||||||
|
|
||||||
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4);
|
||||||
@ -325,6 +328,7 @@ ShaderTypes::ShaderTypes() {
|
|||||||
shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["SKY_COORDS"] = constt(ShaderLanguage::TYPE_VEC2);
|
shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["SKY_COORDS"] = constt(ShaderLanguage::TYPE_VEC2);
|
||||||
shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["HALF_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
|
shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["HALF_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
|
||||||
shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["QUARTER_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
|
shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["QUARTER_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
|
||||||
|
shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["FOG"] = ShaderLanguage::TYPE_VEC4;
|
||||||
|
|
||||||
shader_modes[RS::SHADER_SKY].modes.push_back("use_half_res_pass");
|
shader_modes[RS::SHADER_SKY].modes.push_back("use_half_res_pass");
|
||||||
shader_modes[RS::SHADER_SKY].modes.push_back("use_quarter_res_pass");
|
shader_modes[RS::SHADER_SKY].modes.push_back("use_quarter_res_pass");
|
||||||
|
Loading…
Reference in New Issue
Block a user