Kaydet (Commit) 3ed1e68a authored tarafından Emmanuel Gil Peyrot's avatar Emmanuel Gil Peyrot Kaydeden (comit) Tomaž Vajngerl

slideshow: Blur the shadows the further they are from the object

Change-Id: I63f4fda670b86db2ee1ea66d8755d71697fac0c7
Reviewed-on: https://gerrit.libreoffice.org/22678Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 1a9b62dc
...@@ -29,6 +29,18 @@ bool isBorder(vec2 point) ...@@ -29,6 +29,18 @@ bool isBorder(vec2 point)
void main() void main()
{ {
const vec2 samplingPoints[9] = vec2[](
vec2(0, 0),
vec2(-1, -1),
vec2(-1, 0),
vec2(-1, 1),
vec2(0, 1),
vec2(1, 1),
vec2(1, 0),
vec2(1, -1),
vec2(0, -1)
);
vec4 fragment = vec4(texture(slideTexture, texturePosition).rgb, 1.0); vec4 fragment = vec4(texture(slideTexture, texturePosition).rgb, 1.0);
vec3 lightVector = vec3(0.0, 0.0, 1.0); vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = max(dot(lightVector, normal), 0.0); float light = max(dot(lightVector, normal), 0.0);
...@@ -73,13 +85,23 @@ void main() ...@@ -73,13 +85,23 @@ void main()
fragment.rgb *= actualTime; fragment.rgb *= actualTime;
} }
} }
// Compute the shadow.
float visibility = 1.0; float visibility = 1.0;
const float epsilon = 0.0001; const float epsilon = 0.0001;
if (texture(depthShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon) if (selectedTexture < 0.5) {
visibility *= 0.7 + 0.3 * (1.0 - texture(colorShadowTexture, shadowCoordinate.xy).a); float depthShadow = texture(depthShadowTexture, shadowCoordinate.xy).z;
float shadowRadius = (1.0 / (shadowCoordinate.z - depthShadow)) * 1000.0;
// Only the entering slide.
for (int i = 0; i < 9; ++i) {
vec2 coordinate = shadowCoordinate.xy + samplingPoints[i] / shadowRadius;
if (depthShadow < shadowCoordinate.z - epsilon) {
visibility -= 0.05 * texture(colorShadowTexture, coordinate).a;
}
}
}
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a); vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
if (fragment.a < 0.001)
discard;
gl_FragColor = mix(black, fragment, visibility * light); gl_FragColor = mix(black, fragment, visibility * light);
} }
......
...@@ -67,13 +67,14 @@ void emitHexagonVertex(vec3 center, vec2 translation) ...@@ -67,13 +67,14 @@ void emitHexagonVertex(vec3 center, vec2 translation)
void main() void main()
{ {
vec2 translateVectors[6]; const vec2 translateVectors[6] = vec2[](
translateVectors[0] = vec2(-3, -2); vec2(-3, -2),
translateVectors[1] = vec2(0, -4); vec2(0, -4),
translateVectors[2] = vec2(3, -2); vec2(3, -2),
translateVectors[3] = vec2(3, 2); vec2(3, 2),
translateVectors[4] = vec2(0, 4); vec2(0, 4),
translateVectors[5] = vec2(-3, 2); vec2(-3, 2)
);
vec3 center = gl_in[0].gl_Position.xyz; vec3 center = gl_in[0].gl_Position.xyz;
......
...@@ -18,15 +18,49 @@ in vec3 v_normal; ...@@ -18,15 +18,49 @@ in vec3 v_normal;
in vec4 shadowCoordinate; in vec4 shadowCoordinate;
void main() { void main() {
const vec2 samplingPoints[9] = vec2[](
vec2(0, 0),
vec2(-1, -1),
vec2(-1, 0),
vec2(-1, 1),
vec2(0, 1),
vec2(1, 1),
vec2(1, 0),
vec2(1, -1),
vec2(0, -1)
);
// Compute the shadow...
float visibility = 1.0;
const float epsilon = 0.0001;
// for the leaving slide,
{
float depthShadow = texture(leavingShadowTexture, shadowCoordinate.xy).r;
float shadowRadius = (1.0 / (shadowCoordinate.z - depthShadow)) * 1000.0;
for (int i = 0; i < 9; ++i) {
vec2 coordinate = shadowCoordinate.xy + samplingPoints[i] / shadowRadius;
if (texture(leavingShadowTexture, coordinate).r < shadowCoordinate.z - epsilon) {
visibility -= 0.05;
}
}
}
// and for entering slide.
{
float depthShadow = texture(enteringShadowTexture, shadowCoordinate.xy).r;
float shadowRadius = (1.0 / (shadowCoordinate.z - depthShadow)) * 1000.0;
for (int i = 0; i < 9; ++i) {
vec2 coordinate = shadowCoordinate.xy + samplingPoints[i] / shadowRadius;
if (texture(enteringShadowTexture, coordinate).r < shadowCoordinate.z - epsilon) {
visibility -= 0.05;
}
}
}
vec3 lightVector = vec3(0.0, 0.0, 1.0); vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = max(dot(lightVector, v_normal), 0.0); float light = max(dot(lightVector, v_normal), 0.0);
vec4 fragment = texture(slideTexture, v_texturePosition); vec4 fragment = texture(slideTexture, v_texturePosition);
float visibility = 1.0;
const float epsilon = 0.0001;
if (texture(leavingShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon)
visibility *= 0.7;
if (texture(enteringShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon)
visibility *= 0.7;
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a); vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
gl_FragColor = mix(black, fragment, visibility * light); gl_FragColor = mix(black, fragment, visibility * light);
} }
......
...@@ -1697,8 +1697,8 @@ void VortexTransition::prepareTransition( sal_Int32 glLeavingSlideTex, sal_Int32 ...@@ -1697,8 +1697,8 @@ void VortexTransition::prepareTransition( sal_Int32 glLeavingSlideTex, sal_Int32
for (int i : {0, 1}) { for (int i : {0, 1}) {
glBindTexture(GL_TEXTURE_2D, mnDepthTextures[i]); glBindTexture(GL_TEXTURE_2D, mnDepthTextures[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, 2048, 2048, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, 2048, 2048, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
...@@ -2094,16 +2094,16 @@ void HoneycombTransition::prepareTransition( sal_Int32 glLeavingSlideTex, sal_In ...@@ -2094,16 +2094,16 @@ void HoneycombTransition::prepareTransition( sal_Int32 glLeavingSlideTex, sal_In
glActiveTexture(GL_TEXTURE2); glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, mnDepthTextures[0]); glBindTexture(GL_TEXTURE_2D, mnDepthTextures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2048, 2048, 0, GL_RGBA, GL_FLOAT, nullptr); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2048, 2048, 0, GL_RGBA, GL_FLOAT, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glActiveTexture(GL_TEXTURE3); glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, mnDepthTextures[1]); glBindTexture(GL_TEXTURE_2D, mnDepthTextures[1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, 2048, 2048, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, 2048, 2048, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment