Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week2 Blogpost #800

Merged
merged 9 commits into from
Jun 19, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions docs/source/posts/2023/2023-06-12-week-2-joaodellagli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Week 2: The Importance of (good) Documentation
=====================
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The = symbol should cover the whole title.


.. post:: June 12, 2023
:author: João Victor Dell Agli Floriano
:tags: google
:category: gsoc


Hello everybody, welcome to the week 2 of this project! I must admit I thought this would be simpler than it is currently being, but I forgot that when it comes to dealing with computer graphics' applications, things never are. Below, some updates on what I have been up to for this past week. 

This Last Week's Effort
-----------------------

Last week, I was facing some issues with a VTK feature essential so I could move forward with my project: Framebuffer Objects.
As described in my `last blogpost <https://blogs.python-gsoc.org/en/joaodellaglis-blog/the-fbo-saga-week-1/>`_, for some reason the 2D allocation method for it weren't working.
In a meeting with my mentors, while we were discussing and searching through VTK's FramebufferObject and TextureObject documentation, and the code itself for the problem,
one TextureObject method caught my attention: `vtkTextureObject.SetContext() <https://vtk.org/doc/nightly/html/classvtkTextureObject.html#a0988fa2a30b640c93392c2188030537e>`_.

Where the Problem Was
---------------------
My last week's code was:

| color_texture = vtk.vtkTextureObject() # color texture declaration
| color_texture.Bind() # binding of the texture for operations
|
| color_texture.SetDataType(vtk.VTK_UNSIGNED_CHAR) # setting the datatype for unsigned char
| color_texture.SetInternalFormat(vtk.VTK_RGBA) # setting the format as RGBA
| color_texture.SetFormat(vtk.VTK_RGBA)
| color_texture.SetMinificationFilter(0) # setting the minfilter as linear
| color_texture.SetMagnificationFilter(0) # setting the magfilter as linear
|
| color_texture.Allocate2D(width, height, 4, vtk.VTK_UNSIGNED_CHAR) # here is where the code stops

But it turns out that to allocate the FBO's textures, of type vtkTextureObject, you need to also set the context where the texture object
will be present, so it lacked a line, that should be added after Bind():

| color_texture = vtk.vtkTextureObject()
| color_texture.Bind()
|
| color_texture.SetContext(manager.window) # set the context where the texture object will be present
|
| color_texture.SetDataType(vtk.VTK_UNSIGNED_CHAR)
| color_texture.SetInternalFormat(vtk.VTK_RGB)
| color_texture.SetFormat(vtk.VTK_RGB)
| color_texture.SetMinificationFilter(0)
| color_texture.SetMagnificationFilter(0)

The code worked fine. But as my last blogpost showed, Allocate3D() method worked just fine without a (visible) problem, why is that?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocate2D
Allocate3D

mark them everywhere like you did for assert(this->Context);

Well, in fact, it **didn't work**. If we check the code for the Allocate2D and Allocate3D, one difference can be spotted:



.. image:: https://github.com/JoaoDell/gsoc_assets/main/images/allocate-2d-3d.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the image well

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, it works!

:align: center
:alt: Image comparing Allocate2D and Allocate3D methos



While in Allocate2D there is an ``assert(this->Context);``, in Allocate3D the assertion is translated into:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocate2D
Allocate3D

mark them everywhere like you did for assert(this->Context);


| if(this->Context==nullptr)
| {
| vtkErrorMacro("No context specified. Cannot create texture.");
| return false;
| }

This slight difference is significant: while in Allocate2D the program immediately fails, in Allocate3D the function is simply returned
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocate2D
Allocate3D

mark them everywhere like you did for assert(this->Context);

**false**, with its error pushed to vtkErrorMacro. I could have realised that earlier if I were using vtkErrorMacro, but this contrastant
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contrastant sounds weird to me, maybe you can use another word.

implementation made it harder for me and my mentors to realise what was happening.


This Week's Goals
-----------------
After making that work, this week's goal is to render something to the Framebuffer Object, now that is working. To do that,
first I will need to do some offscreen rendering to it, and afterwards render what it was drawn to its color attachment, the Texture Object I
was struggling to make work, into the screen, drawing its texture to a billboard. Also, I plan to start using vtkErrorMacro, as it seems like
the main error interface when working with VTK, and that may make my life easier.

See you next week!