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); }
protected override void BindData(int shapeSlot, IPropertyWrapper properties, Texture applyData, bool blendOut, ref LodTransform.RenderData renderData) { base.BindData(shapeSlot, properties, applyData, blendOut, ref renderData); // 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 = LodTransform.LodIndex == LodTransform.LodCount - 1 && OceanRenderer.Instance.ScaleCouldDecrease && blendOut; float shapeWeight = needToBlendOutShape ? OceanRenderer.Instance.ViewerAltitudeLevelAlpha : 1f; properties.SetVector(_paramsOceanParams[shapeSlot], new Vector4(LodTransform._renderData._texelWidth, LodTransform._renderData._textureRes, shapeWeight, 1f / LodTransform._renderData._textureRes)); }
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(), TextureArrayHelpers.BlackTextureArray); } }
public override void Bind(IntermediateBuilder context) { _owner?.Bind(context); if (Type != null) { return; } UserType type = (_owner != null ? _owner.Type : _owningType) as UserType; if (_owningType == null) { _owningType = type; } IPropertyWrapper matchProperty = null; var t = type; while (matchProperty == null && t != CodeType.Object) { foreach (var f in t.GetProperties(context)) { if (f.Name == ID) { matchProperty = f; break; } } if (matchProperty == null) { t = t.GetBaseType(); } } _owningType = t; Debug.Assert(matchProperty != null); Type = matchProperty.Type; Property = matchProperty; if (Property.CanRead) { _get = new InterCall(Property.GetFunction, true, _owner); _get.SetOwner(context.CurrentMethod); } if (Property.CanWrite) { _set = new InterCall(Property.SetFunction, true, _owner); _set.SetOwner(context.CurrentMethod); } }
public static void Bind(IPropertyWrapper properties) { if (OceanRenderer.Instance._lodDataClipSurface != null) { properties.SetTexture(ParamIdSampler(), OceanRenderer.Instance._lodDataClipSurface.DataTexture); } else { properties.SetTexture(ParamIdSampler(), s_nullTexture); } }
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); }
public override void TearDown() { base.TearDown(); dummyClass = null; dummyStruct = null; classValueWrapper = null; classReferenceWrapper = null; structValueWrapper = null; structReferenceWrapper = null; }
public override void Setup() { base.Setup(); dummyClass = new DummyClass { Value = 1, Reference = "2" }; dummyStruct = new DummyStruct { Value = 3, Reference = "4" }; classValueWrapper = ReflectionUtility.CreatePropertyWrapper(typeof(DummyClass).GetProperty("Value")); classReferenceWrapper = ReflectionUtility.CreatePropertyWrapper(typeof(DummyClass).GetProperty("Reference")); structValueWrapper = ReflectionUtility.CreatePropertyWrapper(typeof(DummyStruct).GetProperty("Value")); structReferenceWrapper = ReflectionUtility.CreatePropertyWrapper(typeof(DummyStruct).GetProperty("Reference")); }
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)); }
protected override void SetAdditionalSimParams(IPropertyWrapper simMaterial) { base.SetAdditionalSimParams(simMaterial); simMaterial.SetFloat(sp_Damping, Settings._damping); simMaterial.SetFloat(sp_Gravity, OceanRenderer.Instance.Gravity * Settings._gravityMultiplier); simMaterial.SetFloat(sp_CourantNumber, Settings._courantNumber); // assign sea floor depth - to slot 1 current frame data. minor bug here - this depth will actually be from the previous frame, // because the depth is scheduled to render just before the animated waves, and this sim happens before animated waves. LodDataMgrSeaFloorDepth.Bind(simMaterial); LodDataMgrFlow.Bind(simMaterial); }
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)); }
protected override void SetAdditionalSimParams(IPropertyWrapper simMaterial) { base.SetAdditionalSimParams(simMaterial); simMaterial.SetFloat(sp_Damping, Settings._damping); simMaterial.SetFloat(sp_Gravity, OceanRenderer.Instance.Gravity * Settings._gravityMultiplier); float laplacianKernelAngle = _rotateLaplacian ? Mathf.PI * 2f * Random.value : 0f; simMaterial.SetVector(sp_LaplacianAxisX, new Vector2(Mathf.Cos(laplacianKernelAngle), Mathf.Sin(laplacianKernelAngle))); // assign sea floor depth - to slot 1 current frame data. minor bug here - this depth will actually be from the previous frame, // because the depth is scheduled to render just before the animated waves, and this sim happens before animated waves. LodDataMgrSeaFloorDepth.Bind(simMaterial); LodDataMgrFlow.Bind(simMaterial); }
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); } }
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); }
protected override void BindData(IPropertyWrapper properties, Texture applyData, bool blendOut, ref LodTransform.RenderData[] renderData, bool sourceLod = false) { base.BindData(properties, applyData, blendOut, ref renderData, sourceLod); var lt = OceanRenderer.Instance._lodTransform; for (int lodIdx = 0; lodIdx < OceanRenderer.Instance.CurrentLodCount; lodIdx++) { // 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 = lodIdx == OceanRenderer.Instance.CurrentLodCount - 1 && OceanRenderer.Instance.ScaleCouldDecrease && blendOut; float shapeWeight = needToBlendOutShape ? OceanRenderer.Instance.ViewerAltitudeLevelAlpha : 1f; _BindData_paramIdOceans[lodIdx] = new Vector4( lt._renderData[lodIdx]._texelWidth, lt._renderData[lodIdx]._textureRes, shapeWeight, 1f / lt._renderData[lodIdx]._textureRes); } properties.SetVectorArray(LodTransform.ParamIdOcean(sourceLod), _BindData_paramIdOceans); }
protected override void SetAdditionalSimParams(IPropertyWrapper simMaterial) { base.SetAdditionalSimParams(simMaterial); simMaterial.SetFloat(sp_FoamFadeRate, Settings._foamFadeRate); simMaterial.SetFloat(sp_WaveFoamStrength, Settings._waveFoamStrength); simMaterial.SetFloat(sp_WaveFoamCoverage, Settings._waveFoamCoverage); simMaterial.SetFloat(sp_ShorelineFoamMaxDepth, Settings._shorelineFoamMaxDepth); simMaterial.SetFloat(sp_ShorelineFoamStrength, Settings._shorelineFoamStrength); // assign animated waves - to slot 1 current frame data LodDataMgrAnimWaves.Bind(simMaterial); // assign sea floor depth - to slot 1 current frame data LodDataMgrSeaFloorDepth.Bind(simMaterial); // assign flow - to slot 1 current frame data LodDataMgrFlow.Bind(simMaterial); }
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); }
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); }
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 void BindCopySettings(IPropertyWrapper target) { target.SetFloat(sp_HorizDisplace, Settings._horizDisplace); target.SetFloat(sp_DisplaceClamp, Settings._displaceClamp); }
public static void BindNull(int shapeSlot, IPropertyWrapper properties) { properties.SetTexture(ParamIdSampler(shapeSlot), Texture2D.blackTexture); }
private void CheckName(string expectedPropertyName, IPropertyWrapper<MergeTestObject> propertyWrapper) { Assert.AreEqual(expectedPropertyName, propertyWrapper.Name); }
/// <summary> /// Set any sim-specific shader params. /// </summary> protected virtual void SetAdditionalSimParams(IPropertyWrapper simMaterial) { }
public void BindWaveBuffer(IPropertyWrapper properties) { properties.SetTexture(sp_LD_TexArray_WaveBuffer, _waveBuffers); }
public Pair(Type type, IPropertyWrapper wrapper) { this.Type = type; this.Wrapper = wrapper; }
public void BindSourceData(IPropertyWrapper simMaterial, bool paramsOnly) { var rd = OceanRenderer.Instance._lodTransform._renderDataSource; BindData(simMaterial, paramsOnly ? Texture2D.blackTexture : _sources as Texture, true, ref rd, true); }
public void ApplyMaterialParams(int shapeSlot, IPropertyWrapper properties) { ApplyMaterialParams(shapeSlot, properties, true, true); }
private void AddProperty(string name, IPropertyWrapper wrapper) { _properties.Add(name, wrapper); }
public void BindResultData(IPropertyWrapper properties, bool blendOut = true) { BindData(properties, _targets, blendOut, ref OceanRenderer.Instance._lodTransform._renderData); }
public static void BindNull(IPropertyWrapper properties) { properties.SetTexture(ParamIdSampler(), TextureArrayHelpers.BlackTextureArray); }
public static void BindNull(IPropertyWrapper properties, bool sourceLod = false) { properties.SetTexture(ParamIdSampler(sourceLod), TextureArrayHelpers.BlackTextureArray); }
public InjectableProperty(PropertyInfo property) : base(property) { wrapper = property.CreateWrapper(); }