mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Particle system improvements + Emissive materials
Added option for Global particle positions Added material property for particles Added Emissive rendering
This commit is contained in:
@@ -38,6 +38,7 @@ uniform sampler2D m_Albedo;
|
||||
uniform sampler2D m_Material;
|
||||
uniform sampler2D m_Normal;
|
||||
uniform sampler2D m_SSAO;
|
||||
uniform sampler2D m_Emissive;
|
||||
|
||||
// Lights
|
||||
const int MaxLight = 32;
|
||||
@@ -223,10 +224,21 @@ void main()
|
||||
// Convert from [0, 1] to [-1, 1].
|
||||
vec3 albedo = texture(m_Albedo, UV).rgb;
|
||||
vec3 normal = texture(m_Normal, UV).rgb * 2.0 - 1.0;
|
||||
float metallic = texture(m_Material, UV).r;
|
||||
float roughness = texture(m_Material, UV).b;
|
||||
float ao = texture(m_Material, UV).g;
|
||||
float ssao = texture(m_SSAO, UV).r;
|
||||
|
||||
vec4 materialSample = texture(m_Material, UV);
|
||||
float metallic = materialSample.r;
|
||||
float ao = materialSample.g;
|
||||
float roughness = materialSample.b;
|
||||
float unlit = materialSample.a;
|
||||
float ssao = texture(m_SSAO, UV).r;
|
||||
float emissive = texture(m_Emissive, UV).r;
|
||||
|
||||
if (unlit > 0.1f)
|
||||
{
|
||||
FragColor = vec4(albedo * ssao * emissive, 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 N = normal;
|
||||
vec3 V = normalize(u_EyePosition - worldPos);
|
||||
vec3 R = reflect(-V, N);
|
||||
@@ -240,6 +252,7 @@ void main()
|
||||
vec3 fog = vec3(0.0);
|
||||
float shadow = 0.0f;
|
||||
|
||||
|
||||
if (true)
|
||||
{
|
||||
vec3 L = normalize(u_DirectionalLight.Direction);
|
||||
|
||||
@@ -40,6 +40,7 @@ layout(location = 0) out vec4 gAlbedo;
|
||||
layout(location = 1) out vec4 gNormal;
|
||||
layout(location = 2) out vec4 gMaterial;
|
||||
layout(location = 3) out int gEntityID;
|
||||
layout(location = 4) out float gEmissive;
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec2 UV;
|
||||
@@ -67,6 +68,7 @@ layout(std140, binding = 32) uniform u_MaterialUniform
|
||||
int u_HasNormal; // 56 byte
|
||||
int u_HasDisplacement; // 60 byte
|
||||
int u_Unlit;
|
||||
float u_Emissive;
|
||||
};
|
||||
|
||||
void main()
|
||||
@@ -77,10 +79,10 @@ void main()
|
||||
normal = texture(m_Normal, UV).rgb;
|
||||
normal = normal * 2.0 - 1.0;
|
||||
normal = TBN * normalize(normal);
|
||||
gNormal = vec4(normal / 2.0 + 0.5, 1.0);
|
||||
gNormal = vec4(normal / 2.0 + 0.5, 1.0f);
|
||||
|
||||
// Albedo
|
||||
gAlbedo = vec4(m_AlbedoColor, 1.0);
|
||||
gAlbedo = vec4(m_AlbedoColor, 1.0f);
|
||||
if (u_HasAlbedo == 1)
|
||||
{
|
||||
vec4 albedoSample = texture(m_Albedo, UV);
|
||||
@@ -106,10 +108,12 @@ void main()
|
||||
if (u_HasRoughness == 1)
|
||||
finalRoughness = texture(m_Roughness, UV).r;
|
||||
|
||||
gMaterial = vec4(0, 0, 0, 1);
|
||||
gMaterial = vec4(0, 0, 0, u_Unlit);
|
||||
gMaterial.r = finalMetalness;
|
||||
gMaterial.g = finalAO;
|
||||
gMaterial.b = finalRoughness;
|
||||
|
||||
gEntityID = int(u_EntityID);
|
||||
|
||||
gEmissive = u_Emissive;
|
||||
}
|
||||
@@ -65,6 +65,7 @@ layout(location = 0) out vec4 gAlbedo;
|
||||
layout(location = 1) out vec4 gNormal;
|
||||
layout(location = 2) out vec4 gMaterial;
|
||||
layout(location = 3) out int gEntityID;
|
||||
layout(location = 4) out float gEmissive;
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec2 UV;
|
||||
@@ -92,6 +93,7 @@ layout(std140, binding = 32) uniform u_MaterialUniform
|
||||
int u_HasNormal; // 56 byte
|
||||
int u_HasDisplacement; // 60 byte
|
||||
int u_Unlit;
|
||||
float u_Emissive;
|
||||
};
|
||||
|
||||
void main()
|
||||
@@ -102,10 +104,10 @@ void main()
|
||||
normal = texture(m_Normal, UV).rgb;
|
||||
normal = normal * 2.0 - 1.0;
|
||||
normal = TBN * normalize(normal);
|
||||
gNormal = vec4(normal / 2.0 + 0.5, 1.0);
|
||||
gNormal = vec4(normal / 2.0 + 0.5, 1.0f);
|
||||
|
||||
// Albedo
|
||||
gAlbedo = vec4(m_AlbedoColor, 1.0);
|
||||
gAlbedo = vec4(m_AlbedoColor, 1.0f);
|
||||
if (u_HasAlbedo == 1)
|
||||
{
|
||||
vec4 albedoSample = texture(m_Albedo, UV);
|
||||
@@ -131,10 +133,11 @@ void main()
|
||||
if (u_HasRoughness == 1)
|
||||
finalRoughness = texture(m_Roughness, UV).r;
|
||||
|
||||
gMaterial = vec4(0, 0, 0, 1);
|
||||
gMaterial = vec4(0, 0, 0, u_Unlit);
|
||||
gMaterial.r = finalMetalness;
|
||||
gMaterial.g = finalAO;
|
||||
gMaterial.b = finalRoughness;
|
||||
|
||||
gEntityID = int(u_EntityID);
|
||||
gEmissive = u_Emissive;
|
||||
}
|
||||
Reference in New Issue
Block a user