Hey guys, I've been working with shaders for a little bit now but I'm trying to do something a little odd. This talk (http://advances.realtimerendering.com/other/2016/naughty_dog/) from Naughty Dog mentioned something they did where they actually sampled the skybox to determine the color of their fog instead of just using a flat color on every object. I looked, and I couldn't find a macro that let me sample the skybox in the current unity scene in a fragment shader. Does anyone know how I might go about doing something like this, or maybe a clever workaround? Thanks!
1) you can feed skybox in shader as cubemap 2) you can setup reflection probe on camera and then pass it to shader for sampling (useful in case of procedural skybox)
Hadn't considered the cubemap idea - that could definitely work! The question is, can I set cubemaps globally the same way I set textures globally? I'd hate to have to run a script to apply this fog cubemap for every material in my scene.
https://docs.unity3d.com/ScriptReference/Shader.SetGlobalTexture.html SetGlobalTexture takes a "Texture" type, of which Texture2D, RenderTexture, and CubeMap (among a few others) are all based on.
Using "SetGlobalTexture" in a script to dynamically set skybox shader "samplerCUBE" to a cubemap variable doesn't seem to be working for me. I've made sure to remove those variables from the properties section of the shader, but still can't get it to set. E.g. this does not work for me: Code (CSharp): public Cubemap skyboxCubemap; void Start(){ Shader.SetGlobalTexture("_SkyboxCustomTex1", skyboxCubemap); } Will post an update if I solve this.