mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-06 06:09:17 -05:00
Review shader exaples to work on web (GLSL 100)
This commit is contained in:
@ -55,25 +55,21 @@ void main()
|
||||
if (lights[i].enabled == 1)
|
||||
{
|
||||
vec3 light = vec3(0.0);
|
||||
if (lights[i].type == LIGHT_DIRECTIONAL) {
|
||||
light = -normalize(lights[i].target - lights[i].position);
|
||||
}
|
||||
if (lights[i].type == LIGHT_POINT) {
|
||||
light = normalize(lights[i].position - fragPosition);
|
||||
}
|
||||
|
||||
if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position);
|
||||
if (lights[i].type == LIGHT_POINT) light = normalize(lights[i].position - fragPosition);
|
||||
|
||||
float NdotL = max(dot(normal, light), 0.0);
|
||||
lightDot += lights[i].color.rgb * NdotL;
|
||||
lightDot += lights[i].color.rgb*NdotL;
|
||||
|
||||
float specCo = 0.0;
|
||||
if(NdotL > 0.0)
|
||||
specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16);//16 =shine
|
||||
if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // Shine: 16.0
|
||||
specular += specCo;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
finalColor = (texelColor * ((colDiffuse+vec4(specular,1)) * vec4(lightDot, 1.0)));
|
||||
finalColor += texelColor * (ambient/10.0);
|
||||
finalColor = (texelColor*((colDiffuse + vec4(specular,1))*vec4(lightDot, 1.0)));
|
||||
finalColor += texelColor*(ambient/10.0);
|
||||
|
||||
// Gamma correction
|
||||
finalColor = pow(finalColor, vec4(1.0/2.2));
|
||||
|
||||
Reference in New Issue
Block a user