Home 3D Art Showcase & Critiques

Custom Toolbag3 Shader - Triplanar Projection (6-sided Implementation)

polycounter lvl 12
Offline / Send Message
supaclueless polycounter lvl 12


https://gum.co/AXfVz  

2 months after posting the preview of the shader in the tech forums, it is finally available for everyone to use! (and laugh at the code)

This shader is designed to allow meshes inside Marmoset Toolbag 3 to use Triplanar Projection mapping so that you can map textures to objects that do not have or have incorrect UV mappings.

It is free of charge but if you would like to tip me it would be greatly appreciated!
I would definitely recommend people to read the README if you are confused with what each parameter does for the shader.

The biggest issue that I have yet to solve for the shader at the moment is that the shader does not really work with the use of screen-space effects like SSAO, SSR, and GI (there are weird ghosting artifacts but the mesh could "sort of" work with them depending on the material type / angle, but it won't be 100% accurate).

Leave any feedback / bug reports / comments here!

PS: sorry for the late release of the shader. I have been busy in the last few months and was moving to a different country and only recently got *cough* amazing internet *cough*.

Replies

  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    Good job dude! you might get more people downloading if you put this in showcase though.
  • supaclueless
    Offline / Send Message
    supaclueless polycounter lvl 12
    I was not sure if that would be the correct place for this type of topic but I definitely get what you mean. If a mod thinks that it is fine than it would be nice if this thread gets moved to showcase. :)
  • Ged
    Offline / Send Message
    Ged interpolator
    nice work, I will have to give it a try sometime, its really fun taking stuff straight from zbrush into toolbag :)
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    I was not sure if that would be the correct place for this type of topic but I definitely get what you mean. If a mod thinks that it is fine than it would be nice if this thread gets moved to showcase. :)
    I think a lot more artists will see it there, and ultimately this is to benefit them. I'd poke @Eric Chadwick to see if he'll move it =]
  • cromadbomber
    Offline / Send Message
    cromadbomber polycounter lvl 10
    I haven't tried this yet. But is it possible to place decals(Like text, logos, etc)? Would be nice for highpoly hardsurface shots.
  • EarthQuake
    Hey this is really cool! I moved the thread btw.

    I've got some notes:
    • It would be cool if you supported specular as well as metalness, There is a compile error when I try to use that model and the material goes invisible. Looks like this is on your todo.
    • Looks like there is a bug with the IBL, as I rotate the sky (shift+drag) the projection shifts.
    • If I rotate the mesh the projection shifts too. While sort of neat to see, I would say the tri-planar mapping should take the initial transforms and ignore any additional transforms the user adds in Toolbag. This would mean you could do triplanar materials but still be able to do things like animation the mesh. This might be what you're talking about on your todo list?
    • The scale doesn't seem to make much sense, with an object scaled to real world units I have to enter a UV-tile value of about 5000. The scale settings in the scene object properties change the relative nature of texture scale quite a bit, so that might be something you need to account for. I was using Scene: Meters and Imported: CM when I needed to use 5000. If I set both to CM I can use 50, which is outside the shader max of 10.
    • It seems to work with SSR, GI, and SSAO here, but I'm not sure what exactly is wrong with it on your end.
    Here's a render I made with the shader, Highpoly Model, no uvs!



    I look forward to seeing this progress. If you want more feedback, post in the Toolbag Usergroup: https://www.facebook.com/groups/ToolbagUserGroup/

  • supaclueless
    Offline / Send Message
    supaclueless polycounter lvl 12
    @cromadbomber It should work assuming you can deal with the rotating textures issue right now.

    @EarthQuake Thanks for pointing out those bugs/issues! I forgot to write them on my first post.

    I definitely plan to add specular maps to be working soon as I know many people use that, I only added metalness because it worked first for me.

    In regards to the skybox rotating with the textures, my theory was that when you rotate the skybox inside marmoset, what is defined as the XYZ axis gets rotated with it so the world space coordinates get rotated in the matrix? (a very basic guessing at whats going on).
    I definitely would like to have the textures be "baked" into the local bounds of the meshes which could ALSO potentially fix the issue of the skybox rotating the textures when you rotate it around as well (2 bird 1 stone). I just need to study up more on how it would work as the tutorial I followed to implement TPP was done inside UE4 but I have to see how this would work in shader code. Having local bound TPP textures is what I am truly aiming for as right now its definitely usable as you said but its not really that great if the textures keep moving when you move the mesh around.

    I also do plan to redo the scaling parameter as I realized it does not make any sense to users. I initially added it just for convenience because my textures were offsetting too slowly for some test meshes I was using.

    Also here is a pic of the "ghosting" caused by SS effects inside Marmoset. Notice the weird "occlusion" on the leaves and how they don't match with the normals coming from the leaves. If you use the toolbag3 leaf/coal material preset, you will see the ghosting move as you move the camera as well (bound to camera screen space).
     It really is a weird issue because SS effects STILL properly render out onto the mesh but there is this appended render that is causing all this gunk. I have some basic idea of where the problem is originating from but as of now I do not have a solution to it due to my lack of my tech artist experience (disabling normals fixes this weird ghosting). :s


  • supaclueless
    Offline / Send Message
    supaclueless polycounter lvl 12
    I'm just wondering if anyone with better experience than me has an idea of how you can grab information from the vertex shader to fragstate inside toolbag? I've been trying to tackle the texture swimming issue but I am currently struggling to try and get information like the objects position or transforming the vector to a different reference plane.
  • almighty_gir
    Offline / Send Message
    almighty_gir ngon master
    i'm pretty sure s.vertexPosition gives you the vertex position.

    from state.frag:
    vec3 vertexPosition;
    vec3 vertexEye;
    float vertexEyeDistance;
    vec2 vertexTexCoord;
    vec2 vertexTexCoordSecondary;
    vec4 vertexColor;
    vec3 vertexNormal;
    vec3 vertexTangent;
    vec3 vertexBitangent;

    I'm pretty sure these are the only vertex shader components you have access to. You're unlikely to be able to access the object transform directly within the shader. 
  • supaclueless
    Offline / Send Message
    supaclueless polycounter lvl 12
    there are multiple ways to "solve" texture swimming. I was trying to subtract the vertex position from the objects relative position (s.position from vertex shader) so that you offset the texture with the mesh (move the textures along with the mesh) but I have no idea if its even possible to access data from the vertex shader in frag (trying semantics and GLSL globals doesn't seem to work or I have no idea on how to properly write them to work in the custom shader. Looking through other marmoset frag/vert files, it looks like you can't have global inout data while altering the shader subroutine).

    A more robust solution would be to transform the vectors to a local coordinates which might be my current solution milestone but I have no idea on how to properly execute the math for it.
  • supaclueless
    Offline / Send Message
    supaclueless polycounter lvl 12
    With the recent beta release of 3.04 for toolbag, I managed to fix a bunch of issues and bugs (BIG shoutout to Jeff Russell for helping here!) and now have the projection in object space (no more swimming). This means that the mesh can be moved,rotated,scaled with the texture following the mesh.

    I was hoping it would ALSO work with actual animations coming from the vertex but that one is an entirely different beast of its own that would be nice to have working but not right now.

    I also got a specular implementation working by making a triplanar shader that accepts specular maps. So now you just have to switch between specular and metalness TPP shader based on your material setup.

    Hopefully will get a release soon, I just have a couple of bugs to iron out. After this next release, the older version will be depreciated as 3.03 will be missing key functions to allow the new system to work so only 3.04 will be running the new TPP shader.
  • supaclueless
    Offline / Send Message
    supaclueless polycounter lvl 12
    I've kind of hit a wall for fixing this bug so I might as well ask as well as other places but does anyone know if using this logic seems to be the correct approach towards regenerating tangents and bitangents for triplanar projection?:

    (pseudo code)

    T = cross(vertexNormal, vec3(0.0,sign(vertexNormal),0.0)) * (angle direction blend)
    B = cross(N,T)

    Any help would be greatly appreciated if it allows me to get this thing published for a proper update to the shader at this point.

  • supaclueless
    Offline / Send Message
    supaclueless polycounter lvl 12
    Finally, After months of delays and pushing off the release. I have decided to release 1.1 of my TPP shader to the public. Unfortunately, I was not able to fix the normal map issue for the time being. It would be nice and I hope that at some point in future this will be addressed but not for the foreseeable moment.

    This new update makes it work properly in 3.04 (it broke in the newest version) and also makes ALL OLDER VERSIONS OF MARMOSET depreciated as I am utilizing new functions that were added in this new version (BIG SHOUTOUT TO Jeff Russel and all involved in the Toolbag Team!!!).

    I also gave a hopefully better texture unit scaling system to how scaling works but I might redo it again if it's not user friendly to others. For now, the 0-1 UV space will occupy 1cm which is my baseline unit (based on how marmoset generates their primitives and sets their UV scale). The offset world scale is now changed to "CM Unit Divisor", where increasing it will make a 0-1 Texture space space take up a larger amount of unit space. (IE: increasing the divisor to 2 will make a single wrap of a texture need a 1x1m to represent the entire single texture in 0-1 space)

    Big features added in this update: specular support (in seperate shader), local transform (now the standard - move,rotate,scale works) (unfortunately vertex animations do not), and fixes to old SS effects.

    You can now also choose to have 3-sided or 6-sided projection based on your needs (3 sided if you want near seamless textures even when rotating the mesh around with the skybox) - (6 sided if you want to have unmirrored UVs to be able to read text from the back face)

    Once again, I updated the read-me so hopefully any necessary information can be found there.

    https://gumroad.com/products/AXfVz

    Thank you for reading the wall of text and happy custom shader usage! :
  • EarthQuake
    @supaclueless thanks for the new release!

    I'm having a problem here though, when I adjust the UV-Tile setting, it only adjust for certain areas of the material, it looks like it's only adjusting it for the front facing plane projection but not for the other planes, so the texture no longer lines up/there is a vast discrepancy in tiling/resolution.


  • supaclueless
    Offline / Send Message
    supaclueless polycounter lvl 12
    SO bringing this back from the dead.... Someone messaged me that the shader no longer worked and decided to fix it up. Version 1.2 of the shader now works on 3.05-3.06 of toolbag.

    https://gumroad.com/products/AXfVz

    @EarthQuake I apologize for not responding to your post until over half a year later as for some reason Polycount decided to eat your response and not give me any notification that this thread has a new post EVEN though I have the thread in my favorites. It might be a little late but that bug has been fixed (tiling the UV's per axis was causing this issue for some reason, had to tile the UV's in the world coordinate level to resolve this issue)
  • makkraid
    Wow, I think this shader is also work fine in Marmoset 4!

    Thank you this brilliant shader.
    Marmoset + this = another choice for ZBrush external renderer.
    I think why marmoset does not include this diamond in built-in feature.





Sign In or Register to comment.