Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
ProjectiveTextureMapping
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WooHyungChoi
ProjectiveTextureMapping
Commits
7f39587e
Commit
7f39587e
authored
5 years ago
by
Woohyung Choi
Browse files
Options
Downloads
Patches
Plain Diff
update projector shader code
parent
363fa20d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Shaders/Projector/Projector.frag
+48
-8
48 additions, 8 deletions
Shaders/Projector/Projector.frag
Shaders/Projector/Projector.vert
+23
-9
23 additions, 9 deletions
Shaders/Projector/Projector.vert
with
71 additions
and
17 deletions
Shaders/Projector/Projector.frag
+
48
−
8
View file @
7f39587e
#version 330 core
#version 330 core
uniform
sampler2D
image
;
out
vec4
FragColor
;
out
vec4
FragColor
;
in
vec4
TexCoords
;
struct
Material
{
sampler2D
diffuse
;
sampler2D
specular
;
float
shininess
;
};
struct
Light
{
vec3
position
;
vec3
ambient
;
vec3
diffuse
;
vec3
specular
;
};
in
vec3
FragPos
;
in
vec3
Normal
;
in
vec2
TexCoords
;
in
vec4
ProjTexCoords
;
uniform
vec3
viewPos
;
uniform
Material
material
;
uniform
Light
light
;
uniform
sampler2D
projImage
;
void
main
(
void
)
void
main
(
void
)
{
{
vec4
final_color
;
// ambient
if
(
TexCoords
.
q
>
0
.
0
)
vec3
ambient
=
light
.
ambient
*
texture
(
material
.
diffuse
,
TexCoords
).
rgb
;
// diffuse
vec3
norm
=
normalize
(
Normal
);
vec3
lightDir
=
normalize
(
light
.
position
-
FragPos
);
float
diff
=
max
(
dot
(
norm
,
lightDir
),
0
.
0
);
vec3
diffuse
=
light
.
diffuse
*
diff
*
texture
(
material
.
diffuse
,
TexCoords
).
rgb
;
// specular
vec3
viewDir
=
normalize
(
viewPos
-
FragPos
);
vec3
reflectDir
=
reflect
(
-
lightDir
,
norm
);
float
spec
=
pow
(
max
(
dot
(
viewDir
,
reflectDir
),
0
.
0
),
material
.
shininess
);
vec3
specular
=
light
.
specular
*
spec
*
texture
(
material
.
specular
,
TexCoords
).
rgb
;
vec4
result
=
vec4
(
ambient
+
diffuse
+
specular
,
1
.
0
);
vec4
projColor
;
if
(
ProjTexCoords
.
q
>
0
.
0
)
{
{
vec2
finalCoords
=
TexCoords
.
st
/
TexCoords
.
q
;
vec2
finalCoords
=
Proj
TexCoords
.
st
/
Proj
TexCoords
.
q
;
vec4
ProjMapColor_forCam1
=
texture
(
i
mage
,
finalCoords
);
vec4
ProjMapColor_forCam1
=
texture
(
projI
mage
,
finalCoords
);
final_c
olor
=
ProjMapColor_forCam1
;
projC
olor
=
ProjMapColor_forCam1
;
}
}
FragColor
=
final_color
;
FragColor
=
mix
(
result
,
projColor
,
0
.
4
f
)
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Shaders/Projector/Projector.vert
+
23
−
9
View file @
7f39587e
#version 330 core
#version 330 core
layout
(
location
=
0
)
in
vec3
aPos
;
layout
(
location
=
0
)
in
vec3
aPos
;
layout
(
location
=
1
)
in
vec3
aNormal
;
layout
(
location
=
2
)
in
vec2
aTexCoords
;
out
vec4
TexCoords
;
out
vec4
ProjTexCoords
;
out
vec3
FragPos
;
out
vec3
Normal
;
out
vec2
TexCoords
;
uniform
mat4
projectorBias
;
uniform
mat4
projectorProjection
;
uniform
mat4
projectorView
;
uniform
mat4
TexGenMatCam0
;
uniform
mat4
model
;
uniform
mat4
model
;
uniform
mat4
view
;
uniform
mat4
view
;
uniform
mat4
projection
;
uniform
mat4
projection
;
void
main
()
void
main
()
{
{
vec3
FragPos
=
vec3
(
model
*
vec4
(
aPos
,
1
.
0
));
FragPos
=
vec3
(
model
*
vec4
(
aPos
,
1
.
0
));
vec4
VertexPos_eye
=
model
*
view
*
vec4
(
aPos
,
1
.
0
);
Normal
=
mat3
(
transpose
(
inverse
(
model
)))
*
aNormal
;
vec4
VertexPos_world
=
inverse
(
view
)
*
VertexPos_eye
;
TexCoords
=
aTexCoords
;
mat4
InvViewMat
=
inverse
(
view
);
mat4
TexGenMatCam0
=
projectorBias
*
projectorProjection
*
projectorView
;
vec4
posEye
=
view
*
model
*
vec4
(
aPos
,
1
.
0
);
TexCoords
=
TexGenMatCam0
*
VertexPos_world
;
Proj
TexCoords
=
TexGenMatCam0
*
posEye
;
gl_Position
=
projection
*
view
*
vec4
(
FragPos
,
1
.
0
);
gl_Position
=
projection
*
view
*
vec4
(
FragPos
,
1
.
0
);
}
}
\ No newline at end of file
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