mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-15 22:32:13 +00:00
THAT PIXEL IS NOW ANIMATED!?!#@?
This commit is contained in:
1 parent
ef2770a50b
commit
4dab692e2d
2 files changed
+22
-41
No files matched your search
@@ -64,8 +64,8 @@ layout(location = 0) in vec4 inColor;
|
||||
|
||||
out vec4 vertexColor;
|
||||
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
//uniform mat4 view;
|
||||
//uniform mat4 projection;
|
||||
layout(rgba32f) readonly uniform image2D pointCloudTexture;
|
||||
uniform bool enableShading;
|
||||
|
||||
@@ -93,17 +93,19 @@ void main()
|
||||
vec3 vertexPosition = imageLoad(pointCloudTexture, currentDepthPixelCoordinates).xyz;
|
||||
|
||||
//gl_Position = projection * view * vec4(vertexPosition, 1);
|
||||
//gl_Position = vec4(vertexPosition, 1);
|
||||
gl_Position = vec4(0.5, 0.5, 0.5, 1);
|
||||
gl_Position = vec4(vertexPosition, 1);
|
||||
//gl_Position = vec4(0.5, 0.5, 0.5, 1);
|
||||
|
||||
//vertexColor = inColor;
|
||||
vertexColor = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
//TODO TEST WITH vertexColor = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
vertexColor = inColor;
|
||||
|
||||
// Pass along the 'invalid pixel' flag as the alpha channel
|
||||
//
|
||||
if (vertexPosition.z == 0.0f)
|
||||
{
|
||||
//vertexColor.a = 0.0f;
|
||||
vertexColor.a = 0.5f;
|
||||
vertexColor.r = 0.5f;
|
||||
}
|
||||
|
||||
if (enableShading)
|
||||
@@ -159,8 +161,6 @@ void main()
|
||||
|
||||
vertexColor = vec4(attenuation * diffuse * vertexColor.rgb, vertexColor.a);
|
||||
}
|
||||
|
||||
vertexColor = vec4(0.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
";
|
||||
|
||||
@@ -176,14 +176,13 @@ uniform bool enableShading;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (vertexColor.a == 0.0f)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
// if (vertexColor.a == 0.0f)
|
||||
// {
|
||||
// discard;
|
||||
// }
|
||||
|
||||
//fragmentColor = vertexColor;
|
||||
|
||||
fragmentColor = vec4(0.5, 1.0, 0.0, 1.0);
|
||||
// TODO TEST WITH : fragmentColor = vec4(0.5, 1.0, 0.0, 1.0);
|
||||
fragmentColor = vertexColor;
|
||||
}
|
||||
";
|
||||
|
||||
@@ -442,19 +441,12 @@ impl PointCloudRendererShader {
|
||||
}
|
||||
|
||||
pub fn render(&self) -> Result<()> {
|
||||
println!("==== Renderer.render() [the draw call]");
|
||||
unsafe {
|
||||
println!("-> gl::Enable(DEPTH_TEST)");
|
||||
gl::Enable(gl::DEPTH_TEST);
|
||||
println!("-> gl::Enable(BLEND)");
|
||||
gl::Enable(gl::BLEND);
|
||||
println!("-> gl::BlendFunc(...)");
|
||||
gl::BlendFunc(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
println!("-> gl::PointSize(): {:?}", self.point_size as f32);
|
||||
gl::PointSize(self.point_size as f32);
|
||||
|
||||
println!("-> gl::UseProgram(): {:?}", self.program_id);
|
||||
gl::UseProgram(self.program_id);
|
||||
|
||||
// TODO: view and projection matrices
|
||||
@@ -464,30 +456,17 @@ impl PointCloudRendererShader {
|
||||
|
||||
// Update render settings in shader
|
||||
let enable_shading = if self.enable_shading { 1 } else { 0 };
|
||||
let enable_shading = 0; // TODO FIXME FIXME FIXME
|
||||
|
||||
// TODO: Not sure what is setting this false.
|
||||
//let enable_shading = 1;
|
||||
println!("Enable shading: {} -> {}", self.enable_shading, enable_shading);
|
||||
|
||||
|
||||
println!("-> gl::Uniform1i(): {:?}", self.enable_shading_index);
|
||||
gl::Uniform1i(self.enable_shading_index, enable_shading);
|
||||
|
||||
// glDrawArrays(GL_POINTS, 0, m_vertexArraySizeBytes / static_cast<GLsizei>(sizeof(BgraPixel)));
|
||||
let size = self.vertex_array_size_bytes / size_of::<BgraPixel>() as i32;
|
||||
|
||||
// Render point cloud
|
||||
println!("-> gl::BindVertexArray(): {:?}", self.vertex_array_object.id());
|
||||
gl::BindVertexArray(self.vertex_array_object.id());
|
||||
println!("gl::DrawArrays - points in the point cloud; size = {} (indices to be rendered)", size);
|
||||
println!("-> gl::DrawArrays(...)");
|
||||
gl::DrawArrays(
|
||||
gl::POINTS,
|
||||
0,
|
||||
size,
|
||||
);
|
||||
gl::DrawArrays(gl::POINTS, 0, size);
|
||||
|
||||
println!("-> gl::BindVertexArray(0)");
|
||||
gl::BindVertexArray(0);
|
||||
|
||||
gl_get_error()
|
||||
|
||||
@@ -88,11 +88,13 @@ pub enum ColorizationStrategy {
|
||||
|
||||
pub struct PointCloudVisualizer {
|
||||
// TODO: std::pair<DepthPixel, DepthPixel> m_expectedValueRange;
|
||||
// TODO: ImageDimensions m_dimensions;
|
||||
// TODO: ViewControl m_viewControl;
|
||||
// TODO: linmath::mat4x4 m_projection{};
|
||||
// TODO: linmath::mat4x4 m_view{};
|
||||
|
||||
m_dimensions_width : i32,
|
||||
m_dimensions_height : i32,
|
||||
|
||||
enable_color_point_cloud: bool,
|
||||
colorization_strategy: ColorizationStrategy,
|
||||
|
||||
@@ -192,6 +194,8 @@ impl PointCloudVisualizer {
|
||||
).expect("should allocate");*/
|
||||
|
||||
let mut visualizer = Self {
|
||||
m_dimensions_width: 1280, // Resolution of the point cloud texture
|
||||
m_dimensions_height: 1152, // ImageDimensions PointCloudVisualizerTextureDimensions = { 1280, 1152 };
|
||||
enable_color_point_cloud,
|
||||
point_cloud_renderer: PointCloudRendererShader::new(),
|
||||
point_cloud_converter: PointCloudComputeShader::new(),
|
||||
@@ -257,9 +261,7 @@ impl PointCloudVisualizer {
|
||||
return Err(PointCloudVisualizerError::FramebufferError);
|
||||
}
|
||||
|
||||
// TODO: This really warps things in 'imgui' land!
|
||||
gl::Viewport(0, 0, 800, 800);
|
||||
|
||||
gl::Viewport(0, 0, self.m_dimensions_width, self.m_dimensions_height);
|
||||
gl::Enable(gl::DEPTH_TEST);
|
||||
gl::ClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
gl::ClearDepth(1.0);
|
||||
|
||||
Reference in new issue
Block a user