Completed a simple gBuffer
This commit is contained in:
1 parent
4d4b6d51ae
commit
be4df5c853
16 files changed
+168
-83
No files matched your search
@@ -5,6 +5,5 @@ uniform float opacity;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
|
||||
color = vec4(0.0, 0.0, 0.0, opacity);
|
||||
color = vec4(vec3(0.0), opacity);
|
||||
}
|
||||
@@ -3,6 +3,5 @@
|
||||
layout(location = 0) in vec2 pos;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_Position = vec4(pos.xy, 0.0, 1.0);
|
||||
}
|
||||
@@ -1,2 +1,43 @@
|
||||
#version 330 core
|
||||
|
||||
in vec3 fragPos;
|
||||
in vec2 texCoord;
|
||||
in vec3 normal;
|
||||
|
||||
struct Material {
|
||||
bool hasDiffuseTex;
|
||||
sampler2D diffuseTexture;
|
||||
vec3 diffuseColor;
|
||||
bool hasSpecTex;
|
||||
sampler2D specularTexture;
|
||||
float specPower;
|
||||
bool hasNormTex;
|
||||
sampler2D normalTexture;
|
||||
};
|
||||
|
||||
uniform Material material;
|
||||
|
||||
layout(location = 0) out vec3 pos;
|
||||
layout(location = 1) out vec3 normals;
|
||||
layout(location = 2) out vec3 diffuse;
|
||||
layout(location = 3) out vec3 specular;
|
||||
|
||||
void main() {
|
||||
pos = fragPos;
|
||||
|
||||
if (material.hasNormTex)
|
||||
normals = texture(material.normalTexture, texCoord).xyz;
|
||||
else
|
||||
normals = normalize(normal);
|
||||
|
||||
if (material.hasDiffuseTex)
|
||||
diffuse = texture(material.diffuseTexture, texCoord).rgb;
|
||||
else
|
||||
diffuse = material.diffuseColor;
|
||||
|
||||
specular.r = material.specPower;
|
||||
if (material.hasSpecTex)
|
||||
specular.g = texture(material.specularTexture, texCoord).r;
|
||||
else
|
||||
specular.g = 1.0;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ void main() {
|
||||
fragPos = world.xyz;
|
||||
texCoord = texCoords;
|
||||
mat3 normalMat = transpose(inverse(mat3(model)));
|
||||
normal - normalMat * normals;
|
||||
normal = normalMat * normals;
|
||||
|
||||
gl_Position = proj * view * world;
|
||||
}
|
||||
-12
@@ -9,17 +9,6 @@ struct Camera {
|
||||
vec3 pos;
|
||||
};
|
||||
|
||||
struct Material {
|
||||
bool hasDiffuseTex;
|
||||
sampler2D diffuseTexture;
|
||||
vec3 diffuseColor;
|
||||
bool hasSpecTex;
|
||||
sampler2D specularTexture;
|
||||
float specPower;
|
||||
bool hasNormTex;
|
||||
sampler2D normalTexture;
|
||||
};
|
||||
|
||||
struct Light {
|
||||
//Directional = 1, Point = 2
|
||||
int type;
|
||||
@@ -31,7 +20,6 @@ struct Light {
|
||||
};
|
||||
|
||||
uniform Camera camera;
|
||||
uniform Material material;
|
||||
uniform Light light[100];
|
||||
uniform int numberOfLights;
|
||||
uniform bool isContinued;
|
||||
Reference in new issue
Block a user