add MSAA, renderer2D, boundingbox
This commit is contained in:
BIN
Editor/assets/meshes/TestScene.fbx
Normal file
BIN
Editor/assets/meshes/TestScene.fbx
Normal file
Binary file not shown.
@ -34,7 +34,7 @@ out VertexOutput
|
||||
void main()
|
||||
{
|
||||
vs_Output.WorldPosition = vec3(u_Transform * vec4(a_Position, 1.0));
|
||||
vs_Output.Normal = a_Normal;
|
||||
vs_Output.Normal = mat3(u_Transform) * a_Normal;
|
||||
vs_Output.TexCoord = vec2(a_TexCoord.x, 1.0 - a_TexCoord.y);
|
||||
vs_Output.WorldNormals = mat3(u_Transform) * mat3(a_Tangent, a_Binormal, a_Normal);
|
||||
vs_Output.WorldTransform = mat3(u_Transform);
|
||||
@ -271,7 +271,8 @@ vec3 Lighting(vec3 F0)
|
||||
vec3 IBL(vec3 F0, vec3 Lr)
|
||||
{
|
||||
vec3 irradiance = texture(u_EnvIrradianceTex, m_Params.Normal).rgb;
|
||||
vec3 F = fresnelSchlickRoughness(F0, m_Params.NdotV, m_Params.Roughness);
|
||||
// vec3 F = fresnelSchlickRoughness(F0, m_Params.NdotV, m_Params.Roughness);
|
||||
vec3 F = fresnelSchlick(F0, m_Params.NdotV);
|
||||
vec3 kd = (1.0 - F) * (1.0 - m_Params.Metalness);
|
||||
vec3 diffuseIBL = m_Params.Albedo * irradiance;
|
||||
|
||||
@ -316,4 +317,5 @@ void main()
|
||||
vec3 iblContribution = IBL(F0, Lr);
|
||||
|
||||
color = vec4(lightContribution + iblContribution, 1.0);
|
||||
color = vec4(iblContribution, 1.0);
|
||||
}
|
||||
|
||||
43
Editor/assets/shaders/Renderer2D.glsl
Normal file
43
Editor/assets/shaders/Renderer2D.glsl
Normal file
@ -0,0 +1,43 @@
|
||||
// Basic Texture Shader
|
||||
|
||||
#type vertex
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec3 a_Position;
|
||||
layout(location = 1) in vec4 a_Color;
|
||||
layout(location = 2) in vec2 a_TexCoord;
|
||||
layout(location = 3) in float a_TexIndex;
|
||||
layout(location = 4) in float a_TilingFactor;
|
||||
|
||||
uniform mat4 u_ViewProjection;
|
||||
|
||||
out vec4 v_Color;
|
||||
out vec2 v_TexCoord;
|
||||
out float v_TexIndex;
|
||||
out float v_TilingFactor;
|
||||
|
||||
void main()
|
||||
{
|
||||
v_Color = a_Color;
|
||||
v_TexCoord = a_TexCoord;
|
||||
v_TexIndex = a_TexIndex;
|
||||
v_TilingFactor = a_TilingFactor;
|
||||
gl_Position = u_ViewProjection * vec4(a_Position, 1.0);
|
||||
}
|
||||
|
||||
#type fragment
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
in vec4 v_Color;
|
||||
in vec2 v_TexCoord;
|
||||
in float v_TexIndex;
|
||||
in float v_TilingFactor;
|
||||
|
||||
uniform sampler2D u_Textures[32];
|
||||
|
||||
void main()
|
||||
{
|
||||
color = texture(u_Textures[int(v_TexIndex)], v_TexCoord * v_TilingFactor) * v_Color;
|
||||
}
|
||||
29
Editor/assets/shaders/Renderer2D_Line.glsl
Normal file
29
Editor/assets/shaders/Renderer2D_Line.glsl
Normal file
@ -0,0 +1,29 @@
|
||||
// Basic Texture Shader
|
||||
|
||||
#type vertex
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec3 a_Position;
|
||||
layout(location = 1) in vec4 a_Color;
|
||||
|
||||
uniform mat4 u_ViewProjection;
|
||||
|
||||
out vec4 v_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
v_Color = a_Color;
|
||||
gl_Position = u_ViewProjection * vec4(a_Position, 1.0);
|
||||
}
|
||||
|
||||
#type fragment
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
in vec4 v_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = v_Color;
|
||||
}
|
||||
@ -16,20 +16,34 @@ void main()
|
||||
#type fragment
|
||||
#version 430
|
||||
|
||||
layout(location = 0) out vec4 o_Color;
|
||||
|
||||
in vec2 v_TexCoord;
|
||||
|
||||
uniform sampler2D u_Texture;
|
||||
|
||||
layout(location=0) out vec4 outColor;
|
||||
|
||||
uniform sampler2DMS u_Texture;
|
||||
uniform float u_Exposure;
|
||||
uniform int u_TextureSamples;
|
||||
|
||||
vec4 MultiSampleTexture(sampler2DMS tex, ivec2 texCoord, int samples)
|
||||
{
|
||||
vec4 result = vec4(0.0);
|
||||
for (int i = 0; i < samples; i++)
|
||||
result += texelFetch(tex, texCoord, i);
|
||||
|
||||
result /= float(samples);
|
||||
return result;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
const float gamma = 2.2;
|
||||
const float pureWhite = 1.0;
|
||||
|
||||
vec3 color = texture(u_Texture, v_TexCoord).rgb * u_Exposure;
|
||||
ivec2 texSize = textureSize(u_Texture);
|
||||
ivec2 texCoord = ivec2(v_TexCoord * texSize);
|
||||
vec4 msColor = MultiSampleTexture(u_Texture, texCoord, u_TextureSamples);
|
||||
vec3 color = msColor.rgb * u_Exposure;//texture(u_Texture, v_TexCoord).rgb * u_Exposure;
|
||||
|
||||
// Reinhard tonemapping operator.
|
||||
// see: "Photographic Tone Reproduction for Digital Images", eq. 4
|
||||
float luminance = dot(color, vec3(0.2126, 0.7152, 0.0722));
|
||||
@ -39,5 +53,5 @@ void main()
|
||||
vec3 mappedColor = (mappedLuminance / luminance) * color;
|
||||
|
||||
// Gamma correction.
|
||||
outColor = vec4(pow(mappedColor, vec3(1.0/gamma)), 1.0);
|
||||
o_Color = vec4(pow(mappedColor, vec3(1.0 / gamma)), 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user