Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Aide
»
Général
»
Code glsl non compris
Print
Pages: [
1
]
Author
Topic: Code glsl non compris (Read 4415 times)
0 Members and 1 Guest are viewing this topic.
FolliotJunior
Newbie
Posts: 6
Code glsl non compris
«
on:
June 18, 2021, 10:00:25 am »
Bonjour, je commence les shader avec sfml et glsl mais je comprend rien a ce code:
#version 130
uniform sampler2D currentTexture
;
uniform sampler2D distortionMapTexture
;
uniform
float
time
;
uniform
float
level
;
void
main
(
)
{
vec2 coord
=
gl_TexCoord
[
0
]
.
xy
;
// Get the color of the noise texture at a position the current fragment position offset by the time
vec4 noiseTexCol
=
texture2D
(
distortionMapTexture
,
vec2
(
gl_TexCoord
[
0
]
.
x
+
0.5
*
time
,
gl_TexCoord
[
0
]
.
y
+
0.5
*
time
)
)
;
// Reduce the offset
float
reducedOffset
=
noiseTexCol.
x
/
80
;
// Upper part is normal
if
(
coord.
y
+
reducedOffset
<
level
)
{
// lookup the pixel in the texture
vec4 pixel
=
texture2D
(
currentTexture
,
gl_TexCoord
[
0
]
.
xy
)
;
// multiply it by the color
gl_FragColor
=
gl_Color
*
pixel
;
}
else
{
// Get the color of the screen at the offset location
vec4 col
=
texture2D
(
currentTexture
,
gl_TexCoord
[
0
]
.
xy
+
vec2
(
reducedOffset
,
reducedOffset
)
)
;
// Set the fragment color
gl_FragColor
=
vec4
(
col.
r
/
2
,
col.
g
/
2
,
col.
b
/
1
,
col.
a
)
;
}
}
genre je comprend pas a quoi chaque chose correspond
Logged
G.
Hero Member
Posts: 1599
Re: Code glsl non compris
«
Reply #1 on:
June 18, 2021, 12:00:35 pm »
Ah bah pas le choix il va falloir apprendre un minimum le GLSL
Logged
FolliotJunior
Newbie
Posts: 6
Re: Code glsl non compris
«
Reply #2 on:
June 18, 2021, 12:26:11 pm »
J'ai essayé mais toutes les docs que j'ai trouver c'est pour utiliser avec openGl et du coup généralement ca marche pas avec mon code.
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: Code glsl non compris
«
Reply #3 on:
June 21, 2021, 08:14:13 am »
Il va quand même falloir apprendre la syntax et les principes de base du GLSL (et des shaders en général), ici il n'y a rien de spécifique à SFML
Logged
Laurent Gomila - SFML developer
Print
Pages: [
1
]
SFML community forums
»
Aide
»
Général
»
Code glsl non compris