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

polycounter lvl 6
Online / Send Message
supaclueless polycounter lvl 6


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
    Online / Send Message
    almighty_gir polycounter
    Good job dude! you might get more people downloading if you put this in showcase though.
  • supaclueless
    Online / Send Message
    supaclueless polycounter lvl 6
    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 polycounter lvl 10
    nice work, I will have to give it a try sometime, its really fun taking stuff straight from zbrush into toolbag :)
  • almighty_gir
    Online / Send Message
    almighty_gir polycounter
    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 4
    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
    Online / Send Message
    supaclueless polycounter lvl 6
    @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
    Online / Send Message
    supaclueless polycounter lvl 6
    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
    Online / Send Message
    almighty_gir polycounter
    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
    Online / Send Message
    supaclueless polycounter lvl 6
    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.
Sign In or Register to comment.