Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a34b7aa

Browse files
committed
inital commit
1 parent 8ea0cb3 commit a34b7aa

File tree

5 files changed

+233
-0
lines changed

5 files changed

+233
-0
lines changed

CompileShader.bat

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@echo off
2+
3+
setlocal
4+
set error=0
5+
6+
@rem set FXCOPTS=/nologo /WX /Ges /Zi /Zpc /Qstrip_reflect /Qstrip_debug
7+
set FXCOPTS=/nologo /WX /Ges /Qstrip_reflect /Qstrip_debug
8+
set FXCOPTSNS=/nologo /Ges /Qstrip_reflect /Qstrip_debug
9+
10+
@rem Insert Location into quotes
11+
set PCFXC=""
12+
if exist %PCFXC% goto continue
13+
14+
set PCFXC=fxc.exe
15+
16+
:continue
17+
18+
@rem *** compile non-premultiplied version
19+
set FXCEXT=fxc
20+
21+
call :CompileShaderHLSL "counter_gradient" ps ps_main
22+
23+
echo .
24+
if %error% == 0 (
25+
echo Shaders compiled ok
26+
@pause
27+
) else (
28+
echo There were shader compilation errors!
29+
@pause
30+
)
31+
32+
endlocal
33+
exit /b
34+
35+
:CompileShader
36+
@rem set fxc=%PCFXC% %1.fx %FXCOPTS% /T%2_4_0_level_9_1 /E%3 /FhCompiled\%1_%3.inc /FdCompiled\%1_%3.pdb /Vn%1_%3
37+
set fxc=%PCFXC% "%~1.fx11" %FXCOPTS% /T%2_4_0_level_9_1 /E%3 /Fo"%~1.%FXCEXT%"
38+
echo.
39+
echo %fxc%
40+
%fxc% || set error=1
41+
exit /b
42+
43+
:CompileShaderSM4
44+
@rem set fxc=%PCFXC% %1.fx %FXCOPTS% /T%2_4_0 /E%3 /FhCompiled\%1_%3.inc /FdCompiled\%1_%3.pdb /Vn%1_%3
45+
set fxc=%PCFXC% "%~1.fx11" %FXCOPTS% /T%2_4_0 /E%3 /Fo"%~1.%FXCEXT%"
46+
echo.
47+
echo %fxc%
48+
%fxc% || set error=1
49+
exit /b
50+
51+
:CompileShaderHLSL
52+
@rem set fxc=%PCFXC% %1.hlsl %FXCOPTS% /T%2_4_0_level_9_1 /E%3 /FhCompiled\%1_%3.inc /FdCompiled\%1_%3.pdb /Vn%1_%3
53+
set fxc=%PCFXC% "%~1.hlsl" %FXCOPTS% /T%2_4_0_level_9_1 /E%3 /Fo"%~1.%FXCEXT%"
54+
echo.
55+
echo %fxc%
56+
%fxc% || set error=1
57+
exit /b
58+
59+
:CompileShaderHLSL4
60+
@rem set fxc=%PCFXC% %1.hlsl %FXCOPTS% /T%2_4_0_level_9_1 /E%3 /FhCompiled\%1_%3.inc /FdCompiled\%1_%3.pdb /Vn%1_%3
61+
set fxc=%PCFXC% "%~1.hlsl" %FXCOPTS% /T%2_4_0 /E%3 /Fo"%~1.%FXCEXT%"
62+
echo.
63+
echo %fxc%
64+
%fxc% || set error=1
65+
exit /b
66+
67+
:CompileShaderHLSL4ns
68+
@rem set fxc=%PCFXC% %1.hlsl %FXCOPTS% /T%2_4_0_level_9_1 /E%3 /FhCompiled\%1_%3.inc /FdCompiled\%1_%3.pdb /Vn%1_%3
69+
set fxc=%PCFXC% "%~1.hlsl" %FXCOPTSNS% /T%2_4_0 /E%3 /Fo"%~1.%FXCEXT%"
70+
echo.
71+
echo %fxc%
72+
%fxc% || set error=1
73+
exit /b

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Counter Gradient
2+
3+
## Purpose
4+
A replacement for using counters as gradient bars in Clickteam Fusion.
5+
6+
## Compiling:
7+
8+
### Requisites:
9+
FXC (apart of the [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/))
10+
11+
### Windows:
12+
1. Insert `FXC.exe` into the root directory or insert the path for FXC in line 11 of `CompileShader.bat`
13+
2. Run `CompileShader.bat`
14+
3. You should get a successful compilation message:
15+
```
16+
fxc.exe "funky_fisheye.hlsl" /nologo /WX /Ges /Qstrip_reflect /Qstrip_debug /Tps_4_0 /Eps_main /Fo"funky_fisheye.fxc"
17+
compilation object save succeeded; see ROOT\funky_fisheye.fxc
18+
19+
fxc.exe "funky_fisheye.hlsl" /nologo /WX /Ges /Qstrip_reflect /Qstrip_debug /Tps_4_0 /Eps_main_pm /Fo"funky_fisheye.premultiplied.fxc"
20+
compilation object save succeeded; see ROOT\funky_fisheye.premultiplied.fxc
21+
.
22+
Shaders compiled ok
23+
```
24+
25+
## TODO
26+
- Android Support
27+
- MacOS Support
28+
- IOS Support

counter_gradient.fx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
bool vert;
2+
float center;
3+
float counter;
4+
int dir;
5+
float4 color1;
6+
float4 color2;
7+
8+
float4 ps_main(in float2 texCoord : TEXCOORD0) : COLOR0
9+
{
10+
float gradient= vert ? texCoord.y/center : texCoord.x/center;
11+
float4 output=lerp(color1,color2,gradient);
12+
13+
if(dir==0)
14+
{
15+
output*= float4(texCoord.x < counter, texCoord.x < counter, texCoord.x < counter, texCoord.x < counter);
16+
}
17+
if(dir==1)
18+
{
19+
output*= float4(texCoord.x > 1.0-counter, texCoord.x > 1.0-counter, texCoord.x > 1.0-counter, texCoord.x > 1.0-counter);
20+
}
21+
if(dir==2)
22+
{
23+
output*= float4(texCoord.y < counter, texCoord.y < counter, texCoord.y < counter, texCoord.y < counter);
24+
}
25+
if(dir==3)
26+
{
27+
output*= float4(texCoord.y > 1.0-counter, texCoord.y > 1.0-counter, texCoord.y > 1.0-counter, texCoord.y > 1.0-counter);
28+
}
29+
return output;
30+
}
31+
32+
technique tech_main { pass P0 {PixelShader = compile ps_2_0 ps_main();}}

counter_gradient.hlsl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
cbuffer PS_VARIABLES : register(b0)
2+
{
3+
bool vert;
4+
float center;
5+
float counter;
6+
int dir;
7+
float4 color1;
8+
float4 color2;
9+
}
10+
11+
struct PS_INPUT
12+
{
13+
float4 Tint : COLOR0;
14+
float2 texCoord : TEXCOORD0;
15+
float4 Position : SV_POSITION;
16+
};
17+
18+
struct PS_OUTPUT
19+
{
20+
float4 Color : SV_TARGET;
21+
};
22+
23+
float4 ps_main(in PS_INPUT In) : SV_TARGET
24+
{
25+
float2 _texCoord = In.texCoord.xy;
26+
27+
float gradient= vert ? _texCoord.y/center : _texCoord.x/center;
28+
float4 output=lerp(color1,color2,gradient);
29+
30+
if(dir==0)
31+
{
32+
output*= float4(_texCoord.x < counter, _texCoord.x < counter, _texCoord.x < counter, _texCoord.x < counter);
33+
}
34+
if(dir==1)
35+
{
36+
output*= float4(_texCoord.x > 1.0-counter, _texCoord.x > 1.0-counter, _texCoord.x > 1.0-counter, _texCoord.x > 1.0-counter);
37+
}
38+
if(dir==2)
39+
{
40+
output*= float4(_texCoord.y < counter, _texCoord.y < counter, _texCoord.y < counter, _texCoord.y < counter);
41+
}
42+
if(dir==3)
43+
{
44+
output*= float4(_texCoord.y > 1.0-counter, _texCoord.y > 1.0-counter, _texCoord.y > 1.0-counter, _texCoord.y > 1.0-counter);
45+
}
46+
return output;
47+
}

counter_gradient.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<effect>
2+
<name>Counter Gradient</name>
3+
<description>Replacement for counter bars.</description>
4+
<author>Nomok</author>
5+
<parameter>
6+
<name>Gradient Vertical</name>
7+
<code>vert</code>
8+
<description>Toggles if the gradient is vertical.</description>
9+
<type>int</type>
10+
<property>checkbox</property>
11+
<value>0</value>
12+
</parameter>
13+
<parameter>
14+
<name>Center</name>
15+
<code>center</code>
16+
<description>Controls the center of the gradient.</description>
17+
<description></description>
18+
<type>float</type>
19+
<property>edit</property>
20+
<value>1.0</value>
21+
</parameter>
22+
<parameter>
23+
<name>Counter</name>
24+
<code>counter</code>
25+
<description>Controls the fill.</description>
26+
<description></description>
27+
<type>float</type>
28+
<property>edit</property>
29+
<value>1.0</value>
30+
</parameter>
31+
<parameter>
32+
<name>Counter Direction</name>
33+
<code>dir</code>
34+
<description>0 - Left to Right, 1 - Right to Left, 2 - Top to Bottom, 3 - Bottom to Top</description>
35+
<type>int</type>
36+
<property>edit</property>
37+
<value>0</value>
38+
</parameter>
39+
<parameter>
40+
<name>Color 1</name>
41+
<code>color1</code>
42+
<type>int_float4</type>
43+
<property>COLOR</property>
44+
<value>-255</value>
45+
</parameter>
46+
<parameter>
47+
<name>Color 2</name>
48+
<code>color2</code>
49+
<type>int_float4</type>
50+
<property>COLOR</property>
51+
<value>-37632</value>
52+
</parameter>
53+
</effect>

0 commit comments

Comments
 (0)