Permalink
Browse files

Merge github.com:kevingadd/Fracture

  • Loading branch information...
kg committed Feb 25, 2013
2 parents 346e4c4 + 02c6063 commit 8b9ec203d90850221a5837f83bc72c6c0114bb2d
@@ -41,7 +41,9 @@ inline float2 ComputeTexCoord(
in float2 corner,
in float4 texRgn : POSITION1
) {
- return (texRgn.xy + corner);
+ float2 texTL = min(texRgn.xy, texRgn.zw);
+ float2 texBR = max(texRgn.xy, texRgn.zw);
+ return clamp(texRgn.xy + corner, texTL, texBR);
}
inline float2 ComputeRotatedCorner(
@@ -62,15 +64,6 @@ inline float2 ComputeRotatedCorner(
);
}
-inline void OutputRegions(
- in float4 texRgn : POSITION1,
- out float2 texTL : TEXCOORD1,
- out float2 texBR : TEXCOORD2
-) {
- texTL = min(texRgn.xy, texRgn.zw);
- texBR = max(texRgn.xy, texRgn.zw);
-}
-
void ScreenSpaceVertexShader(
in float3 position : POSITION0, // x, y
in float4 texRgn : POSITION1, // x1, y1, x2, y2
@@ -80,9 +73,7 @@ void ScreenSpaceVertexShader(
inout float4 addColor : COLOR1,
in int2 cornerIndex : BLENDINDICES0, // 0-3
out float2 texCoord : TEXCOORD0,
- out float4 result : POSITION0,
- out float2 texTL : TEXCOORD1,
- out float2 texBR : TEXCOORD2
+ out float4 result : POSITION0
) {
float2 regionSize = ComputeRegionSize(texRgn);
float2 corner = ComputeCorner(cornerIndex, regionSize);
@@ -92,7 +83,6 @@ void ScreenSpaceVertexShader(
position.xy += rotatedCorner;
result = TransformPosition(float4(position.xy, position.z, 1), 0.5);
- OutputRegions(texRgn, texTL, texBR);
}
void WorldSpaceVertexShader(
@@ -104,9 +94,7 @@ void WorldSpaceVertexShader(
inout float4 addColor : COLOR1,
in int2 cornerIndex : BLENDINDICES0, // 0-3
out float2 texCoord : TEXCOORD0,
- out float4 result : POSITION0,
- out float2 texTL : TEXCOORD1,
- out float2 texBR : TEXCOORD2
+ out float4 result : POSITION0
) {
float2 regionSize = ComputeRegionSize(texRgn);
float2 corner = ComputeCorner(cornerIndex, regionSize);
@@ -116,5 +104,4 @@ void WorldSpaceVertexShader(
position.xy += rotatedCorner - ViewportPosition;
result = TransformPosition(float4(position.xy * ViewportScale, position.z, 1), 0.5);
- OutputRegions(texRgn, texTL, texBR);
}
@@ -4,11 +4,8 @@ void BasicPixelShader(
in float4 multiplyColor : COLOR0,
in float4 addColor : COLOR1,
in float2 texCoord : TEXCOORD0,
- in float2 texTL : TEXCOORD1,
- in float2 texBR : TEXCOORD2,
out float4 result : COLOR0
) {
- texCoord = clamp(texCoord, texTL, texBR);
addColor.rgb *= addColor.a;
addColor.a = 0;
@@ -1,4 +1,5 @@
@echo Generating shaders...
+@rmdir /s/q generated
@mkdir generated
@mkdir generated\shaders
@for %%f IN (shaders\*.fcg) DO tcc.exe -E %%f -o generated\%%f
@@ -11,9 +11,7 @@ void main(
in float2 texBR : TEXCOORD2,
out float4 result : COLOR
) {
- float2 texCoord = clamp(texCoordOut, texTL, texBR);
-
- float4 texColor = tex2D(BitmapTexture, texCoord);
+ float4 texColor = tex2D(BitmapTexture, texCoordOut);
addColorOut.rgb *= addColorOut.a;
addColorOut.a = 0;
@@ -4,7 +4,7 @@ float4 TransformPosition (
in float4x4 ProjectionMatrix,
float4 position
) {
- return mul(mul(position, ModelViewMatrix), ProjectionMatrix);
+ return mul(mul(position, ProjectionMatrix), ModelViewMatrix);
}
inline float2 ComputeRegionSize(
@@ -34,7 +34,10 @@ inline float2 ComputeTexCoord(
in float2 corner,
in float4 textureRegion
) {
- return (textureRegion.xy + corner) + halfTexel;
+ float2 texTL = min(textureRegion.xy, textureRegion.zw) - halfTexel;
+ float2 texBR = max(textureRegion.xy, textureRegion.zw) + halfTexel;
+
+ return clamp((textureRegion.xy + corner) + halfTexel, texTL, texBR);
}
inline float2 ComputeRotatedCorner(
@@ -56,16 +59,6 @@ inline float2 ComputeRotatedCorner(
(sinCos.x * corner.x) + (sinCos.y * corner.y)
) - halfTexel;
}
-
-inline void OutputRegions(
- in uniform float2 halfTexel,
- in float4 textureRegion,
- out float2 texTL,
- out float2 texBR
-) {
- texTL = min(textureRegion.xy, textureRegion.zw) + halfTexel;
- texBR = max(textureRegion.xy, textureRegion.zw) - halfTexel;
-}
# 3 "shaders/Bitmap.vcgh"
void main(
in uniform float4x4 ProjectionMatrix,
@@ -108,9 +101,6 @@ void main(
transformedPosition = TransformPosition(ProjectionMatrix, ModelViewMatrix, float4(position.xy, position.z, 1));
transformedPosition2 = transformedPosition;
- OutputRegions(
- HalfTexel, textureRegion, texTL, texBR
- );
multiplyColorOut = multiplyColor;
addColorOut = addColor;
@@ -4,7 +4,7 @@ float4 TransformPosition (
in float4x4 ProjectionMatrix,
float4 position
) {
- return mul(mul(position, ModelViewMatrix), ProjectionMatrix);
+ return mul(mul(position, ProjectionMatrix), ModelViewMatrix);
}
inline float2 ComputeRegionSize(
@@ -34,7 +34,10 @@ inline float2 ComputeTexCoord(
in float2 corner,
in float4 textureRegion
) {
- return (textureRegion.xy + corner) + halfTexel;
+ float2 texTL = min(textureRegion.xy, textureRegion.zw) - halfTexel;
+ float2 texBR = max(textureRegion.xy, textureRegion.zw) + halfTexel;
+
+ return clamp((textureRegion.xy + corner) + halfTexel, texTL, texBR);
}
inline float2 ComputeRotatedCorner(
@@ -56,16 +59,6 @@ inline float2 ComputeRotatedCorner(
(sinCos.x * corner.x) + (sinCos.y * corner.y)
) - halfTexel;
}
-
-inline void OutputRegions(
- in uniform float2 halfTexel,
- in float4 textureRegion,
- out float2 texTL,
- out float2 texBR
-) {
- texTL = min(textureRegion.xy, textureRegion.zw) + halfTexel;
- texBR = max(textureRegion.xy, textureRegion.zw) - halfTexel;
-}
# 3 "shaders/Geometry.vcgh"
void main(
in uniform float4x4 ProjectionMatrix,
@@ -11,9 +11,7 @@ void main(
in float2 texBR : TEXCOORD2,
out float4 result : COLOR
) {
- float2 texCoord = clamp(texCoordOut, texTL, texBR);
-
- float4 texColor = tex2D(BitmapTexture, texCoord);
+ float4 texColor = tex2D(BitmapTexture, texCoordOut);
addColorOut.rgb *= addColorOut.a;
addColorOut.a = 0;
@@ -4,7 +4,7 @@ float4 TransformPosition (
in float4x4 ProjectionMatrix,
float4 position
) {
- return mul(mul(position, ModelViewMatrix), ProjectionMatrix);
+ return mul(mul(position, ProjectionMatrix), ModelViewMatrix);
}
inline float2 ComputeRegionSize(
@@ -34,7 +34,10 @@ inline float2 ComputeTexCoord(
in float2 corner,
in float4 textureRegion
) {
- return (textureRegion.xy + corner) + halfTexel;
+ float2 texTL = min(textureRegion.xy, textureRegion.zw) - halfTexel;
+ float2 texBR = max(textureRegion.xy, textureRegion.zw) + halfTexel;
+
+ return clamp((textureRegion.xy + corner) + halfTexel, texTL, texBR);
}
inline float2 ComputeRotatedCorner(
@@ -56,16 +59,6 @@ inline float2 ComputeRotatedCorner(
(sinCos.x * corner.x) + (sinCos.y * corner.y)
) - halfTexel;
}
-
-inline void OutputRegions(
- in uniform float2 halfTexel,
- in float4 textureRegion,
- out float2 texTL,
- out float2 texBR
-) {
- texTL = min(textureRegion.xy, textureRegion.zw) + halfTexel;
- texBR = max(textureRegion.xy, textureRegion.zw) - halfTexel;
-}
# 3 "shaders/Bitmap.vcgh"
void main(
in uniform float4x4 ProjectionMatrix,
@@ -108,9 +101,6 @@ void main(
transformedPosition = TransformPosition(ProjectionMatrix, ModelViewMatrix, float4(position.xy, position.z, 1));
transformedPosition2 = transformedPosition;
- OutputRegions(
- HalfTexel, textureRegion, texTL, texBR
- );
multiplyColorOut = multiplyColor;
addColorOut = addColor;
@@ -4,7 +4,7 @@ float4 TransformPosition (
in float4x4 ProjectionMatrix,
float4 position
) {
- return mul(mul(position, ModelViewMatrix), ProjectionMatrix);
+ return mul(mul(position, ProjectionMatrix), ModelViewMatrix);
}
inline float2 ComputeRegionSize(
@@ -34,7 +34,10 @@ inline float2 ComputeTexCoord(
in float2 corner,
in float4 textureRegion
) {
- return (textureRegion.xy + corner) + halfTexel;
+ float2 texTL = min(textureRegion.xy, textureRegion.zw) - halfTexel;
+ float2 texBR = max(textureRegion.xy, textureRegion.zw) + halfTexel;
+
+ return clamp((textureRegion.xy + corner) + halfTexel, texTL, texBR);
}
inline float2 ComputeRotatedCorner(
@@ -56,16 +59,6 @@ inline float2 ComputeRotatedCorner(
(sinCos.x * corner.x) + (sinCos.y * corner.y)
) - halfTexel;
}
-
-inline void OutputRegions(
- in uniform float2 halfTexel,
- in float4 textureRegion,
- out float2 texTL,
- out float2 texBR
-) {
- texTL = min(textureRegion.xy, textureRegion.zw) + halfTexel;
- texBR = max(textureRegion.xy, textureRegion.zw) - halfTexel;
-}
# 3 "shaders/Geometry.vcgh"
void main(
in uniform float4x4 ProjectionMatrix,
@@ -11,9 +11,7 @@ void main(
in float2 texBR : TEXCOORD2,
out float4 result : COLOR
) {
- float2 texCoord = clamp(texCoordOut, texTL, texBR);
-
- float4 texColor = tex2D(BitmapTexture, texCoord);
+ float4 texColor = tex2D(BitmapTexture, texCoordOut);
addColorOut.rgb *= addColorOut.a;
addColorOut.a = 0;
@@ -4,7 +4,7 @@ float4 TransformPosition (
in float4x4 ProjectionMatrix,
float4 position
) {
- return mul(mul(position, ModelViewMatrix), ProjectionMatrix);
+ return mul(mul(position, ProjectionMatrix), ModelViewMatrix);
}
inline float2 ComputeRegionSize(
@@ -34,7 +34,10 @@ inline float2 ComputeTexCoord(
in float2 corner,
in float4 textureRegion
) {
- return (textureRegion.xy + corner) + halfTexel;
+ float2 texTL = min(textureRegion.xy, textureRegion.zw) - halfTexel;
+ float2 texBR = max(textureRegion.xy, textureRegion.zw) + halfTexel;
+
+ return clamp((textureRegion.xy + corner) + halfTexel, texTL, texBR);
}
inline float2 ComputeRotatedCorner(
@@ -56,16 +59,6 @@ inline float2 ComputeRotatedCorner(
(sinCos.x * corner.x) + (sinCos.y * corner.y)
) - halfTexel;
}
-
-inline void OutputRegions(
- in uniform float2 halfTexel,
- in float4 textureRegion,
- out float2 texTL,
- out float2 texBR
-) {
- texTL = min(textureRegion.xy, textureRegion.zw) + halfTexel;
- texBR = max(textureRegion.xy, textureRegion.zw) - halfTexel;
-}
# 3 "shaders/Bitmap.vcgh"
void main(
in uniform float4x4 ProjectionMatrix,
@@ -108,9 +101,6 @@ void main(
transformedPosition = TransformPosition(ProjectionMatrix, ModelViewMatrix, float4(position.xy, position.z, 1));
transformedPosition2 = transformedPosition;
- OutputRegions(
- HalfTexel, textureRegion, texTL, texBR
- );
multiplyColorOut = multiplyColor;
addColorOut = addColor;
@@ -4,7 +4,7 @@ float4 TransformPosition (
in float4x4 ProjectionMatrix,
float4 position
) {
- return mul(mul(position, ModelViewMatrix), ProjectionMatrix);
+ return mul(mul(position, ProjectionMatrix), ModelViewMatrix);
}
inline float2 ComputeRegionSize(
@@ -34,7 +34,10 @@ inline float2 ComputeTexCoord(
in float2 corner,
in float4 textureRegion
) {
- return (textureRegion.xy + corner) + halfTexel;
+ float2 texTL = min(textureRegion.xy, textureRegion.zw) - halfTexel;
+ float2 texBR = max(textureRegion.xy, textureRegion.zw) + halfTexel;
+
+ return clamp((textureRegion.xy + corner) + halfTexel, texTL, texBR);
}
inline float2 ComputeRotatedCorner(
@@ -56,16 +59,6 @@ inline float2 ComputeRotatedCorner(
(sinCos.x * corner.x) + (sinCos.y * corner.y)
) - halfTexel;
}
-
-inline void OutputRegions(
- in uniform float2 halfTexel,
- in float4 textureRegion,
- out float2 texTL,
- out float2 texBR
-) {
- texTL = min(textureRegion.xy, textureRegion.zw) + halfTexel;
- texBR = max(textureRegion.xy, textureRegion.zw) - halfTexel;
-}
# 3 "shaders/Geometry.vcgh"
void main(
in uniform float4x4 ProjectionMatrix,
@@ -10,9 +10,7 @@ void main(
in float2 texBR : TEXCOORD2,
out float4 result : COLOR
) {
- float2 texCoord = clamp(texCoordOut, texTL, texBR);
-
- float4 texColor = tex2D(BitmapTexture, texCoord);
+ float4 texColor = tex2D(BitmapTexture, texCoordOut);
addColorOut.rgb *= addColorOut.a;
addColorOut.a = 0;
@@ -41,9 +41,6 @@ void main(
transformedPosition = TransformPosition(ProjectionMatrix, ModelViewMatrix, float4(position.xy, position.z, 1));
transformedPosition2 = transformedPosition;
- OutputRegions(
- HalfTexel, textureRegion, texTL, texBR
- );
multiplyColorOut = multiplyColor;
addColorOut = addColor;
Oops, something went wrong.

0 comments on commit 8b9ec20

Please sign in to comment.