postprocess render pass
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
#version 450
|
||||
|
||||
layout(location=0) out vec2 vert_uv;
|
||||
layout(location=0) out vec2 _InUV;
|
||||
|
||||
const vec2 positions[6] = vec2[6](
|
||||
vec2(-1.0, 1.0),
|
||||
@@ -14,6 +14,6 @@ const vec2 positions[6] = vec2[6](
|
||||
|
||||
void main()
|
||||
{
|
||||
vert_uv = positions[gl_VertexIndex];
|
||||
_InUV = positions[gl_VertexIndex];
|
||||
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
#version 450
|
||||
|
||||
layout(set=0, binding=0) uniform texture2D _InTexture;
|
||||
layout(set=0, binding=1) uniform sampler _InTextureSampler;
|
||||
layout(location=0) in vec2 _InUV;
|
||||
layout(location=0) out vec4 _OutColor;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
// Get color
|
||||
vec2 uv = vec2(_InUV.x+1.0, -_InUV.y+1.0) * 0.5;
|
||||
vec3 color = texture(sampler2D(_InTexture, _InTextureSampler), uv).rgb;
|
||||
|
||||
// Viniette
|
||||
color = vec3(1,1,1);
|
||||
|
||||
color *= smoothstep(0.0, 0.2, pow(1.0-length(_InUV), 1.5)) + 0.5;
|
||||
|
||||
// Return
|
||||
_OutColor = vec4(color, 1.0);
|
||||
}
|
||||
Binary file not shown.
@@ -1,4 +1,3 @@
|
||||
// shader.frag
|
||||
#version 450
|
||||
|
||||
struct Material {
|
||||
@@ -7,8 +6,8 @@ struct Material {
|
||||
};
|
||||
|
||||
// Variables
|
||||
layout(location=0) in vec2 vert_uv;
|
||||
layout(location=0) out vec4 out_color;
|
||||
layout(location=0) in vec2 _InUV;
|
||||
layout(location=0) out vec4 _OutColor;
|
||||
|
||||
layout(set=0,binding=0) uniform Uniforms {
|
||||
mat4 _ViewMatrix;
|
||||
@@ -61,7 +60,7 @@ vec3 randomHemisphere(vec3 dir)
|
||||
vec3 solve()
|
||||
{
|
||||
// Calculate ray direction
|
||||
vec3 view_dir = (_ProjMatrixInv * vec4(vert_uv, 0, 1)).xyz;
|
||||
vec3 view_dir = (_ProjMatrixInv * vec4(_InUV, 0, 1)).xyz;
|
||||
vec3 rayDir = normalize(_ViewMatrix * vec4(view_dir,0)).xyz;
|
||||
Ray primaryRay = Ray(_CamPos / SCALE, rayDir);
|
||||
|
||||
@@ -91,6 +90,6 @@ vec3 solve()
|
||||
|
||||
void main()
|
||||
{
|
||||
seed = 420 * vert_uv.x + 1337 * vert_uv.y + _Time * 1234;
|
||||
out_color = vec4(solve(), 1);
|
||||
seed = 420 * _InUV.x + 1337 * _InUV.y + _Time * 1234;
|
||||
_OutColor = vec4(solve(), 1);
|
||||
}
|
||||
Reference in New Issue
Block a user