Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 400
- in vec4 vPosition;
- in vec3 vNormal;
- in vec2 vTexCoord;
- //uniform float LowThreshold;
- //uniform float HighThreshold;
- uniform sampler2D sampler0; // noise texture
- layout( location = 0 ) out vec4 FragColor;
- layout( location = 1 ) out vec4 BrightColor;
- vec3 PhongModel(vec4 eyePosition, vec3 eyeNorm)
- {
- vec3 s = normalize(vec3(vec3(-100,50,-100) - eyePosition)); // Ошибка
- vec3 v = normalize(-eyePosition.xyz);
- vec3 r = reflect(-s, eyeNorm);
- vec3 n = eyeNorm;
- vec3 ambient = vec3(0.1,0.5,0.1) * vec3(1,1,1);
- float sDotN = max(dot(s, n), 0.0f);
- vec3 diffuse = vec3(1.0) * vec3(1.0) * sDotN;
- vec3 specular = vec3(0.0f);
- float eps = 0.000001f; // add eps to shininess below -- pow not defined if second argument is 0 (as described in GLSL documentation)
- if (sDotN > 0.0f)
- specular = vec3(1.0) * vec3(1.0) * pow(max(dot(r, v), 0.0f), 15.0f + eps);
- return ambient + diffuse + specular;
- }
- void main()
- {
- vec4 noise = texture( sampler0, vTexCoord );
- vec3 color = PhongModel(vPosition,vNormal);
- if(noise.a < 0.1) discard;
- if(noise.a > 0.5) discard;
- FragColor = vec4(color, 1.0f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement