Code Monkey home page Code Monkey logo

Comments (3)

Wally869 avatar Wally869 commented on May 17, 2024

I took a quick look and it depends on the method used for billboarding.

  • When using the method outlined in this article (https://www.noveltech.dev/unity-lit-billboard-shadergraph/), it's trivial to implement.
    You can add a Vector3 property frozenAxis to your shadergraph, multiply object position by this vector3
    Then do one minus frozenAxis, multiply the billboard position by it.
    Finally add the two together for your position and feed it to the output node and you're done (basically lerping between basic and billboarded position).

The method outlined in the article also allows lit billboards so it's pretty nice, but it has the unfortunate side effect of reversing UVs so you need to handle it in your shadergraph.

from directionalspriteshader.

Wally869 avatar Wally869 commented on May 17, 2024

The method for billboarding in the implementation in the repo differs from the one I mentionned in the previous comment since it seems to more or less disregard the Y-axis. Instead rotation seems to be purely driven by x and z vertex position so you can't use the previous trick.

I'll try to find a solution and upload cleaned and up-to-date versions for the shaders.

from directionalspriteshader.

StatueTheShaman avatar StatueTheShaman commented on May 17, 2024

For billboarding with locked y I like the following script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Thank you! https://youtu.be/_LRZcmX_xw0
public class Billboard_Sprite : MonoBehaviour
{
private Camera theCam;

public bool useStaticBillboard; //This here prevents the twisting of the trees

// Start is called before the first frame update
void Start()
{
    theCam = Camera.main;
}

// Update is called once per frame
void LateUpdate()
{
    //transform.LookAt(theCam.transform); ((This here causes the trees to twist))

    if (!useStaticBillboard)
    {
        transform.LookAt(theCam.transform);
    } else
    {
        transform.rotation = theCam.transform.rotation;
    }


    transform.rotation = Quaternion.Euler(0f, transform.rotation.eulerAngles.y, 0f);
}

}

from directionalspriteshader.

Related Issues (2)

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.