public static void Bind(IPropertyWrapper properties) { if (OceanRenderer.Instance._lodDataShadow != null) { properties.SetTexture(OceanRenderer.Instance._lodDataShadow.GetParamIdSampler(), OceanRenderer.Instance._lodDataShadow.DataTexture); } else { properties.SetTexture(ParamIdSampler(), s_nullTexture); } }
public static void Bind(IPropertyWrapper properties) { if (OceanRenderer.Instance._lodDataFlow != null) { properties.SetTexture(OceanRenderer.Instance._lodDataFlow.GetParamIdSampler(), OceanRenderer.Instance._lodDataFlow.DataTexture); } else { properties.SetTexture(ParamIdSampler(), TextureArrayHelpers.BlackTextureArray); } }
protected virtual void BindData(IPropertyWrapper properties, Texture applyData, bool blendOut, ref LodTransform.RenderData[] renderData, bool sourceLod = false) { if (applyData) { properties.SetTexture(GetParamIdSampler(sourceLod), applyData); } var lt = OceanRenderer.Instance._lodTransform; for (int lodIdx = 0; lodIdx < OceanRenderer.Instance.CurrentLodCount; lodIdx++) { // NOTE: gets zeroed by unity, see https://www.alanzucconi.com/2016/10/24/arrays-shaders-unity-5-4/ _BindData_paramIdPosScales[lodIdx] = new Vector4( renderData[lodIdx]._posSnapped.x, renderData[lodIdx]._posSnapped.z, OceanRenderer.Instance.CalcLodScale(lodIdx), 0f); _BindData_paramIdOceans[lodIdx] = new Vector4(renderData[lodIdx]._texelWidth, renderData[lodIdx]._textureRes, 1f, 1f / renderData[lodIdx]._textureRes); } // Duplicate the last element as the shader accesses element {slice index + 1] in a few situations. This way going // off the end of this parameter is the same as going off the end of the texture array with our clamped sampler. _BindData_paramIdPosScales[OceanRenderer.Instance.CurrentLodCount] = _BindData_paramIdPosScales[OceanRenderer.Instance.CurrentLodCount - 1]; _BindData_paramIdOceans[OceanRenderer.Instance.CurrentLodCount] = _BindData_paramIdOceans[OceanRenderer.Instance.CurrentLodCount - 1]; properties.SetVectorArray(LodTransform.ParamIdPosScale(sourceLod), _BindData_paramIdPosScales); properties.SetVectorArray(LodTransform.ParamIdOcean(sourceLod), _BindData_paramIdOceans); }
public static void Bind(IPropertyWrapper properties) { if (OceanRenderer.Instance._lodDataSeaDepths != null) { properties.SetTexture(OceanRenderer.Instance._lodDataSeaDepths.GetParamIdSampler(), OceanRenderer.Instance._lodDataSeaDepths.DataTexture); } else { // TextureArrayHelpers prevents use from using this in a static constructor due to blackTexture usage if (s_nullTexture2DArray == null) { InitNullTexture(); } properties.SetTexture(ParamIdSampler(), s_nullTexture2DArray); } }
public static void BindNull(IPropertyWrapper properties, bool sourceLod = false) { // TextureArrayHelpers prevents use from using this in a static constructor due to blackTexture usage if (s_nullTexture2DArray == null) { InitNullTexture(); } properties.SetTexture(ParamIdSampler(sourceLod), s_nullTexture2DArray); }
public void BindWaveBuffer(IPropertyWrapper properties, bool sourceLod = false) { var lt = OceanRenderer.Instance._lodTransform; for (int lodIdx = 0; lodIdx < OceanRenderer.Instance.CurrentLodCount; lodIdx++) { lt._renderData[lodIdx].Validate(0, this); } properties.SetTexture(Shader.PropertyToID("_LD_TexArray_WaveBuffer"), _waveBuffers); BindData(properties, null, true, ref lt._renderData, sourceLod); }
public static void BindNull(IPropertyWrapper properties, bool sourceLod = false) { // Texture2D.whiteTexture prevents us from initialising this in a static constructor. Seemed appropriate to // do it here. if (s_nullTexture2DArray == null) { InitNullTexture(); } properties.SetTexture(ParamIdSampler(sourceLod), s_nullTexture2DArray); }
protected virtual void BindData(int shapeSlot, IPropertyWrapper properties, Texture applyData, bool blendOut, ref LodTransform.RenderData renderData) { if (applyData) { properties.SetTexture(_paramsLodDataSampler[shapeSlot], applyData); } properties.SetVector(_paramsPosScale[shapeSlot], new Vector3(renderData._posSnapped.x, renderData._posSnapped.z, transform.lossyScale.x)); properties.SetFloat(_paramsLodIdx[shapeSlot], LodTransform.LodIndex); properties.SetVector(_paramsOceanParams[shapeSlot], new Vector4(renderData._texelWidth, renderData._textureRes, 1f, 1f / renderData._textureRes)); }
public void ApplyMaterialParams(int shapeSlot, IPropertyWrapper properties, bool applyWaveHeights, bool blendOut) { if (applyWaveHeights) { properties.SetTexture("_WD_Sampler_" + shapeSlot.ToString(), cam.targetTexture); } if (_rtOceanDepth != null) { properties.SetTexture("_WD_OceanDepth_Sampler_" + shapeSlot.ToString(), _rtOceanDepth); } // need to blend out shape if this is the largest lod, and the ocean might get scaled down later (so the largest lod will disappear) bool needToBlendOutShape = _lodIndex == _lodCount - 1 && OceanRenderer.Instance.ScaleCouldDecrease && blendOut; float shapeWeight = needToBlendOutShape ? OceanRenderer.Instance.ViewerAltitudeLevelAlpha : 1f; properties.SetVector("_WD_Params_" + shapeSlot.ToString(), new Vector3(_renderData._texelWidth, _renderData._textureRes, shapeWeight)); properties.SetVector("_WD_Pos_" + shapeSlot.ToString(), new Vector2(_renderData._posSnapped.x, _renderData._posSnapped.z)); properties.SetFloat("_WD_LodIdx_" + shapeSlot.ToString(), _lodIndex); }
protected virtual void BindData(int lodIdx, int shapeSlot, IPropertyWrapper properties, Texture applyData, bool blendOut, ref LodTransform.RenderData renderData) { if (applyData) { properties.SetTexture(GetParamIdSampler(shapeSlot), applyData); } var lt = OceanRenderer.Instance._lods[lodIdx]; properties.SetVector(LodTransform.ParamIdPosScale(shapeSlot), new Vector3(renderData._posSnapped.x, renderData._posSnapped.z, lt.transform.lossyScale.x)); properties.SetVector(LodTransform.ParamIdOcean(shapeSlot), new Vector4(renderData._texelWidth, renderData._textureRes, 1f, 1f / renderData._textureRes)); }
public void ApplyMaterialParams(int shapeSlot, IPropertyWrapper properties, bool applyWaveHeights, bool blendOut) { if (applyWaveHeights) { properties.SetTexture(_paramsDisplacementsSampler[shapeSlot], cam.targetTexture); } if (_rtOceanDepth != null) { properties.SetTexture(_paramsOceanDepthSampler[shapeSlot], _rtOceanDepth); } // need to blend out shape if this is the largest lod, and the ocean might get scaled down later (so the largest lod will disappear) bool needToBlendOutShape = _lodIndex == _lodCount - 1 && OceanRenderer.Instance.ScaleCouldDecrease && blendOut; float shapeWeight = needToBlendOutShape ? OceanRenderer.Instance.ViewerAltitudeLevelAlpha : 1f; properties.SetVector(_paramsOceanParams[shapeSlot], new Vector4(_renderData._texelWidth, _renderData._textureRes, shapeWeight, 1f / _renderData._textureRes)); properties.SetVector(_paramsPosScale[shapeSlot], new Vector3(_renderData._posSnapped.x, _renderData._posSnapped.z, transform.lossyScale.x)); properties.SetFloat(_paramsLodIdx[shapeSlot], _lodIndex); }
protected virtual void BindData(IPropertyWrapper properties, Texture applyData, bool blendOut, ref LodTransform.RenderData[] renderData, bool sourceLod = false) { if (applyData) { properties.SetTexture(GetParamIdSampler(sourceLod), applyData); } var lt = OceanRenderer.Instance._lodTransform; for (int lodIdx = 0; lodIdx < OceanRenderer.Instance.CurrentLodCount; lodIdx++) { // NOTE: gets zeroed by unity, see https://www.alanzucconi.com/2016/10/24/arrays-shaders-unity-5-4/ _BindData_paramIdPosScales[lodIdx] = new Vector4(renderData[lodIdx]._posSnapped.x, renderData[lodIdx]._posSnapped.z, lt.GetLodTransform(lodIdx).lossyScale.x, 0); _BindData_paramIdOceans[lodIdx] = new Vector4(renderData[lodIdx]._texelWidth, renderData[lodIdx]._textureRes, 1f, 1f / renderData[lodIdx]._textureRes); } properties.SetVectorArray(LodTransform.ParamIdPosScale(sourceLod), _BindData_paramIdPosScales); properties.SetVectorArray(LodTransform.ParamIdOcean(sourceLod), _BindData_paramIdOceans); }
public static void BindNull(IPropertyWrapper properties, bool sourceLod = false) { properties.SetTexture(ParamIdSampler(sourceLod), TextureArrayHelpers.BlackTextureArray); }
public void BindWaveBuffer(IPropertyWrapper properties, bool sourceLod = false) { properties.SetTexture(Shader.PropertyToID("_LD_TexArray_WaveBuffer"), _waveBuffers); BindData(properties, null, true, ref OceanRenderer.Instance._lodTransform._renderData, sourceLod); }
public static void BindNull(IPropertyWrapper properties) { properties.SetTexture(ParamIdSampler(), TextureArrayHelpers.BlackTextureArray); }
public void BindWaveBuffer(IPropertyWrapper properties) { properties.SetTexture(sp_LD_TexArray_WaveBuffer, _waveBuffers); }
public static void BindNull(int shapeSlot, IPropertyWrapper properties) { properties.SetTexture(ParamIdSampler(shapeSlot), Texture2D.blackTexture); }