Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
K'van
Tales of MajEyal
Commits
18b21654
Commit
18b21654
authored
11 years ago
by
DarkGod
Browse files
Options
Downloads
Patches
Plain Diff
Improved shields shader
parent
7d7e12db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/modules/tome/data/gfx/shaders/shield.frag
+35
-15
35 additions, 15 deletions
game/modules/tome/data/gfx/shaders/shield.frag
game/modules/tome/data/gfx/shaders/shield.lua
+3
-1
3 additions, 1 deletion
game/modules/tome/data/gfx/shaders/shield.lua
with
38 additions
and
16 deletions
game/modules/tome/data/gfx/shaders/shield.frag
+
35
−
15
View file @
18b21654
...
...
@@ -9,32 +9,52 @@ uniform vec2 impact;
uniform
float
impact_tick
;
uniform
float
impact_time
;
uniform
float
llpow
;
uniform
float
ellipsoidalFactor
;
//1 is perfect circle, >1 is ellipsoidal
uniform
float
oscillationSpeed
;
//oscillation between ellipsoidal and spherical form
float
antialiasingRadius
=
0
.
98
;
//1.0 is no antialiasing, 0.0 - fully smoothed(looks worse)
void
main
(
void
)
{
vec2
uv
=
vec2
(
0
.
5
,
0
.
5
)
-
gl_TexCoord
[
0
].
xy
;
float
l
=
length
(
uv
)
*
2
.
0
;
float
ll
=
pow
(
l
,
llpow
);
vec4
c1
=
texture2D
(
tex
,
(
uv
*
ll
/
1
.
3
+
vec2
(
tick
/
time_factor
,
0
.
0
)));
vec4
c2
=
texture2D
(
tex
,
(
uv
*
ll
/
1
.
3
+
vec2
(
0
.
0
,
tick
/
time_factor
)));
//uv.x *= ellispoidalFactor; //for simple ellipsoid
//comment next line for regular spherical shield
uv
.
x
*=
(
1
.
0
+
ellipsoidalFactor
)
*
0
.
5
+
(
ellipsoidalFactor
-
1
.
0
)
*
0
.
5
*
pow
(
cos
(
tick
/
time_factor
*
oscillationSpeed
),
2
.
0
);
float
uvLen
=
length
(
uv
);
float
antialiasingCoef
=
1
.
0
;
float
hordeLen
=
uvLen
*
2
.
0
;
if
(
hordeLen
>
1
.
0
)
{
gl_FragColor
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
0
.
0
);
return
;
}
else
{
if
(
hordeLen
>
antialiasingRadius
)
{
antialiasingCoef
=
(
1
.
0
-
hordeLen
)
/
(
1
.
0
-
antialiasingRadius
);
}
hordeLen
=
asin
(
length
(
uv
)
*
2
.
0
);
}
vec2
sphericalProjectedCoord
=
vec2
(
0
.
5
,
0
.
5
)
+
uv
*
(
hordeLen
/
(
3
.
141592
/
2
.
0
))
/
uvLen
;
vec4
c1
=
texture2D
(
tex
,
(
sphericalProjectedCoord
+
vec2
(
tick
/
time_factor
,
0
.
0
)));
vec4
c2
=
texture2D
(
tex
,
(
sphericalProjectedCoord
+
vec2
(
0
.
0
,
tick
/
time_factor
)));
vec4
c
=
c1
*
c2
;
float
dist
=
max
(
min
(
1
.
0
,
1
.
0
-
l
),
0
.
0
)
*
3
.
0
;
c
.
a
*=
c
.
a
*
dist
;
float
transperency
=
1
.
0
-
exp
(
-
0
.
07
f
/
cos
(
hordeLen
));
c
.
a
=
c
.
a
*
transperency
;
float
z
=
l
;
c
.
a
*=
z
;
if
(
l
>
1
.
0
)
c
.
a
=
0
.
0
;
if
(
l
<
0
.
5
)
{
c
.
a
*=
ll
*
4
.
0
;
}
// Impact
float
it
=
tick
-
impact_tick
;
float
vaadjust
=
aadjust
;
if
(
it
<
impact_time
)
{
float
l
=
uvLen
*
2
.
0
;
float
ll
=
pow
(
l
,
llpow
);
float
v
=
(
impact_time
-
it
)
/
impact_time
;
float
il
=
distance
(
impact
/
ll
,
(
vec2
(
0
.
5
)
-
gl_TexCoord
[
0
].
xy
)
/
ll
);
if
(
il
<
0
.
5
*
(
1
.
0
-
v
))
{
...
...
@@ -46,9 +66,9 @@ void main(void)
}
c
.
a
*=
vaadjust
;
c
.
rgb
*=
color
;
if
(
l
<=
1
.
0
)
c
.
a
=
m
ax
(
0
.
15
,
c
.
a
)
;
c
.
a
*
=
m
in
(
1
.
0
,
c
.
a
)
*
antialiasingCoef
;
c
.
rgb
*=
color
;
gl_FragColor
=
c
;
}
This diff is collapsed.
Click to expand it.
game/modules/tome/data/gfx/shaders/shield.lua
+
3
−
1
View file @
18b21654
...
...
@@ -29,8 +29,10 @@ return {
impact
=
{
0
,
0
},
impact_tick
=
-
1000
,
impact_color
=
{
1
.
0
,
0
.
3
,
1
.
0
},
impact_time
=
4
00
,
impact_time
=
8
00
,
llpow
=
2
,
ellipsoidalFactor
=
ellipsoidalFactor
or
1
.
2
,
oscillationSpeed
=
oscillationSpeed
or
0
,
},
clone
=
false
,
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment