Пример #1
0
        private void updateUBO_Shadow_Directional(dLight light, int shadow_id)
        {
            int ubo_index = shadow_id * 9;

            for (int i = 0; i < 4; i++)
            {
                _ubo_shadow_directional.update(ubo_index + i, light.shadow_view_matrices[i]);
                _ubo_shadow_directional.update(ubo_index + i + 4, light.shadow_ortho_matrices[i]);
            }
            _ubo_shadow_directional.update(ubo_index + 8, light.spatial.position);

            light.sid = shadow_id;
        }
Пример #2
0
        public int addImage(long handle)
        {
            _ubo_bindless.update(_material_count * 2, handle);

            _material_count++;
            return(_material_count - 1);
        }
Пример #3
0
        private void updateUBO_Shadow()
        {
            int num_shadows_spot        = 0;
            int num_shadows_point       = 0;
            int num_shadows_directional = 0;

            foreach (Light light in _lights_shadowed)
            {
                switch (light.type)
                {
                case Light.type_spot:
                    if (num_shadows_spot >= _max_shadows_spot)
                    {
                        break;
                    }
                    updateUBO_Shadow_Spot((sLight)light, num_shadows_spot);
                    _lights_shadowed_manifest.Add(new Vector4(0, num_shadows_spot, 0, 0));
                    num_shadows_spot++;
                    break;

                case Light.type_point:
                    if (num_shadows_point >= _max_shadows_point)
                    {
                        break;
                    }
                    updateUBO_Shadow_Point((pLight)light, num_shadows_point);
                    _lights_shadowed_manifest.Add(new Vector4(1, num_shadows_point, 0, 0));
                    _lights_shadowed_manifest.Add(new Vector4(1, num_shadows_point, 1, 0));
                    _lights_shadowed_manifest.Add(new Vector4(1, num_shadows_point, 2, 0));
                    _lights_shadowed_manifest.Add(new Vector4(1, num_shadows_point, 3, 0));
                    _lights_shadowed_manifest.Add(new Vector4(1, num_shadows_point, 4, 0));
                    _lights_shadowed_manifest.Add(new Vector4(1, num_shadows_point, 5, 0));
                    num_shadows_point++;
                    break;

                case Light.type_directional:
                    if (num_shadows_directional >= _max_shadows_directional)
                    {
                        break;
                    }
                    updateUBO_Shadow_Directional((dLight)light, num_shadows_directional);
                    _lights_shadowed_manifest.Add(new Vector4(2, num_shadows_directional, 0, 0));
                    num_shadows_directional++;
                    break;
                }
            }

            int shadow_manifest_length = _lights_shadowed_manifest.Count;

            for (int i = 0; i < 32; i++)
            {
                Vector4 temp_manifest_entry = new Vector4(-1);
                if (i < shadow_manifest_length)
                {
                    temp_manifest_entry = _lights_shadowed_manifest[i];
                }
                _ubo_shadow_manifest.update(i, temp_manifest_entry);
            }
        }
Пример #4
0
        private void updateUBO_Shadow_Point(pLight light, int shadow_id)
        {
            int ubo_index = shadow_id * 15;

            for (int i = 0; i < 6; i++)
            {
                _ubo_shadow_point.update(ubo_index + i, light.shadow_view_matrices[i]);
            }
            _ubo_shadow_point.update(ubo_index + 6, light.spatial.perspective);
            for (int i = 0; i < 6; i++)
            {
                _ubo_shadow_point.update(ubo_index + i + 7, light.viewray_matrices[i]);
            }
            _ubo_shadow_point.update(ubo_index + 13, new Vector4(light.spatial.position, light.falloff));
            _ubo_shadow_point.update(ubo_index + 14, new Vector4(light.color, light.intensity));

            light.sid = shadow_id;
        }
Пример #5
0
 public void updateUBO_Camera(
     Matrix4 view, Matrix4 perspective, Matrix4 inv_view_perspective,
     Matrix4 previous_view_perspective, Matrix4 inv_previous_view_perspective,
     Vector3 position, Vector3 look)
 {
     _ubo_camera.update(0, view);
     _ubo_camera.update(1, perspective);
     _ubo_camera.update(2, inv_view_perspective);
     _ubo_camera.update(3, previous_view_perspective);
     _ubo_camera.update(4, inv_previous_view_perspective);
     _ubo_camera.update(5, position);
     _ubo_camera.update(6, look);
 }
Пример #6
0
        private void updateUBO_Shadow_Spot(sLight light, int shadow_id)
        {
            int ubo_index = shadow_id * 7;

            _ubo_shadow_spot.update(ubo_index, light.shadow_view_matrix);
            _ubo_shadow_spot.update(ubo_index + 1, light.shadow_perspective_matrix);
            _ubo_shadow_spot.update(ubo_index + 2, light.viewray_matrix);
            _ubo_shadow_spot.update(ubo_index + 3, new Vector4(light.spatial.position, light.falloff));
            _ubo_shadow_spot.update(ubo_index + 4, new Vector4(light.color, light.intensity));
            _ubo_shadow_spot.update(ubo_index + 5, new Vector4(light.spatial.look, 0.0f));
            _ubo_shadow_spot.update(ubo_index + 6, new Vector4(light.spot_angle, light.spot_blur, 0.0f, 0.0f));

            light.sid = shadow_id;
        }
Пример #7
0
 //------------------------------------------------------
 // Updating
 //------------------------------------------------------
 public void updateUBO_GameConfig(Vector4 near_far, float target_fps)
 {
     _ubo_game_config.update(0, near_far);
     _ubo_game_config.update(1, target_fps);
 }