~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to progs/glsl/CH11-toyball.frag

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// Fragment shader for procedurally generated toy ball
3
 
//
4
 
// Author: Bill Licea-Kane
5
 
//
6
 
// Copyright (c) 2002-2003 ATI Research 
7
 
//
8
 
// See ATI-License.txt for license information
9
 
//
10
 
 
11
 
varying vec4 ECposition;   // surface position in eye coordinates
12
 
varying vec4 ECballCenter; // ball center in eye coordinates
13
 
 
14
 
uniform vec4  LightDir;     // light direction, should be normalized
15
 
uniform vec4  HVector;      // reflection vector for infinite light source
16
 
uniform vec4  SpecularColor;
17
 
uniform vec4  Red, Yellow, Blue;
18
 
 
19
 
uniform vec4  HalfSpace0;   // half-spaces used to define star pattern
20
 
uniform vec4  HalfSpace1;
21
 
uniform vec4  HalfSpace2;
22
 
uniform vec4  HalfSpace3;
23
 
uniform vec4  HalfSpace4;
24
 
 
25
 
uniform float InOrOutInit;  // = -3
26
 
uniform float StripeWidth;  // = 0.3
27
 
uniform float FWidth;       // = 0.005
28
 
 
29
 
void main()
30
 
{
31
 
    vec4  normal;              // Analytically computed normal
32
 
    vec4  p;                   // Point in shader space
33
 
    vec4  surfColor;           // Computed color of the surface
34
 
    float intensity;           // Computed light intensity
35
 
    vec4  distance;            // Computed distance values
36
 
    float inorout;             // Counter for computing star pattern
37
 
 
38
 
    p.xyz = normalize(ECposition.xyz - ECballCenter.xyz);    // Calculate p
39
 
    p.w   = 1.0;
40
 
 
41
 
    inorout = InOrOutInit;     // initialize inorout to -3
42
 
 
43
 
    distance[0] = dot(p, HalfSpace0);
44
 
    distance[1] = dot(p, HalfSpace1);
45
 
    distance[2] = dot(p, HalfSpace2);
46
 
    distance[3] = dot(p, HalfSpace3);
47
 
 
48
 
    distance = smoothstep(-FWidth, FWidth, distance);
49
 
    inorout += dot(distance, vec4(1.0));
50
 
 
51
 
    distance.x = dot(p, HalfSpace4);
52
 
    distance.y = StripeWidth - abs(p.z);
53
 
    distance = smoothstep(-FWidth, FWidth, distance);
54
 
    inorout += distance.x;
55
 
 
56
 
    inorout = clamp(inorout, 0.0, 1.0);
57
 
 
58
 
    surfColor = mix(Yellow, Red, inorout);
59
 
    surfColor = mix(surfColor, Blue, distance.y);
60
 
 
61
 
    // normal = point on surface for sphere at (0,0,0)
62
 
    normal = p;
63
 
 
64
 
    // Per fragment diffuse lighting
65
 
    intensity  = 0.2; // ambient
66
 
    intensity += 0.8 * clamp(dot(LightDir, normal), 0.0, 1.0);
67
 
    surfColor *= intensity;
68
 
 
69
 
    // Per fragment specular lighting
70
 
    intensity  = clamp(dot(HVector, normal), 0.0, 1.0);
71
 
    intensity  = pow(intensity, SpecularColor.a);
72
 
    surfColor += SpecularColor * intensity;
73
 
 
74
 
    gl_FragColor = surfColor;
75
 
}