protected override void InitData() { base.InitData(); // Setup the RenderTexture and compute shader for combining // different animated wave LODs. As we use a single texture array // for all LODs, we employ a compute shader as only they can // read and write to the same texture. _combineShader = Resources.Load <ComputeShader>(ShaderName); krnl_ShapeCombine = _combineShader.FindKernel("ShapeCombine"); krnl_ShapeCombine_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_DISABLE_COMBINE"); krnl_ShapeCombine_FLOW_ON = _combineShader.FindKernel("ShapeCombine_FLOW_ON"); krnl_ShapeCombine_FLOW_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DISABLE_COMBINE"); krnl_ShapeCombine_DYNAMIC_WAVE_SIM_ON = _combineShader.FindKernel("ShapeCombine_DYNAMIC_WAVE_SIM_ON"); krnl_ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE"); krnl_ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON"); krnl_ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE"); _combineProperties = new PropertyWrapperCompute(); int resolution = OceanRenderer.Instance.LodDataResolution; var desc = new RenderTextureDescriptor(resolution, resolution, TextureFormat, 0); _waveBuffers = new RenderTexture(desc); _waveBuffers.wrapMode = TextureWrapMode.Clamp; _waveBuffers.antiAliasing = 1; _waveBuffers.filterMode = FilterMode.Bilinear; _waveBuffers.anisoLevel = 0; _waveBuffers.useMipMap = false; _waveBuffers.name = "WaveBuffer"; _waveBuffers.dimension = TextureDimension.Tex2DArray; _waveBuffers.volumeDepth = OceanRenderer.Instance.CurrentLodCount; _waveBuffers.Create(); }
public override void Start() { base.Start(); _renderProperties = new PropertyWrapperCompute(); _updateShadowShader = ComputeShaderHelpers.LoadShader(UpdateShadow); if (_updateShadowShader == null) { enabled = false; return; } try { krnl_UpdateShadow = _updateShadowShader.FindKernel(UpdateShadow); } catch (Exception) { Debug.LogError("Could not load shadow update kernel. Disabling shadows.", _ocean); enabled = false; return; } // Setup the camera. UpdateCameraMain(); #if UNITY_EDITOR if (!OceanRenderer.Instance.OceanMaterial.IsKeywordEnabled("_SHADOWS_ON")) { Debug.LogWarning("Shadowing is not enabled on the current ocean material and will not be visible.", _ocean); } #endif }
protected override void Start() { base.Start(); _renderProperties = new PropertyWrapperCompute(); _updateShadowShader = Resources.Load <ComputeShader>(UpdateShadow); krnl_UpdateShadow = _updateShadowShader.FindKernel(UpdateShadow); _cameraMain = Camera.main; if (_cameraMain == null) { var viewpoint = OceanRenderer.Instance.Viewpoint; _cameraMain = viewpoint != null?viewpoint.GetComponent <Camera>() : null; if (_cameraMain == null) { Debug.LogError("Could not find main camera, disabling shadow data", this); enabled = false; return; } } #if UNITY_EDITOR if (!OceanRenderer.Instance.OceanMaterial.IsKeywordEnabled("_SHADOWS_ON")) { Debug.LogWarning("Shadowing is not enabled on the current ocean material and will not be visible.", this); } #endif }
public override void Start() { base.Start(); _renderProperties = new PropertyWrapperCompute(); _updateShadowShader = ComputeShaderHelpers.LoadShader(UpdateShadow); if (_updateShadowShader == null) { enabled = false; return; } try { krnl_UpdateShadow = _updateShadowShader.FindKernel(UpdateShadow); } catch (Exception) { Debug.LogError("Could not load shadow update kernel. Disabling shadows.", _ocean); enabled = false; return; } #if UNITY_EDITOR if (OceanRenderer.Instance.OceanMaterial != null && OceanRenderer.Instance.OceanMaterial.HasProperty(MATERIAL_KEYWORD_PROPERTY) && !OceanRenderer.Instance.OceanMaterial.IsKeywordEnabled(MATERIAL_KEYWORD)) { Debug.LogWarning(ERROR_MATERIAL_KEYWORD_MISSING + " " + ERROR_MATERIAL_KEYWORD_MISSING_FIX, _ocean); } #endif }
protected override void InitData() { base.InitData(); // Setup the RenderTexture and compute shader for combining // different animated wave LODs. As we use a single texture array // for all LODs, we employ a compute shader as only they can // read and write to the same texture. _combineShader = Resources.Load <ComputeShader>(ShaderName); krnl_ShapeCombine = _combineShader.FindKernel("ShapeCombine"); krnl_ShapeCombine_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_DISABLE_COMBINE"); krnl_ShapeCombine_FLOW_ON = _combineShader.FindKernel("ShapeCombine_FLOW_ON"); krnl_ShapeCombine_FLOW_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DISABLE_COMBINE"); krnl_ShapeCombine_DYNAMIC_WAVE_SIM_ON = _combineShader.FindKernel("ShapeCombine_DYNAMIC_WAVE_SIM_ON"); krnl_ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE"); krnl_ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON"); krnl_ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE"); _combineProperties = new PropertyWrapperCompute(); int resolution = OceanRenderer.Instance.LodDataResolution; var desc = new RenderTextureDescriptor(resolution, resolution, TextureFormat, 0); _waveBuffers = CreateLodDataTextures(desc, "WaveBuffer", false); _combineBuffer = CreateCombineBuffer(desc); var combineShader = Shader.Find("Hidden/Crest/Simulation/Combine Animated Wave LODs"); _combineMaterial = new PropertyWrapperMaterial[OceanRenderer.Instance.CurrentLodCount]; for (int i = 0; i < _combineMaterial.Length; i++) { var mat = new Material(combineShader); _combineMaterial[i] = new PropertyWrapperMaterial(mat); } }
void CreateProperties() { _shader = ComputeShaderHelpers.LoadShader(ShaderSim); if (_shader == null) { enabled = false; return; } _renderSimProperties = new PropertyWrapperCompute(); }
protected override void InitData() { base.InitData(); // Setup the RenderTexture and compute shader for combining // different animated wave LODs. As we use a single texture array // for all LODs, we employ a compute shader as only they can // read and write to the same texture. int resolution = OceanRenderer.Instance.LodDataResolution; var desc = new RenderTextureDescriptor(resolution, resolution, CompatibleTextureFormat, 0); _waveBuffers = CreateLodDataTextures(desc, "WaveBuffer", false); _combineBuffer = CreateCombineBuffer(desc); // Combine graphics shader - for 'ping pong' approach (legacy hardware) var combineShaderNameGraphics = "Hidden/Crest/Simulation/Combine Animated Wave LODs"; var combineShaderGraphics = Shader.Find(combineShaderNameGraphics); Debug.Assert(combineShaderGraphics != null, $"Could not load shader {combineShaderNameGraphics}. Try right clicking the Crest folder in the Project view and selecting Reimport, and checking for errors.", OceanRenderer.Instance); if (combineShaderGraphics != null) { _combineMaterial = new PropertyWrapperMaterial[OceanRenderer.Instance.CurrentLodCount]; for (int i = 0; i < _combineMaterial.Length; i++) { var mat = new Material(combineShaderGraphics); _combineMaterial[i] = new PropertyWrapperMaterial(mat); } } // Combine compute shader - modern hardware _combineShader = ComputeShaderHelpers.LoadShader(ShaderName); if (_combineShader == null) { enabled = false; return; } krnl_ShapeCombine = _combineShader.FindKernel("ShapeCombine"); krnl_ShapeCombine_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_DISABLE_COMBINE"); krnl_ShapeCombine_FLOW_ON = _combineShader.FindKernel("ShapeCombine_FLOW_ON"); krnl_ShapeCombine_FLOW_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DISABLE_COMBINE"); krnl_ShapeCombine_DYNAMIC_WAVE_SIM_ON = _combineShader.FindKernel("ShapeCombine_DYNAMIC_WAVE_SIM_ON"); krnl_ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE"); krnl_ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON"); krnl_ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE"); _combineProperties = new PropertyWrapperCompute(); }
public override void Start() { base.Start(); _renderProperties = new PropertyWrapperCompute(); _updateShadowShader = ComputeShaderHelpers.LoadShader(UpdateShadow); if (_updateShadowShader == null) { enabled = false; return; } try { krnl_UpdateShadow = _updateShadowShader.FindKernel(UpdateShadow); } catch (Exception) { Debug.LogError("Could not load shadow update kernel. Disabling shadows.", _ocean); enabled = false; return; } _cameraMain = Camera.main; if (_cameraMain == null) { var viewpoint = OceanRenderer.Instance.Viewpoint; _cameraMain = viewpoint != null?viewpoint.GetComponent <Camera>() : null; if (_cameraMain == null) { Debug.LogError("Could not find main camera, disabling shadow data", _ocean); enabled = false; return; } } #if UNITY_EDITOR if (!OceanRenderer.Instance.OceanMaterial.IsKeywordEnabled("_SHADOWS_ON")) { Debug.LogWarning("Shadowing is not enabled on the current ocean material and will not be visible.", _ocean); } #endif }
protected override void InitData() { base.InitData(); // Setup the RenderTexture and compute shader for combining // different animated wave LODs. As we use a single texture array // for all LODs, we employ a compute shader as only they can // read and write to the same texture. _combineShader = Resources.Load <ComputeShader>(ShaderName); krnl_ShapeCombine = _combineShader.FindKernel("ShapeCombine"); krnl_ShapeCombine_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_DISABLE_COMBINE"); krnl_ShapeCombine_FLOW_ON = _combineShader.FindKernel("ShapeCombine_FLOW_ON"); krnl_ShapeCombine_FLOW_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DISABLE_COMBINE"); krnl_ShapeCombine_DYNAMIC_WAVE_SIM_ON = _combineShader.FindKernel("ShapeCombine_DYNAMIC_WAVE_SIM_ON"); krnl_ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE"); krnl_ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON"); krnl_ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE = _combineShader.FindKernel("ShapeCombine_FLOW_ON_DYNAMIC_WAVE_SIM_ON_DISABLE_COMBINE"); _combineProperties = new PropertyWrapperCompute(); int resolution = OceanRenderer.Instance.LodDataResolution; var desc = new RenderTextureDescriptor(resolution, resolution, TextureFormat, 0); _waveBuffers = CreateLodDataTextures(desc, "WaveBuffer", false); }
void CreateProperties(int lodCount) { _shader = Resources.Load <ComputeShader>(ShaderSim); _renderSimProperties = new PropertyWrapperCompute(); }