Cromon

DrawRectangle.hlsl

Oct 11th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1.  
  2. matrix orthoProjMatrix;
  3. float4 elementSize;
  4. float4 strokeWidth;
  5.  
  6. struct VertexShaderInput
  7. {
  8.     float3 position : POSITION0;
  9.     float4 color : COLOR0;
  10.     float2 texCoord : TEXCOORD0;
  11. };
  12.  
  13. struct PixelShaderInput
  14. {
  15.     float4 position : POSITION0;
  16.     float2 texCoord : TEXCOORD0;
  17.     float4 color : TEXCOORD1;
  18. };
  19.  
  20. void VertexMain(in VertexShaderInput vsInput, out PixelShaderInput output)
  21. {
  22.     output = (PixelShaderInput)0;
  23.  
  24.     output.position = mul(float4(vsInput.position, 1), orthoProjMatrix);
  25.     output.texCoord = vsInput.texCoord;
  26.     output.color = vsInput.color;
  27. }
  28.  
  29. void PixelMain(in PixelShaderInput input, out float4 color : COLOR0)
  30. {
  31.     float texStepSizeX = strokeWidth.x / elementSize.x;
  32.     float texStepSizeY = strokeWidth.x / elementSize.y;
  33.     float2 tex = input.texCoord;
  34.  
  35.     if(tex.x <= texStepSizeX || tex.y <= texStepSizeY || (1.0f - tex.x) <= texStepSizeX || (1.0f - tex.y) <= texStepSizeY)
  36.         color = input.color;
  37.     else
  38.         color = float4(0, 0, 0, 0);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment