beginning migrate to shaders
add a few submodules generate C file store with cfs_gen remove FileLoader/TextureLoader add initial color shaders for wfobj objects
This commit is contained in:
1 parent
55fee6b9a9
commit
8028654ff2
21 files changed
+101
-1250
No files matched your search
@@ -0,0 +1,39 @@
|
||||
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec4 ambient, diffuse, specular;
|
||||
uniform float shininess;
|
||||
|
||||
varying vec3 pos_i;
|
||||
varying vec3 normal_i;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 n, lightDir;
|
||||
vec4 color;
|
||||
float NdotL, RdotEye;
|
||||
|
||||
lightDir = normalize(vec3(-0.4, 0, -0.9));
|
||||
color = vec4(0.2, 0.2, 0.2, 1.0) * ambient; /* ambient light */
|
||||
n = normalize(normal_i);
|
||||
|
||||
NdotL = max(dot(n, -lightDir), 0.0);
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
/* diffuse component */
|
||||
color += diffuse * NdotL;
|
||||
/* specular component */
|
||||
RdotEye = dot(normalize(-pos_i), normalize(reflect(-lightDir, n)));
|
||||
if (RdotEye > 0.0)
|
||||
{
|
||||
color += clamp(specular * pow(RdotEye, shininess), 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
uniform mat4 projection;
|
||||
uniform mat4 modelview;
|
||||
|
||||
attribute vec3 pos;
|
||||
attribute vec3 normal;
|
||||
|
||||
varying vec3 pos_i;
|
||||
varying vec3 normal_i;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = projection * modelview * vec4(pos, 1);
|
||||
pos_i = gl_Position.xyz;
|
||||
normal_i = normal;
|
||||
}
|
||||
Reference in new issue
Block a user