Coder Social home page Coder Social logo

habrador / unity-advanced-shaders-tutorial Goto Github PK

View Code? Open in Web Editor NEW
48.0 48.0 6.0 10.02 MB

Implementation of advanced shaders in Unity like raytracing, interior mapping, parallax mapping

Home Page: https://www.habrador.com/tutorials/shaders/

License: MIT License

GLSL 31.43% C# 12.61% ShaderLab 55.96%
death-star interior-mapping open-source parallax-mapping raytracing star-wars unity-shaders unity-tutorials unity3d

unity-advanced-shaders-tutorial's Issues

Parallax shader visual depth changes depending on view angle

Thank you for this great tutorial. I am new to shaders and it is really a huge help.
I played with the parallax shaders and discovered that their visual depth is changing depending on the view position. The sharper the view angle, the less deep they look.
My guess is that stepDistance should depend on view direction, actually we should travel along the ray the longer the sharper the view angle to reach imaginary intersection with next layer.
I added following modifications which seem to fix the issue:

  struct Input 
  {
	  //What Unity can give you
	  float2 uv_NoiseTex;
  
	  //What you have to calculate yourself
	  //The camera direction in tangent space
	  float3 tangentViewDir;
	  // cos of view direction to surface normal
	  float cos;
  };

in vert:
o.cos = -dot(normalize(worldViewDir), normalize(worldNormal));
and in surf:
float stepDistance = 0.01/ IN.cos;

I am not sure this is an optimal solution, so please review. Thank you again

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.