mirror of
https://github.com/ZuneDev/Xune.git
synced 2026-07-27 13:13:10 -07:00
Simplified usages
This commit is contained in:
@@ -17,21 +17,21 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
internal AncestorEnumerator(TreeNode nodeStart)
|
||||
{
|
||||
this.m_nodeStart = nodeStart;
|
||||
this.m_nodeCurrent = (TreeNode)null;
|
||||
this.m_nodeCurrent = null;
|
||||
this.m_nodeNext = this.m_nodeStart;
|
||||
}
|
||||
|
||||
object IEnumerator.Current => (object)this.m_nodeCurrent;
|
||||
object IEnumerator.Current => m_nodeCurrent;
|
||||
|
||||
public TreeNode Current => this.m_nodeCurrent;
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => (IEnumerator)this;
|
||||
IEnumerator IEnumerable.GetEnumerator() => this;
|
||||
|
||||
public AncestorEnumerator GetEnumerator() => this;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.m_nodeCurrent = (TreeNode)null;
|
||||
this.m_nodeCurrent = null;
|
||||
this.m_nodeNext = this.m_nodeStart;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
if (!fInDispose || this.m_remoteCamera == null)
|
||||
return;
|
||||
this.m_remoteCamera.Dispose();
|
||||
this.m_remoteCamera = (RemoteCamera)null;
|
||||
this.m_remoteCamera = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -63,7 +63,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
|
||||
RENDERHANDLE IRenderHandleOwner.RenderHandle => this.m_remoteCamera.RenderHandle;
|
||||
|
||||
void IRenderHandleOwner.OnDisconnect() => this.m_remoteCamera = (RemoteCamera)null;
|
||||
void IRenderHandleOwner.OnDisconnect() => this.m_remoteCamera = null;
|
||||
|
||||
internal RemoteCamera RemoteStub => this.m_remoteCamera;
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
|
||||
private void SetZn(float flZn)
|
||||
{
|
||||
if ((double)this.m_flZn == (double)flZn)
|
||||
if (m_flZn == (double)flZn)
|
||||
return;
|
||||
this.m_flZn = flZn;
|
||||
if (!this.m_session.IsValid || !this.m_remoteCamera.IsValid)
|
||||
@@ -151,13 +151,13 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
|
||||
uint IAnimatableObject.GetPropertyId(string propertyName)
|
||||
{
|
||||
if (propertyName == Camera.EyeProperty)
|
||||
if (propertyName == EyeProperty)
|
||||
return 1;
|
||||
if (propertyName == Camera.AtProperty)
|
||||
if (propertyName == AtProperty)
|
||||
return 2;
|
||||
if (propertyName == Camera.UpProperty)
|
||||
if (propertyName == UpProperty)
|
||||
return 3;
|
||||
if (propertyName == Camera.ZnProperty)
|
||||
if (propertyName == ZnProperty)
|
||||
return 4;
|
||||
Debug2.Validate(false, typeof(ArgumentException), "Unsupported property");
|
||||
return 0;
|
||||
@@ -166,9 +166,9 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
AnimationInputType IAnimatableObject.GetPropertyType(
|
||||
string propertyName)
|
||||
{
|
||||
if (propertyName == Camera.EyeProperty || propertyName == Camera.AtProperty || propertyName == Camera.UpProperty)
|
||||
if (propertyName == EyeProperty || propertyName == AtProperty || propertyName == UpProperty)
|
||||
return AnimationInputType.Vector3;
|
||||
if (propertyName == Camera.ZnProperty)
|
||||
if (propertyName == ZnProperty)
|
||||
return AnimationInputType.Float;
|
||||
Debug2.Validate(false, typeof(ArgumentException), "Unsupported property");
|
||||
return AnimationInputType.Float;
|
||||
|
||||
@@ -18,69 +18,69 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
ref Dx9EffectBuilder effectBuilder)
|
||||
{
|
||||
effectBuilder.PixelShaderOutput = effectBuilder.GenerateLocalVariable(Dx9VariableType.Vector4, efiBlend.Name);
|
||||
string str1 = (string)null;
|
||||
string str1 = null;
|
||||
switch (efiBlend.ColorOperation)
|
||||
{
|
||||
case ColorOperation.Add:
|
||||
str1 = InvariantString.Format(" // Blend the RGB - result\r\n float4 {0};\r\n {0}.rgb = {1}.rgb + {2}.rgb;\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB - result\r\n float4 {0};\r\n {0}.rgb = {1}.rgb + {2}.rgb;\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case ColorOperation.Subtract:
|
||||
str1 = InvariantString.Format(" // Blend the RGB - result\r\n float4 {0};\r\n {0}.rgb = float3(abs({1}.rgb - {2}.rgb));\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB - result\r\n float4 {0};\r\n {0}.rgb = float3(abs({1}.rgb - {2}.rgb));\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case ColorOperation.Multiply:
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = {1}.rgb * {2}.rgb;\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = {1}.rgb * {2}.rgb;\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case ColorOperation.Lighten:
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = max({1}.rgb, {2}.rgb);\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = max({1}.rgb, {2}.rgb);\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case ColorOperation.Darken:
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = min({1}.rgb, {2}.rgb);\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = min({1}.rgb, {2}.rgb);\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case ColorOperation.ColorDodge:
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = {1}.rgb / (1 - {2}.rgb);\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = {1}.rgb / (1 - {2}.rgb);\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case ColorOperation.ColorBurn:
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = 1 - ((1 - {1}.rgb) / {2}.rgb);\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = 1 - ((1 - {1}.rgb) / {2}.rgb);\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case ColorOperation.Screen:
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = 1 - ((1 - {1}.rgb) * (1 - {2}.rgb));\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = 1 - ((1 - {1}.rgb) * (1 - {2}.rgb));\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case ColorOperation.Overlay:
|
||||
string localVariable1 = effectBuilder.GenerateLocalVariable(Dx9VariableType.Float, "trueClause");
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float3 {3} = ceil({1}.rgb - 0.5);\r\n float4 {0};\r\n {0}.rgb = {3}.rgb * (1 - (1 - 2 * ({1}.rgb - 0.5)) * (1 - {2}.rgb)) \r\n + (1 - {3}.rgb) * (2 * {1}.rgb * {2}.rgb);\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2, (object)localVariable1);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float3 {3} = ceil({1}.rgb - 0.5);\r\n float4 {0};\r\n {0}.rgb = {3}.rgb * (1 - (1 - 2 * ({1}.rgb - 0.5)) * (1 - {2}.rgb)) \r\n + (1 - {3}.rgb) * (2 * {1}.rgb * {2}.rgb);\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2, localVariable1);
|
||||
break;
|
||||
case ColorOperation.SoftLight:
|
||||
string localVariable2 = effectBuilder.GenerateLocalVariable(Dx9VariableType.Float, "trueClause");
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float3 {3} = ceil({2}.rgb - 0.5);\r\n float4 {0};\r\n {0}.rgb = {3}.rgb * (1 - (2 * (1 - (({1}.rgb / 2) + 0.25)) * (1 - {2}.rgb)))\r\n + (1 - {3}.rgb) * (2 * ({1}.rgb / 2 + 0.25) * {2}.rgb);\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2, (object)localVariable2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float3 {3} = ceil({2}.rgb - 0.5);\r\n float4 {0};\r\n {0}.rgb = {3}.rgb * (1 - (2 * (1 - (({1}.rgb / 2) + 0.25)) * (1 - {2}.rgb)))\r\n + (1 - {3}.rgb) * (2 * ({1}.rgb / 2 + 0.25) * {2}.rgb);\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2, localVariable2);
|
||||
break;
|
||||
case ColorOperation.HardLight:
|
||||
string localVariable3 = effectBuilder.GenerateLocalVariable(Dx9VariableType.Float, "trueClause");
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float3 {3} = ceil({2}.rgb - 0.5);\r\n float4 {0};\r\n {0}.rgb = {3}.rgb * (1 - (1 - 2 * ({2}.rgb - 0.5)) * (1 - {1}.rgb)) \r\n + (1 - {3}.rgb) * (2 * {1}.rgb * {2}.rgb);\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2, (object)localVariable3);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float3 {3} = ceil({2}.rgb - 0.5);\r\n float4 {0};\r\n {0}.rgb = {3}.rgb * (1 - (1 - 2 * ({2}.rgb - 0.5)) * (1 - {1}.rgb)) \r\n + (1 - {3}.rgb) * (2 * {1}.rgb * {2}.rgb);\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2, localVariable3);
|
||||
break;
|
||||
case ColorOperation.LinearBurn:
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = {1}.rgb + {2}.rgb - 1;\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str1 = InvariantString.Format(" // Blend the RGB result\r\n float4 {0};\r\n {0}.rgb = {1}.rgb + {2}.rgb - 1;\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
default:
|
||||
Debug2.Throw(false, "Unknown color blend operation");
|
||||
break;
|
||||
}
|
||||
string str2 = (string)null;
|
||||
string str2 = null;
|
||||
switch (efiBlend.AlphaOperation)
|
||||
{
|
||||
case AlphaOperation.Add:
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a + {2}.a;\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a + {2}.a;\r\n\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case AlphaOperation.Subtract:
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a - {2}.a;\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a - {2}.a;\r\n\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case AlphaOperation.Multiply:
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a * {2}.a;\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1, (object)stBlendOutput2);
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a * {2}.a;\r\n\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1, stBlendOutput2);
|
||||
break;
|
||||
case AlphaOperation.Source1:
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a;\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput1);
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a;\r\n\r\n", effectBuilder.PixelShaderOutput, stBlendOutput1);
|
||||
break;
|
||||
case AlphaOperation.Source2:
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a;\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)stBlendOutput2);
|
||||
str2 = InvariantString.Format(" // Blend the Alpha result\r\n {0}.a = {1}.a;\r\n\r\n", effectBuilder.PixelShaderOutput, stBlendOutput2);
|
||||
break;
|
||||
default:
|
||||
Debug2.Throw(false, "Unknown alpha blend operation");
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
VariableInfo variableInfo = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoBrightness.BrightnessID,
|
||||
ID = efoBrightness.BrightnessID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoBrightness.IsDynamicProperty("Brightness")
|
||||
};
|
||||
variableInfo.Name = variableInfo.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo.Type, efoBrightness.Name) : effectBuilder.GenerateGlobalConstant(variableInfo.Type, efoBrightness.Name);
|
||||
variableInfo.DefaultValue = (object)efoBrightness.Brightness;
|
||||
variableInfo.DefaultValue = efoBrightness.Brightness;
|
||||
effectBuilder.AddPropertyVariable(variableInfo);
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // adjust brightness based on input\r\n {0}.rgb += float3({1}, {1}, {1});\r\n }}\r\n", (object)effectBuilder.PixelShaderOutput, (object)variableInfo.Name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // adjust brightness based on input\r\n {0}.rgb += float3({1}, {1}, {1});\r\n }}\r\n", effectBuilder.PixelShaderOutput, variableInfo.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
VariableInfo variableInfo = new VariableInfo()
|
||||
{
|
||||
ID = (int)efiColor.ColorID,
|
||||
ID = efiColor.ColorID,
|
||||
Type = Dx9VariableType.Vector4,
|
||||
IsDynamic = efiColor.IsDynamicProperty("Color")
|
||||
};
|
||||
variableInfo.Name = variableInfo.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo.Type, efiColor.Name) : effectBuilder.GenerateGlobalConstant(variableInfo.Type, efiColor.Name);
|
||||
variableInfo.DefaultValue = (object)efiColor.Color.ToVector4();
|
||||
variableInfo.DefaultValue = efiColor.Color.ToVector4();
|
||||
effectBuilder.AddPropertyVariable(variableInfo);
|
||||
string name = variableInfo.Name;
|
||||
effectBuilder.PixelShaderOutput = effectBuilder.GenerateLocalVariable(Dx9VariableType.Vector4, efiColor.Name);
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Load the color\r\n float4 {0} = {1};\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Load the color\r\n float4 {0} = {1};\r\n\r\n", effectBuilder.PixelShaderOutput, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,53 +14,53 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
VariableInfo variableInfo1 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efiImage.MinFilterID,
|
||||
ID = efiImage.MinFilterID,
|
||||
Type = Dx9VariableType.Integer,
|
||||
IsDynamic = efiImage.IsDynamicProperty("MinFilter")
|
||||
};
|
||||
variableInfo1.Name = variableInfo1.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo1.Type, efiImage.Name + "MinFilter") : effectBuilder.GenerateGlobalConstant(variableInfo1.Type, efiImage.Name + "MinFilter");
|
||||
variableInfo1.DefaultValue = (object)(int)efiImage.MinFilter;
|
||||
variableInfo1.DefaultValue = (int)efiImage.MinFilter;
|
||||
effectBuilder.AddPropertyVariable(variableInfo1);
|
||||
string name1 = variableInfo1.Name;
|
||||
VariableInfo variableInfo2 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efiImage.MagFilterID,
|
||||
ID = efiImage.MagFilterID,
|
||||
Type = Dx9VariableType.Integer,
|
||||
IsDynamic = efiImage.IsDynamicProperty("MagFilter")
|
||||
};
|
||||
variableInfo2.Name = variableInfo2.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo2.Type, efiImage.Name + "MagFilter") : effectBuilder.GenerateGlobalConstant(variableInfo2.Type, efiImage.Name + "MagFilter");
|
||||
variableInfo2.DefaultValue = (object)(int)efiImage.MagFilter;
|
||||
variableInfo2.DefaultValue = (int)efiImage.MagFilter;
|
||||
effectBuilder.AddPropertyVariable(variableInfo2);
|
||||
string name2 = variableInfo2.Name;
|
||||
effectBuilder.AddPropertyVariable(new VariableInfo()
|
||||
{
|
||||
ID = (int)efiImage.CoordinateMapIndexID,
|
||||
ID = efiImage.CoordinateMapIndexID,
|
||||
Type = Dx9VariableType.Integer,
|
||||
IsDynamic = efiImage.IsDynamicProperty("CoordinateMapIndex"),
|
||||
Name = (string)null,
|
||||
DefaultValue = (object)(int)efiImage.CoordinateMapIndex
|
||||
Name = null,
|
||||
DefaultValue = (int)efiImage.CoordinateMapIndex
|
||||
});
|
||||
Dx9TextureInfo dx9TextureInfo = effectBuilder.AllocateTexture();
|
||||
TextureVariableInfo textureVariableInfo = new TextureVariableInfo();
|
||||
textureVariableInfo.ID = (int)efiImage.ImageID;
|
||||
textureVariableInfo.ID = efiImage.ImageID;
|
||||
textureVariableInfo.Type = Dx9VariableType.Texture;
|
||||
textureVariableInfo.Name = effectBuilder.GenerateGlobalVariable(textureVariableInfo.Type, efiImage.Name);
|
||||
textureVariableInfo.DefaultValue = (object)efiImage.Image;
|
||||
textureVariableInfo.DefaultValue = efiImage.Image;
|
||||
textureVariableInfo.SamplerName = dx9TextureInfo.Sampler;
|
||||
textureVariableInfo.MinFilter = InvariantString.Format("<{0}>", (object)name1);
|
||||
textureVariableInfo.MagFilter = InvariantString.Format("<{0}>", (object)name2);
|
||||
textureVariableInfo.CoordinateMapID = (int)efiImage.CoordinateMapIndexID;
|
||||
textureVariableInfo.ImageIndexID = (int)efiImage.ImageIndexID;
|
||||
effectBuilder.AddPropertyVariable((VariableInfo)textureVariableInfo);
|
||||
textureVariableInfo.MinFilter = InvariantString.Format("<{0}>", name1);
|
||||
textureVariableInfo.MagFilter = InvariantString.Format("<{0}>", name2);
|
||||
textureVariableInfo.CoordinateMapID = efiImage.CoordinateMapIndexID;
|
||||
textureVariableInfo.ImageIndexID = efiImage.ImageIndexID;
|
||||
effectBuilder.AddPropertyVariable(textureVariableInfo);
|
||||
effectBuilder.PixelShaderOutput = effectBuilder.GenerateLocalVariable(Dx9VariableType.Vector4, efiImage.Name);
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Load the image\r\n float4 {0} = tex2D({1}, {2});\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)dx9TextureInfo.Sampler, (object)dx9TextureInfo.TexCoordInput));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Load the image\r\n float4 {0} = tex2D({1}, {2});\r\n\r\n", effectBuilder.PixelShaderOutput, dx9TextureInfo.Sampler, dx9TextureInfo.TexCoordInput));
|
||||
effectBuilder.AddPropertyVariable(new VariableInfo()
|
||||
{
|
||||
ID = (int)efiImage.ImageIndexID,
|
||||
ID = efiImage.ImageIndexID,
|
||||
Type = Dx9VariableType.Integer,
|
||||
IsDynamic = efiImage.IsDynamicProperty("ImageIndex"),
|
||||
Name = (string)null,
|
||||
DefaultValue = (object)(int)efiImage.ImageIndex
|
||||
Name = null,
|
||||
DefaultValue = (int)efiImage.ImageIndex
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
VariableInfo variableInfo = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoContrast.ContrastID,
|
||||
ID = efoContrast.ContrastID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoContrast.IsDynamicProperty("Contrast")
|
||||
};
|
||||
variableInfo.Name = variableInfo.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo.Type, efoContrast.Name) : effectBuilder.GenerateGlobalConstant(variableInfo.Type, efoContrast.Name);
|
||||
variableInfo.DefaultValue = (object)efoContrast.Contrast;
|
||||
variableInfo.DefaultValue = efoContrast.Contrast;
|
||||
effectBuilder.AddPropertyVariable(variableInfo);
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // apply the gain factor \r\n {0}.rgb -= float3(0.5f, 0.5f, 0.5f)\r\n; {0}.rgb *= float3({1}, {1}, {1});\r\n {0}.rgb += float3(0.5f, 0.5f, 0.5f)\r\n; }}\r\n", (object)effectBuilder.PixelShaderOutput, (object)variableInfo.Name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // apply the gain factor \r\n {0}.rgb -= float3(0.5f, 0.5f, 0.5f)\r\n; {0}.rgb *= float3({1}, {1}, {1});\r\n {0}.rgb += float3(0.5f, 0.5f, 0.5f)\r\n; }}\r\n", effectBuilder.PixelShaderOutput, variableInfo.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
VariableInfo variableInfo = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoDesaturate.DesaturateID,
|
||||
ID = efoDesaturate.DesaturateID,
|
||||
Type = Dx9VariableType.Float,
|
||||
DefaultValue = (object)efoDesaturate.Desaturate,
|
||||
DefaultValue = efoDesaturate.Desaturate,
|
||||
IsDynamic = efoDesaturate.IsDynamicProperty("Desaturate")
|
||||
};
|
||||
variableInfo.Name = variableInfo.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo.Type, efoDesaturate.Name) : effectBuilder.GenerateGlobalConstant(variableInfo.Type, efoDesaturate.Name);
|
||||
effectBuilder.AddPropertyVariable(variableInfo);
|
||||
string name = variableInfo.Name;
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Desaturate the value\r\n {{\r\n float3 vGray = {{.15, .55, .30}};\r\n float fLuminance = dot({0}.rgb, vGray);\r\n {0}.rgb = lerp({0}.rgb, fLuminance.rrr, {1});\r\n\r\n }}\r\n", (object)effectBuilder.PixelShaderOutput, (object)name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Desaturate the value\r\n {{\r\n float3 vGray = {{.15, .55, .30}};\r\n float fLuminance = dot({0}.rgb, vGray);\r\n {0}.rgb = lerp({0}.rgb, fLuminance.rrr, {1});\r\n\r\n }}\r\n", effectBuilder.PixelShaderOutput, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,42 +15,42 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
ref Dx9EffectBuilder effectBuilder)
|
||||
{
|
||||
Dx9TextureInfo textureInfo = effectBuilder.AllocateTexture();
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.SampleBackbuffer, (object)(int)efiDestination.DownsampleID);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.DisablePerspectiveCorrection, (object)null);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.TexelSize, (object)null);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.SampleBackbuffer, (int)efiDestination.DownsampleID);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.DisablePerspectiveCorrection, null);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.TexelSize, null);
|
||||
TextureVariableInfo textureVariableInfo = new TextureVariableInfo();
|
||||
textureVariableInfo.ID = (int)efiDestination.DestinationID;
|
||||
textureVariableInfo.ID = efiDestination.DestinationID;
|
||||
textureVariableInfo.Type = Dx9VariableType.Texture;
|
||||
textureVariableInfo.Name = effectBuilder.GenerateGlobalVariable(textureVariableInfo.Type, efiDestination.Name);
|
||||
textureVariableInfo.DefaultValue = (object)null;
|
||||
textureVariableInfo.DefaultValue = null;
|
||||
textureVariableInfo.SamplerName = textureInfo.Sampler;
|
||||
textureVariableInfo.MinFilter = "Linear";
|
||||
textureVariableInfo.MagFilter = "Linear";
|
||||
textureVariableInfo.CoordinateMapID = -1;
|
||||
textureVariableInfo.ImageIndexID = -1;
|
||||
effectBuilder.AddPropertyVariable((VariableInfo)textureVariableInfo);
|
||||
effectBuilder.AddPropertyVariable(textureVariableInfo);
|
||||
effectBuilder.AddPropertyVariable(new VariableInfo()
|
||||
{
|
||||
ID = (int)efiDestination.DownsampleID,
|
||||
ID = efiDestination.DownsampleID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efiDestination.IsDynamicProperty("Downsample"),
|
||||
Name = (string)null,
|
||||
DefaultValue = (object)efiDestination.Downsample
|
||||
Name = null,
|
||||
DefaultValue = efiDestination.Downsample
|
||||
});
|
||||
VariableInfo variableInfo = new VariableInfo()
|
||||
{
|
||||
ID = (int)efiDestination.UVOffsetID,
|
||||
ID = efiDestination.UVOffsetID,
|
||||
Type = Dx9VariableType.Vector2,
|
||||
IsDynamic = efiDestination.IsDynamicProperty("UVOffset")
|
||||
};
|
||||
variableInfo.Name = variableInfo.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo.Type, "UVOffset") : effectBuilder.GenerateGlobalConstant(variableInfo.Type, "UVOffset");
|
||||
variableInfo.DefaultValue = (object)efiDestination.UVOffset;
|
||||
variableInfo.DefaultValue = efiDestination.UVOffset;
|
||||
effectBuilder.AddPropertyVariable(variableInfo);
|
||||
effectBuilder.PixelShaderOutput = effectBuilder.GenerateLocalVariable(Dx9VariableType.Texture, efiDestination.Name);
|
||||
if (variableInfo.IsDynamic || !efiDestination.UVOffset.IsApproximate(Vector2.Zero))
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Load the image\r\n float4 {0} = tex2D({1}, {2} + float2({3}.x * {4}.x, {3}.y * {4}.y));\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)textureInfo.Sampler, (object)textureInfo.TexCoordInput, (object)textureInfo.TexelSize, (object)variableInfo.Name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Load the image\r\n float4 {0} = tex2D({1}, {2} + float2({3}.x * {4}.x, {3}.y * {4}.y));\r\n\r\n", effectBuilder.PixelShaderOutput, textureInfo.Sampler, textureInfo.TexCoordInput, textureInfo.TexelSize, variableInfo.Name));
|
||||
else
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Load the image\r\n float4 {0} = tex2D({1}, {2});\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)textureInfo.Sampler, (object)textureInfo.TexCoordInput));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" // Load the image\r\n float4 {0} = tex2D({1}, {2});\r\n\r\n", effectBuilder.PixelShaderOutput, textureInfo.Sampler, textureInfo.TexCoordInput));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,17 +15,17 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
ref Dx9EffectBuilder effectBuilder)
|
||||
{
|
||||
Dx9TextureInfo textureInfo = effectBuilder.GetTextureInfo(effectBuilder.ImageCount - 1);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.TexelSize, (object)null);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.TexelSize, null);
|
||||
VariableInfo variableInfo = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoEdgeDetection.EdgeLimitID,
|
||||
ID = efoEdgeDetection.EdgeLimitID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoEdgeDetection.IsDynamicProperty("EdgeLimit")
|
||||
};
|
||||
variableInfo.Name = variableInfo.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo.Type, efoEdgeDetection.Name) : effectBuilder.GenerateGlobalConstant(variableInfo.Type, efoEdgeDetection.Name);
|
||||
variableInfo.DefaultValue = (object)efoEdgeDetection.EdgeLimit;
|
||||
variableInfo.DefaultValue = efoEdgeDetection.EdgeLimit;
|
||||
effectBuilder.AddPropertyVariable(variableInfo);
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // Sample neightbour pixel\r\n float4 vBottomPixel = tex2D({1}, {2} + float2(0.0f, {3}.y));\r\n float currentAvg = {0}.r + {0}.g + {0}.b;\r\n currentAvg = currentAvg / 3.0f;\r\n float bottomAvg = vBottomPixel.r + vBottomPixel.g + vBottomPixel.b;\r\n bottomAvg = bottomAvg / 3.0f;\r\n float diff = abs(currentAvg - bottomAvg);\r\n // change color into black or white depending on what the delta is\r\n if (diff < {4})\r\n {{\r\n {0}.rgb = 1.0f;\r\n }}\r\n else\r\n {{\r\n {0}.rgb = 0.0f;\r\n }}\r\n }}\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)textureInfo.Sampler, (object)textureInfo.TexCoordInput, (object)textureInfo.TexelSize, (object)variableInfo.Name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // Sample neightbour pixel\r\n float4 vBottomPixel = tex2D({1}, {2} + float2(0.0f, {3}.y));\r\n float currentAvg = {0}.r + {0}.g + {0}.b;\r\n currentAvg = currentAvg / 3.0f;\r\n float bottomAvg = vBottomPixel.r + vBottomPixel.g + vBottomPixel.b;\r\n bottomAvg = bottomAvg / 3.0f;\r\n float diff = abs(currentAvg - bottomAvg);\r\n // change color into black or white depending on what the delta is\r\n if (diff < {4})\r\n {{\r\n {0}.rgb = 1.0f;\r\n }}\r\n else\r\n {{\r\n {0}.rgb = 0.0f;\r\n }}\r\n }}\r\n\r\n", effectBuilder.PixelShaderOutput, textureInfo.Sampler, textureInfo.TexCoordInput, textureInfo.TexelSize, variableInfo.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
internal class Dx9Effect : Effect
|
||||
{
|
||||
internal Dx9Effect(Dx9EffectTemplate effectTemplate)
|
||||
: base((EffectTemplate)effectTemplate)
|
||||
=> this.m_remoteEffect = (Microsoft.Iris.Render.Protocols.Splash.Rendering.RemoteEffect)this.m_effectTemplate.Session.BuildRemoteDx9Effect(this);
|
||||
: base(effectTemplate)
|
||||
=> this.m_remoteEffect = this.m_effectTemplate.Session.BuildRemoteDx9Effect(this);
|
||||
|
||||
internal Dx9EffectManager EffectManager => ((Dx9GraphicsDevice)this.m_effectTemplate.Device).EffectManager;
|
||||
|
||||
|
||||
@@ -116,18 +116,18 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
}
|
||||
else
|
||||
stringBuilder.Append("Temp");
|
||||
return stringBuilder.ToString() + (object)this.m_nUniqueVariableID++;
|
||||
return stringBuilder.ToString() + this.m_nUniqueVariableID++;
|
||||
}
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
this.m_stPixelOutput = (string)null;
|
||||
this.m_stPixelOutput = null;
|
||||
this.m_nUniqueVariableID = 0;
|
||||
this.m_nRequirements = 0;
|
||||
this.m_sbPixelShader = (StringBuilder)null;
|
||||
this.m_sbVertexShader = (StringBuilder)null;
|
||||
this.m_sbDeclarations = (StringBuilder)null;
|
||||
this.m_sbEffect = (StringBuilder)null;
|
||||
this.m_sbPixelShader = null;
|
||||
this.m_sbVertexShader = null;
|
||||
this.m_sbDeclarations = null;
|
||||
this.m_sbEffect = null;
|
||||
if (this.m_alPropertyVariables != null)
|
||||
this.m_alPropertyVariables.Clear();
|
||||
if (this.m_alGlobalVariables != null)
|
||||
@@ -181,8 +181,8 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
ImageIndex = this.ImageCount
|
||||
};
|
||||
dx9TextureInfo.TexCoordInput = InvariantString.Format("{0}{1}", (object)"vTexCoord", (object)dx9TextureInfo.ImageIndex);
|
||||
dx9TextureInfo.Sampler = InvariantString.Format("{0}{1}", (object)"Sampler", (object)dx9TextureInfo.ImageIndex);
|
||||
dx9TextureInfo.TexCoordInput = InvariantString.Format("{0}{1}", "vTexCoord", dx9TextureInfo.ImageIndex);
|
||||
dx9TextureInfo.Sampler = InvariantString.Format("{0}{1}", "Sampler", dx9TextureInfo.ImageIndex);
|
||||
dx9TextureInfo.DownsamplePropertyID = -1;
|
||||
if (this.m_alTextureInfos == null)
|
||||
this.m_alTextureInfos = new Vector<Dx9TextureInfo>();
|
||||
@@ -201,7 +201,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
case Dx9TextureRequirements.TexelSize:
|
||||
if (textureInfo.TexelSize != null)
|
||||
break;
|
||||
string stName1 = InvariantString.Format("{0}{1}", (object)"TexelSize", (object)textureInfo.ImageIndex);
|
||||
string stName1 = InvariantString.Format("{0}{1}", "TexelSize", textureInfo.ImageIndex);
|
||||
VariableInfo variableInfo1 = new VariableInfo()
|
||||
{
|
||||
IsDynamic = true,
|
||||
@@ -209,7 +209,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
Type = Dx9VariableType.Vector2
|
||||
};
|
||||
variableInfo1.Name = this.GenerateGlobalVariable(variableInfo1.Type, stName1);
|
||||
variableInfo1.DefaultValue = (object)new Vector2(0.0f, 0.0f);
|
||||
variableInfo1.DefaultValue = new Vector2(0.0f, 0.0f);
|
||||
this.AddGlobalVariable(variableInfo1);
|
||||
textureInfo.TexelSize = variableInfo1.Name;
|
||||
break;
|
||||
@@ -219,7 +219,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
case Dx9TextureRequirements.TexUVSize:
|
||||
if (textureInfo.TexUVSize != null)
|
||||
break;
|
||||
string stName2 = InvariantString.Format("{0}{1}", (object)"TexUVSize", (object)textureInfo.ImageIndex);
|
||||
string stName2 = InvariantString.Format("{0}{1}", "TexUVSize", textureInfo.ImageIndex);
|
||||
VariableInfo variableInfo2 = new VariableInfo()
|
||||
{
|
||||
IsDynamic = true,
|
||||
@@ -227,14 +227,14 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
Type = Dx9VariableType.Vector2
|
||||
};
|
||||
variableInfo2.Name = this.GenerateGlobalVariable(variableInfo2.Type, stName2);
|
||||
variableInfo2.DefaultValue = (object)new Vector2(0.0f, 0.0f);
|
||||
variableInfo2.DefaultValue = new Vector2(0.0f, 0.0f);
|
||||
this.AddGlobalVariable(variableInfo2);
|
||||
textureInfo.TexUVSize = variableInfo2.Name;
|
||||
break;
|
||||
case Dx9TextureRequirements.TexUVRefPoint:
|
||||
if (textureInfo.TexUVRefPoint != null)
|
||||
break;
|
||||
string stName3 = InvariantString.Format("{0}{1}", (object)"TexUVRefPoint", (object)textureInfo.ImageIndex);
|
||||
string stName3 = InvariantString.Format("{0}{1}", "TexUVRefPoint", textureInfo.ImageIndex);
|
||||
VariableInfo variableInfo3 = new VariableInfo()
|
||||
{
|
||||
IsDynamic = true,
|
||||
@@ -242,7 +242,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
Type = Dx9VariableType.Vector2
|
||||
};
|
||||
variableInfo3.Name = this.GenerateGlobalVariable(variableInfo3.Type, stName3);
|
||||
variableInfo3.DefaultValue = (object)new Vector2(0.0f, 0.0f);
|
||||
variableInfo3.DefaultValue = new Vector2(0.0f, 0.0f);
|
||||
this.AddGlobalVariable(variableInfo3);
|
||||
textureInfo.TexUVRefPoint = variableInfo3.Name;
|
||||
break;
|
||||
@@ -269,7 +269,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
return "";
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int index = 0; index < this.m_alIncludes.Count; ++index)
|
||||
stringBuilder.AppendFormat("#include {0}\r\n", (object)this.m_alIncludes[index]);
|
||||
stringBuilder.AppendFormat("#include {0}\r\n", this.m_alIncludes[index]);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
this.m_sbDeclarations.Append("struct PS_OUTPUT\r\n{\r\n float4 Color : COLOR; // Object space position\r\n};\r\n\r\n");
|
||||
this.m_sbDeclarations.Append("struct VS_INPUT\r\n{\r\n float4 ObjPos : POSITION; // Object space position\r\n float4 Color : COLOR; // Vertex color\r\n");
|
||||
for (int index = 0; index < this.ImageCount; ++index)
|
||||
this.m_sbDeclarations.AppendFormat(" float2 TexCoord{0} : TEXCOORD{0}; // Texture {0} UV coordinates\r\n", (object)index);
|
||||
this.m_sbDeclarations.AppendFormat(" float2 TexCoord{0} : TEXCOORD{0}; // Texture {0} UV coordinates\r\n", index);
|
||||
this.m_sbDeclarations.Append("};\r\n\r\n");
|
||||
this.m_sbDeclarations.Append("struct VS_OUTPUT\r\n{\r\n float4 ProjPos : POSITION; // Projected space position\r\n float4 Color : COLOR; // Vertex color\r\n");
|
||||
if (Bits.TestFlag(this.m_nRequirements, 1))
|
||||
@@ -312,9 +312,9 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
for (int index = 0; index < this.ImageCount; ++index)
|
||||
{
|
||||
if (Bits.TestFlag(this.m_alTextureInfos[index].Requirements, 16))
|
||||
this.m_sbDeclarations.AppendFormat(" float3 TexCoord{0} : TEXCOORD{0}; // Texture {0} UVW coordinates\r\n", (object)index);
|
||||
this.m_sbDeclarations.AppendFormat(" float3 TexCoord{0} : TEXCOORD{0}; // Texture {0} UVW coordinates\r\n", index);
|
||||
else
|
||||
this.m_sbDeclarations.AppendFormat(" float2 TexCoord{0} : TEXCOORD{0}; // Texture {0} UV coordinates\r\n", (object)index);
|
||||
this.m_sbDeclarations.AppendFormat(" float2 TexCoord{0} : TEXCOORD{0}; // Texture {0} UV coordinates\r\n", index);
|
||||
}
|
||||
this.m_sbDeclarations.Append("};\r\n\r\n");
|
||||
}
|
||||
@@ -333,9 +333,9 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
for (int index = 0; index < this.ImageCount; ++index)
|
||||
{
|
||||
if (Bits.TestFlag(this.m_alTextureInfos[index].Requirements, 16))
|
||||
this.m_sbVertexShader.AppendFormat(" Output.TexCoord{0} = float3(Input.TexCoord{0}.x * Output.ProjPos.w, Input.TexCoord{0}.y * Output.ProjPos.w, Output.ProjPos.w);\r\n", (object)index);
|
||||
this.m_sbVertexShader.AppendFormat(" Output.TexCoord{0} = float3(Input.TexCoord{0}.x * Output.ProjPos.w, Input.TexCoord{0}.y * Output.ProjPos.w, Output.ProjPos.w);\r\n", index);
|
||||
else
|
||||
this.m_sbVertexShader.AppendFormat(" Output.TexCoord{0} = Input.TexCoord{0};\r\n", (object)index);
|
||||
this.m_sbVertexShader.AppendFormat(" Output.TexCoord{0} = Input.TexCoord{0};\r\n", index);
|
||||
}
|
||||
}
|
||||
return this.m_sbVertexShader.ToString();
|
||||
@@ -348,9 +348,9 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
Dx9TextureInfo alTextureInfo = this.m_alTextureInfos[index];
|
||||
if (Bits.TestFlag(alTextureInfo.Requirements, 16))
|
||||
stringBuilder.AppendFormat(" float2 {0} = Input.TexCoord{1}.xy / Input.TexCoord{1}.z;\r\n", (object)alTextureInfo.TexCoordInput, (object)index);
|
||||
stringBuilder.AppendFormat(" float2 {0} = Input.TexCoord{1}.xy / Input.TexCoord{1}.z;\r\n", alTextureInfo.TexCoordInput, index);
|
||||
else
|
||||
stringBuilder.AppendFormat(" float2 {0} = Input.TexCoord{1};\r\n", (object)alTextureInfo.TexCoordInput, (object)index);
|
||||
stringBuilder.AppendFormat(" float2 {0} = Input.TexCoord{1};\r\n", alTextureInfo.TexCoordInput, index);
|
||||
}
|
||||
stringBuilder.Append("\r\n");
|
||||
stringBuilder.Append(this.m_sbPixelShader.ToString());
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
return;
|
||||
Map<ByteBuilder, Dx9EffectResource>.ValueCollection.Enumerator enumerator = this.m_mapEffectCache.Values.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
enumerator.Current?.UnregisterUsage((object)this);
|
||||
this.m_mapEffectCache = (Map<ByteBuilder, Dx9EffectResource>)null;
|
||||
enumerator.Current?.UnregisterUsage(this);
|
||||
this.m_mapEffectCache = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -53,11 +53,11 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
if (this.m_mapEffectCache == null)
|
||||
{
|
||||
resource = (Dx9EffectResource)null;
|
||||
resource = null;
|
||||
return false;
|
||||
}
|
||||
bool flag = this.m_mapEffectCache.ContainsKey(cacheKey);
|
||||
resource = !flag ? (Dx9EffectResource)null : this.m_mapEffectCache[cacheKey];
|
||||
resource = !flag ? null : this.m_mapEffectCache[cacheKey];
|
||||
return flag;
|
||||
}
|
||||
|
||||
@@ -77,18 +77,18 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
int nPropCacheSize,
|
||||
out Dx9EffectResource dxEffectResource)
|
||||
{
|
||||
Dx9EffectResource resource = (Dx9EffectResource)null;
|
||||
Dx9EffectResource resource = null;
|
||||
ByteBuilder byteBuilder = new ByteBuilder(nPropCacheSize);
|
||||
element.AddCacheKey(byteBuilder);
|
||||
if (!this.CacheLookup(byteBuilder, out resource))
|
||||
{
|
||||
resource = new Dx9EffectResource(this.m_session, stName, this);
|
||||
resource.RegisterUsage((object)this);
|
||||
resource.RegisterUsage(this);
|
||||
if (!resource.Create(element))
|
||||
{
|
||||
resource.UnregisterUsage((object)this);
|
||||
dxEffectResource = (Dx9EffectResource)null;
|
||||
this.AddCachedEffect(byteBuilder, (Dx9EffectResource)null);
|
||||
resource.UnregisterUsage(this);
|
||||
dxEffectResource = null;
|
||||
this.AddCachedEffect(byteBuilder, null);
|
||||
return false;
|
||||
}
|
||||
this.AddCachedEffect(byteBuilder, resource);
|
||||
@@ -107,7 +107,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
if (keyValueEntry.Value != null)
|
||||
{
|
||||
if (keyValueEntry.Value.UsageCount == 1)
|
||||
keyValueEntry.Value.UnregisterUsage((object)this);
|
||||
keyValueEntry.Value.UnregisterUsage(this);
|
||||
else
|
||||
map.Add(keyValueEntry.Key, keyValueEntry.Value);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
if (this.m_fPendingCacheUpdate || this.m_mapEffectCache.Count < 50)
|
||||
return;
|
||||
this.m_session.DeferredInvoke((Delegate)this.m_cbUpdateCache, (object)null, DeferredInvokePriority.Idle, new TimeSpan(0, 0, 5));
|
||||
this.m_session.DeferredInvoke(m_cbUpdateCache, null, DeferredInvokePriority.Idle, new TimeSpan(0, 0, 5));
|
||||
this.m_fPendingCacheUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
this.m_session = session;
|
||||
this.m_stName = stName;
|
||||
this.m_effectManager = effectManager;
|
||||
this.m_tracker = MessagingSession.Current.CreateDataBufferTracker((object)this);
|
||||
this.m_tracker = MessagingSession.Current.CreateDataBufferTracker(this);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool fInDispose)
|
||||
@@ -48,8 +48,8 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
if (this.m_remoteEffect != null)
|
||||
this.m_remoteEffect.Dispose();
|
||||
}
|
||||
this.m_tracker = (DataBufferTracker)null;
|
||||
this.m_remoteEffect = (RemoteDx9EffectResource)null;
|
||||
this.m_tracker = null;
|
||||
this.m_remoteEffect = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
|
||||
RENDERHANDLE IRenderHandleOwner.RenderHandle => this.m_remoteEffect.RenderHandle;
|
||||
|
||||
void IRenderHandleOwner.OnDisconnect() => this.m_remoteEffect = (RemoteDx9EffectResource)null;
|
||||
void IRenderHandleOwner.OnDisconnect() => this.m_remoteEffect = null;
|
||||
|
||||
internal bool Create(EffectInput element)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
nBlobSize = 0U;
|
||||
try
|
||||
{
|
||||
EngineApi.IFC(EngineApi.SpDx9CompileEffect(effectBuilder.EffectDefinition, (string)null, out pErrorString, out pErrorBuffer, out pEffectBlob, out nBlobSize, out pBlobBuffer));
|
||||
EngineApi.IFC(EngineApi.SpDx9CompileEffect(effectBuilder.EffectDefinition, null, out pErrorString, out pErrorBuffer, out pEffectBlob, out nBlobSize, out pBlobBuffer));
|
||||
flag = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -134,7 +134,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
uint nBlobSize)
|
||||
{
|
||||
DataBuffer dataBuffer = this.m_session.BuildDataBuffer(pEffectBlob, nBlobSize);
|
||||
this.m_tracker.Track(dataBuffer, new DataBufferTracker.CleanupEventHandler(Dx9EffectResource.OnReleaseLocalData), (object)pBlobBuffer);
|
||||
this.m_tracker.Track(dataBuffer, new DataBufferTracker.CleanupEventHandler(OnReleaseLocalData), pBlobBuffer);
|
||||
dataBuffer.Commit();
|
||||
this.m_remoteEffect = this.m_session.BuildRemoteDx9EffectResource(this, this.m_effectManager.Device, dataBuffer);
|
||||
Vector<VariableInfo> propertyVariables = effectBuilder.PropertyVariables;
|
||||
@@ -212,47 +212,47 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
case Dx9VariableType.Integer:
|
||||
if (variableInfo.IsDynamic)
|
||||
{
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name));
|
||||
continue;
|
||||
}
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name, (object)(int)variableInfo.DefaultValue));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name, (int)variableInfo.DefaultValue));
|
||||
continue;
|
||||
case Dx9VariableType.Float:
|
||||
if (variableInfo.IsDynamic)
|
||||
{
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name));
|
||||
continue;
|
||||
}
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name, (object)(float)variableInfo.DefaultValue));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name, (float)variableInfo.DefaultValue));
|
||||
continue;
|
||||
case Dx9VariableType.Vector2:
|
||||
if (variableInfo.IsDynamic)
|
||||
{
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name));
|
||||
continue;
|
||||
}
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name, (object)((Vector2)variableInfo.DefaultValue).ToDxShaderString()));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name, ((Vector2)variableInfo.DefaultValue).ToDxShaderString()));
|
||||
continue;
|
||||
case Dx9VariableType.Vector3:
|
||||
if (variableInfo.IsDynamic)
|
||||
{
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name));
|
||||
continue;
|
||||
}
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name, (object)((Vector3)variableInfo.DefaultValue).ToDxShaderString()));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name, ((Vector3)variableInfo.DefaultValue).ToDxShaderString()));
|
||||
continue;
|
||||
case Dx9VariableType.Vector4:
|
||||
if (variableInfo.IsDynamic)
|
||||
{
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("{0} {1};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name));
|
||||
continue;
|
||||
}
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", (object)effectBuilder.ConvertToString(variableInfo.Type), (object)variableInfo.Name, (object)((Vector4)variableInfo.DefaultValue).ToDxShaderString()));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("static const {0} {1} = {2};\r\n", effectBuilder.ConvertToString(variableInfo.Type), variableInfo.Name, ((Vector4)variableInfo.DefaultValue).ToDxShaderString()));
|
||||
continue;
|
||||
case Dx9VariableType.Texture:
|
||||
TextureVariableInfo textureVariableInfo = (TextureVariableInfo)variableInfo;
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("\r\n{0} {1};\r\n", (object)effectBuilder.ConvertToString(textureVariableInfo.Type), (object)textureVariableInfo.Name));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("sampler {0} = \r\n sampler_state\r\n {{\r\n Texture = <{1}>;\r\n MinFilter = {2};\r\n MagFilter = {3};\r\n AddressU = Clamp;\r\n AddressV = Clamp;\r\n }};\r\n\r\n", (object)textureVariableInfo.SamplerName, (object)textureVariableInfo.Name, (object)textureVariableInfo.MinFilter, (object)textureVariableInfo.MagFilter));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("\r\n{0} {1};\r\n", effectBuilder.ConvertToString(textureVariableInfo.Type), textureVariableInfo.Name));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("sampler {0} = \r\n sampler_state\r\n {{\r\n Texture = <{1}>;\r\n MinFilter = {2};\r\n MagFilter = {3};\r\n AddressU = Clamp;\r\n AddressV = Clamp;\r\n }};\r\n\r\n", textureVariableInfo.SamplerName, textureVariableInfo.Name, textureVariableInfo.MinFilter, textureVariableInfo.MagFilter));
|
||||
continue;
|
||||
default:
|
||||
continue;
|
||||
@@ -267,11 +267,11 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
protected void EmitShaders(Dx9EffectBuilder effectBuilder)
|
||||
{
|
||||
effectBuilder.EmitEffectFragment(effectBuilder.ShaderDeclarations);
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("VS_OUTPUT {0}(VS_INPUT Input)\r\n{{\r\n VS_OUTPUT Output;\r\n\r\n{1}\r\n return Output;\r\n}}\r\n\r\n", (object)Dx9EffectResource.k_stVertexShaderName, (object)effectBuilder.VertexShader));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("PS_OUTPUT {0}(VS_OUTPUT Input)\r\n{{\r\n PS_OUTPUT Output;\r\n\r\n{1} // Include Vertex color contribution\r\n Output.Color = {2} * Input.Color;\r\n\r\n // Return the final result\r\n return Output;\r\n}}\r\n\r\n", (object)Dx9EffectResource.k_stPixelShaderName, (object)effectBuilder.PixelShader, (object)effectBuilder.PixelShaderOutput));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("VS_OUTPUT {0}(VS_INPUT Input)\r\n{{\r\n VS_OUTPUT Output;\r\n\r\n{1}\r\n return Output;\r\n}}\r\n\r\n", k_stVertexShaderName, effectBuilder.VertexShader));
|
||||
effectBuilder.EmitEffectFragment(InvariantString.Format("PS_OUTPUT {0}(VS_OUTPUT Input)\r\n{{\r\n PS_OUTPUT Output;\r\n\r\n{1} // Include Vertex color contribution\r\n Output.Color = {2} * Input.Color;\r\n\r\n // Return the final result\r\n return Output;\r\n}}\r\n\r\n", k_stPixelShaderName, effectBuilder.PixelShader, effectBuilder.PixelShaderOutput));
|
||||
}
|
||||
|
||||
protected void EmitTechnique(Dx9EffectBuilder effectBuilder) => effectBuilder.EmitEffectFragment(InvariantString.Format("technique GeneratedTechnique\r\n{{\r\n pass P0\r\n {{\r\n // Shaders\r\n PixelShader = compile {0} {1}();\r\n VertexShader = compile {2} {3}();\r\n }}\r\n}}\r\n", (object)this.PixelShaderVersion, (object)Dx9EffectResource.k_stPixelShaderName, (object)this.VertexShaderVersion, (object)Dx9EffectResource.k_stVertexShaderName));
|
||||
protected void EmitTechnique(Dx9EffectBuilder effectBuilder) => effectBuilder.EmitEffectFragment(InvariantString.Format("technique GeneratedTechnique\r\n{{\r\n pass P0\r\n {{\r\n // Shaders\r\n PixelShader = compile {0} {1}();\r\n VertexShader = compile {2} {3}();\r\n }}\r\n}}\r\n", PixelShaderVersion, k_stPixelShaderName, VertexShaderVersion, k_stVertexShaderName));
|
||||
|
||||
private void GenerateEffect(Dx9EffectBuilder effectBuilder)
|
||||
{
|
||||
@@ -337,7 +337,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
return false;
|
||||
if (eflCurrent.Operations != null)
|
||||
{
|
||||
foreach (EffectOperation operation in (IEnumerable)eflCurrent.Operations)
|
||||
foreach (EffectOperation operation in eflCurrent.Operations)
|
||||
{
|
||||
switch (operation.Type)
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
if (!fInDispose || this.m_effectResource == null)
|
||||
return;
|
||||
this.m_effectResource.UnregisterUsage((object)this);
|
||||
this.m_effectResource = (Dx9EffectResource)null;
|
||||
this.m_effectResource.UnregisterUsage(this);
|
||||
this.m_effectResource = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
public override IEffect CreateInstance(object objUser)
|
||||
{
|
||||
Debug2.Validate(this.m_fBuilt, typeof(InvalidOperationException), "Cannot create instance if the template is not built");
|
||||
Dx9Effect dx9Effect = (Dx9Effect)null;
|
||||
Dx9Effect dx9Effect = null;
|
||||
if (this.m_cache != null)
|
||||
dx9Effect = (Dx9Effect)this.m_cache.Remove(objUser);
|
||||
if (dx9Effect == null)
|
||||
@@ -69,7 +69,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
dx9Effect.RegisterUsage(objUser);
|
||||
dx9Effect.RemoteEffect();
|
||||
}
|
||||
return (IEffect)dx9Effect;
|
||||
return dx9Effect;
|
||||
}
|
||||
|
||||
private bool ProcessEffectElement(
|
||||
@@ -79,7 +79,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
if (!(this.m_graphicsDevice as Dx9GraphicsDevice).EffectManager.CreateEffectResource(this.m_stName, element, nPropCacheSize, out this.m_effectResource))
|
||||
return false;
|
||||
this.m_effectResource.RegisterUsage((object)this);
|
||||
this.m_effectResource.RegisterUsage(this);
|
||||
foreach (KeyValueEntry<string, EffectProperty> allProp in allProps)
|
||||
{
|
||||
EffectProperty effectProperty = allProp.Value;
|
||||
|
||||
@@ -13,26 +13,26 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
internal static void Generate(EmbossElement efoEmboss, ref Dx9EffectBuilder effectBuilder)
|
||||
{
|
||||
Dx9TextureInfo textureInfo = effectBuilder.GetTextureInfo(effectBuilder.ImageCount - 1);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.TexelSize, (object)null);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.TexelSize, null);
|
||||
VariableInfo variableInfo1 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoEmboss.DirectionID,
|
||||
ID = efoEmboss.DirectionID,
|
||||
Type = Dx9VariableType.Integer,
|
||||
IsDynamic = efoEmboss.IsDynamicProperty("Direction")
|
||||
};
|
||||
variableInfo1.Name = variableInfo1.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo1.Type, efoEmboss.Name + "Direction") : effectBuilder.GenerateGlobalConstant(variableInfo1.Type, efoEmboss.Name + "Direction");
|
||||
variableInfo1.DefaultValue = (object)efoEmboss.Direction;
|
||||
variableInfo1.DefaultValue = efoEmboss.Direction;
|
||||
effectBuilder.AddPropertyVariable(variableInfo1);
|
||||
VariableInfo variableInfo2 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoEmboss.GrayLevelID,
|
||||
ID = efoEmboss.GrayLevelID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoEmboss.IsDynamicProperty("GrayLevel")
|
||||
};
|
||||
variableInfo2.Name = variableInfo2.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo2.Type, efoEmboss.Name + "GrayLevel") : effectBuilder.GenerateGlobalConstant(variableInfo2.Type, efoEmboss.Name + "GrayLevel");
|
||||
variableInfo2.DefaultValue = (object)efoEmboss.GrayLevel;
|
||||
variableInfo2.DefaultValue = efoEmboss.GrayLevel;
|
||||
effectBuilder.AddPropertyVariable(variableInfo2);
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // Sample neightbour pixel\r\n float4 vNeightbourPixel;\r\n if ({5} == 0)\r\n {{\r\n vNeightbourPixel = tex2D({1}, {2} + float2(-{3}.x, -{3}.y));\r\n }}\r\n else\r\n {{\r\n vNeightbourPixel = tex2D({1}, {2} + float2(+{3}.x, +{3}.y));\r\n }}\r\n float4 vDiff = {0} - vNeightbourPixel;\r\n float maxDiffColor = vDiff.r;\r\n if (abs(vDiff.g) > abs(maxDiffColor))\r\n {{\r\n maxDiffColor = vDiff.g;\r\n }}\r\n if (abs(vDiff.b) > abs(maxDiffColor))\r\n {{\r\n maxDiffColor = vDiff.b;\r\n }}\r\n maxDiffColor += {4};\r\n float minGray = min(maxDiffColor, 1.0f);\r\n float grayLevel = max(minGray, 0.0f);\r\n {0}.rgb = grayLevel;\r\n }}\r\n\r\n", (object)effectBuilder.PixelShaderOutput, (object)textureInfo.Sampler, (object)textureInfo.TexCoordInput, (object)textureInfo.TexelSize, (object)variableInfo2.Name, (object)variableInfo1.Name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // Sample neightbour pixel\r\n float4 vNeightbourPixel;\r\n if ({5} == 0)\r\n {{\r\n vNeightbourPixel = tex2D({1}, {2} + float2(-{3}.x, -{3}.y));\r\n }}\r\n else\r\n {{\r\n vNeightbourPixel = tex2D({1}, {2} + float2(+{3}.x, +{3}.y));\r\n }}\r\n float4 vDiff = {0} - vNeightbourPixel;\r\n float maxDiffColor = vDiff.r;\r\n if (abs(vDiff.g) > abs(maxDiffColor))\r\n {{\r\n maxDiffColor = vDiff.g;\r\n }}\r\n if (abs(vDiff.b) > abs(maxDiffColor))\r\n {{\r\n maxDiffColor = vDiff.b;\r\n }}\r\n maxDiffColor += {4};\r\n float minGray = min(maxDiffColor, 1.0f);\r\n float grayLevel = max(minGray, 0.0f);\r\n {0}.rgb = grayLevel;\r\n }}\r\n\r\n", effectBuilder.PixelShaderOutput, textureInfo.Sampler, textureInfo.TexCoordInput, textureInfo.TexelSize, variableInfo2.Name, variableInfo1.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
double num4 = Math.Sqrt(2.0 * Math.PI) * flDeviation;
|
||||
for (int index = 0; index < num1; ++index)
|
||||
{
|
||||
double num5 = (double)(index - nKernelRadius);
|
||||
double num5 = index - nKernelRadius;
|
||||
double num6 = Math.Exp(-(num5 * num5) / num3);
|
||||
arKernel[index] = num6 / num4;
|
||||
num2 += arKernel[index];
|
||||
@@ -49,8 +49,8 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
{
|
||||
for (int index2 = 0; index2 < num2; ++index2)
|
||||
{
|
||||
double num6 = (double)(index2 - nKernelRadius);
|
||||
double num7 = (double)(index1 - nKernelRadius);
|
||||
double num6 = index2 - nKernelRadius;
|
||||
double num7 = index1 - nKernelRadius;
|
||||
double num8 = Math.Exp(-(num6 * num6 + num7 * num7) / num4);
|
||||
arKernel[index2, index1] = num8 / num5;
|
||||
num1 += arKernel[index2, index1];
|
||||
@@ -66,13 +66,13 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
internal static void Generate(GaussianBlurElement efoBlur, ref Dx9EffectBuilder effectBuilder)
|
||||
{
|
||||
Dx9TextureInfo textureInfo = effectBuilder.GetTextureInfo(effectBuilder.ImageCount - 1);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.TexelSize, (object)null);
|
||||
effectBuilder.AddRequirement(textureInfo, Dx9TextureRequirements.TexelSize, null);
|
||||
switch (efoBlur.Mode)
|
||||
{
|
||||
case GaussianBlurMode.Normal:
|
||||
int length1 = 1 + efoBlur.KernelRadius * 2;
|
||||
double[,] arKernel1 = new double[length1, length1];
|
||||
Dx9GaussianBlurElement.GenerateWeights2D(efoBlur.KernelRadius, (double)efoBlur.Bluriness, arKernel1);
|
||||
GenerateWeights2D(efoBlur.KernelRadius, efoBlur.Bluriness, arKernel1);
|
||||
effectBuilder.EmitPixelFragment(" {\r\n // Gaussian filter\r\n float4 vBlur = 0;\r\n");
|
||||
for (int index1 = 0; index1 < length1; ++index1)
|
||||
{
|
||||
@@ -81,31 +81,31 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
int num1 = index2 - efoBlur.KernelRadius;
|
||||
int num2 = index1 - efoBlur.KernelRadius;
|
||||
if (num1 == 0 && num2 == 0)
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += {0} * {1};\r\n", (object)effectBuilder.PixelShaderOutput, (object)arKernel1[index2, index1]));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += {0} * {1};\r\n", effectBuilder.PixelShaderOutput, arKernel1[index2, index1]));
|
||||
else
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += tex2D({0}, {1} + float2({2}.x * {3}, {2}.y * {4})) * {5};\r\n", (object)textureInfo.Sampler, (object)textureInfo.TexCoordInput, (object)textureInfo.TexelSize, (object)num1, (object)num2, (object)arKernel1[index2, index1]));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += tex2D({0}, {1} + float2({2}.x * {3}, {2}.y * {4})) * {5};\r\n", textureInfo.Sampler, textureInfo.TexCoordInput, textureInfo.TexelSize, num1, num2, arKernel1[index2, index1]));
|
||||
}
|
||||
}
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {0} = vBlur;\r\n }}\r\n\r\n", (object)effectBuilder.PixelShaderOutput));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {0} = vBlur;\r\n }}\r\n\r\n", effectBuilder.PixelShaderOutput));
|
||||
break;
|
||||
case GaussianBlurMode.Horizontal:
|
||||
case GaussianBlurMode.Vertical:
|
||||
bool flag = efoBlur.Mode == GaussianBlurMode.Horizontal;
|
||||
int length2 = 1 + efoBlur.KernelRadius * 2;
|
||||
double[] arKernel2 = new double[length2];
|
||||
Dx9GaussianBlurElement.GenerateWeights1D(efoBlur.KernelRadius, (double)efoBlur.Bluriness, arKernel2);
|
||||
GenerateWeights1D(efoBlur.KernelRadius, efoBlur.Bluriness, arKernel2);
|
||||
effectBuilder.EmitPixelFragment(" {\r\n // Gaussian filter\r\n float4 vBlur = 0;\r\n");
|
||||
for (int index = 0; index < length2; ++index)
|
||||
{
|
||||
int num = index - efoBlur.KernelRadius;
|
||||
if (num == 0)
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += {0} * {1};\r\n", (object)effectBuilder.PixelShaderOutput, (object)arKernel2[index]));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += {0} * {1};\r\n", effectBuilder.PixelShaderOutput, arKernel2[index]));
|
||||
else if (flag)
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += tex2D({0}, {1} + float2({2}.x * {3}, 0)) * {4};\r\n", (object)textureInfo.Sampler, (object)textureInfo.TexCoordInput, (object)textureInfo.TexelSize, (object)num, (object)arKernel2[index]));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += tex2D({0}, {1} + float2({2}.x * {3}, 0)) * {4};\r\n", textureInfo.Sampler, textureInfo.TexCoordInput, textureInfo.TexelSize, num, arKernel2[index]));
|
||||
else
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += tex2D({0}, {1} + float2(0, {2}.y * {3})) * {4};\r\n", (object)textureInfo.Sampler, (object)textureInfo.TexCoordInput, (object)textureInfo.TexelSize, (object)num, (object)arKernel2[index]));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" vBlur += tex2D({0}, {1} + float2(0, {2}.y * {3})) * {4};\r\n", textureInfo.Sampler, textureInfo.TexCoordInput, textureInfo.TexelSize, num, arKernel2[index]));
|
||||
}
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {0} = vBlur;\r\n }}\r\n\r\n", (object)effectBuilder.PixelShaderOutput));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {0} = vBlur;\r\n }}\r\n\r\n", effectBuilder.PixelShaderOutput));
|
||||
break;
|
||||
default:
|
||||
Debug2.Validate(false, typeof(InvalidOperationException), "Unknown blur mode");
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
if (this.m_renderingQuality != GraphicsRenderingQuality.MinQuality)
|
||||
{
|
||||
Dx9GraphicsDevice.PixelShaderProfileType pixelShaderProfile = (Dx9GraphicsDevice.PixelShaderProfileType)this.m_graphicsCaps.PixelShaderProfile;
|
||||
if ((byte)this.m_graphicsCaps.VertexShaderProfile < (byte)1 || pixelShaderProfile < Dx9GraphicsDevice.PixelShaderProfileType.PS_2_0)
|
||||
if ((byte)this.m_graphicsCaps.VertexShaderProfile < 1 || pixelShaderProfile < PixelShaderProfileType.PS_2_0)
|
||||
this.m_renderingQuality = GraphicsRenderingQuality.MinQuality;
|
||||
}
|
||||
this.m_sizeGutterPxl = new Size(1, 1);
|
||||
@@ -39,7 +39,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
if (!fInDispose || this.m_effectManager == null)
|
||||
return;
|
||||
this.m_effectManager.Dispose();
|
||||
this.m_effectManager = (Dx9EffectManager)null;
|
||||
this.m_effectManager = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -103,7 +103,7 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
|
||||
public override bool CanPlayAnimationType(AnimationInputType type) => true;
|
||||
|
||||
internal override EffectTemplate CreateEffectTemplate(string stName) => (EffectTemplate)new Dx9EffectTemplate(this.m_session, (GraphicsDevice)this, stName);
|
||||
internal override EffectTemplate CreateEffectTemplate(string stName) => new Dx9EffectTemplate(this.m_session, this, stName);
|
||||
|
||||
private enum PixelShaderProfileType : byte
|
||||
{
|
||||
|
||||
@@ -15,32 +15,32 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
effectBuilder.EmitIncludesFragment("\"HSL.fx\"");
|
||||
VariableInfo variableInfo1 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoHSL.HueID,
|
||||
ID = efoHSL.HueID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoHSL.IsDynamicProperty("Hue")
|
||||
};
|
||||
variableInfo1.Name = variableInfo1.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo1.Type, efoHSL.Name + "Hue") : effectBuilder.GenerateGlobalConstant(variableInfo1.Type, efoHSL.Name + "Hue");
|
||||
variableInfo1.DefaultValue = (object)efoHSL.Hue;
|
||||
variableInfo1.DefaultValue = efoHSL.Hue;
|
||||
effectBuilder.AddPropertyVariable(variableInfo1);
|
||||
VariableInfo variableInfo2 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoHSL.SaturationID,
|
||||
ID = efoHSL.SaturationID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoHSL.IsDynamicProperty("Saturation")
|
||||
};
|
||||
variableInfo2.Name = variableInfo2.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo2.Type, efoHSL.Name + "Saturation") : effectBuilder.GenerateGlobalConstant(variableInfo2.Type, efoHSL.Name + "Saturation");
|
||||
variableInfo2.DefaultValue = (object)efoHSL.Saturation;
|
||||
variableInfo2.DefaultValue = efoHSL.Saturation;
|
||||
effectBuilder.AddPropertyVariable(variableInfo2);
|
||||
VariableInfo variableInfo3 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoHSL.LightnessID,
|
||||
ID = efoHSL.LightnessID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoHSL.IsDynamicProperty("Lightness")
|
||||
};
|
||||
variableInfo3.Name = variableInfo3.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo3.Type, efoHSL.Name + "Lightness") : effectBuilder.GenerateGlobalConstant(variableInfo3.Type, efoHSL.Name + "Lightness");
|
||||
variableInfo3.DefaultValue = (object)efoHSL.Lightness;
|
||||
variableInfo3.DefaultValue = efoHSL.Lightness;
|
||||
effectBuilder.AddPropertyVariable(variableInfo3);
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // convert to HSL color space\r\n float3 fHSL = RGBToHSL({0});\r\n\r\n // adjust Hue, Sat and Luma\r\n fHSL *= float3({1}, {2}, {3});\r\n fHSL = saturate(fHSL);\r\n\r\n // convert back to RGB space\r\n float3 fBackToRGB = HSLToRGB(fHSL);\r\n {0}.rgb = fBackToRGB;\r\n }}\r\n", (object)effectBuilder.PixelShaderOutput, (object)variableInfo1.Name, (object)variableInfo2.Name, (object)variableInfo3.Name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // convert to HSL color space\r\n float3 fHSL = RGBToHSL({0});\r\n\r\n // adjust Hue, Sat and Luma\r\n fHSL *= float3({1}, {2}, {3});\r\n fHSL = saturate(fHSL);\r\n\r\n // convert back to RGB space\r\n float3 fBackToRGB = HSLToRGB(fHSL);\r\n {0}.rgb = fBackToRGB;\r\n }}\r\n", effectBuilder.PixelShaderOutput, variableInfo1.Name, variableInfo2.Name, variableInfo3.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,32 +15,32 @@ namespace Microsoft.Iris.Render.Graphics
|
||||
effectBuilder.EmitIncludesFragment("\"HSV.fx\"");
|
||||
VariableInfo variableInfo1 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoHSV.HueID,
|
||||
ID = efoHSV.HueID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoHSV.IsDynamicProperty("Hue")
|
||||
};
|
||||
variableInfo1.Name = variableInfo1.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo1.Type, efoHSV.Name + "Hue") : effectBuilder.GenerateGlobalConstant(variableInfo1.Type, efoHSV.Name + "Hue");
|
||||
variableInfo1.DefaultValue = (object)efoHSV.Hue;
|
||||
variableInfo1.DefaultValue = efoHSV.Hue;
|
||||
effectBuilder.AddPropertyVariable(variableInfo1);
|
||||
VariableInfo variableInfo2 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoHSV.SaturationID,
|
||||
ID = efoHSV.SaturationID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoHSV.IsDynamicProperty("Saturation")
|
||||
};
|
||||
variableInfo2.Name = variableInfo2.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo2.Type, efoHSV.Name + "Saturation") : effectBuilder.GenerateGlobalConstant(variableInfo2.Type, efoHSV.Name + "Saturation");
|
||||
variableInfo2.DefaultValue = (object)efoHSV.Saturation;
|
||||
variableInfo2.DefaultValue = efoHSV.Saturation;
|
||||
effectBuilder.AddPropertyVariable(variableInfo2);
|
||||
VariableInfo variableInfo3 = new VariableInfo()
|
||||
{
|
||||
ID = (int)efoHSV.ValueID,
|
||||
ID = efoHSV.ValueID,
|
||||
Type = Dx9VariableType.Float,
|
||||
IsDynamic = efoHSV.IsDynamicProperty("Value")
|
||||
};
|
||||
variableInfo3.Name = variableInfo3.IsDynamic ? effectBuilder.GenerateGlobalVariable(variableInfo3.Type, efoHSV.Name + "Value") : effectBuilder.GenerateGlobalConstant(variableInfo3.Type, efoHSV.Name + "Value");
|
||||
variableInfo3.DefaultValue = (object)efoHSV.Value;
|
||||
variableInfo3.DefaultValue = efoHSV.Value;
|
||||
effectBuilder.AddPropertyVariable(variableInfo3);
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // convert to HSV color space\r\n float3 fHSV = RGBToHSV({0});\r\n\r\n // adjust Hue, Sat and Value\r\n fHSV *= float3(1.0f, {2}, {3});\r\n fHSV[0] += {0};\r\n fHSV = saturate(fHSV);\r\n\r\n // convert back to RGB space\r\n float3 fBackToRGB = HSVToRGB(fHSV);\r\n {0}.rgb = fBackToRGB;\r\n }}\r\n", (object)effectBuilder.PixelShaderOutput, (object)variableInfo1.Name, (object)variableInfo2.Name, (object)variableInfo3.Name));
|
||||
effectBuilder.EmitPixelFragment(InvariantString.Format(" {{\r\n // convert to HSV color space\r\n float3 fHSV = RGBToHSV({0});\r\n\r\n // adjust Hue, Sat and Value\r\n fHSV *= float3(1.0f, {2}, {3});\r\n fHSV[0] += {0};\r\n fHSV = saturate(fHSV);\r\n\r\n // convert back to RGB space\r\n float3 fBackToRGB = HSVToRGB(fHSV);\r\n {0}.rgb = fBackToRGB;\r\n }}\r\n", effectBuilder.PixelShaderOutput, variableInfo1.Name, variableInfo2.Name, variableInfo3.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user