Fichas
SIT354 Code Fragments

Fichas del conjunto (19)
- 1—// Fragment Shader
// Colour RED
out_fragmentColour = vec4(1.0f, 0, 0, 1);
- 2—// Fragment Shader
out_fragmentColour = vec4(frag.normal.x, 0, 0, 1);
- 3—// Fragment Shader
out_fragmentColour = vec4(frag.normal, 1);
- 4—// Fragment Shader
vec2 st = gl_FragCoord.xy/u_resolution.xy;
vec2 pos = (vec2(0.5)-st)*2;
out_fragmentColour = vec4(pos,0,1);
- 5—// Fragment Shader
out_fragmentColour = vec4(mod (10 * pos.x, 1), mod (10 * pos.x, 1),0,1);
- 6—// Fragment Shader
out_fragmentColour = vec4(sin (10 * pos.x), sin (10 * pos.x), 0, 1);
- 7—// Fragment Shader
out_fragmentColour = vec4 (pow (sin (frequency * pos.x), sharpness) *
pow (sin (frequency * pos.y), sharpness), 0, 0, 1);
- 8—// Fragment Shader
st *= ((a+1.)*3.); // Scale up the space by 3
st = fract(st); // Wrap around 1.0
// Now we have 3 spaces that goes from
- 9—// Vertex Shader
gl_Position = vec4 (VertexPosition.x,
VertexPosition.y + 0.1 * sin (30. * VertexPosition.x),
Vertex
- 10—// Vertex Shader
float angle = a * 10;
mat4 T = mat4 (vec4 (cos (angle), sin(angle), 0, 0), vec4 (-sin(angle), cos(angle), 0, 0),
vec4 (0, 0, 1, 0), vec4 (0, 0, 0, 1) );
gl_Position = T * vec4 (VertexPosition, 1);
- 11—out_fragmentColour = vec4(frag.normal, 1);

- 12—mat4 normalMatrix = transpose(inverse(ViewMatrix * WorldMatrix));
VertexOut.normal = normalize((normalMatrix * vec4(VertexNormal, 0)).xyz);
- 13—float Ka = max(0,a);
float Ia = max(0,b);
vec3 AmbientColour = vec3 (0.4, 0.7, 0.3);
colour = colour + Ka * Ia * AmbientColour;
out_fragmentColour = vec4(colour,1.0);
- 14—vec3 N = normalize (frag.normal);
vec3 L = normalize (vec3 (frag.EyeSpaceLightPosition - frag.EyeSpacePosition));
colour = L;
- 15—vec3 LightColour = vec3 (0.9, 0.9, 1.0);
float Kd = max(0,c);
// 4. Add in the diffuse component.
colour = colour + MaterialColour *
(Kd * max (0.0, dot (N, L))) * LightColour;
- 16—vec3 R = normalize(reflect (L, N));
colour = R;
- 17—vec3 V = normalize (vec3 (frag.EyeSpacePosition) - vec3 (0, 0, 0));
colour = V;
- 18—vec3 HighlightColour = vec3 (1.0, 1.0, 1.0);
float Ks = max(0,d);
float n = 30 * (max(0,e) + 3);
colour = colour + MaterialColour *
(Ks * pow (max (0.0, dot (R, V)), n)) * HighlightColour;
- 19—fragColour = vec4 ( texture2D( texture1, vec2(s,t)));
out_fragmentColour = fragColour;
Información
- Descripción
- Shader code fragments to accomplish a specific task
- Creado por
- Dan All
- Visitas
- 39
- Etiquetas
- Valoración