ippdev
October 20, 2014, 3:04pm
1
Is there a method to create spherical environment maps on the fly so I can send them to the ShadowGun type shader I posted in my previous thread? Convolution of a cube map? Making a 180 x 360 degree fisheye lens for an environment mapping camera? Suggestions and discussion welcomed.
Check out some of this stuff I was dabbling with… might do what you need;
CubemapToEquirectangularWizard.cs
// Wizard to convert a cubemap to an equirectangular cubemap.
// Put this into an /Editor folder
// Run it from Tools > Cubemap to Equirectangular Map
using UnityEditor;
using UnityEngine;
using System.IO;
class CubemapToEquirectangularWizard : ScriptableWizard {
This file has been truncated. show original
EquirectangularAmbient.shader
// This shader samples the equirectangular map to get an ambient and a specular value from it.
Shader "Custom/Equirectangular/DynamicAmbient" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Diffuse (RGB) Alpha (A)", 2D) = "gray" {}
_SpecularTex ("Specular (R) Gloss (B) Fresnel (B)", 2D) = "gray" {}
_BumpMap ("Normal (Normal)", 2D) = "bump" {}
}
This file has been truncated. show original
cubemapToEquirectangular.shader
// This takes in the cubemap generated by your cubemap camera and feeds back out an equirectangular image.
// Create a new material and give it this shader. Then give that material to the "cubemapToEquirectangularMateral" property of the dynamicAmbient.js script in this gist.
// You could probably abstract this to C#/JS code and feed it in a pre-baked cubemap to sample and then spit out an equirectangular map if you don't have render textures.
Shader "Custom/cubemapToEquirectangular" {
Properties {
_MainTex ("Cubemap (RGB)", CUBE) = "" {}
}
Subshader {
This file has been truncated. show original
There are more than three files. show original
1 Like
ippdev
October 20, 2014, 5:27pm
3
Great work Farfarer. The whole nine yards! Thx for something for me to ponder and play with.