View3D plugin to view/modify 3D mesh with the current image as texture

I converted all the heavy bits to C and it seems to work. I need to test it further before making a new release since writing native code can be easier to introduce bugs, but if nothing else it is much faster - to the point where i didn’t bother reimplementing progress bars for the triplanar paste and gradient commands since they’re applied instantly.

I’ve also added a new feature to force the colors of a texture be part of a palette - most likely very few will care about this, unless you do (very) retro gamedev (the palette in the video is from a game i made 4 years ago for an MSDOS game jam) or want to make models for Quake or Half-Life:

This was completely impossible with pure Python.

4 Likes

And another small feature (you probably need to view the image in full size to see it):

Visualizing the current selection on the model (this can be toggled - and is off by default - from the popup menu).

4 Likes

You can, though it is a little awkward:

  • Select whatever you want to save as a mask
  • From “Select” check “Show Global Selection Mask”, it will cause a “Selection Mask” layer to appear in the layers docker
  • Right click on the layer and duplicate it and hide the new layer to avoid cluttering the view
  • Repeat for any masks you want to save
  • Uncheck “Show Global Selection Mask” after you are done (at least if you find the selection layer appearing and disappearing annoying :-P)

To “load” the mask, right click on the saved layer and select “Select Opaque (Replace)”. You can also add a group layer and drag+drop the masks in there.

Note that there is a bug (at least with my Krita) where the cloned/duplicated layer keeps the name “Selection Layer” but the actual selection layer is renamed to “Copy of Selection Layer” - it is easy to see if the bug is there, just modify the selection and check which layer changes. I think the selection layer (not the copy) is always meant to be at the top so perhaps this is what causes it.

1 Like

Uploaded a new version, 20240313, which uses the new C library. Functionality-wise it is mostly the same as the previous one except much faster. I also added the selection visualization and the direction gradient generation i mentioned above. Here is the full changelog:

  1. Converted various CPU intensive tasks from Python to a separate C library for a huge speedup

  2. Added an option to visualize the current selection on the model

  3. Replaced “snapshots” with “texture modifiers” that show the texture scaled in realtime

  4. Added a “texture modifier” for forcing the colors of the texture to adhere to a specified palette (even after scaling)

  5. Added a “direction” gradient mode for generating gradients based on a reference direction (the camera or a cardinal direction)

  6. Added internal “cube” and “plane” meshes

  7. Added a check to avoid “zooming past” the model

  8. Added mouse wheel support for zooming in/out

  9. Now the plugin tries to fail more gracefully when OpenGL initialization fails

  10. Fixed more potential Qt leaks

I’ve only done minimal testing for the Windows version under Wine, so tell me if it works or not.

2 Likes

Started experimenting with shaders to add bump mapping (notice the belt). A bunch of things are hardcoded right now and it uses the same image for both texture and bump map, which isn’t very useful (i’ll need to rework some things to be able to use two different images), but i think this will be usable for simple bumps.

2 Likes

Some more progress, i made it so that different documents can be assigned as different textures. They need to be the same size as the “primary” image (i.e. the color/diffuse/albedo/whatever-you-want-to-call-it) and you can use the same image for both if you feel like it.

In the shot above i used triplanar paste to “wrap” a tiled texture around the bucket, made a clone of the image, converted it to grayscale and set it as a bump map. Then using the backprojection (and after disabling shading) i drew a red stroke on the color texture. After that i drag+dropped the newly painted layer to the bump map image, made it grayscale and inverted the colors (so it is bright) and used additive blending for the layer so that the stroke appears as paint that is layered on top of whatever bumps are below it.

2 Likes

Pardon me for asking silly question. Can the 3D rendering ability be ported to Krita core and can we use it to create a 3D mannequin type of feature or is blender required for this?

1 Like

No I do not mean 3D modelling, rigging, or skinning capabilities. I mean just importing and manipulating pre rigged poses inside krita on canvas for reference and drawing help.

There is a feature request for this see here - Digital doll/puppet model - #6 by AhabGreybeard

And also check out similar feature in Clip Studio paint - https://tips.clip-studio.com/en-us/articles/6949

There is also a plugin for Krita for this here - Plugin: Blender Layer - Live 3d View in Krita

Well, i would do ‘2.5D’ the oldschool way of taking some screenshots of my model and then painting over those. That being said, those still look useful indeed.

These features are waaay outside the scope of View3D - and just adding loading a skeletal model and moving bones around will be more than the entire C and Python code combined :-P. You’d need a dedicated plugin for this task.

The closest you can do with View3D is something like this:

…by using “Images → Create Texture Coordinate Mask”, the “Similar Color Selection Tool” to select all white areas in the newly created layer, “Select → Border Selection” from the Krita menu to select the selection’s borders for a few pixels, fill it with black color, “Images → Create Texture Coordinate Wireframe”, lower the opacity to something around 25%-30%, “Images → Create Image from View” and delete all layers except “Render”. Then drag and drop the layer to the image you want.

But you’d need to do and export the pose elsewhere. And you need to make sure each individual part you want to have lines for has its own texture coordinate “island”.

The “Blender Layer” plugin sounds like a much better existing solution - especially since with View3D you’d need Blender to do the pose (or convert the JTF file from another program if you are not using Blender) anyway.

I think we could totally implement a “3D model layer”, just like the paint or vector layers. It could be dead simple initially, and then extended with more features.

There’s value in having it built-in and not dependent on plugins or Blender being installed alongside. However, it is a pretty deep subject with many decisions to make along the way.

Given the required developer resources, it may be better in the interim to just provide support and optimizations for the plugins we have today.

@raghukamath not sure why deleting that comment was needed it seemed like a legit and correct response to what was asked. Also Qt5 can render 3d even on the current version it is just easier on Qt6 reason why I was so excited for the change to happen. However posing the character is not possible without making Krita into a 3d animation sort of app or maybe it is easier than I think and I don’t know ( I did not explore the 3d modules on Qt6 )

Those links are just about how to cheat making 2D illustrations by using 3d models by Tracing over them.

This plugin actually helps with the process of creation of 3D models by making textures using Krita and not just copy 3d sculpts. The Krita brushes are really good so making textures with them makes a lot of sense as they will look cooler and more stylish too.

Also I should make abundantly clear that creating textures is within Krita’s stated goals. How Krita decides to go about it though is another story. But this has been stated by Krita for a long while and is still present in the manual. Also the wrap around mode which is to create seamless textures is literally one of the top selling points for Krita in the front page.

If Krita is able to like have a layer and you can somehow project paint to a static mesh that you could rotate it will be already super amazing for texture creation.

1 Like

Yeah, being a core feature of Krita with dedicated layer type would be the best as it’d allow for things like selecting and manipulating models/parts/etc directly on the canvas. In terms of being able to display a model in a layer it is already possible via plugins by doing the rendering in an offscreen OpenGL buffer and transferring the bytes to a paint layer but the UX for the rest of it would be subpar.

Oh I did not delete it. I just clarified what I asked earlier. The user deleted their account along with the comments I do not know why.

1 Like

:man_facepalming:
It would have been better to ask our administration team to change your username, which is easily possible here and will be gladly granted.
By deleting your posts, you have broken the contextual links wherever replies have referred to your posts. That’s an unkind way of dealing with others.

@AhabGreybeard, @raghukamath, @sooz, can you possibly restore the deleted posts and topics of @s…tion with the new username @TangoInfiltrator?
Or would that be too much work?

Michelist

As a moderator, it seems that I can only see small and superficial details of deleted accounts and I have no idea how to allocate deleted account content to another user.
Only @raghukamath would have any idea if that was possible.

I would suggest that @TangoInfiltrator repeats their content and tries hard not to do anything like this again, unless they really want to leave.
If they do want to leave, please contact the moderators about it so that a tidy exit can be arranged.

2 Likes

I’ve Undeleted the last reply but it seems strange?
Also, there are more of them. I think @raghukamath should make a decision about this situation.

2 Likes

That is a reason why users should read the rules and regulations which they agree to observe in the course of their registration. Here it even can be found in the much shorter FAQ, so to say forum guidelines and terms of service in short:

Michelist

Unless I missed something, those were your posts here, in this topic, in chronological order:

[Krita Artists] [Resources/Plugins] View3D plugin to view/modify 3D mesh with the current image as texture

Yes, the objective is one behemoth. Thanks for peeling back the curtain on the official plans for the 3D painter as i didn’t know about that.

Have you considered writing interoperable scripts for Blender and Krita where they could be utilized to their strengths? Baking in Blender and porting the files across and maybe plugging them into your shading network—if you go that route.
from 8th March 12.00

####################
It’s just that, in general, these things can be interesting to think about.
from 8th March 12.20

####################
Kung Fury - Favorite Scenes - Hackerman
from 9th March 9.27

####################
Thanks a bunch, that is just what i was looking for.
from 12th 19.11

####################
Venturing out to say that providing 3D modeling, rigging, and skinning capabilities for a poseable figure falls outside the scope of Krita.

Blender gives you much more breadth in terms of what it already gives you out of the box.
from 14th 8.16

Michelist

In
[Krita Artists] [Artwork/Finished Artworks] Orc Live Practice
you wrote:
For the HORDE!
from 08th March 13:29

You’re right, now that you mention it, there was another post missing. It seems to me that I must have set the filter too narrow.

Michelist