<commit_before>﻿/**
Copyright 2014-2016 <NAME> and Associates

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**/

using ccl;
using ccl.ShaderNodes;
using Rhino.Display;
using RhinoCyclesCore.Materials;

namespace RhinoCyclesCore.Shaders
{
	public class RhinoBackground : RhinoShader
	{
		readonly BackgroundNode m_background = new BackgroundNode("m_shader bg");

		readonly BackgroundNode m_sky_bg = new BackgroundNode("sky bg");
		readonly BackgroundNode m_refl_bg = new BackgroundNode("refl bg");

		readonly LightPathNode m_lightpath = new LightPathNode("lightpath");
		readonly MixClosureNode m_mix_skylightswitch = new MixClosureNode("mix_skylightswitch");
		readonly MixClosureNode m_mix_bg_and_refl = new MixClosureNode("mix_bg_and_refl");
		readonly MathNode m_max = new MathNode("max") { Operation = MathNode.Operations.Maximum };
		// normal gradient texture (linear) has gradient from left to right
		// We want that to go along the window
		readonly TextureCoordinateNode m_texture_coordinates = new TextureCoordinateNode("texture_coordinates");
		// the mapping node should rotate the texture coordinate input 90 around
		// texture z axis (we're looking onto it)
		readonly MappingNode m_mapping = new MappingNode("mapping")
		{
			Mapping = MappingNode.MappingType.Texture,
			Translation = RenderEngine.CreateFloat4(0.0, 0.0, 0.0),
			Scale = RenderEngine.CreateFloat4(1.0, 1.0, 1.0),
			Rotation = RenderEngine.CreateFloat4(0.0, 0.0, 1.570796),
		};

		// the actual gradient node, used as factor for color ramp node
		readonly GradientTextureNode m_gradient = new GradientTextureNode { Gradient = GradientTextureNode.GradientType.Linear };

		// Add color ramp. Color stop on 1.0 is bottom color,
		// color stop on 0.0 is top color
		readonly ColorRampNode m_colorramp = new ColorRampNode();

		readonly EnvironmentTextureNode m_bg_env_texture = new EnvironmentTextureNode { ColorSpace = TextureNode.TextureColorSpace.None, IsLinear = false };
		readonly EnvironmentTextureNode m_refl_env_texture = new EnvironmentTextureNode { ColorSpace = TextureNode.TextureColorSpace.None, IsLinear = false };
		readonly EnvironmentTextureNode m_sky_env_texture = new EnvironmentTextureNode { ColorSpace = TextureNode.TextureColorSpace.None, IsLinear = false };

		public RhinoBackground(Client client, CyclesBackground intermediate, Shader existing) : this(client, intermediate, existing, "background")
		{
		}

		public RhinoBackground(Client client, CyclesBackground intermediate, Shader existing, string name) : base(client, intermediate)
		{
			if (existing != null)
			{
				m_shader = existing;
				m_shader.Recreate();
			}
			else
			{
				m_shader = new Shader(m_client, Shader.ShaderType.World)
				{
					UseMis = true,
					UseTransparentShadow = true,
					HeterogeneousVolume = false,
					Name = name<commit_msg>Explicitly use Cubic interpolation for background environment.<commit_after>﻿/**
Copyright 2014-2016 <NAME> and Associates

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**/

using ccl;
using ccl.ShaderNodes;
using Rhino.Display;
using RhinoCyclesCore.Materials;

namespace RhinoCyclesCore.Shaders
{
	public class RhinoBackground : RhinoShader
	{
		readonly BackgroundNode m_background = new BackgroundNode("m_shader bg");

		readonly BackgroundNode m_sky_bg = new BackgroundNode("sky bg");
		readonly BackgroundNode m_refl_bg = new BackgroundNode("refl bg");

		readonly LightPathNode m_lightpath = new LightPathNode("lightpath");
		readonly MixClosureNode m_mix_skylightswitch = new MixClosureNode("mix_skylightswitch");
		readonly MixClosureNode m_mix_bg_and_refl = new MixClosureNode("mix_bg_and_refl");
		readonly MathNode m_max = new MathNode("max") { Operation = MathNode.Operations.Maximum };
		// normal gradient texture (linear) has gradient from left to right
		// We want that to go along the window
		readonly TextureCoordinateNode m_texture_coordinates = new TextureCoordinateNode("texture_coordinates");
		// the mapping node should rotate the texture coordinate input 90 around
		// texture z axis (we're looking onto it)
		readonly MappingNode m_mapping = new MappingNode("mapping")
		{
			Mapping = MappingNode.MappingType.Texture,
			Translation = RenderEngine.CreateFloat4(0.0, 0.0, 0.0),
			Scale = RenderEngine.CreateFloat4(1.0, 1.0, 1.0),
			Rotation = RenderEngine.CreateFloat4(0.0, 0.0, 1.570796),
		};

		// the actual gradient node, used as factor for color ramp node
		readonly GradientTextureNode m_gradient = new GradientTextureNode { Gradient = GradientTextureNode.GradientType.Linear };

		// Add color ramp. Color stop on 1.0 is bottom color,
		// color stop on 0.0 is top color
		readonly ColorRampNode m_colorramp = new ColorRampNode();

		readonly EnvironmentTextureNode m_bg_env_texture = new EnvironmentTextureNode { ColorSpace = TextureNode.TextureColorSpace.None, IsLinear = false, Interpolation = InterpolationType.Cubic };
		readonly EnvironmentTextureNode m_refl_env_texture = new EnvironmentTextureNode { ColorSpace = TextureNode.TextureColorSpace.None, IsLinear = false };
		readonly EnvironmentTextureNode m_sky_env_texture = new EnvironmentTextureNode { ColorSpace = TextureNode.TextureColorSpace.None, IsLinear = false };

		public RhinoBackground(Client client, CyclesBackground intermediate, Shader existing) : this(client, intermediate, existing, "background")
		{
		}

		public RhinoBackground(Client client, CyclesBackground intermediate, Shader existing, string name) : base(client, intermediate)
		{
			if (existing != null)
			{
				m_shader = existing;
				m_shader.Recreate();
			}
			else
			{
				m_shader = new Shader(m_client, Shader.ShaderType.World)
				{
					UseMis = true,
					UseTransparentShadow = true,
					HeterogeneousVolume = false,
					Name = name
{'fraction_non_alphanumeric': 0.07694601849090367, 'fraction_numerical': 0.0131225767968983, 'mean_word_length': 4.8627622377622375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2069352', 'n_tokens_mistral': 2122, 'n_tokens_neox': 1872, 'n_words': 619}