Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gkit2light
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
Alexandre MEYER
gkit2light
Commits
33f194ee
Commit
33f194ee
authored
3 years ago
by
IEHL JEAN CLAUDE
Browse files
Options
Downloads
Patches
Plain Diff
data/shaders: debug normales + texcoords...
parent
ed759ba1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
data/shaders/mesh.glsl
+2
-1
2 additions, 1 deletion
data/shaders/mesh.glsl
data/shaders/normals.glsl
+86
-0
86 additions, 0 deletions
data/shaders/normals.glsl
data/shaders/texcoords.glsl
+48
-0
48 additions, 0 deletions
data/shaders/texcoords.glsl
with
136 additions
and
1 deletion
data/shaders/mesh.glsl
+
2
−
1
View file @
33f194ee
#version 330
#ifdef VERTEX_SHADER
...
...
@@ -120,7 +121,7 @@ void main( )
#endif
// hachure les triangles mal orientes
if
(
gl_FrontFacing
==
false
)
// if(!gl_FrontFacing) bug sur mac ?!
if
(
gl_FrontFacing
==
false
)
{
ivec2
pixel
=
ivec2
(
gl_FragCoord
.
xy
/
4
)
%
ivec2
(
2
,
2
);
if
((
pixel
.
x
^
pixel
.
y
)
==
0
)
...
...
This diff is collapsed.
Click to expand it.
data/shaders/normals.glsl
0 → 100644
+
86
−
0
View file @
33f194ee
#version 330
#ifdef VERTEX_SHADER
layout
(
location
=
0
)
in
vec3
position
;
layout
(
location
=
2
)
in
vec3
normal
;
out
vec3
vertex_normal
;
void
main
(
)
{
gl_Position
=
vec4
(
position
,
1
);
vertex_normal
=
normal
;
}
#endif
#ifdef GEOMETRY_SHADER
uniform
mat4
mvpMatrix
;
uniform
mat4
normalMatrix
;
uniform
float
scale
=
1
;
in
vec3
vertex_normal
[];
out
vec3
geometry_color
;
layout
(
triangles
)
in
;
layout
(
line_strip
,
max_vertices
=
16
)
out
;
void
main
(
)
{
//aretes du triangle
vec3
ab
=
gl_in
[
1
].
gl_Position
.
xyz
-
gl_in
[
0
].
gl_Position
.
xyz
;
vec3
ac
=
gl_in
[
2
].
gl_Position
.
xyz
-
gl_in
[
0
].
gl_Position
.
xyz
;
//normale geometrique du triangle
vec3
gn
=
normalize
(
cross
(
ab
,
ac
));
geometry_color
=
vec3
(
0
.
8
,
0
.
4
,
0
);
vec3
c
=
gl_in
[
0
].
gl_Position
.
xyz
+
ab
/
3
+
ac
/
3
;
// centre du triangle
gl_Position
=
mvpMatrix
*
vec4
(
c
,
1
);
EmitVertex
();
gl_Position
=
mvpMatrix
*
vec4
(
c
+
gn
*
scale
/
2
,
1
);
EmitVertex
();
EndPrimitive
();
geometry_color
=
vec3
(
0
.
4
,
0
.
8
,
0
);
// normale en a
gl_Position
=
mvpMatrix
*
gl_in
[
0
].
gl_Position
;
EmitVertex
();
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
0
].
gl_Position
.
xyz
+
vertex_normal
[
0
]
*
scale
,
1
);
EmitVertex
();
EndPrimitive
();
// normale en b
gl_Position
=
mvpMatrix
*
gl_in
[
1
].
gl_Position
;
EmitVertex
();
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
1
].
gl_Position
.
xyz
+
vertex_normal
[
1
]
*
scale
,
1
);
EmitVertex
();
EndPrimitive
();
// normale en c
gl_Position
=
mvpMatrix
*
gl_in
[
2
].
gl_Position
;
EmitVertex
();
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
2
].
gl_Position
.
xyz
+
vertex_normal
[
2
]
*
scale
,
1
);
EmitVertex
();
EndPrimitive
();
geometry_color
=
vec3
(
0
.
8
,
0
.
4
,
0
);
// arete ab
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
0
].
gl_Position
.
xyz
+
gn
*
0
.
005
,
1
);
EmitVertex
();
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
1
].
gl_Position
.
xyz
+
gn
*
0
.
005
,
1
);
EmitVertex
();
EndPrimitive
();
// arete bc
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
1
].
gl_Position
.
xyz
+
gn
*
0
.
005
,
1
);
EmitVertex
();
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
2
].
gl_Position
.
xyz
+
gn
*
0
.
005
,
1
);
EmitVertex
();
EndPrimitive
();
// arete ca
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
2
].
gl_Position
.
xyz
+
gn
*
0
.
005
,
1
);
EmitVertex
();
gl_Position
=
mvpMatrix
*
vec4
(
gl_in
[
0
].
gl_Position
.
xyz
+
gn
*
0
.
005
,
1
);
EmitVertex
();
EndPrimitive
();
}
#endif
#ifdef FRAGMENT_SHADER
in
vec3
geometry_color
;
out
vec4
fragment_color
;
void
main
(
)
{
fragment_color
=
vec4
(
geometry_color
,
1
);
}
#endif
This diff is collapsed.
Click to expand it.
data/shaders/texcoords.glsl
0 → 100644
+
48
−
0
View file @
33f194ee
#version 330
#ifdef VERTEX_SHADER
layout
(
location
=
0
)
in
vec3
position
;
uniform
mat4
mvpMatrix
;
uniform
mat4
mvMatrix
;
layout
(
location
=
1
)
in
vec2
texcoord
;
out
vec3
vertex_position
;
out
vec2
vertex_texcoord
;
void
main
(
)
{
gl_Position
=
mvpMatrix
*
vec4
(
position
,
1
);
vertex_position
=
vec3
(
mvMatrix
*
vec4
(
position
,
1
));
vertex_texcoord
=
texcoord
;
}
#endif
#ifdef FRAGMENT_SHADER
in
vec3
vertex_position
;
in
vec2
vertex_texcoord
;
uniform
sampler2D
diffuse_color
;
out
vec4
fragment_color
;
void
main
(
)
{
vec3
color
=
vec3
(
vertex_texcoord
,
0
);
ivec2
p
=
ivec2
(
vertex_texcoord
*
1024
);
if
(
p
.
x
%
32
<
2
)
color
=
vec3
(
1
);
if
(
p
.
y
%
32
<
2
)
color
=
vec3
(
1
);
vec3
t
=
dFdx
(
vertex_position
);
vec3
b
=
dFdy
(
vertex_position
);
vec3
n
=
normalize
(
cross
(
t
,
b
));
vec3
l
=
normalize
(
-
vertex_position
);
float
cos_theta
=
max
(
0
,
dot
(
n
,
l
));
fragment_color
=
vec4
(
color
*
cos_theta
,
1
);
}
#endif
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