Page MenuHome

Export UV Layout: Update png export to use offscreen rendering
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Nov 5 2018, 5:15 PM.

Details

Summary

Previously the exporter built a scene for eevee which felt a bit overkill. The code is much nicer now and has the same functionality.
My main intention here was to learn how to use offscreen rendering with the new gpu api though.

Diff Detail

Repository
rBA Blender Add-ons
Branch
export_uv_offscreen
Build Status
Buildable 2397
Build 2397: arc lint + arc unit

Event Timeline

io_mesh_uv_layout/export_uv_png.py
146

I don't really like the idea of compiling and keeping shaders in the global scope.
They are created whenever the module is imported (which in most cases occurs when Blender is opened) and will rarely be used.
Could you do this in the register function?
In this case however I think it would be best to use the builtin shaders.
If the problem are the matrices, you can use the gpu.matrix module.

with gpu.matrix.push_pop():
    mat = Matrix.Identity(4)
    gpu.matrix.load_matrix(mat)
    gpu.matrix.load_projection_matrix(mat)
    """draw things"""
io_mesh_uv_layout/export_uv_png.py
146

This module is only loaded when it is actually needed. So compiling the shader at module level is fine.

Yes, took me a while to figure out that I could use the gpu.matrix module... First I tried to set the matrix using uniform_float.
I did not use the builtin shader yet because I liked that I could just offset the vertices in the shader. However I just noticed that I could just use a matrix to move the uv coordinates to the right place. ^^

  • use builtin shaders
This revision is now accepted and ready to land.Nov 14 2018, 2:35 AM
This revision was automatically updated to reflect the committed changes.