Sha256: 64df6ed8653b05f8c54c6e3be438c02703e4b67c784a8fc70332ed5ef91ed926

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

// Copyright (C) 2007 Dave Griffiths
// Copyright (C) 2007 Dave Griffiths
// Licence: GPLv2 (see COPYING)
// Fluxus Shader Library
// ---------------------
// Glossy Specular Reflection Shader
// A more controllable version of blinn shading,
// Useful for ceramic or fluids - from Advanced 
// Renderman, thanks to Larry Gritz

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

uniform vec3 AmbientColour;
uniform vec3 DiffuseColour;
uniform vec3 SpecularColour;
uniform float AmbientIntensity;
uniform float DiffuseIntensity;
uniform float SpecularIntensity;
uniform float Roughness;
uniform float Sharpness;

varying vec3 N;
varying vec3 P;
varying vec3 V;
varying vec3 L;
    
void main() { 
  float w = 0.18*(1.0-Sharpness);
	
  vec3 l = normalize(L);
  vec3 n = normalize(N);
  vec3 v = normalize(V);
  vec3 h = normalize(l+v);

  float diffuse = dot(l,n);
  float specular = smoothstep(0.72-w,0.72+w,pow(max(0.0,dot(n,h)),1.0/Roughness));
    
  gl_FragColor = vec4(AmbientColour*AmbientIntensity + 
                      DiffuseColour*diffuse*DiffuseIntensity +
                      SpecularColour*specular*SpecularIntensity,1);
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.6.2 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.6.1 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.6.0 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.5.1 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.5.0 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.4.4 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.4.3 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.4.2 samples/processing_app/topics/shaders/data/GlossyFrag.glsl
ruby-processing-2.4.1 samples/processing_app/topics/shaders/data/GlossyFrag.glsl