Cromon

DrawRectangle.hlsl

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