generated from GlennFolker/MindustryModTemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate color in vertex shader instead
- Loading branch information
1 parent
5c80c06
commit 5edc246
Showing
2 changed files
with
14 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
uniform vec3 u_ambientColor; | ||
uniform vec3 u_camPos; | ||
|
||
varying vec3 v_pos; | ||
varying vec4 v_color; | ||
varying vec3 v_normal; | ||
varying vec3 v_light; | ||
varying vec3 v_color; | ||
|
||
void main(){ | ||
vec3 specular = vec3(0.0); | ||
vec3 ref = reflect(-v_light, v_normal); | ||
vec3 eye = normalize(u_camPos - v_pos); | ||
float factor = dot(eye, ref); | ||
if(factor > 0.0){ | ||
specular = vec3(pow(factor, 40.0)) * (1.0 - v_color.a); | ||
} | ||
|
||
vec3 diffuse = (u_ambientColor + specular) * vec3(0.01 + clamp((dot(v_normal, v_light) + 1.0) / 2.0, 0.0, 1.0)); | ||
gl_FragColor = vec4(v_color.rgb, 1.0) * vec4(diffuse, 1.0); | ||
gl_FragColor = vec4(v_color, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters