Sketchy skybox
This commit is contained in:
29
assets/shaders/skybox.frag
Normal file
29
assets/shaders/skybox.frag
Normal file
@@ -0,0 +1,29 @@
|
||||
#version 460
|
||||
|
||||
in Varyings {
|
||||
layout(location = 0) vec3 texCoord;
|
||||
} var;
|
||||
|
||||
layout(set = 0, binding = 1) uniform sampler _Sampler;
|
||||
layout(set = 0, binding = 2) uniform textureCube _Texture;
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
vec3 toneMapAcesNarkowicz(vec3 color) {
|
||||
const float A = 2.51;
|
||||
const float B = 0.03;
|
||||
const float C = 2.43;
|
||||
const float D = 0.59;
|
||||
const float E = 0.14;
|
||||
return clamp((color * (A * color + B)) / (color * (C * color + D) + E), 0.0, 1.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 texel = texture(samplerCube(_Texture, _Sampler), var.texCoord);
|
||||
vec3 outgoingRadiance = texel.rgb;
|
||||
|
||||
vec3 toneMappedLinearColor = toneMapAcesNarkowicz(outgoingRadiance);
|
||||
vec3 toneMappedSrgbColor = pow(toneMappedLinearColor, vec3(1.0 / 2.2));
|
||||
|
||||
fragColor = vec4(toneMappedSrgbColor, 1.0);
|
||||
}
|
||||
22
assets/shaders/skybox.vert
Normal file
22
assets/shaders/skybox.vert
Normal file
@@ -0,0 +1,22 @@
|
||||
#version 460
|
||||
#extension GL_EXT_scalar_block_layout : require
|
||||
|
||||
layout(location = 0) in vec3 directionWS;
|
||||
|
||||
out Varyings {
|
||||
layout(location = 0) vec3 texCoord;
|
||||
} var;
|
||||
|
||||
layout(set = 0, binding = 0, scalar) uniform GlobalUniforms {
|
||||
mat4 matrixWStoVS;
|
||||
mat4 matrixVStoCS;
|
||||
vec3 ambientLight;
|
||||
} _Global;
|
||||
|
||||
void main() {
|
||||
vec3 directionVS = (_Global.matrixWStoVS * vec4(directionWS, 0.0)).xyz;
|
||||
vec4 directionCS = _Global.matrixVStoCS * vec4(directionVS, 0.0);
|
||||
|
||||
gl_Position = vec4(directionCS.xy, 0.0, directionCS.w);
|
||||
var.texCoord = -directionWS;
|
||||
}
|
||||
Reference in New Issue
Block a user