|
|
|
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
public static SurfaceMaterialOptions GetMaterialOptions(AlphaMode alphaMode, bool twoSided) |
|
|
|
public static SurfaceMaterialOptions GetMaterialOptions(SurfaceType surfaceType, AlphaMode alphaMode, bool twoSided) |
|
|
|
switch (alphaMode) |
|
|
|
switch (surfaceType) |
|
|
|
case AlphaMode.Opaque: |
|
|
|
case SurfaceType.Opaque: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.Zero; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Opaque; |
|
|
|
break; |
|
|
|
case AlphaMode.Fade: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.SrcAlpha; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.OneMinusSrcAlpha; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
break; |
|
|
|
case AlphaMode.Transparent: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.OneMinusSrcAlpha; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
break; |
|
|
|
case AlphaMode.Additive: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
break; |
|
|
|
case AlphaMode.Multiply: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.DstColor; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.Zero; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
case SurfaceType.Transparent: |
|
|
|
switch (alphaMode) |
|
|
|
{ |
|
|
|
case AlphaMode.Alpha: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.SrcAlpha; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.OneMinusSrcAlpha; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
break; |
|
|
|
case AlphaMode.Premultiply: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.OneMinusSrcAlpha; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
break; |
|
|
|
case AlphaMode.Additive: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.One; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
break; |
|
|
|
case AlphaMode.Multiply: |
|
|
|
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.DstColor; |
|
|
|
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.Zero; |
|
|
|
materialOptions.cullMode = twoSided ? SurfaceMaterialOptions.CullMode.Off : SurfaceMaterialOptions.CullMode.Back; |
|
|
|
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual; |
|
|
|
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off; |
|
|
|
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent; |
|
|
|
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
return materialOptions; |
|
|
|
} |
|
|
|
|
|
|
|