Update deferred_shading.fs for GLES3
This commit is contained in:
parent
b51a84977f
commit
1e3dc61a1f
|
|
@ -1,12 +1,11 @@
|
||||||
#version 100
|
#version 300 es
|
||||||
|
|
||||||
precision mediump float;
|
precision highp float;
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
out vec4 finalColor;
|
||||||
varying vec2 fragTexCoord;
|
|
||||||
varying vec4 fragColor;
|
in vec2 texCoord;
|
||||||
|
|
||||||
// Input uniform values
|
|
||||||
uniform sampler2D gPosition;
|
uniform sampler2D gPosition;
|
||||||
uniform sampler2D gNormal;
|
uniform sampler2D gNormal;
|
||||||
uniform sampler2D gAlbedoSpec;
|
uniform sampler2D gAlbedoSpec;
|
||||||
|
|
@ -26,14 +25,13 @@ uniform vec3 viewPosition;
|
||||||
const float QUADRATIC = 0.032;
|
const float QUADRATIC = 0.032;
|
||||||
const float LINEAR = 0.09;
|
const float LINEAR = 0.09;
|
||||||
|
|
||||||
void main()
|
void main() {
|
||||||
{
|
vec3 fragPosition = texture(gPosition, texCoord).rgb;
|
||||||
vec3 fragPosition = texture2D(gPosition, fragTexCoord).rgb;
|
vec3 normal = texture(gNormal, texCoord).rgb;
|
||||||
vec3 normal = texture2D(gNormal, fragTexCoord).rgb;
|
vec3 albedo = texture(gAlbedoSpec, texCoord).rgb;
|
||||||
vec3 albedo = texture2D(gAlbedoSpec, fragTexCoord).rgb;
|
float specular = texture(gAlbedoSpec, texCoord).a;
|
||||||
float specular = texture2D(gAlbedoSpec, fragTexCoord).a;
|
|
||||||
|
|
||||||
vec3 ambient = albedo*vec3(0.1);
|
vec3 ambient = albedo * vec3(0.1f);
|
||||||
vec3 viewDirection = normalize(viewPosition - fragPosition);
|
vec3 viewDirection = normalize(viewPosition - fragPosition);
|
||||||
|
|
||||||
for(int i = 0; i < NR_LIGHTS; ++i)
|
for(int i = 0; i < NR_LIGHTS; ++i)
|
||||||
|
|
@ -54,6 +52,5 @@ void main()
|
||||||
ambient += diffuse + specular;
|
ambient += diffuse + specular;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = vec4(ambient, 1.0);
|
finalColor = vec4(ambient, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user