mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Huge rework of editor and other changes.
This commit is contained in:
@@ -103,7 +103,7 @@ class Vector3 {
|
||||
}
|
||||
|
||||
Cross(vec) {
|
||||
Math.Cross(this, vec)
|
||||
return Math.Cross(this, vec)
|
||||
}
|
||||
|
||||
Normalize() {
|
||||
|
||||
@@ -19,7 +19,8 @@ uniform int u_Stage;
|
||||
|
||||
uniform sampler2D u_Source;
|
||||
uniform vec2 u_SourceSize;
|
||||
|
||||
uniform float u_Exposure;
|
||||
uniform float u_Gamma;
|
||||
uniform sampler2D u_Source2;
|
||||
uniform vec2 u_Source2Size;
|
||||
|
||||
@@ -99,28 +100,7 @@ vec4 blur9(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 acesOperator(vec3 rgbColour)
|
||||
{
|
||||
const mat3 inputMatrix = mat3
|
||||
(
|
||||
vec3(0.59719, 0.07600, 0.02840),
|
||||
vec3(0.35458, 0.90834, 0.13383),
|
||||
vec3(0.04823, 0.01566, 0.83777)
|
||||
);
|
||||
|
||||
const mat3 outputMatrix = mat3
|
||||
(
|
||||
vec3(1.60475, -0.10208, -0.00327),
|
||||
vec3(-0.53108, 1.10813, -0.07276),
|
||||
vec3(-0.07367, -0.00605, 1.07602)
|
||||
);
|
||||
|
||||
vec3 inputColour = inputMatrix * rgbColour;
|
||||
vec3 a = inputColour * (inputColour + vec3(0.0245786)) - vec3(0.000090537);
|
||||
vec3 b = inputColour * (0.983729 * inputColour + 0.4329510) + 0.238081;
|
||||
vec3 c = a / b;
|
||||
return outputMatrix * c;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -150,15 +130,7 @@ void main()
|
||||
outputColor += texture(u_Source2, UV);
|
||||
|
||||
vec3 color = outputColor.rgb;
|
||||
|
||||
//color = acesOperator(color);
|
||||
|
||||
color = color / (color + vec3(2.0));
|
||||
color = vec3(1.0) - exp(-color * 1.0);
|
||||
color = pow(color, vec3(1.0 / 2.2));
|
||||
|
||||
outputColor = vec4(color, 1.0);//vec4(acesOperator(outputColor.rgb), 1.0f);
|
||||
|
||||
}
|
||||
FragColor = outputColor;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ void main()
|
||||
|
||||
// scale light by NdotL
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
Lo += (kD * albedo / PI + specular) * radiance * NdotL;// note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again
|
||||
Lo += (kD * albedo / PI) * radiance * NdotL;// note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again
|
||||
}
|
||||
|
||||
/// ambient lighting (we now use IBL as the ambient term)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#shader vertex
|
||||
#version 460 core
|
||||
|
||||
|
||||
layout(location = 0) in vec3 VertexPosition;
|
||||
|
||||
uniform mat4 u_Projection;
|
||||
|
||||
@@ -78,7 +78,7 @@ void main()
|
||||
if (u_HasAlbedo == 1)
|
||||
gAlbedo.rgb = texture(m_Albedo, UV).rgb;
|
||||
|
||||
gAlbedo.rgb = texture(m_Albedo, UV).rgb;
|
||||
gAlbedo.rgb = texture(m_Albedo, UV).rgb * m_AlbedoColor.rgb;
|
||||
|
||||
// Material
|
||||
float finalMetalness = u_MetalnessValue;
|
||||
|
||||
29
Editor/resources/Shaders/line.shader
Normal file
29
Editor/resources/Shaders/line.shader
Normal file
@@ -0,0 +1,29 @@
|
||||
#shader vertex
|
||||
#version 460 core
|
||||
|
||||
layout(location = 0) in vec3 VertexPosition;
|
||||
layout(location = 0) in vec4 VertexColor;
|
||||
|
||||
uniform mat4 u_Projection;
|
||||
uniform mat4 u_View;
|
||||
uniform mat4 u_Model;
|
||||
|
||||
out vec4 LineColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
LineColor = VertexColor;
|
||||
gl_Position = u_Projection * u_View * vec4(VertexPosition, 1.0f);
|
||||
}
|
||||
|
||||
#shader fragment
|
||||
#version 460 core
|
||||
|
||||
in vec4 LineColor;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = LineColor;
|
||||
}
|
||||
@@ -16,19 +16,32 @@ void main()
|
||||
#version 460 core
|
||||
|
||||
uniform sampler2D u_Source;
|
||||
uniform float u_Gamma;
|
||||
uniform float u_Exposure;
|
||||
|
||||
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 aces(vec3 x) {
|
||||
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((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(u_Source, UV);
|
||||
vec3 color = texture(u_Source, UV).rgb;
|
||||
|
||||
color = mix(color, color * u_Exposure, 0.1f);
|
||||
// reinhard
|
||||
color = color / (color + vec3(1.0));
|
||||
const float gamma = 2.2;
|
||||
// HDR tonemapping
|
||||
color = vec3(1.0) - exp(-color * u_Exposure);
|
||||
// gamma correct
|
||||
color = pow(color, vec3(1.0 / gamma));
|
||||
FragColor = color;
|
||||
color = pow(color, vec3(1.0 / u_Gamma));
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user