SIT354 Code Fragments

Dan All
Flashcards by Dan All, updated more than 1 year ago
Dan All
Created by Dan All over 2 years ago
19
0

Description

Shader code fragments to accomplish a specific task
Tags

Resource summary

Question Answer
// Fragment Shader // Colour RED out_fragmentColour = vec4(1.0f, 0, 0, 1);
// Fragment Shader out_fragmentColour = vec4(frag.normal.x, 0, 0, 1);
// Fragment Shader out_fragmentColour = vec4(frag.normal, 1);
// Fragment Shader vec2 st = gl_FragCoord.xy/u_resolution.xy; vec2 pos = (vec2(0.5)-st)*2; out_fragmentColour = vec4(pos,0,1);
// Fragment Shader out_fragmentColour = vec4(mod (10 * pos.x, 1), mod (10 * pos.x, 1),0,1);
// Fragment Shader out_fragmentColour = vec4(sin (10 * pos.x), sin (10 * pos.x), 0, 1);
// Fragment Shader out_fragmentColour = vec4 (pow (sin (frequency * pos.x), sharpness) * pow (sin (frequency * pos.y), sharpness), 0, 0, 1);
// 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
// Vertex Shader gl_Position = vec4 (VertexPosition.x, VertexPosition.y + 0.1 * sin (30. * VertexPosition.x), Vertex
// 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);
out_fragmentColour = vec4(frag.normal, 1);
mat4 normalMatrix = transpose(inverse(ViewMatrix * WorldMatrix)); VertexOut.normal = normalize((normalMatrix * vec4(VertexNormal, 0)).xyz);
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);
vec3 N = normalize (frag.normal); vec3 L = normalize (vec3 (frag.EyeSpaceLightPosition - frag.EyeSpacePosition)); colour = L;
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;
vec3 R = normalize(reflect (L, N)); colour = R;
vec3 V = normalize (vec3 (frag.EyeSpacePosition) - vec3 (0, 0, 0)); colour = V;
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;
fragColour = vec4 ( texture2D( texture1, vec2(s,t))); out_fragmentColour = fragColour;
Show full summary Hide full summary

Similar

Python Quiz
karljmurphy
Angular
Kingsley Bawuah
Java & Programming Quizz
gouber
Take It Further (pg. 16)
munchkin .
National 5 - Computing
Ryan Thompson
Code Questions - Python
Keir Clarke
Pears of Wisdom - Java Programming
Alex Poiry
Codes and Conventions of Film Trailers
Mollie Green
Roland Barthes' 5 Code Theory
Hannah Morris
Data Structures and Algorithm analysis
Bart Allen
4th Grade Language - Unit 1: Sentence or Fragment
rrcastro04