コード例 #1
0
ファイル: LodDataMgrAnimWaves.cs プロジェクト: swordow/crest
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 public static void Bind(IPropertyWrapper properties)
 {
     if (OceanRenderer.Instance._lodDataClipSurface != null)
     {
         properties.SetTexture(ParamIdSampler(), OceanRenderer.Instance._lodDataClipSurface.DataTexture);
     }
     else
     {
         properties.SetTexture(ParamIdSampler(), s_nullTexture);
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        public override void TearDown()
        {
            base.TearDown();

            dummyClass = null;
            dummyStruct = null;
            classValueWrapper = null;
            classReferenceWrapper = null;
            structValueWrapper = null;
            structReferenceWrapper = null;
        }
コード例 #8
0
        public override void TearDown()
        {
            base.TearDown();

            dummyClass             = null;
            dummyStruct            = null;
            classValueWrapper      = null;
            classReferenceWrapper  = null;
            structValueWrapper     = null;
            structReferenceWrapper = null;
        }
コード例 #9
0
        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"));
        }
コード例 #10
0
ファイル: LodData.cs プロジェクト: domme/crest-oceanrender
        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));
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        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"));
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        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);
        }
コード例 #21
0
 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);
 }
コード例 #22
0
 public void BindCopySettings(IPropertyWrapper target)
 {
     target.SetFloat(sp_HorizDisplace, Settings._horizDisplace);
     target.SetFloat(sp_DisplaceClamp, Settings._displaceClamp);
 }
コード例 #23
0
 public static void BindNull(int shapeSlot, IPropertyWrapper properties)
 {
     properties.SetTexture(ParamIdSampler(shapeSlot), Texture2D.blackTexture);
 }
コード例 #24
0
ファイル: PropertyWrapperTests.cs プロジェクト: vermie/Merger
 private void CheckName(string expectedPropertyName, IPropertyWrapper<MergeTestObject> propertyWrapper)
 {
     Assert.AreEqual(expectedPropertyName, propertyWrapper.Name);
 }
コード例 #25
0
 /// <summary>
 /// Set any sim-specific shader params.
 /// </summary>
 protected virtual void SetAdditionalSimParams(IPropertyWrapper simMaterial)
 {
 }
コード例 #26
0
 public void BindWaveBuffer(IPropertyWrapper properties)
 {
     properties.SetTexture(sp_LD_TexArray_WaveBuffer, _waveBuffers);
 }
コード例 #27
0
 public Pair(Type type, IPropertyWrapper wrapper)
 {
     this.Type = type;
     this.Wrapper = wrapper;
 }
コード例 #28
0
        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);
        }
コード例 #29
0
 public void ApplyMaterialParams(int shapeSlot, IPropertyWrapper properties)
 {
     ApplyMaterialParams(shapeSlot, properties, true, true);
 }
コード例 #30
0
 private void AddProperty(string name, IPropertyWrapper wrapper)
 {
     _properties.Add(name, wrapper);
 }
コード例 #31
0
 public void BindResultData(IPropertyWrapper properties, bool blendOut = true)
 {
     BindData(properties, _targets, blendOut, ref OceanRenderer.Instance._lodTransform._renderData);
 }
コード例 #32
0
 public static void BindNull(IPropertyWrapper properties)
 {
     properties.SetTexture(ParamIdSampler(), TextureArrayHelpers.BlackTextureArray);
 }
コード例 #33
0
 public static void BindNull(IPropertyWrapper properties, bool sourceLod = false)
 {
     properties.SetTexture(ParamIdSampler(sourceLod), TextureArrayHelpers.BlackTextureArray);
 }
コード例 #34
0
 public InjectableProperty(PropertyInfo property) : base(property)
 {
     wrapper = property.CreateWrapper();
 }