Mistři v programování na #hovnokod

C/C++ #943

OpenGL lighting :-)

vec4 spotLight(Light light, Material material, vec3 position, vec3 normal)
{
  vec3 ret = vec3(0.0f);

  ret = light . ambient * material . ambient;
 
  ret += material . diffuse * light . diffuse * 
		max ( 
			dot ( normalize ( normal ), normalize ( light . spotDirection ) ) 
			, 0 
		);
  
  ret += material . specular * light . specular * 
	  pow ( 
		max ( 
			dot ( 
				normalize ( 
					reflect ( 
						normalize ( -light . spotDirection ), 
						normalize ( normal ) 
					) 
				)
				,  normalize ( -position ) 
			) 
			, 0 
		) 
		,  material . shininess );

  return vec4(ret, 1.0f);
}

Ondřej Šejvl,