GithubHelp home page GithubHelp logo

Comments (4)

andybak avatar andybak commented on May 13, 2024 1

Not to preempt Keenan but it strikes me that Triplanar is the wrong tool for the job here. The behaviour you're complaining about is the defining character of a triplanar shader. That's what they do.

Instead you probably want to add a post-processing step after deform to assign UV coords in an approximation of how triplanar works (matching it exactly would be very tricky - you'd probably have to settle for seams at the triangle level)

from deform.

andybak avatar andybak commented on May 13, 2024 1

Using UV is not possible for us unfortunatly :/ we are thinking of a way to make it work (even partially) without UV.

In blender it is possible to solve this problem by using the Generated output of the Texture Coordinate node

https://docs.blender.org/manual/en/latest/render/shader_nodes/input/texture_coordinate.html

so is it possible to reproduce this node in Unity?

I guess the equivalent in Unity would be to store the worldspace coordinates BEFORE deform has been run and use those in the triplanar shader.

But you can't do it all in an actual Unity shader because by that point it's too late. You need to do some calculations in C# (or maybe a compute shader) prior to hitting the Unity material shader.

from deform.

usernameHed avatar usernameHed commented on May 13, 2024

Using UV is not possible for us unfortunatly :/ we are thinking of a way to make it work (even partially) without UV.

In blender it is possible to solve this problem by using the Generated output of the Texture Coordinate node

https://docs.blender.org/manual/en/latest/render/shader_nodes/input/texture_coordinate.html

so is it possible to reproduce this node in Unity?

from deform.

keenanwoodall avatar keenanwoodall commented on May 13, 2024

Thanks for hoppin in, @andybak - I agree. I would recommend storing the original/undeformed vertex position in the vertex color or a uv channel for use by your shader. You could write a tool to do this in your modeling program, or write some editor code in Unity to automate the process on import.

To test, here's a simple asset post processor I wrote that saves the object-space vertex position to the vertex color when a model is imported into Unity. (I would be hesitant to use this unmodified in a large project, just posting it in case it helps!)

public class VertexColorModelPostProcessor : AssetPostprocessor
{
    private void OnPostprocessModel(GameObject g)
    {
        var meshFilters = g.GetComponentsInChildren<MeshFilter>();
        foreach (var meshFilter in meshFilters)
        {
            CopyPositionToColorFor(meshFilter);
        }
    }

    private void CopyPositionToColorFor(MeshFilter mf)
    {
        Mesh mesh = mf.sharedMesh;
        Vector3[] vertices = mesh.vertices;
        Color[] colors = new Color[vertices.Length];

        for (int i = 0; i < vertices.Length; i++)
        {
            var v = vertices[i];
            colors[i] = new Color(v.x, v.y, v.z, 0f);
        }

        mesh.colors = colors;
    }
}

from deform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.