Giter Site home page Giter Site logo

jiangweiff / unity_sphericalharmonics_tools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pieroaccardi/unity_sphericalharmonics_tools

0.0 0.0 0.0 19.99 MB

Two tools for Unity to deal with spherical harmonics

C# 60.88% ShaderLab 35.07% HLSL 4.05%

unity_sphericalharmonics_tools's Introduction

Unity Spherical Harmonics Tools

Overview

In this project the are two tools: the first one takes an input cubemap and project into the spherical harmonic basis and print the first three bands (9 coefficients). It's possible to compute this projection with 3 different techniques:

  • On the CPU with uniform sampling, which means reading all the texels of the cubemap.
  • On the CPU with Monte Carlo sampling, which means less texture readings, more rapid but with an approximated result.
  • On the GPU with Monte Carlo sampling, with a result similar to the CPU one but faster.
  • On the GPU with uniform sampling, using a Compute Shader, this gives the accuracy of CPU uniform sampling with maximum speed. I Recommend using this.

Once the result is computed you can see it and toggle the original version and the projected one.

The second tool is a component to add on a game object; its purpose is to get all the game object's children and foreach of their vertices compute and project onto the SH basis the **Geometry Factor**. It won't change directly the objects meshes but will create a clone object to modify.

The Geometry Factor describes the visibility from the vertex (so 0 if the vertex is occluded or 1 if the vertex can see direclty the environment from direction v) multiplied with che cosine of the vertex normal with the direction v.

At the momenty Unity doesn't support custom vertex attributes so i had to put the 9 coefficients in the existing ones, organizing them in this way: first 4 coefficients in the vertex color rgba, the next 2 in the uv2, the next 2 in the uv3 and the last one in the x component of uv4. It's a temporary solution and i hope to find a better workaround.

unity_sphericalharmonics_tools's People

Contributors

pieroaccardi avatar 4rknova avatar

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.