Begin motion blur.
This commit is contained in:
parent
d486d38614
commit
37155ddf6b
16
Assets/motion_blur_material.json
Normal file
16
Assets/motion_blur_material.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"material_resources": [
|
||||||
|
{
|
||||||
|
"contexts": [
|
||||||
|
{
|
||||||
|
"bind_constants": [],
|
||||||
|
"bind_textures": [
|
||||||
|
],
|
||||||
|
"id": "motion_blur_pass"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": "motion_blur_material",
|
||||||
|
"shader": "motion_blur_pass/motion_blur_pass"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -35,6 +35,10 @@ os.chdir('../blur_pass')
|
||||||
make_resources.make('blur_pass.shader.json')
|
make_resources.make('blur_pass.shader.json')
|
||||||
make_variants.make('blur_pass.shader.json')
|
make_variants.make('blur_pass.shader.json')
|
||||||
|
|
||||||
|
os.chdir('../motion_blur_pass')
|
||||||
|
make_resources.make('motion_blur_pass.shader.json')
|
||||||
|
make_variants.make('motion_blur_pass.shader.json')
|
||||||
|
|
||||||
# os.chdir('../combine_pass')
|
# os.chdir('../combine_pass')
|
||||||
# make_resources.make('combine_pass.shader.json')
|
# make_resources.make('combine_pass.shader.json')
|
||||||
# make_variants.make('combine_pass.shader.json')
|
# make_variants.make('combine_pass.shader.json')
|
||||||
|
|
|
@ -81,7 +81,7 @@ void main() {
|
||||||
|
|
||||||
// occlusion
|
// occlusion
|
||||||
|
|
||||||
gl_FragData[0] = vec4(normal.x * 0.5 + 0.5, normal.y * 0.5 + 0.5, normal.z * 0.5 + 0.5, depth);
|
gl_FragData[0] = vec4(normal.xyz * 0.5 + 0.5, depth);
|
||||||
gl_FragData[1] = vec4(position.xyz, roughness);
|
gl_FragData[1] = vec4(position.xyz * 0.5 + 0.5, roughness);
|
||||||
gl_FragData[2] = vec4(baseColor.rgb, metalness);
|
gl_FragData[2] = vec4(baseColor.rgb, metalness);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ void main() {
|
||||||
float ao = texture(ssaotex, texCoord).r; // Normals, depth
|
float ao = texture(ssaotex, texCoord).r; // Normals, depth
|
||||||
|
|
||||||
vec3 n = g0.rgb * 2.0 - 1.0;
|
vec3 n = g0.rgb * 2.0 - 1.0;
|
||||||
vec3 p = g1.rgb;
|
vec3 p = g1.rgb * 2.0 - 1.0;
|
||||||
//n = normalize(n);
|
//n = normalize(n);
|
||||||
vec3 baseColor = g2.rgb;
|
vec3 baseColor = g2.rgb;
|
||||||
|
|
||||||
|
|
28
raw/motion_blur_pass/motion_blur_pass.frag.glsl
Normal file
28
raw/motion_blur_pass/motion_blur_pass.frag.glsl
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform sampler2D gbuffer0;
|
||||||
|
uniform sampler2D gbuffer1;
|
||||||
|
uniform sampler2D gbuffer2;
|
||||||
|
|
||||||
|
uniform sampler2D tex;
|
||||||
|
uniform mat4 prevVP;
|
||||||
|
|
||||||
|
in vec2 texCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 col = texture(tex, texCoord);
|
||||||
|
|
||||||
|
vec4 g0 = texture(gbuffer0, texCoord);
|
||||||
|
vec4 g1 = texture(gbuffer0, texCoord);
|
||||||
|
float depth = g0.a;
|
||||||
|
// vec3 p = getViewPos(texCoord, depth);
|
||||||
|
vec3 p = g1.rgb * 2.0 - 1.0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gl_FragColor = col;
|
||||||
|
}
|
38
raw/motion_blur_pass/motion_blur_pass.shader.json
Executable file
38
raw/motion_blur_pass/motion_blur_pass.shader.json
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"contexts": [
|
||||||
|
{
|
||||||
|
"id": "motion_blur_pass",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"id": "depth_write",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "compare_mode",
|
||||||
|
"value": "always"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "cull_mode",
|
||||||
|
"value": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "blend_source",
|
||||||
|
"value": "blend_one"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "blend_destination",
|
||||||
|
"value": "blend_zero"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"id": "prevVP",
|
||||||
|
"link": "_prevViewProjectionMatrix"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"texture_params": [],
|
||||||
|
"vertex_shader": "motion_blur_pass.vert.glsl",
|
||||||
|
"fragment_shader": "motion_blur_pass.frag.glsl"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
18
raw/motion_blur_pass/motion_blur_pass.vert.glsl
Normal file
18
raw/motion_blur_pass/motion_blur_pass.vert.glsl
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision highp float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
in vec2 pos;
|
||||||
|
|
||||||
|
out vec2 texCoord;
|
||||||
|
|
||||||
|
const vec2 madd = vec2(0.5, 0.5);
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// Scale vertex attribute to [0-1] range
|
||||||
|
texCoord = pos.xy * madd + madd;
|
||||||
|
|
||||||
|
gl_Position = vec4(pos.xy, 0.0, 1.0);
|
||||||
|
}
|
Loading…
Reference in a new issue