Esempio n. 1
0
 /// <summary>
 /// Compiles a shader from an effect that contains one or more functions.
 /// </summary>
 /// <param name="functionHandle">The function handle.</param>
 /// <param name="target">The target.</param>
 /// <param name="flags">The flags.</param>
 /// <exception cref="CompilationException">If a compilation errors occurs</exception>
 /// <returns>The bytecode of the effect.</returns>
 /// <unmanaged>HRESULT ID3DXEffectCompiler::CompileShader([In] D3DXHANDLE hFunction,[In] const char* pTarget,[In] unsigned int Flags,[In] ID3DXBuffer** ppShader,[In] ID3DXBuffer** ppErrorMsgs,[In] ID3DXConstantTable** ppConstantTable)</unmanaged>
 public ShaderBytecode CompileShader(EffectHandle functionHandle, string target, ShaderFlags flags)
 {
     ConstantTable constantTable;
     var result = CompileShader(functionHandle, target, flags, out constantTable);
     constantTable.Dispose();
     return result;
 }
        public MyEffectAtmosphereBase(string effectPath)
            : base(effectPath)
        {
            m_cameraHeight2 = m_D3DEffect.GetParameter(null, "CameraHeight2");
            m_cameraHeight = m_D3DEffect.GetParameter(null, "CameraHeight");
            m_cameraPos = m_D3DEffect.GetParameter(null, "CameraPos");

            m_outerRadius = m_D3DEffect.GetParameter(null, "OuterRadius");
            m_outerRadius2 = m_D3DEffect.GetParameter(null, "OuterRadius2");
            m_innerRadius = m_D3DEffect.GetParameter(null, "InnerRadius");
            m_innerRadius2 = m_D3DEffect.GetParameter(null, "InnerRadius2");

            m_scaleAtmosphere = m_D3DEffect.GetParameter(null, "ScaleAtmosphere");

            m_scaleDepth = m_D3DEffect.GetParameter(null, "ScaleDepth");

            m_scaleOverScaleDepth = m_D3DEffect.GetParameter(null, "ScaleOverScaleDepth");

            m_lightPosition = m_D3DEffect.GetParameter(null, "LightPosition");

            m_isInside = m_D3DEffect.GetParameter(null, "IsInAtmosphere");

            m_invWavelength = m_D3DEffect.GetParameter(null, "InvWavelength");

        }
 public MyEffectSpriteBatchShader()
     : base("Effects2\\Sprites\\MyEffectSpriteBatchShader")
 {
     m_Texture1 = m_D3DEffect.GetParameter(null, "Texture1");
     m_Texture2 = m_D3DEffect.GetParameter(null, "Texture2");
     m_TextureTiling = m_D3DEffect.GetParameter(null, "Texture2Tiling");
 }
        public MyEffectTransparentGeometry()
            : base("Effects2\\TransparentGeometry\\MyEffectTransparentGeometry")
        {
            m_worldMatrix = m_D3DEffect.GetParameter(null, "WorldMatrix");
            m_projectionMatrix = m_D3DEffect.GetParameter(null, "ProjectionMatrix");
            m_viewMatrix = m_D3DEffect.GetParameter(null, "ViewMatrix");

            m_worldViewMatrix = m_D3DEffect.GetParameter(null, "WorldViewMatrix");
            m_worldViewProjectionMatrix = m_D3DEffect.GetParameter(null, "WorldViewProjectionMatrix");

            m_billboardTexture = m_D3DEffect.GetParameter(null, "BillboardTexture");
            m_billboardBlendTexture = m_D3DEffect.GetParameter(null, "BillboardBlendTexture");
            m_billboardBlendRatio = m_D3DEffect.GetParameter(null, "BillboardBlendRatio");
            m_depthsRT = m_D3DEffect.GetParameter(null, "DepthsRT");
            m_halfPixel = m_D3DEffect.GetParameter(null, "HalfPixel");
            m_scale = m_D3DEffect.GetParameter(null, "Scale");
            m_softParticleDistanceScale = m_D3DEffect.GetParameter(null, "SoftParticleDistanceScale");

            m_colorizeColor = m_D3DEffect.GetParameter(null, "ColorizeColor");
            m_colorizePlaneNormal = m_D3DEffect.GetParameter(null, "ColorizePlaneNormal");
            m_colorizePlaneDistance = m_D3DEffect.GetParameter(null, "ColorizePlaneDistance");
            m_colorizeSoftDistance = m_D3DEffect.GetParameter(null, "ColorizeSoftDistance");

            m_alphaMultiplier = m_D3DEffect.GetParameter(null, "AlphaMultiplierSaturation");

            m_litBasicTechnique = m_D3DEffect.GetTechnique("Technique_LitBasic");
            m_unlitBasicTechnique = m_D3DEffect.GetTechnique("Technique_UnlitBasic");
            m_unlitBasicForwardTechnique = m_D3DEffect.GetTechnique("Technique_UnlitBasic_Forward");
            m_ignoreDepthBasicTechnique = m_D3DEffect.GetTechnique("Technique_IgnoreDepthBasic");
            m_colorizeTechnique = m_D3DEffect.GetTechnique("Technique_ColorizeHeight");

            m_visualizeOverdrawTechnique = m_D3DEffect.GetTechnique("Technique_VisualizeOverdraw");

            Reflector = new MyEffectReflectorBase(m_D3DEffect);
        }
        public MyEffectShadowMap()
            : base("Effects2\\Shadows\\MyEffectShadowMap")
        {
            m_bias = m_D3DEffect.GetParameter(null, "ShadowBias");
            m_invViewMatrix = m_D3DEffect.GetParameter(null, "InvViewMatrix");
            m_lightViewProjMatrices = m_D3DEffect.GetParameter(null, "LightViewProjMatrices");
            m_frustumCornersVS = m_D3DEffect.GetParameter(null, "FrustumCornersVS");
            m_clipPlanes = m_D3DEffect.GetParameter(null, "ClipPlanes");
            m_shadowMap = m_D3DEffect.GetParameter(null, "ShadowMap");
            m_depthTexture = m_D3DEffect.GetParameter(null, "DepthTexture");
            m_shadowTermHalfPixel = m_D3DEffect.GetParameter(null, "ShadowTermHalfPixel");
            m_shadowMapSize = m_D3DEffect.GetParameter(null, "ShadowMapSize");
            m_showSplitColors = m_D3DEffect.GetParameter(null, "ShowSplitColors");
            m_halfPixel = m_D3DEffect.GetParameter(null, "HalfPixel");
            m_worldMatrix = m_D3DEffect.GetParameter(null, "WorldMatrix");
            m_viewProjMatrix = m_D3DEffect.GetParameter(null, "ViewProjMatrix");
            m_bones = m_D3DEffect.GetParameter(null, "Bones");
            m_dithering = m_D3DEffect.GetParameter(null, "Dithering");
            m_ditheringTexture = m_D3DEffect.GetParameter(null, "TextureDithering");
            m_ditheringTextureSize = m_D3DEffect.GetParameter(null, "TextureDitheringSize");


            m_createShadowTerm2x2 = m_D3DEffect.GetTechnique("CreateShadowTerm2x2PCF");
            m_createShadowTerm3x3 = m_D3DEffect.GetTechnique("CreateShadowTerm3x3PCF");
            m_createShadowTerm5x5 = m_D3DEffect.GetTechnique("CreateShadowTerm5x5PCF");
            m_createShadowTerm7x7 = m_D3DEffect.GetTechnique("CreateShadowTerm7x7PCF");
            m_generateShadowMap = m_D3DEffect.GetTechnique("GenerateShadowMap");
            m_generateVoxelShadowMap = m_D3DEffect.GetTechnique("GenerateVoxelShadowMap");
            m_generateShadowSkinned = m_D3DEffect.GetTechnique("GenerateShadowMapSkinned");
            m_clearTechnique = m_D3DEffect.GetTechnique("Clear");

            m_generateShadowMapInstanced = m_D3DEffect.GetTechnique("GenerateShadowMapInstanced");
            m_generateShadowMapInstancedGeneric = m_D3DEffect.GetTechnique("GenerateShadowMapInstancedGeneric");
        }
        public MyEffectBlendLights()
            : base("Effects2\\Lights\\MyEffectBlendLights")
        {
            m_Diffuse = m_D3DEffect.GetParameter(null, "DiffuseTexture");
            m_Lights = m_D3DEffect.GetParameter(null, "LightTexture");
            m_LightsMod = m_D3DEffect.GetParameter(null, "LightTextureMod");
            m_LightsDiv = m_D3DEffect.GetParameter(null, "LightTextureDiv");
            m_Depth = m_D3DEffect.GetParameter(null, "DepthTexture");
            m_Normal = m_D3DEffect.GetParameter(null, "NormalsTexture");
            m_backgroundTexture = m_D3DEffect.GetParameter(null, "BackgroundTexture");
            m_halfPixel = m_D3DEffect.GetParameter(null, "HalfPixel");
            m_scale = m_D3DEffect.GetParameter(null, "Scale");
            m_AmbientColor = m_D3DEffect.GetParameter(null, "AmbientColor");

            m_basicTechnique = m_D3DEffect.GetTechnique("BasicTechnique");
            m_disableLightsTechnique = m_D3DEffect.GetTechnique("DisableLightsTechnique");
            m_onlyLightsTechnique = m_D3DEffect.GetTechnique("OnlyLightsTechnique");
            m_onlySpecularIntensityTechnique = m_D3DEffect.GetTechnique("OnlySpecularIntensity");
            m_onlySpecularPowerTechnique = m_D3DEffect.GetTechnique("OnlySpecularPower");
            m_onlyEmissivityTechnique = m_D3DEffect.GetTechnique("OnlyEmissivity");
            m_onlyReflectivityTechnique = m_D3DEffect.GetTechnique("OnlyReflectivity");
            m_copyEmissivity = m_D3DEffect.GetTechnique("CopyEmissivity");

            DefaultTechnique = Technique.LightsEnabled;
            CopyEmissivityTechnique = Technique.CopyEmissivity;
            SetTechnique(DefaultTechnique);
        }
        public MyEffectAtmosphere()
            : base("Effects2\\Models\\MyEffectAtmosphere")
        {
            m_viewMatrix = m_D3DEffect.GetParameter(null, "ViewMatrix");
            m_worldMatrix = m_D3DEffect.GetParameter(null, "WorldMatrix");
            m_projectionMatrix = m_D3DEffect.GetParameter(null, "ProjectionMatrix");

            m_normalTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityNormal");
        
            m_cameraHeight2 = m_D3DEffect.GetParameter(null, "CameraHeight2");
            m_cameraHeight = m_D3DEffect.GetParameter(null, "CameraHeight");
            m_cameraPos = m_D3DEffect.GetParameter(null, "CameraPos");

            m_outerRadius = m_D3DEffect.GetParameter(null, "OuterRadius");
            m_outerRadius2 = m_D3DEffect.GetParameter(null, "OuterRadius2");
            m_innerRadius = m_D3DEffect.GetParameter(null, "InnerRadius");
            m_innerRadius2 = m_D3DEffect.GetParameter(null, "InnerRadius2");

            m_scaleAtmosphere = m_D3DEffect.GetParameter(null, "ScaleAtmosphere");

            m_scaleDepth = m_D3DEffect.GetParameter(null, "ScaleDepth");

            m_scaleOverScaleDepth = m_D3DEffect.GetParameter(null, "ScaleOverScaleDepth");

            m_lightPosition = m_D3DEffect.GetParameter(null, "LightPosition");

            m_isInside = m_D3DEffect.GetParameter(null, "IsInAtmosphere");

        }
 public MyEffectBackgroundCube()
     : base("Effects2\\BackgroundCube\\MyBackgroundCube")
 {
     m_backgroundTexture = m_D3DEffect.GetParameter(null, "BackgroundTexture");
     m_backgroundColor = m_D3DEffect.GetParameter(null, "BackgroundColor");
     m_viewProjectionMatrix = m_D3DEffect.GetParameter(null, "ViewProjectionMatrix");
 }
        public override void Init(Effect effect)
        {
            _gTexture = effect.GetParameter(null, "gTexture");
            SetTexture(_gTexture, _texture);

            base.Init(effect);
        }
        public MyEffectVoxelsBase(string asset)
            : base(asset)
        {
            m_projectionMatrix = m_D3DEffect.GetParameter(null, "ProjectionMatrix");

            m_textureDiffuseForAxisXZ = m_D3DEffect.GetParameter(null, "TextureDiffuseForAxisXZ");
            m_textureDiffuseForAxisY = m_D3DEffect.GetParameter(null, "TextureDiffuseForAxisY");
            m_textureNormalMapForAxisXZ = m_D3DEffect.GetParameter(null, "TextureNormalMapForAxisXZ");
            m_textureNormalMapForAxisY = m_D3DEffect.GetParameter(null, "TextureNormalMapForAxisY");

            m_textureDiffuseForAxisXZ2 = m_D3DEffect.GetParameter(null, "TextureDiffuseForAxisXZ2");
            m_textureDiffuseForAxisY2 = m_D3DEffect.GetParameter(null, "TextureDiffuseForAxisY2");
            m_textureNormalMapForAxisXZ2 = m_D3DEffect.GetParameter(null, "TextureNormalMapForAxisXZ2");
            m_textureNormalMapForAxisY2 = m_D3DEffect.GetParameter(null, "TextureNormalMapForAxisY2");

            m_textureDiffuseForAxisXZ3 = m_D3DEffect.GetParameter(null, "TextureDiffuseForAxisXZ3");
            m_textureDiffuseForAxisY3 = m_D3DEffect.GetParameter(null, "TextureDiffuseForAxisY3");
            m_textureNormalMapForAxisXZ3 = m_D3DEffect.GetParameter(null, "TextureNormalMapForAxisXZ3");
            m_textureNormalMapForAxisY3 = m_D3DEffect.GetParameter(null, "TextureNormalMapForAxisY3");

            m_specularIntensity = m_D3DEffect.GetParameter(null, "SpecularIntensity");
            m_specularPower = m_D3DEffect.GetParameter(null, "SpecularPower");

            m_specularIntensity2 = m_D3DEffect.GetParameter(null, "SpecularIntensity2");
            m_specularPower2 = m_D3DEffect.GetParameter(null, "SpecularPower2");

            m_specularIntensity3 = m_D3DEffect.GetParameter(null, "SpecularIntensity3");
            m_specularPower3 = m_D3DEffect.GetParameter(null, "SpecularPower3");

            m_textureDistances = m_D3DEffect.GetParameter(null, "TEXTURE_DISTANCE");
            m_textureScales = m_D3DEffect.GetParameter(null, "TEXTURE_SCALE");

            m_lowTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityLow");
            m_normalTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityNormal");
            m_highTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityHigh");
            m_extremeTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityExtreme");

            m_normalMultimaterialTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityNormal_Multimaterial");
            m_highMultimaterialTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityHigh_Multimaterial");
            m_extremeMultimaterialTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityExtreme_Multimaterial");

            m_normalFarTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityNormal_Far");
            m_normalMultimaterialFarTechnique = D3DEffect.GetTechnique("Technique_RenderQualityNormal_Mulitmaterial_Far");

            m_highFarTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityHigh_Far");
            m_highMultimaterialFarTechnique = D3DEffect.GetTechnique("Technique_RenderQualityHigh_Mulitmaterial_Far");

            m_extremeFarTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityExtreme_Far");
            m_extremeMultimaterialFarTechnique = D3DEffect.GetTechnique("Technique_RenderQualityExtreme_Mulitmaterial_Far"); 


            m_lowInstancedTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityLow_Instanced");
            m_normalInstancedTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityNormal_Instanced");
            m_highInstancedTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityHigh_Instanced");
            m_extremeInstancedTechnique = m_D3DEffect.GetTechnique("Technique_RenderQualityExtreme_Instanced");

            DynamicLights = new MyEffectDynamicLightingBase(m_D3DEffect);
            Reflector = new MyEffectReflectorBase(m_D3DEffect);

        }
 public MyEffectThreshold()
     : base("Effects2\\HDR\\MyEffectThreshold")
 {
     m_threshold = m_D3DEffect.GetParameter(null, "Threshold");
     m_bloomIntensity = m_D3DEffect.GetParameter(null, "BloomIntensity");
     m_bloomIntensityBackground = m_D3DEffect.GetParameter(null, "BloomIntensityBackground");
 }
        private void Init()
        {
              m_dynamicLightsCount = m_D3DEffect.GetParameter(null, "DynamicLightsCount");

            m_sunColor = m_D3DEffect.GetParameter(null, "SunColor");
            m_sunIntensity = m_D3DEffect.GetParameter(null, "SunIntensity");
            m_directionToSun = m_D3DEffect.GetParameter(null, "DirectionToSun");
            m_ambientColor = m_D3DEffect.GetParameter(null, "AmbientColor");


            //  Dynamic lights array
            EffectHandle dynamicLights = m_D3DEffect.GetParameter(null, "DynamicLights");
            if (dynamicLights != null)
            {
                DynamicLightsPosition = new EffectHandle[MyLightsConstants.MAX_LIGHTS_FOR_EFFECT];
                DynamicLightsColor = new EffectHandle[MyLightsConstants.MAX_LIGHTS_FOR_EFFECT];
                DynamicLightsFalloff = new EffectHandle[MyLightsConstants.MAX_LIGHTS_FOR_EFFECT];
                DynamicLightsRange = new EffectHandle[MyLightsConstants.MAX_LIGHTS_FOR_EFFECT];
                for (int i = 0; i < MyLightsConstants.MAX_LIGHTS_FOR_EFFECT; i++)
                {
                    DynamicLightsPosition[i] = m_D3DEffect.GetParameter(m_D3DEffect.GetParameterElement(dynamicLights, i), "Position");
                    DynamicLightsColor[i] = m_D3DEffect.GetParameter(m_D3DEffect.GetParameterElement(dynamicLights, i), "Color");
                    DynamicLightsFalloff[i] = m_D3DEffect.GetParameter(m_D3DEffect.GetParameterElement(dynamicLights, i), "Falloff");
                    DynamicLightsRange[i] = m_D3DEffect.GetParameter(m_D3DEffect.GetParameterElement(dynamicLights, i), "Range");
                }
            }
        }
 public MyEffectRenderGizmo()
     : base("Effects2\\Models\\MyEffectRenderGizmo")
 {
     m_worldViewProjectionMatrix = m_D3DEffect.GetParameter(null, "WorldViewProjectionMatrix");
     m_textureDiffuse = m_D3DEffect.GetParameter(null, "TextureDiffuse");
     m_diffuseColor = m_D3DEffect.GetParameter(null, "DiffuseColor");
     m_technique_RenderGizmo = m_D3DEffect.GetTechnique("Technique_RenderGizmo");
 }
 public MyEffectColorMapping() :
     base("Effects2\\Fullscreen\\MyEffectColorMapping")
 {
     m_inputTexture      = m_D3DEffect.GetParameter(null, "InputTexture");
     m_halfPixel         = m_D3DEffect.GetParameter(null, "HalfPixel");
     m_techniqueEnabled  = m_D3DEffect.GetTechnique("ColorMappingEnabled");
     m_techniqueDisabled = m_D3DEffect.GetTechnique("ColorMappingDisabled");
 }
 public MyEffectVignetting():
     base("Effects2\\Fullscreen\\MyEffectVignetting")
 {
     m_inputTexture       = m_D3DEffect.GetParameter(null, "InputTexture");
     m_halfPixel          = m_D3DEffect.GetParameter(null, "HalfPixel");
     m_vignettingPower    = m_D3DEffect.GetParameter(null, "VignettingPower");
     m_vignettingEnabled  = m_D3DEffect.GetTechnique("VignettingEnabled");
     m_vignettingDisabled = m_D3DEffect.GetTechnique("VignettingDisabled");
 }
        private void Init()
        {
            m_cameraPosition = m_D3DEffect.GetParameter(null, "CameraPosition");
            m_reflectorDirection = m_D3DEffect.GetParameter(null, "ReflectorDirection");
            m_reflectorConeMaxAngleCos = m_D3DEffect.GetParameter(null, "ReflectorConeMaxAngleCos");
            m_reflectorColor = m_D3DEffect.GetParameter(null, "ReflectorColor");
            m_reflectorRange = m_D3DEffect.GetParameter(null, "ReflectorRange");

        }
 public MyEffectVoxelsDebris()
     : base("Effects2\\Voxels\\MyEffectVoxelsDebris")
 {
     m_worldMatrix = m_D3DEffect.GetParameter(null, "WorldMatrix");
     m_viewWorldScaleMatrix = m_D3DEffect.GetParameter(null, "ViewWorldScaleMatrix");
     m_textureCoordRandomPositionOffset = m_D3DEffect.GetParameter(null, "TextureCoordRandomPositionOffset");
     m_textureCoordScale = m_D3DEffect.GetParameter(null, "TextureCoordScale");
     m_diffuseTextureColorMultiplier = m_D3DEffect.GetParameter(null, "DiffuseTextureColorMultiplier");
 }
Esempio n. 18
0
 public MyEffectAntiAlias()
     : base("Effects2\\Fullscreen\\MyEffectAntiAlias")
 {
     m_diffuse = m_D3DEffect.GetParameter(null, "DiffuseTexture");
     m_fullPixel = m_D3DEffect.GetParameter(null, "FullPixel");
     m_halfPixel = m_D3DEffect.GetParameter(null, "HalfPixel");
     m_applyFxaa = m_D3DEffect.GetTechnique("ApplyFxaa");
     m_noAntialiasing = m_D3DEffect.GetTechnique("NoAntialiasing");
 }
 public MyEffectContrast()
     : base("Effects2\\Fullscreen\\MyEffectContrast")
 {
     m_diffuseTexture = m_D3DEffect.GetParameter(null, "DiffuseTexture");
     m_contrast = m_D3DEffect.GetParameter(null, "Contrast");
     m_hue = m_D3DEffect.GetParameter(null, "Hue");
     m_saturation = m_D3DEffect.GetParameter(null, "Saturation");
     m_halfPixel = m_D3DEffect.GetParameter(null, "HalfPixel");
 }
Esempio n. 20
0
 /// <summary>
 /// Gets the value of the specified parameter.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="parameter">Handle of the parameter.</param>
 /// <param name="count">The count.</param>
 /// <returns>
 /// The value of the parameter.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::GetValue([In] D3DXHANDLE hParameter,[In] void* pData,[In] unsigned int Bytes)</unmanaged>
 public T[] GetValue <T>(EffectHandle parameter, int count) where T : struct
 {
     unsafe
     {
         var value = new T[count];
         GetValue(parameter, (IntPtr)Interop.Fixed(value), Utilities.SizeOf <T>());
         return(value);
     }
 }
Esempio n. 21
0
        public override void Init(Effect effect)
        {
            _gTime = effect.GetParameter(null, "gTime");
            Set(_gTime, (float)_time.TotalSeconds);
            _gSource = effect.GetParameter(null, "gSource");
            Set(_gSource, _source);

            base.Init(effect);
        }
 public MyEffectSSAOBlur2()
     : base("Effects2\\SSAO\\MyEffectSSAOBlur2")
 {
     m_depthsRT = m_D3DEffect.GetParameter(null, "DepthsRT");
     m_halfPixel = m_D3DEffect.GetParameter(null, "HalfPixel");
     m_SSAOhalfPixel = m_D3DEffect.GetParameter(null, "SSAOHalfPixel");
     m_ssaoRT = m_D3DEffect.GetParameter(null, "SsaoRT");
     m_blurDirection = m_D3DEffect.GetParameter(null, "BlurDirection");
 }
Esempio n. 23
0
 /// <summary>
 /// Gets the value of the specified parameter.
 /// </summary>
 /// <param name="parameter">Handle of the parameter.</param>
 /// <returns>The value of the parameter.</returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::GetValue([In] D3DXHANDLE hParameter,[In] void* pData,[In] unsigned int Bytes)</unmanaged>
 public T GetValue <T>(EffectHandle parameter) where T : struct
 {
     unsafe
     {
         var value = default(T);
         GetValue(parameter, (IntPtr)Interop.Fixed(ref value), Utilities.SizeOf <T>());
         return(value);
     }
 }
 public MyEffectSolarMapGrid()
     : base("Effects2\\SolarSystemMap\\MySolarSystemMapGrid")
 {
     m_gridTexture = m_D3DEffect.GetParameter(null, "GridTexture");
     m_colorA = m_D3DEffect.GetParameter(null, "ColorA");
     m_alphaA = m_D3DEffect.GetParameter(null, "AlphaA");
     m_worldMatrix = m_D3DEffect.GetParameter(null, "WorldMatrix");
     m_viewProjectionMatrix = m_D3DEffect.GetParameter(null, "ViewProjectionMatrix");
 }
Esempio n. 25
0
        internal ShaderPass(DeviceContext context, Shader shader, EffectHandle passHandle, int index)
        {
            Shader = shader;
            Effect = shader.Effect;
            Context = context;
            Index = index;

            PassDescription desc = shader.Effect.GetPassDescription(passHandle);
            Name = desc.Name;
        }
Esempio n. 26
0
 public MyEffectHDRBase(string asset)
     : base(asset)
 {
     m_sourceMod = m_D3DEffect.GetParameter(null, "SourceTexture");
     m_sourceDiv = m_D3DEffect.GetParameter(null, "SourceTextureDiv");
     m_lumSource = m_D3DEffect.GetParameter(null, "LumTexture");
     m_halfPixel = m_D3DEffect.GetParameter(null, "HalfPixel");
     //m_middleGrey = m_xnaEffect.GetParameter(null, "MiddleGrey");
     m_Exposure = m_D3DEffect.GetParameter(null, "Exposure");
 }
Esempio n. 27
0
        public MyEffectComponentVoxelVertex(Effect effect)
        {
            m_effect = effect;

            m_cellOffset         = effect.GetParameter(null, "VoxelVertex_CellOffset");
            m_cellScale          = effect.GetParameter(null, "VoxelVertex_CellScale");
            m_cellRelativeCamera = effect.GetParameter(null, "VoxelVertex_CellRelativeCamera");
            m_bounds             = effect.GetParameter(null, "VoxelVertex_Bounds");
            m_morphDebug         = effect.GetParameter(null, "VoxelVertex_MorphDebug");
        }
        public MyEffectSpotShadowBase(string asset)
            : base(asset)
        {
            m_shadowBias = m_D3DEffect.GetParameter(null, "ShadowBias");
            m_slopeBias = m_D3DEffect.GetParameter(null, "SlopeBias");
            m_shadowMap = m_D3DEffect.GetParameter(null, "ShadowMap");
            m_shadowMapSize = m_D3DEffect.GetParameter(null, "ShadowMapSize");

            m_invViewMatrix = m_D3DEffect.GetParameter(null, "InvViewMatrix");
            m_lightViewProjectionShadow = m_D3DEffect.GetParameter(null, "LightViewProjectionShadow");
        }
Esempio n. 29
0
 /// <summary>
 /// Method to marshal from native to managed struct
 /// </summary>
 /// <param name="__from">The __from.</param>
 /// <param name="ref">The @ref.</param>
 internal static void __MarshalFrom(ref EffectHandle __from, ref __Native @ref)
 {
     if (@ref.Pointer == IntPtr.Zero)
     {
         __from = null;
     }
     else
     {
         __from.pointer = @ref.Pointer;
     }
 }
Esempio n. 30
0
        public MyEffectVoxels()
            : base("Effects2\\Voxels\\MyEffectVoxels")
        {
            m_viewMatrix = m_D3DEffect.GetParameter(null, "ViewMatrix");
            m_voxelMapPosition = m_D3DEffect.GetParameter(null, "VoxelMapPosition");
            m_diffuseColor = m_D3DEffect.GetParameter(null, "DiffuseColor");
            m_highlightColor = m_D3DEffect.GetParameter(null, "Highlight");

            m_worldMatrix = m_D3DEffect.GetParameter(null, "WorldMatrix");
            m_enablePerVertexAmbient = m_D3DEffect.GetParameter(null, "EnablePerVertexAmbient");
        }
Esempio n. 31
0
 /// <summary>
 /// Method to marshal from managed struct tot native
 /// </summary>
 /// <param name="__from">The __from.</param>
 /// <param name="ref">The @ref.</param>
 internal static void __MarshalTo(ref EffectHandle __from, ref __Native @ref)
 {
     if (__from == null)
     {
         @ref.Pointer = IntPtr.Zero;
     }
     else
     {
         @ref.Pointer = __from.pointer;
     }
 }
 public MyEffectLuminance()
     : base("Effects2\\HDR\\MyEffectLuminance")
 {
     m_DT = m_D3DEffect.GetParameter(null, "DT");
     m_Tau = m_D3DEffect.GetParameter(null, "Tau");
     m_MipLevel = m_D3DEffect.GetParameter(null, "MipLevel");
     m_SourceTexture2 = m_D3DEffect.GetParameter(null, "SourceTexture2");
     m_luminance = m_D3DEffect.GetTechnique("Luminance");
     m_calcAdaptedLuminance = m_D3DEffect.GetTechnique("CalcAdaptedLuminance");
     m_luminanceMipmap = m_D3DEffect.GetTechnique("LuminanceMipmap");
 }
Esempio n. 33
0
 public MyEffectScale()
     : base("Effects2\\HDR\\MyEffectScale")
 {
     m_sourceDimensions = m_D3DEffect.GetParameter(null, "SourceDimensions");
     m_scale = m_D3DEffect.GetParameter(null, "Scale");
     //m_downscale = m_xnaEffect.GetTechnique("Downscale"];
     //m_downscaleLuminance = m_xnaEffect.Technique = m_xnaEffect.GetTechnique("DownscaleLuminance"];
     m_HWScale = m_D3DEffect.Technique = m_D3DEffect.GetTechnique("HWScale");
     m_HWScalePrefabPreviews = m_D3DEffect.Technique = m_D3DEffect.GetTechnique("HWScalePrefabPreviews");
     m_downscale8 = m_D3DEffect.Technique = m_D3DEffect.GetTechnique("Downscale8");
     m_downscale4 = m_D3DEffect.Technique = m_D3DEffect.GetTechnique("Downscale4");
 }
Esempio n. 34
0
        public MyEffectPointLight()
            : base("Effects2\\Lights\\MyEffectPointLight")
        {
            m_normalsRT = m_D3DEffect.GetParameter(null, "NormalsRT");
            m_diffuseRT = m_D3DEffect.GetParameter(null, "DiffuseRT");
            m_depthsRT = m_D3DEffect.GetParameter(null, "DepthsRT");
            m_halfPixel = m_D3DEffect.GetParameter(null, "HalfPixel");
            m_scale = m_D3DEffect.GetParameter(null, "Scale");

            m_lightPosition = m_D3DEffect.GetParameter(null, "LightPosition");
            m_lightRadius = m_D3DEffect.GetParameter(null, "LightRadius");
            m_lightColor = m_D3DEffect.GetParameter(null, "LightColor");
            m_lightSpecularColor = m_D3DEffect.GetParameter(null, "LightSpecularColor");
            m_lightIntensity = m_D3DEffect.GetParameter(null, "LightIntensity");
            m_lightFalloff = m_D3DEffect.GetParameter(null, "Falloff");

            m_worldViewProjMatrix = m_D3DEffect.GetParameter(null, "WorldViewProjMatrix");
            m_viewProjMatrix = m_D3DEffect.GetParameter(null, "ViewProjMatrix");
            m_worldMatrix = m_D3DEffect.GetParameter(null, "WorldMatrix");
            m_viewMatrix = m_D3DEffect.GetParameter(null, "ViewMatrix");
            m_lightViewProjection = m_D3DEffect.GetParameter(null, "LightViewProjection");
            
            m_cameraPosition = m_D3DEffect.GetParameter(null, "CameraPosition");
            m_reflectorDirection = m_D3DEffect.GetParameter(null, "ReflectorDirection");
            m_reflectorConeMaxAngleCos = m_D3DEffect.GetParameter(null, "ReflectorConeMaxAngleCos");
            m_reflectorColor = m_D3DEffect.GetParameter(null, "ReflectorColor");
            m_reflectorRange = m_D3DEffect.GetParameter(null, "ReflectorRange");
            m_reflectorIntensity = m_D3DEffect.GetParameter(null, "ReflectorIntensity");
            m_reflectorFalloff = m_D3DEffect.GetParameter(null, "ReflectorFalloff");
            m_reflectorTexture = m_D3DEffect.GetParameter(null, "ReflectorTexture");
            m_reflectorTextureEnabled = m_D3DEffect.GetParameter(null, "ReflectorTextureEnabled");

            m_nearSlopeBiasDistance = m_D3DEffect.GetParameter(null, "NearSlopeBiasDistance");

            m_pointTechnique = m_D3DEffect.GetTechnique("Technique_Lighting");

            m_pointWithReflectorTechnique = m_D3DEffect.GetTechnique("Technique_LightingWithReflector");
            m_spotTechnique = m_D3DEffect.GetTechnique("Technique_Spot");
            m_spotShadowsTechnique = m_D3DEffect.GetTechnique("Technique_SpotShadows");

            // Reflector texture disabled unless set
            m_D3DEffect.SetValue(m_reflectorTextureEnabled, false);

            DefaultTechnique = MyEffectPointLightTechnique.Default;
            DefaultPointTechnique = MyEffectPointLightTechnique.Default;
            DefaultHemisphereTechnique = MyEffectPointLightTechnique.Default;

            DefaultReflectorTechnique = MyEffectPointLightTechnique.Reflector;
            DefaultSpotTechnique = MyEffectPointLightTechnique.Spot;
            DefaultSpotShadowTechnique = MyEffectPointLightTechnique.SpotShadows;

            SetTechnique(DefaultTechnique);
        }
Esempio n. 35
0
        /// <summary>
        /// Compiles a shader from an effect that contains one or more functions.
        /// </summary>
        /// <param name="functionHandle">The function handle.</param>
        /// <param name="target">The target.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="constantTable">The constant table.</param>
        /// <exception cref="CompilationException">If a compilation errors occurs</exception>
        /// <returns>The bytecode of the effect.</returns>
        /// <unmanaged>HRESULT ID3DXEffectCompiler::CompileShader([In] D3DXHANDLE hFunction,[In] const char* pTarget,[In] unsigned int Flags,[In] ID3DXBuffer** ppShader,[In] ID3DXBuffer** ppErrorMsgs,[In] ID3DXConstantTable** ppConstantTable)</unmanaged>
        public ShaderBytecode CompileShader(EffectHandle functionHandle, string target, ShaderFlags flags, out ConstantTable constantTable)
        {
            Blob shaderBytecode;
            Blob blobForErrors = null;

            try
            {
                CompileShader(functionHandle, target, (int)flags, out shaderBytecode, out blobForErrors, out constantTable);
            }
            catch (SharpDXException ex)
            {
                if (blobForErrors != null)
                {
                    throw new CompilationException(ex.ResultCode, Utilities.BlobToString(blobForErrors));
                }
                throw;
            }
            return(new ShaderBytecode(shaderBytecode));
        }
Esempio n. 36
0
        /// <summary>
        /// Sets an array of bools.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="effectHandle">The effect handle.</param>
        /// <param name="values">The values.</param>
        /// <returns>A <see cref="SharpDX.Result" /> object describing the result of the operation.</returns>
        /// <unmanaged>HRESULT ID3DXConstantTable::SetBoolArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const BOOL* pb,[In] unsigned int Count)</unmanaged>
        public void SetValue(Device device, EffectHandle effectHandle, bool[] values)
        {
            var tempArray = Utilities.ConvertToIntArray(values);

            SetBoolArray(device, effectHandle, tempArray, values.Length);
        }
Esempio n. 37
0
 /// <summary>
 /// Sets an array of 4D vectors.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="values">The values.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetVectorArray([In] D3DXHANDLE hConstant,[In, Buffer] const D3DXVECTOR4* pVector,[In] unsigned int Count)</unmanaged>
 public void SetValue(EffectHandle effectHandle, Vector4[] values)
 {
     SetVectorArray(effectHandle, values, values.Length);
 }
Esempio n. 38
0
 /// <summary>
 /// marshal free.
 /// </summary>
 /// <param name="__from">The __from.</param>
 /// <param name="ref">The @ref.</param>
 internal static void __MarshalFree(ref EffectHandle __from, ref __Native @ref)
 {
 }
Esempio n. 39
0
 /// <summary>
 /// Sets a float value.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXConstantTable::SetFloat([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] float f)</unmanaged>
 public void SetValue(Device device, EffectHandle effectHandle, float value)
 {
     SetFloat(device, effectHandle, value);
 }
Esempio n. 40
0
 /// <summary>
 /// Sets an array of 4D vectors.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="values">The values.</param>
 /// <returns>A <see cref="SharpDX.Result" /> object describing the result of the operation.</returns>
 /// <unmanaged>HRESULT ID3DXConstantTable::SetVectorArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const D3DXVECTOR4* pVector,[In] unsigned int Count)</unmanaged>
 public void SetValue(Device device, EffectHandle effectHandle, Vector4[] values)
 {
     SetVectorArray(device, effectHandle, values, values.Length);
 }
Esempio n. 41
0
 /// <summary>
 /// Sets a matrix.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetMatrix([In] D3DXHANDLE hConstant,[In] const D3DXMATRIX* pMatrix)</unmanaged>
 public void SetValue(EffectHandle effectHandle, Matrix value)
 {
     SetMatrix(effectHandle, ref value);
 }
Esempio n. 42
0
 /// <summary>
 /// Sets a 4D vector.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetVector([In] D3DXHANDLE hConstant,[In] const D3DXVECTOR4* pVector)</unmanaged>
 public void SetValue(EffectHandle effectHandle, Vector4 value)
 {
     SetVector(effectHandle, value);
 }
Esempio n. 43
0
 /// <summary>
 /// Sets an array of floats.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="values">The values.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetFloatArray([In] D3DXHANDLE hConstant,[In, Buffer] const float* pf,[In] unsigned int Count)</unmanaged>
 public void SetValue(EffectHandle effectHandle, float[] values)
 {
     SetFloatArray(effectHandle, values, values.Length);
 }
Esempio n. 44
0
 /// <summary>
 /// Sets an array of ints.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="values">The values.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetIntArray([In] D3DXHANDLE hConstant,[In, Buffer] const int* pn,[In] unsigned int Count)</unmanaged>
 public void SetValue(EffectHandle effectHandle, int[] values)
 {
     SetIntArray(effectHandle, values, values.Length);
 }
Esempio n. 45
0
 /// <summary>
 /// Sets an array of matrices.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="values">The values.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetMatrixArray([In] D3DXHANDLE hConstant,[In, Buffer] const D3DXMATRIX* pMatrix,[In] unsigned int Count)</unmanaged>
 public void SetValue(EffectHandle effectHandle, Matrix[] values)
 {
     SetMatrixArray(effectHandle, values, values.Length);
 }
Esempio n. 46
0
 /// <summary>
 /// Sets an array of ints.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="values">The values.</param>
 /// <returns>A <see cref="SharpDX.Result" /> object describing the result of the operation.</returns>
 /// <unmanaged>HRESULT ID3DXConstantTable::SetIntArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const int* pn,[In] unsigned int Count)</unmanaged>
 public void SetValue(Device device, EffectHandle effectHandle, int[] values)
 {
     SetIntArray(device, effectHandle, values, values.Length);
 }
Esempio n. 47
0
 /// <summary>
 /// Sets an array of matrices.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="values">The values.</param>
 /// <returns>A <see cref="SharpDX.Result" /> object describing the result of the operation.</returns>
 /// <unmanaged>HRESULT ID3DXConstantTable::SetMatrixArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const D3DXMATRIX* pMatrix,[In] unsigned int Count)</unmanaged>
 public void SetValue(Device device, EffectHandle effectHandle, Matrix[] values)
 {
     SetMatrixArray(device, effectHandle, values, values.Length);
 }
Esempio n. 48
0
 /// <summary>
 /// Sets an int value.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetInt([In] D3DXHANDLE hConstant,[In] int n)</unmanaged>
 public void SetValue(EffectHandle effectHandle, int value)
 {
     SetInt(effectHandle, value);
 }
Esempio n. 49
0
 /// <summary>
 /// Sets a bool value.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXConstantTable::SetBool([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] BOOL b)</unmanaged>
 public void SetValue(Device device, EffectHandle effectHandle, bool value)
 {
     SetBool(device, effectHandle, value);
 }
Esempio n. 50
0
        protected void ProcessParamElement(D3D9.EffectHandle parent, string prefix, int index)
        {
            var constant = this.constTable.GetConstant(parent, index);

            // Since D3D HLSL doesn't deal with naming of array and struct parameters
            // automatically, we have to do it by hand
            var desc = this.constTable.GetConstantDescription(constant);

            var paramName = desc.Name;

            // trim the odd '$' which appears at the start of the names in HLSL
            if (paramName.StartsWith("$"))
            {
                paramName = paramName.Remove(0, 1);
            }

            // Also trim the '[0]' suffix if it exists, we will add our own indexing later
            if (paramName.EndsWith("[0]"))
            {
                paramName.Remove(paramName.Length - 3);
            }

            if (desc.Class == D3D9.ParameterClass.Struct)
            {
                // work out a new prefix for the nextest members if its an array, we need the index
                prefix += paramName + ".";
                // Cascade into struct
                for (var i = 0; i < desc.StructMembers; ++i)
                {
                    ProcessParamElement(constant, prefix, i);
                }
            }
            else
            {
                // process params
                if (desc.Type == D3D9.ParameterType.Float || desc.Type == D3D9.ParameterType.Int ||
                    desc.Type == D3D9.ParameterType.Bool)
                {
                    var paramIndex = desc.RegisterIndex;
                    var name       = prefix + paramName;

                    var def = new GpuProgramParameters.GpuConstantDefinition();
                    def.LogicalIndex = paramIndex;
                    // populate type, array size & element size
                    PopulateDef(desc, def);
                    if (def.IsFloat)
                    {
                        def.PhysicalIndex = floatLogicalToPhysical.BufferSize;
                        lock (floatLogicalToPhysical.Mutex)
                        {
                            floatLogicalToPhysical.Map.Add(paramIndex,
                                                           new GpuProgramParameters.GpuLogicalIndexUse(def.PhysicalIndex,
                                                                                                       def.ArraySize * def.ElementSize,
                                                                                                       GpuProgramParameters.
                                                                                                       GpuParamVariability.Global));

                            floatLogicalToPhysical.BufferSize += def.ArraySize * def.ElementSize;
                            constantDefs.FloatBufferSize       = floatLogicalToPhysical.BufferSize;
                        }
                    }
                    else
                    {
                        def.PhysicalIndex = intLogicalToPhysical.BufferSize;
                        lock (intLogicalToPhysical.Mutex)
                        {
                            intLogicalToPhysical.Map.Add(paramIndex,
                                                         new GpuProgramParameters.GpuLogicalIndexUse(def.PhysicalIndex,
                                                                                                     def.ArraySize * def.ElementSize,
                                                                                                     GpuProgramParameters.
                                                                                                     GpuParamVariability.Global));
                            intLogicalToPhysical.BufferSize += def.ArraySize * def.ElementSize;
                            constantDefs.IntBufferSize       = intLogicalToPhysical.BufferSize;
                        }
                    }

                    constantDefs.Map.Add(paramName.ToLower(), def);

                    // Now deal with arrays
                    constantDefs.GenerateConstantDefinitionArrayEntries(name, def);
                }
            }
        }
Esempio n. 51
0
 /// <summary>
 /// Set a contiguous range of shader constants with a memory copy.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <param name="data">The data.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="countInBytes">The count in bytes.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXEffect::SetRawValue([In] D3DXHANDLE hParameter,[In] const void* pData,[In] unsigned int ByteOffset,[In] unsigned int Bytes)</unmanaged>
 public void SetRawValue(EffectHandle handle, DataStream data, int offset, int countInBytes)
 {
     SetRawValue(handle, (IntPtr)data.PositionPointer, offset, countInBytes);
 }
Esempio n. 52
0
        protected override void LoadFromSource()
        {
            // Populate preprocessor defines
            var defines = new List <D3D9.Macro>();

            if (!string.IsNullOrEmpty(PreprocessorDefines))
            {
                var tmp = PreprocessorDefines.Split(' ', ',', ';');
                foreach (string define in tmp)
                {
                    var macro = new D3D9.Macro();
                    if (define.Contains("="))
                    {
                        var split = define.Split('=');
                        macro.Name       = split[0];
                        macro.Definition = split[1];
                    }
                    else
                    {
                        macro.Name       = define;
                        macro.Definition = "1";
                    }

                    if (!string.IsNullOrEmpty(macro.Name))
                    {
                        defines.Add(macro);
                    }
                }
            }

            // Populate compile flags
            var compileFlags = UseColumnMajorMatrices
                                                ? D3D9.ShaderFlags.PackMatrixColumnMajor
                                                : D3D9.ShaderFlags.PackMatrixRowMajor;

#if DEBUG
            compileFlags |= D3D9.ShaderFlags.Debug;
#endif
            switch (OptimizationLevel)
            {
            case OptimizationLevel.Default:
                compileFlags |= D3D9.ShaderFlags.OptimizationLevel1;
                break;

            case OptimizationLevel.None:
                compileFlags |= D3D9.ShaderFlags.SkipOptimization;
                break;

            case OptimizationLevel.LevelZero:
                compileFlags |= D3D9.ShaderFlags.OptimizationLevel0;
                break;

            case OptimizationLevel.LevelOne:
                compileFlags |= D3D9.ShaderFlags.OptimizationLevel1;
                break;

            case OptimizationLevel.LevelTwo:
                compileFlags |= D3D9.ShaderFlags.OptimizationLevel2;
                break;

            case OptimizationLevel.LevelThree:
                compileFlags |= D3D9.ShaderFlags.OptimizationLevel3;
                break;
            }

            var parseFlags = compileFlags;
            compileFlags ^= UseColumnMajorMatrices ? D3D9.ShaderFlags.PackMatrixColumnMajor : D3D9.ShaderFlags.PackMatrixRowMajor;

            // include handler
            var includeHandler = new HLSLIncludeHandler(this);

            // Compile & assemble into microcode
            var effectCompiler = new D3D9.EffectCompiler(Source, defines.ToArray(), includeHandler, parseFlags);
            var effectHandle   = new D3D9.EffectHandle(EntryPoint);
            var errors         = string.Empty;

            try
            {
                MicroCode = effectCompiler.CompileShader(effectHandle, Target, compileFlags, out this.constTable);
            }
            catch (DX.SharpDXException ex)
            {
                if (ex is DX.CompilationException)
                {
                    errors = ex.Message;
                }

                // check for errors
                if (!string.IsNullOrEmpty(errors))
                {
                    if (MicroCode != null)
                    {
                        if (LogManager.Instance != null)
                        {
                            LogManager.Instance.Write("HLSL: Warnings while compiling high level shader {0}:\n{1}", Name, errors);
                        }
                    }
                    else
                    {
                        throw new AxiomException("HLSL: Unable to compile high level shader {0}:\n{1}", Name, errors);
                    }
                }
            }
            finally
            {
                effectCompiler.Dispose();
                effectHandle.Dispose();
                includeHandler.Dispose();
            }
        }
Esempio n. 53
0
 /// <summary>
 /// Set a contiguous range of shader constants with a memory copy.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <param name="data">The data.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXEffect::SetRawValue([In] D3DXHANDLE hParameter,[In] const void* pData,[In] unsigned int ByteOffset,[In] unsigned int Bytes)</unmanaged>
 public void SetRawValue(EffectHandle handle, DataStream data)
 {
     SetRawValue(handle, data, 0, (int)data.Length);
 }
Esempio n. 54
0
 /// <summary>
 /// Sets an int value.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXConstantTable::SetInt([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] int n)</unmanaged>
 public void SetValue(Device device, EffectHandle effectHandle, int value)
 {
     SetInt(device, effectHandle, value);
 }
Esempio n. 55
0
 /// <summary>
 /// Set a contiguous range of shader constants with a memory copy.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <param name="data">The data.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXEffect::SetRawValue([In] D3DXHANDLE hParameter,[In] const void* pData,[In] unsigned int ByteOffset,[In] unsigned int Bytes)</unmanaged>
 public void SetRawValue(EffectHandle handle, float[] data)
 {
     SetRawValue(handle, data, 0, data.Length);
 }
Esempio n. 56
0
 /// <summary>
 /// Sets a float value.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetFloat([In] D3DXHANDLE hConstant,[In] float f)</unmanaged>
 public void SetValue(EffectHandle effectHandle, float value)
 {
     SetFloat(effectHandle, value);
 }
Esempio n. 57
0
 /// <summary>
 /// Sets a matrix.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXConstantTable::SetMatrix([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] const D3DXMATRIX* pMatrix)</unmanaged>
 public void SetValue(Device device, EffectHandle effectHandle, Matrix value)
 {
     SetMatrix(device, effectHandle, ref value);
 }
Esempio n. 58
0
 /// <summary>
 /// Gets the string.
 /// </summary>
 /// <param name="parameter">The parameter.</param>
 /// <returns></returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::GetString([In] D3DXHANDLE hParameter,[Out] const void** ppString)</unmanaged>
 public string GetString(EffectHandle parameter)
 {
     return(Marshal.PtrToStringAnsi(GetString_(parameter)));
 }
Esempio n. 59
0
 /// <summary>
 /// Sets a 4D vector.
 /// </summary>
 /// <param name="device">The device.</param>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXConstantTable::SetVector([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] const D3DXVECTOR4* pVector)</unmanaged>
 public void SetValue(Device device, EffectHandle effectHandle, Vector4 value)
 {
     SetVector(device, effectHandle, value);
 }
Esempio n. 60
0
 /// <summary>
 /// Sets a bool value.
 /// </summary>
 /// <param name="effectHandle">The effect handle.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 /// A <see cref="SharpDX.Result"/> object describing the result of the operation.
 /// </returns>
 /// <unmanaged>HRESULT ID3DXBaseEffect::SetBool([In] D3DXHANDLE hConstant,[In] BOOL b)</unmanaged>
 public void SetValue(EffectHandle effectHandle, bool value)
 {
     SetBool(effectHandle, value);
 }