private void OnCameraPreCull ( Camera camera ) { if (!camera) return; if (_excludedCameras.Contains(camera)) return; #if UNITY_EDITOR // The frame debugger is rendered through a temporary "Camera", and we // shouldn't interfere with that. If the camera we're dealing with is // used for an editor preview, then ignore it. if (camera.cameraType == CameraType.Preview) return; #endif MetaballCameraConfiguration cameraConfig = null; if (_cameraConfigs.ContainsKey(camera)) { cameraConfig = _cameraConfigs[camera]; }else{ cameraConfig = _cameraConfigs[camera] = new MetaballCameraConfiguration(camera); //config.cullingGroup.SetBoundingSpheres(_chargeBounds); } BindSurfaceProperties(); BindCameraProperties( cameraConfig ); // Field pre-pass currently disabled. The additional performance gain isn't worth the // hassle of regenerating the commandbuffer on the fly. Plus, the lack of 3D blit support // means that each depth slice of the field texture has to be blitted separately. // I may be able to unroll the 3D texture into a packed 2D texture down the line. //Graphics.ExecuteCommandBuffer( cameraConfig.fieldPrepass ); Graphics.ExecuteCommandBuffer( cameraConfig.vertexPrepass ); Graphics.DrawMesh( cameraConfig.sampleMesh, Matrix4x4.identity, isosurfaceMaterial, 0, camera ); }
private void BindCameraProperties ( MetaballCameraConfiguration config ) { Shader.SetGlobalVectorArray( "_CameraFrustumCorners", config.GetFrustumCorners() ); Shader.SetGlobalVector( "_CameraWorldPosition", config.camera.transform.position ); Shader.SetGlobalVector( "_Isosurface_VoxelResolution", config.sampleResolution ); Shader.SetGlobalTexture( "_Isosurface_VertexTexture", config.vertexTexture ); }