tweaked some groovy color effects, updated screeny. I think I might have added fog in this one too?

master
MitchellHansen 8 years ago
parent 259f6a8488
commit c98adefa3a

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 554 KiB

@ -84,7 +84,8 @@ __kernel void raycaster(
global float3* cam_pos,
global float* lights,
global int* light_count,
__write_only image2d_t image
__write_only image2d_t image,
global int* seed
){
size_t id = get_global_id(0);
@ -138,15 +139,19 @@ __kernel void raycaster(
}
// use a ghetto ass rng to give rays a "fog" appearance
int2 randoms = { 3, 14 };
uint seed = randoms.x + id;
uint t = seed ^ (seed << 11);
int2 randoms = { seed, ray_dir.y };
uint tseed = randoms.x + id;
uint t = tseed ^ (tseed << 11);
uint result = randoms.y ^ (randoms.y >> 19) ^ (t ^ (t >> 8));
*seed = result % 50;
int max_dist = 800 + result % 50;
int max_dist = 800 + result % 100;
int dist = 0;
int3 mask = { 0, 0, 0 };
float4 color = { 0.73, 0.81, 0.89, 0.6 };
float4 c = (float4)(0.40, 0.00, 0.40, 0.2);
c.x += ray_dir.y;// (result % 100) / 100;
// Andrew Woo's raycasting algo
do {
@ -160,11 +165,11 @@ __kernel void raycaster(
int3 undershoot = voxel > 0;
if (overshoot.x == 0 || overshoot.y == 0 || overshoot.z == 0 || undershoot.x == 0 || undershoot.y == 0){
write_imagef(image, pixel, (float4)(.73, .81, .89, 1.0));
write_imagef(image, pixel, white_light(mix(color, (float4)(0.40, 0.00, 0.40, 0.2), 1.0 - max(dist / 700.0f, (float)0)), (float3)(lights[7], lights[8], lights[9]), mask));
return;
}
if (undershoot.z == 0) {
write_imagef(image, pixel, (float4)(.14, .30, .50, 1.0));
write_imagef(image, pixel, white_light(mix(color, (float4)(0.40, 0.00, 0.40, 0.2), 1.0 - max(dist / 700.0f, (float)0)), (float3)(lights[7], lights[8], lights[9]), mask));
return;
}
@ -190,8 +195,8 @@ __kernel void raycaster(
return;
case 5:
//write_imagef(image, pixel, (float4)(.00, .00, + 0.5, 1.00));
write_imagef(image, pixel, white_light((float4)(0.40, 0.00, 0.40, 0.2), (float3)(lights[7], lights[8], lights[9]), mask));
//write_imagef(image, pixel, (float4)(0.40, 0.00, 0.40, 0.2));
write_imagef(image, pixel, white_light(mix(color, c, 1.0 - max((dist/700.0f) - 0.3f, (float)0)), (float3)(lights[7], lights[8], lights[9]), mask));
return;
float3 vox = convert_float3(voxel);
@ -221,8 +226,10 @@ __kernel void raycaster(
}
dist++;
} while (dist < max_dist);
write_imagef(image, pixel, (float4)(.73, .81, .89, 1.0));
} while (dist / 700.0f < 1);
//dist < max_dist
write_imagef(image, pixel, white_light(mix(color, (float4)(0.40, 0.00, 0.40, 0.2), 1.0 - max(dist / 700.0f, (float)0)), (float3)(lights[7], lights[8], lights[9]), mask));
//write_imagef(image, pixel, (float4)(.73, .81, .89, 1.0));
return;
}

@ -113,7 +113,7 @@ void GL_Testing::create_buffers() {
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); // Note that this is allowed, the call to glVertexAttribPointer registered VBO as the currently bound vertex buffer object so afterwards we can safely unbind
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}

@ -36,6 +36,11 @@ int Hardware_Caster::init() {
return error;
}
srand(NULL);
int seed = rand();
create_buffer("seed", sizeof(int), &seed);
return 1;
}
@ -80,6 +85,7 @@ void Hardware_Caster::validate()
set_kernel_arg("raycaster", 6, "lights");
set_kernel_arg("raycaster", 7, "light_count");
set_kernel_arg("raycaster", 8, "image");
set_kernel_arg("raycaster", 9, "seed");
print_kernel_arguments();
}

@ -73,7 +73,6 @@ int main() {
t.compile_shader("../shaders/passthrough.vert", GL_Testing::Shader_Type::VERTEX);
t.create_program();
t.create_buffers();
t.transform();
// Initialize the raycaster hardware, compat, or software
RayCaster *rc = new Hardware_Caster();
@ -233,9 +232,9 @@ int main() {
window.popGLStates();
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
t.rotate(delta_time);
t.transform();
t.draw();
//t.rotate(delta_time);
//t.transform();
//t.draw();
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

Loading…
Cancel
Save