Eevee: Update matrices operations to not use combined matrices
This commit is contained in:
@@ -53,6 +53,8 @@ extern char datatoc_shadow_store_frag_glsl[];
|
||||
extern char datatoc_shadow_copy_frag_glsl[];
|
||||
extern char datatoc_concentric_samples_lib_glsl[];
|
||||
|
||||
extern char datatoc_common_view_lib_glsl[];
|
||||
|
||||
/* Prototypes */
|
||||
static void eevee_light_setup(Object *ob, EEVEE_Light *evli);
|
||||
static float light_attenuation_radius_get(Light *la, float light_threshold);
|
||||
@@ -111,8 +113,11 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata)
|
||||
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
|
||||
|
||||
if (!e_data.shadow_sh) {
|
||||
e_data.shadow_sh = DRW_shader_create(
|
||||
datatoc_shadow_vert_glsl, NULL, datatoc_shadow_frag_glsl, NULL);
|
||||
e_data.shadow_sh = DRW_shader_create_with_lib(datatoc_shadow_vert_glsl,
|
||||
NULL,
|
||||
datatoc_shadow_frag_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (!sldata->lights) {
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
static struct {
|
||||
char *frag_shader_lib;
|
||||
char *vert_shader_str;
|
||||
char *vert_shadow_shader_str;
|
||||
char *volume_shader_lib;
|
||||
|
||||
struct GPUShader *default_prepass_sh;
|
||||
@@ -609,18 +610,20 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata,
|
||||
e_data.vert_shader_str = BLI_string_joinN(
|
||||
datatoc_common_view_lib_glsl, datatoc_common_hair_lib_glsl, datatoc_lit_surface_vert_glsl);
|
||||
|
||||
e_data.vert_shadow_shader_str = BLI_string_joinN(
|
||||
datatoc_common_view_lib_glsl, datatoc_common_hair_lib_glsl, datatoc_shadow_vert_glsl);
|
||||
|
||||
e_data.default_background = DRW_shader_create(
|
||||
datatoc_background_vert_glsl, NULL, datatoc_default_world_frag_glsl, NULL);
|
||||
|
||||
e_data.default_prepass_sh = DRW_shader_create(
|
||||
datatoc_prepass_vert_glsl, NULL, datatoc_prepass_frag_glsl, NULL);
|
||||
|
||||
e_data.default_prepass_clip_sh = DRW_shader_create(
|
||||
datatoc_prepass_vert_glsl, NULL, datatoc_prepass_frag_glsl, "#define CLIP_PLANES\n");
|
||||
|
||||
char *vert_str = BLI_string_joinN(
|
||||
datatoc_common_view_lib_glsl, datatoc_common_hair_lib_glsl, datatoc_prepass_vert_glsl);
|
||||
|
||||
e_data.default_prepass_sh = DRW_shader_create(vert_str, NULL, datatoc_prepass_frag_glsl, NULL);
|
||||
|
||||
e_data.default_prepass_clip_sh = DRW_shader_create(
|
||||
vert_str, NULL, datatoc_prepass_frag_glsl, "#define CLIP_PLANES\n");
|
||||
|
||||
e_data.default_hair_prepass_sh = DRW_shader_create(
|
||||
vert_str, NULL, datatoc_prepass_frag_glsl, "#define HAIR_SHADER\n");
|
||||
|
||||
@@ -853,7 +856,7 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get(struct Scene *scene,
|
||||
ma,
|
||||
engine,
|
||||
options,
|
||||
(is_shadow) ? datatoc_shadow_vert_glsl :
|
||||
(is_shadow) ? e_data.vert_shadow_shader_str :
|
||||
e_data.vert_shader_str,
|
||||
NULL,
|
||||
frag_str,
|
||||
@@ -1896,6 +1899,7 @@ void EEVEE_materials_free(void)
|
||||
}
|
||||
MEM_SAFE_FREE(e_data.frag_shader_lib);
|
||||
MEM_SAFE_FREE(e_data.vert_shader_str);
|
||||
MEM_SAFE_FREE(e_data.vert_shadow_shader_str);
|
||||
MEM_SAFE_FREE(e_data.volume_shader_lib);
|
||||
DRW_SHADER_FREE_SAFE(e_data.default_hair_prepass_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.default_hair_prepass_clip_sh);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 ModelViewMatrix;
|
||||
#ifndef USE_ATTR
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 ModelMatrixInverse;
|
||||
@@ -55,21 +53,19 @@ void main()
|
||||
hairThickness,
|
||||
hairThickTime);
|
||||
|
||||
gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
|
||||
viewPosition = (ViewMatrix * vec4(pos, 1.0)).xyz;
|
||||
worldPosition = pos;
|
||||
hairTangent = normalize(hairTangent);
|
||||
worldNormal = cross(binor, hairTangent);
|
||||
viewNormal = mat3(ViewMatrix) * worldNormal;
|
||||
worldPosition = pos;
|
||||
#else
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
worldPosition = point_object_to_world(pos);
|
||||
viewPosition = point_world_to_view(worldPosition);
|
||||
|
||||
worldNormal = normalize(normal_object_to_world(nor));
|
||||
#endif
|
||||
|
||||
/* No need to normalize since this is just a rotation. */
|
||||
viewNormal = normal_world_to_view(worldNormal);
|
||||
#endif
|
||||
|
||||
viewPosition = point_world_to_view(worldPosition);
|
||||
gl_Position = point_world_to_ndc(worldPosition);
|
||||
|
||||
/* Used for planar reflections */
|
||||
gl_ClipDistance[0] = dot(vec4(worldPosition, 1.0), ClipPlanes[0]);
|
||||
|
||||
@@ -19,25 +19,23 @@ void main()
|
||||
{
|
||||
#ifdef HAIR_SHADER
|
||||
float time, thick_time, thickness;
|
||||
vec3 pos, tan, binor;
|
||||
vec3 worldPosition, tan, binor;
|
||||
hair_get_pos_tan_binor_time((ProjectionMatrix[3][3] == 0.0),
|
||||
ModelMatrixInverse,
|
||||
ViewMatrixInverse[3].xyz,
|
||||
ViewMatrixInverse[2].xyz,
|
||||
pos,
|
||||
worldPosition,
|
||||
tan,
|
||||
binor,
|
||||
time,
|
||||
thickness,
|
||||
thick_time);
|
||||
|
||||
gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
|
||||
vec4 worldPosition = vec4(pos, 1.0);
|
||||
#else
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
vec4 worldPosition = (ModelMatrix * vec4(pos, 1.0));
|
||||
vec3 worldPosition = point_object_to_world(pos);
|
||||
#endif
|
||||
|
||||
gl_Position = point_world_to_ndc(worldPosition);
|
||||
|
||||
#ifdef CLIP_PLANES
|
||||
gl_ClipDistance[0] = dot(vec4(worldPosition.xyz, 1.0), ClipPlanes[0]);
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
#ifdef MESH_SHADER
|
||||
uniform mat4 ModelViewMatrix;
|
||||
# ifndef USE_ATTR
|
||||
#ifndef USE_ATTR
|
||||
uniform mat4 ModelMatrix;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
in vec3 pos;
|
||||
@@ -19,10 +15,11 @@ out vec3 viewNormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
#ifdef MESH_SHADER
|
||||
viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
|
||||
worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
|
||||
worldPosition = world_pos;
|
||||
viewPosition = point_world_to_view(worldPosition);
|
||||
|
||||
worldNormal = normalize(normal_object_to_world(nor));
|
||||
/* No need to normalize since this is just a rotation. */
|
||||
|
||||
Reference in New Issue
Block a user