<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 30, 2017 at 8:48 AM, Matej Tyc <span dir="ltr"><<a href="mailto:matej.tyc@gmail.com" target="_blank">matej.tyc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>Hello again, I have took another iteration and we still need your
help to proceed:<br>
</p>
<br>
<div class="m_-3378700745088093681moz-cite-prefix">On 17.5.2017 14:37, Nathan Goldbaum
wrote:<br>
</div>
<blockquote type="cite">
<div><br>
<div class="gmail_quote">...
<div><div class="h5"><div><br>
</div>
<div>You will be using a VolumeSource in that case, not a
MeshSource. There will still be a source to be rendered
though.</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">Would be the following
snippet OK if I implement the MyCustomTF correctly?<br>
<br>
import scipy as sp<br>
import yt<br>
import yt.visualization.volume_<wbr>rendering.api as vr_api<br>
<br>
trans = sp.rand(20, 40, 40)<br>
color = sp.rand(20, 40, 40)<br>
<br>
ds = yt.load_uniform_grid(dict(<wbr>color=color, trans=trans),<br>
color.shape)<br>
<br>
scene = vr_api.Scene()<br>
<br>
source = vr_api.VolumeSource(ds.all_<wbr>data(), ["color",
"trans"])<br>
source.log_field = False<br>
source.transfer_function = MyCustomTF(...)<br>
scene.add_source(source)<br>
<br>
scene.add_camera()<br>
scene.save('render.png')</div>
</blockquote>
<div><br>
</div>
<div>In principle yes.</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"><br>
<blockquote type="cite">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>You are right that each source only renders a
single field. If you want to render more than
one field you will need to create multiple
sources.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If I am wrong
and it is meaningful and possible to construct a
source<br>
with multiple fields, could you please provide
an example?<br>
</blockquote>
<div><br>
</div>
<div>Here's an example:</div>
<div><br>
</div>
<div><a href="https://github.com/yt-project/yt/blob/master/doc/source/cookbook/render_two_fields.py" target="_blank">https://github.com/yt-project/<wbr>yt/blob/master/doc/source/<wbr>cookbook/render_two_fields.py</a><br>
</div>
<div><br>
</div>
<div>That said, this is simply compositing two
separate volume renderings together. A bivariate
transfer function is a bit more complex than
this.</div>
</div>
</div>
</div>
</blockquote>
</div>
<div text="#000000" bgcolor="#FFFFFF"> Transfer function is
a property of a volume source, isn't it? So if one source
means one field, then how can a transfer function access
multiple fields? At least PlanckTransferFunction uses
multiple fields.<br>
</div>
</blockquote>
</div></div></div>
</div>
</blockquote><div><div class="h5">
<blockquote type="cite">
<div>
<div class="gmail_quote">
<div>Good point. You may need to relax that assumption.</div>
</div>
</div>
</blockquote></div></div>
What do you mean by "relaxing that assumption"? Am I wrong when I
think that the transfer function needs to use multiple fields?<br>
Regarding the volume source, I have examined the source code
<a class="m_-3378700745088093681moz-txt-link-freetext" href="https://github.com/yt-project/yt/blob/master/yt/visualization/volume_rendering/render_source.py#L160" target="_blank">https://github.com/yt-project/<wbr>yt/blob/master/yt/<wbr>visualization/volume_<wbr>rendering/render_source.py#<wbr>L160</a>
and although I can pass a dataset with a list of fields, the
__init__ method completely forgets that there is more than one
fields involved.<br></div></blockquote><div><br></div><div>I mean that code modifications will need to happen. The behaviors you are describing will need to be changed to get the multivariate transfer function working once again with the current volume rendering interface.</div><div><br></div><div>It might even make sense to leave VolumeSource alone and instead create a new MultiVariateVolumeSource to handle multivariate volume renderings.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
<br>
I have tried to fiddle with the ColorTransferFunction by making my
own CTF and changing all the field IDs in the code from 0 to 1 (see
<a class="m_-3378700745088093681moz-txt-link-freetext" href="https://github.com/yt-project/yt/blob/master/yt/visualization/volume_rendering/transfer_functions.py#L393" target="_blank">https://github.com/yt-project/<wbr>yt/blob/master/yt/<wbr>visualization/volume_<wbr>rendering/transfer_functions.<wbr>py#L393</a>),
but although I have assigned the CTF to a supposedly two-field
source, nothing came out (as opposed to the case when field IDs were
flipped back to 0).</div></blockquote><div><br></div><div>Unfortunately I don't know the details of how the color transfer function is implemented to give you educated advice here. I think you're going to need to poke at it with a debugger.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><span class=""><br>
<br>
<blockquote type="cite">
<div>
<div class="gmail_quote">
<div text="#000000" bgcolor="#FFFFFF">
<blockquote type="cite">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> 2. I have no
doubts that transfer functions work, but I was
unable to<br>
find out how are they involved in the integration
process. What I came<br>
across were the integration routines and they have
mentioned that the<br>
transfer function is not used:<br>
<a href="https://github.com/yt-project/yt/blob/master/yt/utilities/lib/ray_integrators.pyx#L235" rel="noreferrer" target="_blank">https://github.com/yt-project/<wbr>yt/blob/master/yt/utilities/<wbr>lib/ray_integrators.pyx#L235</a><br>
. This is really interesting, how is it in
reality?<br>
</blockquote>
<div><br>
</div>
<div>I believe the low-level routine you want to
look at in is yt/utlities/lib/image_<wbr>samplers.pyx,
in particular the VolumeRenderSampler. The
PlaneVoxelIntegration class you linked to here is
experimental code that is not used elsewhere in
yt.</div>
</div>
</div>
</div>
</blockquote>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"> okay, I am happy
about this as the code was extremely hard to read. This
one is somehow easier, although the code still doesn't
reveal much intent and names of variables are difficult to
understand for an outsider. Anyway, I will proceed and if
I manage to understand it, I may be able to come up with
some proposals.</div>
</blockquote>
<div><br>
</div>
<div>Feel free to ask questions as you have them.</div>
</div>
</div>
</blockquote></span>
I see, it is VolumeRenderSampler.sample and ImageSampler.__call__,
walk_volume etc. There is some very impressive functionality in
there, but I would have to study that for weeks just to get to some
level of understanding, which I can't do. So I hope that we will be
able to achieve this multimodal visualization without understanding
those masterful, but also quite sophisticated low-level routines.<br></div></blockquote><div><br></div><div>To get this to work you might need to come back to these low-level routines, in particular to figure out how the transfer function is expressed at this level.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
<br>
</div>
<br>______________________________<wbr>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/<wbr>listinfo.cgi/yt-users-<wbr>spacepope.org</a><br>
<br></blockquote></div><br></div></div>