Skip to content

Commit 2a2f216

Browse files
committed
simple cue shadow in raycast rendering
1 parent 7adc2bb commit 2a2f216

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

poolvr/shaders/sphere_projection_fs.glsl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,14 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
135135
);
136136

137137
float tmin = 10000.0;
138-
vec3 nor = vec3(0.0);
138+
vec3 nor = vec3(0.0);
139139
float occ = 1.0;
140-
vec3 pos = vec3(0.0);
140+
vec3 pos = vec3(0.0);
141141
vec3 sur = vec3(1.0);
142142
vec4 sph = vec4(0.0, 0.0, 0.0, ball_radius);
143143
int imin = -1;
144144
float h, ss;
145+
145146
for (int i = 0; i < 16; i++) {
146147
sph.xyz = ball_positions[i];
147148
h = iSphere( ro, rd, sph );
@@ -165,7 +166,13 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
165166
sph.xyz = ball_positions[j];
166167
occ *= oSphere( pos, nor, sph );
167168
}
168-
sur = table_color;
169+
float h2 = iCylinder( pos, nor, cue_world_matrix, cue_length, cue_radius );
170+
if (h2 > 0.0) {
171+
occ *= 0.5;
172+
sur = 0.4 * table_color;
173+
} else {
174+
sur = table_color;
175+
}
169176
}
170177

171178
h = iCylinder( ro, rd, cue_world_matrix, cue_length, cue_radius );

0 commit comments

Comments
 (0)