aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/builtins/110/refract
blob: 522ab4117347b01d4086592debdca08ebe79f493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
((function refract
   (signature float
     (parameters
       (declare (in) float i)
       (declare (in) float n)
       (declare (in) float eta))
     ((declare () float k)
      (assign (constant bool (1)) (var_ref k)
              (expression float - (constant float (1.0))
	        (expression float * (var_ref eta)
	          (expression float * (var_ref eta)
		    (expression float - (constant float (1.0))
		      (expression float * 
		        (expression float dot (var_ref n) (var_ref i))
		        (expression float dot (var_ref n) (var_ref i))))))))
      (if (expression bool < (var_ref k) (constant float (0.0)))
          ((return (constant float (0.0))))
	  ((return (expression float -
	             (expression float * (var_ref eta) (var_ref i))
		     (expression float *
		       (expression float +
		         (expression float * (var_ref eta)
			   (expression float dot (var_ref n) (var_ref i)))
		         (expression float sqrt (var_ref k)))
		       (var_ref n))))))))

   (signature vec2
     (parameters
       (declare (in) vec2 i)
       (declare (in) vec2 n)
       (declare (in) float eta))
     ((declare () float k)
      (assign (constant bool (1)) (var_ref k)
              (expression float - (constant float (1.0))
	        (expression float * (var_ref eta)
	          (expression float * (var_ref eta)
		    (expression float - (constant float (1.0))
		      (expression float * 
		        (expression float dot (var_ref n) (var_ref i))
		        (expression float dot (var_ref n) (var_ref i))))))))
      (if (expression bool < (var_ref k) (constant float (0.0)))
          ((return (constant vec2 (0.0 0.0))))
	  ((return (expression vec2 -
	             (expression vec2 * (var_ref eta) (var_ref i))
		     (expression vec2 *
		       (expression float +
		         (expression float * (var_ref eta)
			   (expression float dot (var_ref n) (var_ref i)))
		         (expression float sqrt (var_ref k)))
		       (var_ref n))))))))

   (signature vec3
     (parameters
       (declare (in) vec3 i)
       (declare (in) vec3 n)
       (declare (in) float eta))
     ((declare () float k)
      (assign (constant bool (1)) (var_ref k)
              (expression float - (constant float (1.0))
	        (expression float * (var_ref eta)
	          (expression float * (var_ref eta)
		    (expression float - (constant float (1.0))
		      (expression float * 
		        (expression float dot (var_ref n) (var_ref i))
		        (expression float dot (var_ref n) (var_ref i))))))))
      (if (expression bool < (var_ref k) (constant float (0.0)))
          ((return (constant vec3 (0.0 0.0 0.0))))
	  ((return (expression vec3 -
	             (expression vec3 * (var_ref eta) (var_ref i))
		     (expression vec3 *
		       (expression float +
		         (expression float * (var_ref eta)
			   (expression float dot (var_ref n) (var_ref i)))
		         (expression float sqrt (var_ref k)))
		       (var_ref n))))))))

   (signature vec4
     (parameters
       (declare (in) vec4 i)
       (declare (in) vec4 n)
       (declare (in) float eta))
     ((declare () float k)
      (assign (constant bool (1)) (var_ref k)
              (expression float - (constant float (1.0))
	        (expression float * (var_ref eta)
	          (expression float * (var_ref eta)
		    (expression float - (constant float (1.0))
		      (expression float * 
		        (expression float dot (var_ref n) (var_ref i))
		        (expression float dot (var_ref n) (var_ref i))))))))
      (if (expression bool < (var_ref k) (constant float (0.0)))
          ((return (constant vec4 (0.0 0.0 0.0 0.0))))
	  ((return (expression vec4 -
	             (expression vec4 * (var_ref eta) (var_ref i))
		     (expression vec4 *
		       (expression float +
		         (expression float * (var_ref eta)
			   (expression float dot (var_ref n) (var_ref i)))
		         (expression float sqrt (var_ref k)))
		       (var_ref n))))))))

))