Code Monkey home page Code Monkey logo

grid-shader-unity's Introduction

Grid Shader

A Grid Shader for Unity !
It can scale infinitely (log10 scaling). Main lines will show a one to one grid for the current scale, while secondary lines show up secondary units.
It performs much better than relying on GL lines to draw a grid, has more customization possibilities and works in a lot more situations.

Plane Cube Thickness

How To

Download the .unitypackage in the Release tab (or checkout and copy the Assets/Plugins/GridShader folder to your Assets folder)

grid-shader-unity's People

Contributors

fyiuramron avatar ogxd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grid-shader-unity's Issues

small refactoring

I know it's arguable, but honestly I think that refactoring those

            pos.x = floor(frac((i.uv.x - 0.5 * _Thickness) * localScale) + _Thickness * localScale);
            pos.y = floor(frac((i.uv.y - 0.5 * _Thickness) * localScale) + _Thickness * localScale);
// ...
               pos.x = floor(frac((i.uv.x - 0.5 * _Thickness) * 10.0 * localScale) + _Thickness * 10.0 * localScale);
               pos.y = floor(frac((i.uv.y - 0.5 * _Thickness) * 10.0 * localScale) + _Thickness * 10.0 * localScale);

into a util method along the lines of

         float xform( float base, float scale ){
            return floor(frac((base - 0.5 * _Thickness) * scale) + _Thickness * scale);
         }

and then calling them like

            pos.x = xform(i.uv.x, localScale);
            pos.y = xform(i.uv.y, localScale);

// ...
               pos.x = xform(i.uv.x, 10.0 * localScale);
               pos.y = xform(i.uv.y, 10.0 * localScale);

would make the code cleaner, more readable and beginner-friendly.

(Obviously, I can do a PR if you prefer that instead of an issue ticket)

Consider renaming _BackgroundColor (or _MainColor) to _Color

as per https://docs.unity3d.com/ScriptReference/Material.SetColor.html , having the property name for the "main" color in the shader set to _Color makes it essentially the 'main' color as far as Unity internals are concerned, allowing easy access to it from code. Arguably, the background color is the main (dominant) color of the grid.

Alternatively, do that with _MainColor instead, if you consider it the 'main' color of this shader. Of course, the string descriptions for them can (and probably should) remain unchanged.

unused sampler

there's the

         sampler2D _GridTexture;
         float4 _GridTexture_ST;

sampler/texture, but it doesn't seem to be used anywhere. I assume this was intended to be implemented in some way, but currently (unless I'm missing something obvious here) I don't see it handled anywhere in the code, and it's neither set nor accessed anywhere.

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.