public void Sync()
        {
            bool needUpdate = false;

            if (transform.position != lastPositon)
            {
                lastPositon = transform.position;
                needUpdate  = true;
            }
            if (transform.rotation != lastRostation)
            {
                lastRostation = transform.rotation;
                needUpdate    = true;
            }
            if (transform.lossyScale != lastScale)
            {
                lastScale  = transform.lossyScale;
                needUpdate = true;
            }

            if (needUpdate)
            {
                BocsCyclesAPI.UpdateObject(this.gameObject);
            }
        }
Example #2
0
        private static void GUI_Draw_Updatebar(SceneView sceneView)
        {
            if (waitForNextFrame)
            {
                return;
            }

            int sample = BocsCyclesAPI.Cycles_progress();

            if (sample == samples)
            {
                return;
            }

            float barLength = (float)sample / (float)samples;

            if (fullScreen)
            {
                EditorGUI.DrawRect(new Rect(0, sceneView.position.height - 24, barLength * sceneView.position.width, 4), Color.blue);
            }
            else
            {
                EditorGUI.DrawRect(new Rect(10, sceneView.position.height - 24, barLength * 256.0f, 4), Color.blue);
            }
        }
Example #3
0
        private static void Update()
        {
            if (synced == false)
            {
                float syncTime = Time.realtimeSinceStartup + .03f;//Try to maintain 30fps til synced...
                while (synced == false)
                {
                    if (Time.realtimeSinceStartup >= syncTime)
                    {
                        break;
                    }
                    StepSync();
                }
                SceneView.lastActiveSceneView.Repaint();
            }
            else
            {
                SyncScene();

                if (BocsCyclesAPI.Cycles_image_ready())
                {
                    //Debug.Log("UPDATE RENDER " + BocsCyclesAPI.cycles_progress());
                    GL.IssuePluginEvent(BocsCyclesAPI.GetRenderEventFunc(), 1);
                    SceneView.lastActiveSceneView.Repaint();
                    waitForNextFrame = false;
                }
            }
        }
Example #4
0
 private static void UpdateFramebuffer()
 {
     frameBuffer            = new Texture2D(width, height, TextureFormat.ARGB32, false, true);
     frameBuffer.filterMode = FilterMode.Point;
     frameBuffer.Apply();
     BocsCyclesAPI.Cycles_set_texture(frameBuffer.GetNativeTexturePtr(), frameBuffer.width, frameBuffer.height);
     waitForNextFrame = true;
 }
 private void UpdateMat(string mat)
 {
     for (int i = 0; i < script.GetGraphCount(); i++)
     {
         script.Nodes[i] = mat;
     }
     UpdateNodeEditor();
     BocsCyclesAPI.UpdateMaterial(script.gameObject);
 }
        // Reset to default values.
        public void Reset()
        {
            UpdateMaterials();

            for (int i = 0; i < GetGraphCount(); i++)
            {
                string m = BocsCyclesShaderConvert.Convert(Smats[i]);
                m        = Regex.Replace(m, "[^a-zA-Z0-9_.:,|=+-;<>/| ]", string.Empty);
                Nodes[i] = m;
            }

            NSync();
            BocsCyclesAPI.ObjectDelete(this.gameObject);
            BocsCyclesAPI.AddMesh(this.gameObject);
        }
Example #7
0
        //[MenuItem("Test/Shutdown")]
        private static void Shutdown()
        {
            //Debug.Log("Shutdown");
            EditorApplication.update -= Update;
            EditorApplication.playmodeStateChanged   -= PlaymodeStateChanged;
            EditorApplication.hierarchyWindowChanged -= HierarchyWindowChanged;
            SceneView.onSceneGUIDelegate             -= OnSceneView;
            Selection.selectionChanged -= SelectionChanged;

            GameObject.DestroyImmediate(GameObject.Find("<HDO>"));
            sceneID = 0;

            started = false;

            BocsCyclesAPI.Cycles_reset();
            BocsCyclesAPI.Cycles_debug();
            frameBuffer = null;
        }
Example #8
0
        // Reset to default values.
        protected void Reset()
        {
            Camera c = GetComponent <Camera>();

            _fov = c.fieldOfView;

            _type = 0;
            if (c.orthographic)
            {
                _type = 1;
            }

            //_nearClip = c.nearClipPlane;
            _nearclip = .001f;//default unity is too far away...
            _farclip  = c.farClipPlane;

            Nodes[0] = "node|t=BocsNodeOutput,x=940,y=60,c=0:node|t=BocsNodeBackground,x=530,y=40,c=0:node|t=BocsNodeSkyTexture,x=42,y=30,c=0:node|t=BocsNodeEnviromentTexture,x=80,y=200,c=0:val|n=1,s=color,v=FFFFFFFF:val|n=1,s=strength,v=0.75:val|n=2,s=sun_direction,v=0 0 1:val|n=2,s=turbidity,v=2.2:val|n=2,s=ground_albedo,v=0.3:val|n=3,s=filename,v=:val|n=3,s=color_space,v=1:val|n=3,s=use_alpha,v=True:val|n=3,s=interpolation,v=1:val|n=3,s=projection,v=0:connect|n1=1,n2=0,s1=background,s2=surface,:connect|n1=2,n2=1,s1=color,s2=color,:";

            BocsCyclesAPI.Cycles_request_settings();
            BocsCyclesAPI.Cycles_request_reset();
        }
Example #9
0
        // Reset to default values.
        protected void Reset()
        {
            Light l = GetComponent <Light>();

            if (l.shadows == LightShadows.None)
            {
                Shadow = false;
            }
            else
            {
                Shadow = true;
            }

            if (l.type == LightType.Point)
            {
                ConvertPoint(l);
                TypeSelected = 0;
            }
            if (l.type == LightType.Directional)
            {
                ConvertGeneric(l);
                TypeSelected = 1;
            }
            if (l.type == LightType.Spot)
            {
                ConvertSpot(l);
                TypeSelected = 2;
            }
            if (l.type == LightType.Area)
            {
                ConvertGeneric(l);
                TypeSelected = 3;
            }

            //Debug.Log("Reset Light");
            NSync();
            BocsCyclesAPI.AddLight(this.gameObject);
        }
Example #10
0
        private void UpdateCycles()
        {
            if (cyclesNeedsUpdate == false)
            {
                return;
            }

            if (graphType == GraphType.Material)
            {
                BocsCyclesAPI.UpdateMaterial(bcg.gameObject);
            }
            if (graphType == GraphType.Light)
            {
                BocsCyclesAPI.UpdateObject(bcg.gameObject);
            }
            if (graphType == GraphType.World)
            {
                BocsCyclesAPI.Cycles_request_settings();
                BocsCyclesAPI.Cycles_request_reset();
            }

            cyclesNeedsUpdate = false;
        }
Example #11
0
        private static void GUI_Draw_Render(SceneView sceneView)
        {
            if (frameBuffer)
            {
                if (fullScreen)
                {
                    if (!waitForNextFrame)
                    {
                        GUI.DrawTexture(new Rect(0, 0, sceneView.camera.pixelWidth, sceneView.camera.pixelHeight), frameBuffer, ScaleMode.ScaleAndCrop);
                    }

                    if (GUI.Button(new Rect(sceneView.position.width - 18, sceneView.position.height - 40, 18, 18), texRestore))
                    {
                        fullScreen = false;
                        cameraSettings._transparent = false;
                        BocsCyclesAPI.UpdateSettings(camera, cameraSettings, width, height, samples);
                    }
                }
                else
                {
                    Rect renderRect = new Rect(10 - 2, sceneView.position.height - 145 - 24 - 2, 256 + 4, 145 + 4);
                    EditorGUI.DrawRect(renderRect, Color.black);

                    Rect previewRect = new Rect(10, sceneView.position.height - 145 - 24, 256, 145);
                    GUI.DrawTexture(previewRect, frameBuffer, ScaleMode.ScaleAndCrop);

                    if (GUI.Button(new Rect(10 + 256 - 18, sceneView.position.height - 24 - 18, 18, 18), texFullScreen))
                    {
                        fullScreen = true;
                        cameraSettings._transparent = true;
                        BocsCyclesAPI.UpdateSettings(camera, cameraSettings, width, height, samples);
                    }
                }

                GUI_Draw_Updatebar(sceneView);
            }
        }
Example #12
0
        public void Sync()
        {
            bool needUpdate = false;

            if (transform.position != lastPositon)
            {
                needUpdate = true;
            }
            if (transform.rotation != lastRostation)
            {
                needUpdate = true;
            }
            if (transform.lossyScale != lastScale)
            {
                needUpdate = true;
            }

            bool needReset = false;

            if (AutoSync)
            {
                Light l = GetComponent <Light>();
                if (lastColor != l.color)
                {
                    needReset = true;
                }
                if (lastType != l.type)
                {
                    needReset = true;
                }
                if (lastIntensity != l.intensity)
                {
                    needReset = true;
                }
                if (lastRange != l.range)
                {
                    needReset = true;
                }
                if (lastAngle != l.spotAngle)
                {
                    needReset = true;
                }
                if (lastShadow != l.shadows)
                {
                    needReset = true;
                }
            }

            NSync();

            if (needReset)
            {
                Reset();
                return;
            }

            if (needUpdate)
            {
                BocsCyclesAPI.UpdateObject(this.gameObject);
            }
        }
Example #13
0
 //Delete object
 protected void OnDestroy()
 {
     BocsCyclesAPI.ObjectDelete(this.gameObject);
 }
Example #14
0
 //Dup object
 protected void Awake()
 {
     //Debug.Log("Awake Light");
     NSync();
     BocsCyclesAPI.AddLight(this.gameObject);
 }
        public override void OnInspectorGUI()
        {
            BocsCyclesLight script = (BocsCyclesLight)target;

            script.AutoSync = EditorGUILayout.Toggle("Auto Sync", script.AutoSync);

            if (script.AutoSync)
            {
                return;
            }

            if (GUILayout.Button("Editor"))
            {
                EditorWindow.GetWindow <EditorNodeEdit>();
            }

            EditorGUI.BeginChangeCheck();

            GUILayout.BeginVertical(GUI.skin.box);

            //script._enabled = EditorGUILayout.Toggle("Enabled",script._enabled);
            script.TypeSelected = EditorGUILayout.Popup("Type", script.TypeSelected, script.Type);
            if (script.TypeSelected == 2)
            {
                script.SpotAngle = EditorGUILayout.FloatField("Spot Angle", script.SpotAngle);
            }

            script.Shadow       = EditorGUILayout.Toggle("Shadow", script.Shadow);
            script.UseMis       = EditorGUILayout.Toggle("Multiple Importance", script.UseMis);
            script.Size         = EditorGUILayout.FloatField("Size", script.Size);
            script.MaxBounces   = EditorGUILayout.IntField("Max Bounces", script.MaxBounces);
            script.Diffuse      = EditorGUILayout.Toggle("Diffuse", script.Diffuse);
            script.Glossy       = EditorGUILayout.Toggle("Glossy", script.Glossy);
            script.Transmission = EditorGUILayout.Toggle("Transmission", script.Transmission);
            script.Scatter      = EditorGUILayout.Toggle("Scatter", script.Scatter);

            script.IsPortal = EditorGUILayout.Toggle("Portal", script.IsPortal);

            GUILayout.EndVertical();

            bool needUpdate = false;

            if (EditorGUI.EndChangeCheck())
            {
                needUpdate = true;
            }

            if (script.transform.root.position != lastPositon)
            {
                lastPositon = script.transform.root.position;
                needUpdate  = true;
            }
            if (script.transform.root.rotation != lastRostation)
            {
                lastRostation = script.transform.root.rotation;
                needUpdate    = true;
            }
            if (script.transform.root.localScale != lastScale)
            {
                lastScale  = script.transform.root.localScale;
                needUpdate = true;
            }

            //Some Checks...

            if (script.Size < 0)
            {
                script.Size = 0;
            }
            if (script.MaxBounces < 0)
            {
                script.MaxBounces = 0;
            }

            if (needUpdate)
            {
                BocsCyclesAPI.UpdateObject(script.gameObject);
            }

            debug = EditorGUILayout.Foldout(debug, "Debug");
            if (debug)
            {
                //Debug.Log(script.GetShaderCount());
                for (int i = 0; i < script.GetGraphCount(); i++)
                {
                    //GUILayout.TextField(script._nodes);
                    GUI.skin.textArea.wordWrap = true;
                    EditorGUILayout.TextArea(script.Nodes[i]);
                }
            }
        }
        public override void OnInspectorGUI()
        {
            if (texlogo == null)
            {
                Init();
            }
            //Rect imgRect = GUILayoutUtility.GetRect(Screen.width - 64, 32);
            //GUI.DrawTexture(imgRect, _logo, ScaleMode.ScaleToFit);

            BocsCyclesCamera script = (BocsCyclesCamera)target;

            bool needUpdate = false;

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(texSky, GUILayout.Width(45), GUILayout.Height(45)))
            {
                script.Nodes[0] = "node|t=BocsNodeOutput,x=940,y=60,c=0:node|t=BocsNodeBackground,x=530,y=40,c=0:node|t=BocsNodeSkyTexture,x=42,y=30,c=0:node|t=BocsNodeEnviromentTexture,x=80,y=200,c=0:val|n=1,s=color,v=FFFFFFFF:val|n=1,s=strength,v=0.75:val|n=2,s=sun_direction,v=0 0 1:val|n=2,s=turbidity,v=2.2:val|n=2,s=ground_albedo,v=0.3:val|n=3,s=filename,v=:val|n=3,s=color_space,v=1:val|n=3,s=use_alpha,v=True:val|n=3,s=interpolation,v=1:val|n=3,s=projection,v=0:connect|n1=1,n2=0,s1=background,s2=surface,:connect|n1=2,n2=1,s1=color,s2=color,:";
                UpdateNodeEditor();
                needUpdate = true;
            }
            if (GUILayout.Button(texSoftlight, GUILayout.Width(45), GUILayout.Height(45)))
            {
                script.Nodes[0] = "node|t=BocsNodeOutput,x=940,y=60,c=0:node|t=BocsNodeBackground,x=530,y=40,c=0:node|t=BocsNodeSkyTexture,x=42,y=30,c=0:node|t=BocsNodeEnviromentTexture,x=80,y=200,c=0:val|n=1,s=color,v=FFFFFFFF:val|n=1,s=strength,v=0.25:val|n=2,s=sun_direction,v=0 0 1:val|n=2,s=turbidity,v=2.2:val|n=2,s=ground_albedo,v=0.3:val|n=3,s=filename,v=:val|n=3,s=color_space,v=1:val|n=3,s=use_alpha,v=True:val|n=3,s=interpolation,v=1:val|n=3,s=projection,v=0:connect|n1=1,n2=0,s1=background,s2=surface,:";
                UpdateNodeEditor();
                needUpdate = true;
            }
            if (GUILayout.Button(texHDR, GUILayout.Width(45), GUILayout.Height(45)))
            {
                script.Nodes[0] = "node|t=BocsNodeOutput,x=940,y=60,c=0:node|t=BocsNodeBackground,x=530,y=40,c=0:node|t=BocsNodeSkyTexture,x=42,y=30,c=0:node|t=BocsNodeEnviromentTexture,x=80,y=200,c=0:val|n=1,s=color,v=FFFFFFFF:val|n=1,s=strength,v=0.5:val|n=2,s=sun_direction,v=0 0 1:val|n=2,s=turbidity,v=2.2:val|n=2,s=ground_albedo,v=0.3:val|n=3,s=filename,v=12a586c687c7a544890dc2fe09370550:val|n=3,s=color_space,v=1:val|n=3,s=use_alpha,v=True:val|n=3,s=interpolation,v=1:val|n=3,s=projection,v=0:connect|n1=1,n2=0,s1=background,s2=surface,:connect|n1=3,n2=1,s1=color,s2=color,:";
                UpdateNodeEditor();
                needUpdate = true;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Background Shader Editor"))
            {
                EditorWindow.GetWindow <EditorNodeEdit>();
            }

            quick = EditorGUILayout.Foldout(quick, "Quick Settings");
            if (quick)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);

                EditorGUI.BeginChangeCheck();

                script._type = EditorGUILayout.Popup("Projection", script._type, script._types);

                script._fov     = EditorGUILayout.FloatField("Field of View", script._fov);
                script._farclip = EditorGUILayout.FloatField("Far Clip", script._farclip);

                script._exposure = EditorGUILayout.FloatField("Exposure", script._exposure);

                //script._aperturesize = EditorGUILayout.FloatField("Aperture Size", script._aperturesize);

                //EditorGUILayout.BeginHorizontal();
                //script._focaldistance = EditorGUILayout.FloatField("Focal Distance", script._focaldistance);
                //EditorGUILayout.EndHorizontal();

                script._visibility = (BocsCyclesCamera.PathRayFlag)EditorGUILayout.EnumMaskField("Background Visibility", (System.Enum)script._visibility);
                script._use_shader = GUILayout.Toggle(script._use_shader, "Use Shader");

                script._filter_glossy            = EditorGUILayout.FloatField("Filter Glossy", script._filter_glossy);
                script._sample_clamp_direct      = EditorGUILayout.FloatField("Clamp Direct", script._sample_clamp_direct);
                script._sample_clamp_indirect    = EditorGUILayout.FloatField("Clamp Indirect", script._sample_clamp_indirect);
                script._light_sampling_threshold = EditorGUILayout.FloatField("Light Sampling Threshold", script._light_sampling_threshold);

                script._caustics_reflective = GUILayout.Toggle(script._caustics_reflective, "Reflective Caustics");
                script._caustics_refractive = GUILayout.Toggle(script._caustics_refractive, "Refractive Caustics");

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                EditorGUILayout.EndVertical();
            }

            camera = EditorGUILayout.Foldout(camera, "Camera");
            if (camera)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);

                EditorGUI.BeginChangeCheck();

                script._shuttertime = EditorGUILayout.FloatField("Shutter Time", script._shuttertime);

                script._motion_position          = EditorGUILayout.Popup("Motion Positon", script._motion_position, script._motion_positions);
                script._rolling_shutter_type     = EditorGUILayout.Popup("Rolling Shutter Type", script._rolling_shutter_type, script._rolling_shutter_types);
                script._rolling_shutter_duration = EditorGUILayout.FloatField("Rolling Shutter Duration", script._rolling_shutter_duration);

                script._aperturesize = EditorGUILayout.FloatField("Aperture Size", script._aperturesize);

                EditorGUILayout.BeginHorizontal();
                script._focaldistance = EditorGUILayout.FloatField("Focal Distance", script._focaldistance);
                EditorGUILayout.EndHorizontal();

                script._blades         = EditorGUILayout.IntField("Blades", script._blades);
                script._bladesrotation = EditorGUILayout.FloatField("Blades Rotation", script._bladesrotation);

                script._aperture_ratio = EditorGUILayout.FloatField("Aperture Ratio", script._aperture_ratio);

                script._type = EditorGUILayout.Popup("Projection", script._type, script._types);

                script._panorama_type = EditorGUILayout.Popup("Panorama", script._panorama_type, script._panorama_types);

                script._fisheye_fov  = EditorGUILayout.FloatField("Fisheye Field of View", script._fisheye_fov);
                script._fisheye_lens = EditorGUILayout.FloatField("Fisheye Lens", script._fisheye_lens);

                //public float _latitude_min = -1.5707f;
                //public float _latitude_max = 1.5707f;
                //public float _longitude_min = -3.141592f;
                //public float _longitude_max = 3.141592f;

                script._fov      = EditorGUILayout.FloatField("Field of View", script._fov);
                script._fov_pre  = EditorGUILayout.FloatField("Field of View Pre", script._fov_pre);
                script._fov_post = EditorGUILayout.FloatField("Field of View Post", script._fov_post);

                script._stereo_eye           = EditorGUILayout.Popup("Stereo Eye", script._stereo_eye, script._stereo_eyes);
                script._interocular_distance = EditorGUILayout.FloatField("Interocular Distance", script._interocular_distance);
                script._convergence_distance = EditorGUILayout.FloatField("Convergence Distance", script._convergence_distance);

                script._nearclip = EditorGUILayout.FloatField("Near Clip", script._nearclip);
                script._farclip  = EditorGUILayout.FloatField("Far Clip", script._farclip);

                //SOCKET_FLOAT(viewplane.left, "Viewplane Left", 0);
                //SOCKET_FLOAT(viewplane.right, "Viewplane Right", 0);
                //SOCKET_FLOAT(viewplane.bottom, "Viewplane Bottom", 0);
                //SOCKET_FLOAT(viewplane.top, "Viewplane Top", 0);

                //SOCKET_FLOAT(border.left, "Border Left", 0);
                //SOCKET_FLOAT(border.right, "Border Right", 0);
                //SOCKET_FLOAT(border.bottom, "Border Bottom", 0);
                //SOCKET_FLOAT(border.top, "Border Top", 0);

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                EditorGUILayout.EndVertical();
            }

            background = EditorGUILayout.Foldout(background, "Background");
            if (background)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                EditorGUI.BeginChangeCheck();

                script._use_ao      = GUILayout.Toggle(script._use_ao, "Use AO");
                script._ao_factor   = EditorGUILayout.FloatField("AO Factor", script._ao_factor);
                script._ao_distance = EditorGUILayout.FloatField("AO Distance", script._ao_distance);
                script._use_shader  = GUILayout.Toggle(script._use_shader, "Use Shader");

                script._visibility = (BocsCyclesCamera.PathRayFlag)EditorGUILayout.EnumMaskField("Visibility", (System.Enum)script._visibility);

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                GUILayout.EndVertical();
            }

            film = EditorGUILayout.Foldout(film, "Film");
            if (film)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                EditorGUI.BeginChangeCheck();

                script._exposure = EditorGUILayout.FloatField("Exposure", script._exposure);

                script._filter_type  = EditorGUILayout.Popup("Filter Type", script._filter_type, script._filter_types);
                script._filter_width = EditorGUILayout.FloatField("Filter Width", script._filter_width);

                script._mist_start   = EditorGUILayout.FloatField("Mist Start", script._mist_start);
                script._mist_depth   = EditorGUILayout.FloatField("Mist Depth", script._mist_depth);
                script._mist_falloff = EditorGUILayout.FloatField("Mist Falloff", script._mist_falloff);

                script._use_sample_clamp = GUILayout.Toggle(script._use_sample_clamp, "Use Sample Clamp");

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                GUILayout.EndVertical();
            }

            integrator = EditorGUILayout.Foldout(integrator, "Integrator");
            if (integrator)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                EditorGUI.BeginChangeCheck();

                script._min_bounce = EditorGUILayout.IntField("Min Bounce", script._min_bounce);
                script._max_bounce = EditorGUILayout.IntField("Max Bounce", script._max_bounce);

                script._max_diffuse_bounce      = EditorGUILayout.IntField("Max Diffuse Bounce", script._max_diffuse_bounce);
                script._max_glossy_bounce       = EditorGUILayout.IntField("Max Glossy Bounce", script._max_glossy_bounce);
                script._max_transmission_bounce = EditorGUILayout.IntField("Max Transmission Bounce", script._max_transmission_bounce);
                script._max_volume_bounce       = EditorGUILayout.IntField("Max Volume Bounce", script._max_volume_bounce);

                script._transparent_min_bounce = EditorGUILayout.IntField("Min Transparent Bounce", script._transparent_min_bounce);
                script._transparent_max_bounce = EditorGUILayout.IntField("Max Transparent Bounce", script._transparent_max_bounce);

                script._transparent_shadows = GUILayout.Toggle(script._transparent_shadows, "Transparent Shadows");

                script._ao_bounces = EditorGUILayout.IntField("AO Bounces", script._ao_bounces);

                script._volume_max_steps = EditorGUILayout.IntField("Max Volume Steps", script._volume_max_steps);
                script._volume_step_size = EditorGUILayout.FloatField("Volume Step Size", script._volume_step_size);

                script._caustics_reflective = GUILayout.Toggle(script._caustics_reflective, "Reflective Caustics");
                script._caustics_refractive = GUILayout.Toggle(script._caustics_refractive, "Refractive Caustics");

                script._filter_glossy         = EditorGUILayout.FloatField("Filter Glossy", script._filter_glossy);
                script._sample_clamp_direct   = EditorGUILayout.FloatField("Clamp Direct", script._sample_clamp_direct);
                script._sample_clamp_indirect = EditorGUILayout.FloatField("Clamp Indirect", script._sample_clamp_indirect);

                script._motion_blur = GUILayout.Toggle(script._motion_blur, "Motion Blur");

                script._aa_samples           = EditorGUILayout.IntField("AA Samples", script._aa_samples);
                script._diffuse_samples      = EditorGUILayout.IntField("Diffuse Samples", script._diffuse_samples);
                script._glossy_samples       = EditorGUILayout.IntField("Glossy Samples", script._glossy_samples);
                script._transmission_samples = EditorGUILayout.IntField("Transmission Samples", script._transmission_samples);
                script._ao_samples           = EditorGUILayout.IntField("AO Samples", script._ao_samples);
                script._mesh_light_samples   = EditorGUILayout.IntField("Mesh Light Samples", script._mesh_light_samples);
                script._subsurface_samples   = EditorGUILayout.IntField("Subsurface Samples", script._subsurface_samples);
                script._volume_samples       = EditorGUILayout.IntField("Volume Samples", script._volume_samples);

                script._sample_all_lights_direct   = GUILayout.Toggle(script._sample_all_lights_direct, "Sample All Lights Direct");
                script._sample_all_lights_indirect = GUILayout.Toggle(script._sample_all_lights_indirect, "Sample All Lights Indirect");
                script._light_sampling_threshold   = EditorGUILayout.FloatField("Light Sampling Threshold", script._light_sampling_threshold);

                script._method           = EditorGUILayout.Popup("Path Type", script._method, script._methods);
                script._sampling_pattern = EditorGUILayout.Popup("Sampling Pattern", script._sampling_pattern, script._sampling_patterns);

                if (EditorGUI.EndChangeCheck())
                {
                    needUpdate = true;
                }
                GUILayout.EndVertical();
            }

            //Some Checks...
            if (script._nearclip <= 0)
            {
                script._nearclip = .001f;
            }

            if (needUpdate)
            {
                BocsCyclesAPI.Cycles_request_settings();
                BocsCyclesAPI.Cycles_request_reset();
            }

            debug = EditorGUILayout.Foldout(debug, "Debug");
            if (debug)
            {
                //Debug.Log(script.GetShaderCount());
                for (int i = 0; i < script.GetGraphCount(); i++)
                {
                    //GUILayout.TextField(script._nodes);
                    GUI.skin.textArea.wordWrap = false;
                    EditorGUILayout.TextArea(script.Nodes[i]);
                }
            }
        }
 //Dup object
 protected void Awake()
 {
     NSync();
     BocsCyclesAPI.AddMesh(this.gameObject);
 }
Example #18
0
        private static void Startup()
        {
            if (started)
            {
                return;
            }
            if (Application.isPlaying)
            {
                return;
            }

            if (Camera.main == null)
            {
                Debug.Log("No MainCamera Found!");
                return;
            }
            if (SceneView.lastActiveSceneView == null)
            {
                Debug.Log("No SceneView Active!");
                return;
            }

            camera = SceneView.lastActiveSceneView.camera;

            if (camera == null)
            {
                Debug.Log("No SceneView Camera Found!");
                return;
            }

            cameraSettings = Camera.main.GetComponent <BocsCyclesCamera>();

            if (cameraSettings == null)
            {
                cameraSettings = Camera.main.gameObject.AddComponent <BocsCyclesCamera>();
            }

            if (fullScreen)
            {
                cameraSettings._transparent = true;
            }
            else
            {
                cameraSettings._transparent = false;
            }

            lastPosition = camera.transform.position;
            lastRotation = camera.transform.rotation;

            //Debug.Log("Startup...");

            StartSync();

            EditorApplication.update += Update;
            EditorApplication.playmodeStateChanged   += PlaymodeStateChanged;
            EditorApplication.hierarchyWindowChanged += HierarchyWindowChanged;
            SceneView.onSceneGUIDelegate             += OnSceneView;
            Selection.selectionChanged += SelectionChanged;

            GameObject o = GameObject.Find("<HDO>");

            if (o == null)
            {
                o = new GameObject("<HDO>");
            }
            o.hideFlags = HideFlags.HideInHierarchy;
            sceneID     = o.GetInstanceID();

            started = true;

            BocsCyclesAPI.Cycles_reset();
            BocsCyclesAPI.Cycles_set_active();
            BocsCyclesAPI.UpdateSettings(camera, cameraSettings, width, height, samples);
        }
        public override void OnInspectorGUI()
        {
            if (texLogo == null)
            {
                Init();
            }
            //Rect imgRect = GUILayoutUtility.GetRect(Screen.width - 64, 32);
            //GUI.DrawTexture(imgRect, _logo, ScaleMode.ScaleToFit);

            script = (BocsCyclesMaterial)target;

            int w = 32;
            int h = 32;

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(texReset, GUILayout.Width(w), GUILayout.Height(h)))
            {
                script.Reset();
                UpdateNodeEditor();
            }

            if (GUILayout.Button(texShiny, GUILayout.Width(w), GUILayout.Height(h)))
            {
                UpdateMat("node|t=BocsNodeOutput,x=380,y=10:node|t=BocsNodeDisneyBsdf,x=40,y=10:val|n=1,s=distribution,v=0:val|n=1,s=base_color,v=FF0000FF:val|n=1,s=subsurface_color,v=FF0000FF:val|n=1,s=subsurface,v=0:val|n=1,s=subsurface_radius,v=1 1 1:val|n=1,s=metallic,v=0:val|n=1,s=specular,v=1:val|n=1,s=specular_tint,v=0:val|n=1,s=roughness,v=0:val|n=1,s=anisotropic,v=0:val|n=1,s=anisotropic_rotation,v=0:val|n=1,s=sheen,v=1:val|n=1,s=sheen_tint,v=0:val|n=1,s=clearcoat,v=0:val|n=1,s=clearcoat_gloss,v=1:val|n=1,s=ior,v=1.45:val|n=1,s=transparency,v=0:connect|n1=1,n2=0,s1=bsdf,s2=surface,:");
                UpdateNodeEditor();
            }
            if (GUILayout.Button(texGlass, GUILayout.Width(w), GUILayout.Height(h)))
            {
                UpdateMat("node|t=BocsNodeOutput,x=350,y=10:node|t=BocsNodeDisneyBsdf,x=30,y=10:node|t=BocsNodeAbsorptionVolume,x=30,y=460:val|n=1,s=distribution,v=0:val|n=1,s=base_color,v=FFFFFFFF:val|n=1,s=subsurface_color,v=FF0000FF:val|n=1,s=subsurface,v=0:val|n=1,s=subsurface_radius,v=1 1 1:val|n=1,s=metallic,v=0:val|n=1,s=specular,v=0:val|n=1,s=specular_tint,v=0:val|n=1,s=roughness,v=0:val|n=1,s=anisotropic,v=0.5:val|n=1,s=anisotropic_rotation,v=0:val|n=1,s=sheen,v=1:val|n=1,s=sheen_tint,v=0:val|n=1,s=clearcoat,v=0:val|n=1,s=clearcoat_gloss,v=1:val|n=1,s=ior,v=1.45:val|n=1,s=transparency,v=1:val|n=2,s=color,v=FF0000FF:val|n=2,s=density,v=0:connect|n1=1,n2=0,s1=bsdf,s2=surface,:connect|n1=2,n2=0,s1=volume,s2=volume,:");
                UpdateNodeEditor();
            }
            if (GUILayout.Button(texChrome, GUILayout.Width(w), GUILayout.Height(h)))
            {
                UpdateMat("node|t=BocsNodeOutput,x=380,y=10:node|t=BocsNodeDisneyBsdf,x=40,y=10:val|n=1,s=distribution,v=0:val|n=1,s=base_color,v=FFFFFFFF:val|n=1,s=subsurface_color,v=FF0000FF:val|n=1,s=subsurface,v=0:val|n=1,s=subsurface_radius,v=1 1 1:val|n=1,s=metallic,v=1:val|n=1,s=specular,v=0:val|n=1,s=specular_tint,v=0:val|n=1,s=roughness,v=0:val|n=1,s=anisotropic,v=0:val|n=1,s=anisotropic_rotation,v=0:val|n=1,s=sheen,v=1:val|n=1,s=sheen_tint,v=0:val|n=1,s=clearcoat,v=0:val|n=1,s=clearcoat_gloss,v=1:val|n=1,s=ior,v=1.45:val|n=1,s=transparency,v=0:connect|n1=1,n2=0,s1=bsdf,s2=surface,:");
                UpdateNodeEditor();
            }
            if (GUILayout.Button(texMetal, GUILayout.Width(w), GUILayout.Height(h)))
            {
                UpdateMat("node|t=BocsNodeOutput,x=380,y=10:node|t=BocsNodeDisneyBsdf,x=40,y=10:val|n=1,s=distribution,v=0:val|n=1,s=base_color,v=FFFFFFFF:val|n=1,s=subsurface_color,v=FF0000FF:val|n=1,s=subsurface,v=0:val|n=1,s=subsurface_radius,v=1 1 1:val|n=1,s=metallic,v=1:val|n=1,s=specular,v=0:val|n=1,s=specular_tint,v=0:val|n=1,s=roughness,v=0.25:val|n=1,s=anisotropic,v=1:val|n=1,s=anisotropic_rotation,v=0:val|n=1,s=sheen,v=0:val|n=1,s=sheen_tint,v=0:val|n=1,s=clearcoat,v=1:val|n=1,s=clearcoat_gloss,v=1:val|n=1,s=ior,v=1.45:val|n=1,s=transparency,v=0:connect|n1=1,n2=0,s1=bsdf,s2=surface,:");
                UpdateNodeEditor();
            }
            if (GUILayout.Button(texChecker, GUILayout.Width(w), GUILayout.Height(h)))
            {
                UpdateMat("node|t=BocsNodeOutput,x=690,y=20,c=0:node|t=BocsNodeDisneyBsdf,x=350,y=20,c=0:node|t=BocsNodeCheckerTexture,x=20,y=20,c=0:val|n=1,s=distribution,v=0:val|n=1,s=base_color,v=FFFFFFFF:val|n=1,s=subsurface_color,v=FF0000FF:val|n=1,s=subsurface,v=0:val|n=1,s=subsurface_radius,v=1 1 1:val|n=1,s=metallic,v=0:val|n=1,s=specular,v=0:val|n=1,s=specular_tint,v=0:val|n=1,s=roughness,v=0.5:val|n=1,s=anisotropic,v=0.5:val|n=1,s=anisotropic_rotation,v=0:val|n=1,s=sheen,v=1:val|n=1,s=sheen_tint,v=0:val|n=1,s=clearcoat,v=0:val|n=1,s=clearcoat_gloss,v=1:val|n=1,s=ior,v=1.45:val|n=1,s=transparency,v=0:val|n=2,s=color1,v=848484FF:val|n=2,s=color2,v=FFFFFFFF:val|n=2,s=scale,v=4:connect|n1=1,n2=0,s1=bsdf,s2=surface,:connect|n1=2,n2=1,s1=color,s2=base_color,:");
                UpdateNodeEditor();
            }
            if (GUILayout.Button(texWire, GUILayout.Width(w), GUILayout.Height(h)))
            {
                UpdateMat("node|t=BocsNodeOutput,x=540,y=10:node|t=BocsNodeDisneyBsdf,x=40,y=120:node|t=BocsNodeWireframe,x=40,y=10:node|t=BocsNodeMixShader,x=380,y=10:node|t=BocsNodeDiffuseBsdf,x=40,y=580:val|n=1,s=distribution,v=0:val|n=1,s=base_color,v=FFFFFFFF:val|n=1,s=subsurface_color,v=FF0000FF:val|n=1,s=subsurface,v=0:val|n=1,s=subsurface_radius,v=1 1 1:val|n=1,s=metallic,v=0:val|n=1,s=specular,v=0:val|n=1,s=specular_tint,v=0:val|n=1,s=roughness,v=0.5:val|n=1,s=anisotropic,v=0.5:val|n=1,s=anisotropic_rotation,v=0:val|n=1,s=sheen,v=1:val|n=1,s=sheen_tint,v=0:val|n=1,s=clearcoat,v=0:val|n=1,s=clearcoat_gloss,v=1:val|n=1,s=ior,v=1.45:val|n=1,s=transparency,v=0:val|n=2,s=use_pixel_size,v=False:val|n=2,s=size,v=0.01:val|n=3,s=fac,v=1:val|n=4,s=color,v=FF0000FF:val|n=4,s=roughness,v=0:connect|n1=1,n2=3,s1=bsdf,s2=closure1,:connect|n1=2,n2=3,s1=fac,s2=fac,:connect|n1=3,n2=0,s1=closure,s2=surface,:connect|n1=4,n2=3,s1=bsdf,s2=closure2,:");
                UpdateNodeEditor();
            }
            if (GUILayout.Button(texLight, GUILayout.Width(w), GUILayout.Height(h)))
            {
                UpdateMat("node|t=BocsNodeOutput,x=370,y=20,c=0:node|t=BocsNodeEmission,x=30,y=20,c=0:val|n=1,s=color,v=FAF3B5FF:val|n=1,s=strength,v=1:connect|n1=1,n2=0,s1=emission,s2=surface,:");
                UpdateNodeEditor();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Editor"))
            {
                EditorWindow.GetWindow <EditorNodeEdit>();
            }
            //script._cacheMesh = EditorGUILayout.Toggle("Cache Mesh",script._cacheMesh);

            EditorGUI.BeginChangeCheck();//Don't Update Because we click Editor!!

            GUILayout.BeginVertical(GUI.skin.box);

            script.Visibility = (BocsCyclesMaterial.PathRayFlag)EditorGUILayout.EnumMaskField("Visibility", (System.Enum)script.Visibility);
            //script._smooth = EditorGUILayout.Toggle("Smooth",script._smooth);

            GUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                BocsCyclesAPI.UpdateObject(script.gameObject);
            }

            //EditorGUI.BeginChangeCheck();//Don't Update Because we click Editor!!

            //GUILayout.BeginVertical(GUI.skin.box);

            //script._use_mis = EditorGUILayout.Toggle("Multiple Importance",script._use_mis);
            //script._use_transparent_shadow = EditorGUILayout.Toggle("Transparent Shadow",script._use_transparent_shadow);
            //script._heterogeneous_volume = EditorGUILayout.Toggle("Heterogeneous Volume",script._heterogeneous_volume);
            //script._volume_sampling_method =  EditorGUILayout.Popup("Volume Sampling",script._volume_sampling_method,script._volume_sampling_methods);
            //script._volume_interpolation_method =  EditorGUILayout.Popup("Volume Interpolation",script._volume_interpolation_method,script._volume_interpolation_methods);

            //GUILayout.EndVertical();

            //if (EditorGUI.EndChangeCheck()) BocsCycles.CyclesUpdateMaterial(script.gameObject);

            debug = EditorGUILayout.Foldout(debug, "Debug");
            if (debug)
            {
                //Debug.Log(script.GetShaderCount());
                for (int i = 0; i < script.GetGraphCount(); i++)
                {
                    //GUILayout.TextField(script._nodes);
                    GUI.skin.textArea.wordWrap = true;
                    EditorGUILayout.TextArea(script.Nodes[i]);
                }
            }
        }
Example #20
0
        private static void StepSync()
        {
            if (syncLights.Length > 0)
            {
                if (syncLightsIndex < syncLights.Length)
                {
                    if (syncLights[syncLightsIndex].GetComponent <BocsCyclesSkip>() == null)
                    {
                        if (syncLights[syncLightsIndex].GetComponent <BocsCyclesLight>() == null)
                        {
                            syncLights[syncLightsIndex].gameObject.AddComponent <BocsCyclesLight>();
                        }
                        else
                        {
                            BocsCyclesAPI.AddLight(syncLights[syncLightsIndex].gameObject);
                        }
                    }
                    syncLightsIndex++;
                    syncCurrent++;
                    return;
                }
            }
            if (syncMeshes.Length > 0)
            {
                if (syncMeshesIndex < syncMeshes.Length)
                {
                    if (syncMeshes[syncMeshesIndex].GetComponent <BocsCyclesSkip>() == null)
                    {
                        if (syncMeshes[syncMeshesIndex].GetComponent <BocsCyclesMaterial>() == null)
                        {
                            syncMeshes[syncMeshesIndex].gameObject.AddComponent <BocsCyclesMaterial>();
                        }
                        else
                        {
                            BocsCyclesAPI.AddMesh(syncMeshes[syncMeshesIndex].gameObject);
                        }
                    }
                    syncMeshesIndex++;
                    syncCurrent++;
                    return;
                }
            }

            if (syncSkins.Length > 0)
            {
                if (syncSkinsIndex < syncSkins.Length)
                {
                    if (syncSkins[syncSkinsIndex].GetComponent <BocsCyclesSkip>() == null)
                    {
                        if (syncSkins[syncSkinsIndex].GetComponent <BocsCyclesMaterial>() == null)
                        {
                            syncSkins[syncSkinsIndex].gameObject.AddComponent <BocsCyclesMaterial>();
                        }
                        else
                        {
                            BocsCyclesAPI.AddMesh(syncSkins[syncSkinsIndex].gameObject);
                        }
                    }
                    syncSkinsIndex++;
                    syncCurrent++;
                    return;
                }
            }

            synced = true;
        }
Example #21
0
        private static void SyncScene()
        {
            SceneView view = SceneView.lastActiveSceneView;

            if (view == null)
            {
                return;
            }

            cameraSettings._fov = camera.fieldOfView;

            int w = 256;
            int h = 145;

            if (fullScreen)
            {
                w = view.camera.pixelWidth / 2;
                h = view.camera.pixelHeight / 2;
            }

            //hack..size keeps toggling by 1 pixel wtf????
            if (Mathf.Abs(w - width) > 2 || Mathf.Abs(h - height) > 2)
            {
                //Debug.Log("resize: " + w + "," + h);

                width       = w;
                height      = h;
                frameBuffer = null;

                updateCamera = true;
                BocsCyclesAPI.Cycles_request_reset();

                hasUpdated       = true;
                waitForNextFrame = true;
                nextUpdate       = Time.realtimeSinceStartup + .25f;
            }

            if (frameBuffer == null)
            {
                UpdateFramebuffer();
                hasUpdated       = true;
                waitForNextFrame = true;
                nextUpdate       = Time.realtimeSinceStartup + .25f;
            }

            if (camera.transform.position != lastPosition || camera.transform.rotation != lastRotation)
            {
                lastPosition = camera.transform.position;
                lastRotation = camera.transform.rotation;

                updateCamera = true;
                BocsCyclesAPI.Cycles_request_reset();

                waitForNextFrame = true;
                hasUpdated       = true;
                nextUpdate       = Time.realtimeSinceStartup + .25f;
            }

            if (BocsCyclesAPI.Cycles_need_reset())
            {
                hasUpdated       = true;
                waitForNextFrame = true;
                nextUpdate       = Time.realtimeSinceStartup + .25f;
            }

            if (hasUpdated && Time.realtimeSinceStartup > nextUpdate)
            {
                if (BocsCyclesAPI.Cycles_need_settings())
                {
                    BocsCyclesAPI.UpdateSettings(camera, cameraSettings, width, height, samples);
                }
                else if (updateCamera)
                {
                    BocsCyclesAPI.UpdateCameraPositon(camera, cameraSettings, width, height);
                }

                BocsCyclesAPI.Cycles_render_async();

                hasUpdated   = false;
                updateCamera = false;
            }
        }