From 96d96e8909207c6e152e7fff4dcf3e0f2ef4a6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 25 Jul 2022 09:44:15 +0200 Subject: EEVEE-Next: Fix some Material compilation errors --- .../eevee_next/shaders/eevee_attributes_lib.glsl | 42 +-------------------- .../eevee_next/shaders/eevee_nodetree_lib.glsl | 44 ++++++++++++++++++++++ .../eevee_next/shaders/eevee_surf_depth_frag.glsl | 12 ++++++ 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl index 326481a1db6..974581e674e 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl @@ -3,6 +3,8 @@ #pragma BLENDER_REQUIRE(common_math_lib.glsl) #pragma BLENDER_REQUIRE(gpu_shader_codegen_lib.glsl) +#defined EEVEE_ATTRIBUTE_LIB + #if defined(MAT_GEOM_MESH) /* -------------------------------------------------------------------- */ @@ -282,43 +284,3 @@ vec3 attr_load_uv(vec3 attr) /** \} */ #endif - -/* -------------------------------------------------------------------- */ -/** \name Volume Attribute post - * - * TODO(@fclem): These implementation details should concern the DRWManager and not be a fix on - * the engine side. But as of now, the engines are responsible for loading the attributes. - * - * \{ */ - -#if defined(MAT_GEOM_VOLUME) - -float attr_load_temperature_post(float attr) -{ - /* Bring the into standard range without having to modify the grid values */ - attr = (attr > 0.01) ? (attr * drw_volume.temperature_mul + drw_volume.temperature_bias) : 0.0; - return attr; -} -vec4 attr_load_color_post(vec4 attr) -{ - /* Density is premultiplied for interpolation, divide it out here. */ - attr.rgb *= safe_rcp(attr.a); - attr.rgb *= drw_volume.color_mul.rgb; - attr.a = 1.0; - return attr; -} - -#else /* Noop for any other surface. */ - -float attr_load_temperature_post(float attr) -{ - return attr; -} -vec4 attr_load_color_post(vec4 attr) -{ - return attr; -} - -#endif - -/** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl index 71921d0477a..c488216eeac 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl @@ -269,6 +269,10 @@ void output_aov(vec4 color, float value, uint hash) # define nodetree_thickness() 0.1 #endif +#ifdef GPU_VERTEX_SHADER +# define closure_to_rgba(a) vec4(0.0) +#endif + /* -------------------------------------------------------------------- */ /** \name Fragment Displacement * @@ -373,3 +377,43 @@ vec3 coordinate_incoming(vec3 P) } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Volume Attribute post + * + * TODO(@fclem): These implementation details should concern the DRWManager and not be a fix on + * the engine side. But as of now, the engines are responsible for loading the attributes. + * + * \{ */ + +#if defined(MAT_GEOM_VOLUME) + +float attr_load_temperature_post(float attr) +{ + /* Bring the into standard range without having to modify the grid values */ + attr = (attr > 0.01) ? (attr * drw_volume.temperature_mul + drw_volume.temperature_bias) : 0.0; + return attr; +} +vec4 attr_load_color_post(vec4 attr) +{ + /* Density is premultiplied for interpolation, divide it out here. */ + attr.rgb *= safe_rcp(attr.a); + attr.rgb *= drw_volume.color_mul.rgb; + attr.a = 1.0; + return attr; +} + +#else /* Noop for any other surface. */ + +float attr_load_temperature_post(float attr) +{ + return attr; +} +vec4 attr_load_color_post(vec4 attr) +{ + return attr; +} + +#endif + +/** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_depth_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_depth_frag.glsl index f19b6038a6a..34ea288852a 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_depth_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_depth_frag.glsl @@ -10,6 +10,18 @@ #pragma BLENDER_REQUIRE(eevee_surf_lib.glsl) #pragma BLENDER_REQUIRE(eevee_velocity_lib.glsl) +vec4 closure_to_rgba(Closure cl) +{ + vec4 out_color; + out_color.rgb = g_emission; + out_color.a = saturate(1.0 - avg(g_transmittance)); + + /* Reset for the next closure tree. */ + closure_weights_reset(); + + return out_color; +} + /* From the paper "Hashed Alpha Testing" by Chris Wyman and Morgan McGuire. */ float hash(vec2 a) { -- cgit v1.2.3