void Awake() { if (!componentUpdateReflectionTextures) { componentUpdateReflectionTextures = GameObject.Find("RealtimeReflections").GetComponent <UpdateReflectionTextures>(); } if (!componentUpdateReflectionTextures) { DaggerfallUnity.LogMessage("InjectReflectiveMaterialProperty: Could not locate UpdateReflectionTextures component.", true); if (Application.isEditor) { Debug.Break(); } else { Application.Quit(); } } StreamingWorld.OnInitWorld += InjectMaterialProperties; StreamingWorld.OnTeleportToCoordinates += InjectMaterialProperties; FloatingOrigin.OnPositionUpdate += InjectMaterialProperties; DaggerfallTerrain.OnInstantiateTerrain += InjectMaterialProperties; SaveLoadManager.OnLoad += OnLoadEvent; }
private void Awake() { componentUpdateReflectionTextures = GameObject.Find("RealtimeReflections").GetComponent <UpdateReflectionTextures>(); if (m_Camera == null) { m_Camera = this.gameObject.AddComponent <Camera>(); m_Camera.CopyFrom(Camera.main); m_Camera.renderingPath = RenderingPath.Forward; // important to make fragment shader work with function Camera.RenderWithShader() - it won't work in deferred, this is no problem since we only want to render a custom index rendertexture anyway m_Camera.enabled = false; // important to disable camera so we can invoke Camera.RenderWithShader() manually later } }
private void Awake() { componentUpdateReflectionTextures = GameObject.Find("RealtimeReflections").GetComponent <UpdateReflectionTextures>(); if (m_Camera == null) { m_Camera = this.gameObject.AddComponent <Camera>(); m_Camera.CopyFrom(Camera.main); m_Camera.RemoveAllCommandBuffers(); m_Camera.renderingPath = RenderingPath.Forward; // important to make fragment shader work with function Camera.RenderWithShader() - it won't work in deferred, this is no problem since we only want to render a custom index rendertexture anyway m_Camera.depthTextureMode = DepthTextureMode.None; m_Camera.clearFlags = CameraClearFlags.SolidColor; m_Camera.backgroundColor = new Color(0.0f, 0.0f, 0.0f, 1.0f); m_Camera.enabled = false; // important to disable camera so we can invoke Camera.RenderWithShader() manually later } //Shader.WarmupAllShaders(); }
public static void initMod() { //Debug.Log("init of ReflectionMod standalone"); gameobjectRealtimeReflections = new GameObject("RealtimeReflections"); componentUpdateReflectionTextures = gameobjectRealtimeReflections.AddComponent <UpdateReflectionTextures>(); componentUpdateReflectionTextures.FloorReflectionTextureWidth = floorReflectionTextureWidth; componentUpdateReflectionTextures.FloorReflectionTextureHeight = floorReflectionTextureHeight; componentUpdateReflectionTextures.LowerLevelReflectionTextureWidth = lowerLevelReflectionTextureWidth; componentUpdateReflectionTextures.LowerLevelReflectionTextureHeight = lowerLevelReflectionTextureHeight; componentUpdateReflectionTextures.RoughnessMultiplier = roughnessMultiplier; componentUpdateReflectionTextures.ShaderTilemapWithReflections = shaderTilemapWithReflections; componentUpdateReflectionTextures.ShaderTilemapTextureArrayWithReflections = shaderTilemapTextureArrayWithReflections; componentUpdateReflectionTextures.ShaderCreateLookupReflectionTextureCoordinates = shaderCreateLookupReflectionTextureCoordinates; componentUpdateReflectionTextures.ShaderCreateLookupReflectionTextureIndex = shaderCreateLookupReflectionTextureIndex; componentUpdateReflectionTextures.ShaderDeferredPlanarReflections = shaderDeferredPlanarReflections; componentUpdateReflectionTextures.TextureTileatlasReflective = textureTileatlasReflective; componentUpdateReflectionTextures.TextureTileatlasReflectiveRaining = textureTileatlasReflectiveRaining; }
public static void Init(InitParams initParams) { mod = initParams.Mod; gameobjectRealtimeReflections = new GameObject("RealtimeReflections"); componentUpdateReflectionTextures = gameobjectRealtimeReflections.AddComponent <UpdateReflectionTextures>(); ModSettings settings = mod.GetSettings(); shaderTilemapWithReflections = mod.GetAsset <Shader>("Shaders/DaggerfallTilemapWithReflections.shader"); shaderTilemapTextureArrayWithReflections = mod.GetAsset <Shader>("Shaders/DaggerfallTilemapTextureArrayWithReflections.shader"); shaderCreateLookupReflectionTextureCoordinates = mod.GetAsset <Shader>("Shaders/CreateLookupReflectionTextureCoordinates.shader"); shaderCreateLookupReflectionTextureIndex = mod.GetAsset <Shader>("Shaders/CreateLookupReflectionTextureIndex.shader"); shaderDeferredPlanarReflections = mod.GetAsset <Shader>("Shaders/DeferredPlanarReflections.shader"); shaderDungeonWaterWithReflections = mod.GetAsset <Shader>("Shaders/DungeonWaterWithReflections.shader"); shaderInvisible = mod.GetAsset <Shader>("Shaders/Invisible.shader"); textureTileatlasReflective = mod.GetAsset <Texture2D>("Resources/tileatlas_reflective"); textureTileatlasReflectiveRaining = mod.GetAsset <Texture2D>("Resources/tileatlas_reflective_raining"); componentUpdateReflectionTextures.IsEnabledOutdoorGroundReflections = settings.GetValue <bool>("GeneralSettings", "OutdoorGroundReflections"); componentUpdateReflectionTextures.IsEnabledOutdoorSeaReflections = settings.GetValue <bool>("GeneralSettings", "OutdoorSeaReflections"); componentUpdateReflectionTextures.IsEnabledIndoorBuildingFloorReflections = settings.GetValue <bool>("GeneralSettings", "IndoorBuildingFloorReflections"); componentUpdateReflectionTextures.IsEnabledIndoorBuildingLowerLevelReflection = settings.GetValue <bool>("GeneralSettings", "IndoorBuildingLowerLevelReflection"); componentUpdateReflectionTextures.IsEnabledDungeonGroundReflections = settings.GetValue <bool>("GeneralSettings", "DungeonGroundReflections"); componentUpdateReflectionTextures.IsEnabledDungeonWaterReflections = settings.GetValue <bool>("GeneralSettings", "DungeonWaterReflections"); componentUpdateReflectionTextures.IsFeatureEnabledFakeParallaxReflections = settings.GetValue <bool>("Features", "FakeParallaxReflections"); componentUpdateReflectionTextures.FloorReflectionTextureWidth = settings.GetValue <int>("FloorReflectionTexture", "width"); componentUpdateReflectionTextures.FloorReflectionTextureHeight = settings.GetValue <int>("FloorReflectionTexture", "height"); componentUpdateReflectionTextures.LowerLevelReflectionTextureWidth = settings.GetValue <int>("LowerLevelReflectionTexture", "width"); componentUpdateReflectionTextures.LowerLevelReflectionTextureHeight = settings.GetValue <int>("LowerLevelReflectionTexture", "height"); componentUpdateReflectionTextures.RoughnessMultiplier = settings.GetValue <float>("ReflectionParameters", "roughnessMultiplier"); componentUpdateReflectionTextures.ShaderTilemapWithReflections = shaderTilemapWithReflections; componentUpdateReflectionTextures.ShaderTilemapTextureArrayWithReflections = shaderTilemapTextureArrayWithReflections; componentUpdateReflectionTextures.ShaderCreateLookupReflectionTextureCoordinates = shaderCreateLookupReflectionTextureCoordinates; componentUpdateReflectionTextures.ShaderCreateLookupReflectionTextureIndex = shaderCreateLookupReflectionTextureIndex; componentUpdateReflectionTextures.ShaderDeferredPlanarReflections = shaderDeferredPlanarReflections; componentUpdateReflectionTextures.ShaderDungeonWaterWithReflections = shaderDungeonWaterWithReflections; componentUpdateReflectionTextures.ShaderInvisible = shaderInvisible; componentUpdateReflectionTextures.TextureTileatlasReflective = textureTileatlasReflective; componentUpdateReflectionTextures.TextureTileatlasReflectiveRaining = textureTileatlasReflectiveRaining; }
private void OnEnable() { //if (!RealtimeReflections.ImageEffectHelper.IsSupported(shader, false, true, this)) //{ // enabled = false; // return; //} camera_.depthTextureMode |= DepthTextureMode.Depth; kFinalReflectionTexture = Shader.PropertyToID("_FinalReflectionTexture"); kTempTexture = Shader.PropertyToID("_TempTexture"); GameObject goRealtimeReflections = GameObject.Find("RealtimeReflections"); componentUpdateReflectionTextures = goRealtimeReflections.GetComponent <UpdateReflectionTextures>(); goCreateReflectionLookupTextures = new GameObject("CreateReflectionLookupTextures"); goCreateReflectionLookupTextures.transform.SetParent(goRealtimeReflections.transform); componentCreateReflectionLookupTextures = goCreateReflectionLookupTextures.AddComponent <CreateReflectionLookupTextures>(); }