Update gbuffer.fs for GLES3

This commit is contained in:
MikiZX1 2025-01-18 15:52:51 +01:00 committed by GitHub
parent 2f70fd998d
commit b51a84977f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,36 +1,26 @@
#version 100 #version 300 es
precision mediump float; precision highp float;
// Input vertex attributes (from vertex shader) layout (location = 0) out vec4 gPosition;
varying vec3 fragPosition; layout (location = 1) out vec4 gNormal;
varying vec2 fragTexCoord; layout (location = 2) out vec4 gAlbedoSpec;
varying vec3 fragNormal;
varying vec4 fragColor;
// TODO: Is there some alternative for GLSL100 in vec3 fragPosition;
//layout (location = 0) out vec3 gPosition; in vec2 fragTexCoord;
//layout (location = 1) out vec3 gNormal; in vec3 fragNormal;
//layout (location = 2) out vec4 gAlbedoSpec; in vec4 fragColor;
//uniform vec3 gPosition;
//uniform vec3 gNormal;
//uniform vec4 gAlbedoSpec;
// Input uniform values uniform sampler2D diffuseTexture;
uniform sampler2D texture0; // Diffuse texture
uniform sampler2D specularTexture; uniform sampler2D specularTexture;
void main() void main() {
{ // store the fragment position vector in the first gbuffer texture
// Store the fragment position vector in the first gbuffer texture gPosition = vec4(fragPosition,1.0);
//gPosition = fragPosition; // also store the per-fragment normals into the gbuffer
gNormal = vec4(normalize(fragNormal),1.0);
// Store the per-fragment normals into the gbuffer // and the diffuse per-fragment color
//gNormal = normalize(fragNormal); gAlbedoSpec.rgb = texture(diffuseTexture, fragTexCoord).rgb;
// store specular intensity in gAlbedoSpec's alpha component
// Store the diffuse per-fragment color gAlbedoSpec.a = texture(specularTexture, fragTexCoord).r;
gl_FragColor.rgb = texture2D(texture0, fragTexCoord).rgb;
// Store specular intensity in gAlbedoSpec's alpha component
gl_FragColor.a = texture2D(specularTexture, fragTexCoord).r;
} }