Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenFlipper-Free
Type-SplatCloud
Commits
6977a82a
Commit
6977a82a
authored
Feb 17, 2017
by
Jan Möbius
Browse files
Inclomplete merge fixed
parent
f34e2ad9
Changes
5
Show whitespace changes
Inline
Side-by-side
Plugin-TypeSplatCloud/Shaders/SplatCloud_ShaderGen/splat_fs.glsl
0 → 100644
View file @
6977a82a
#version 150
// splat shader version compatible with the ACG shader generator
in
vec2
g2f_posQS
;
void
main
()
{
// discard fragments outside of splat radius
if
(
dot
(
g2f_posQS
,
g2f_posQS
)
>
1
)
discard
;
SG_FRAGMENT_BEGIN
;
SG_FRAGMENT_END
;
}
Plugin-TypeSplatCloud/Shaders/SplatCloud_ShaderGen/splat_gs.glsl
0 → 100644
View file @
6977a82a
#version 150
layout
(
points
)
in
;
layout
(
triangle_strip
,
max_vertices
=
4
)
out
;
in
vec3
v2g_tangentVS
[];
in
vec3
v2g_bitangentVS
[];
in
float
v2g_pointSize
[];
out
vec2
g2f_posQS
;
// quad space position in range [-1,1]^2
uniform
vec2
screenSize
;
void
main
()
{
// center of point
vec4
centerVS
=
SG_INPUT_POSVS
[
0
];
// point size
float
pointSize
=
v2g_pointSize
[
0
].
x
;
// create normal-aligned quad
vec3
offsetX
=
v2g_tangentVS
[
0
]
*
pointSize
;
vec3
offsetY
=
v2g_bitangentVS
[
0
]
*
pointSize
;
// offset factors for the quad vertices
vec2
posQS
[
4
]
=
{
vec2
(
-
1
,
1
),
vec2
(
-
1
,
-
1
),
vec2
(
1
,
1
),
vec2
(
1
,
-
1
)
};
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
// pass default io from shader generator
sg_MapIO
(
i
);
vec2
uv
=
posQS
[
i
];
// expand to quad
vec4
posVS
=
centerVS
;
posVS
.
xyz
+=
uv
.
x
*
offsetX
+
uv
.
y
*
offsetY
;
// transform
vec4
posCS
=
g_mP
*
posVS
;
// output
gl_Position
=
posCS
;
g2f_posQS
=
uv
;
#ifdef SG_OUTPUT_POSVS
SG_OUTPUT_POSVS
=
posVS
;
#endif
#ifdef SG_OUTPUT_POSCS
SG_OUTPUT_POSCS
=
posCS
;
#endif
EmitVertex
();
}
EndPrimitive
();
}
Plugin-TypeSplatCloud/Shaders/SplatCloud_ShaderGen/splat_vs.glsl
0 → 100644
View file @
6977a82a
#version 150
////////////////////////////////////////////////////////////////////////////////////////////
/**/
/**/
/**/
// WARNING: When modifying this file, modify file "PickVertex.glsl" accordingly! /**/
/**/
/**/
////////////////////////////////////////////////////////////////////////////////////////////
// splat shader version compatible with the ACG shader generator
// request common attributes
#define SG_REQUEST_POSVS
#define SG_REQUEST_NORMALOS
#define SG_REQUEST_NORMALVS
out
vec3
v2g_tangentVS
;
// tangent in view space
out
vec3
v2g_bitangentVS
;
// bitangent in view space
out
float
v2g_pointSize
;
// point size in view space
uniform
float
pointsizeScale
=
1
.
0
;
uniform
bool
backfaceCulling
=
false
;
uniform
float
modelviewScale
;
uniform
float
viewportScaleFov_y
;
uniform
float
defaultPointsize
;
uniform
vec3
defaultNormal
;
void
main
()
{
#ifdef SG_INPUT_NORMALOS
vec3
splatNormal
=
SG_INPUT_NORMALOS
;
#else
vec3
splatNormal
=
defaultNormal
;
#endif
#ifdef SG_INPUT_TEXCOORD
(
SG_INPUT_TEXCOORD
.
x
is
the
pointsize
in
model
-
coordinates
)
float
splatPointSize
=
SG_INPUT_TEXCOORD
.
x
;
#else
float
splatPointSize
=
defaultPointsize
;
#endif
// cull if normal is pointing away from eye
if
(
backfaceCulling
&&
dot
(
SG_INPUT_POSOS
.
xyz
-
g_vCamPos
,
splatNormal
)
>
0
.
0
)
// second part is evaluated only if backfaceCulling is true
{
// discard vertex
gl_Position
.
w
=
0
.
0
;
}
else
{
SG_VERTEX_BEGIN
;
// compute tangent vectors
if
(
all
(
lessThan
(
abs
(
sg_vNormalVS
.
xy
),
vec2
(
0
.
1
,
0
.
1
))))
v2g_tangentVS
=
cross
(
sg_vNormalVS
,
vec3
(
0
,
1
,
0
));
else
v2g_tangentVS
=
cross
(
sg_vNormalVS
,
vec3
(
0
,
0
,
1
));
v2g_tangentVS
=
normalize
(
v2g_tangentVS
);
v2g_bitangentVS
=
cross
(
sg_vNormalVS
,
v2g_tangentVS
);
// calculate pointsize
v2g_pointSize
=
modelviewScale
*
pointsizeScale
*
splatPointSize
;
SG_VERTEX_END
;
}
}
Plugin-TypeSplatCloud/Shaders/SplatCloud_Splats/Fragment_shadergen.glsl
0 → 100644
View file @
6977a82a
#version 140
// splat shader version compatible with the ACG shader generator
in
vec3
ecScaledNormal
;
in
float
ecSquaredRadius
;
uniform
mat4
invProjection
;
uniform
vec4
invViewportScale
;
uniform
vec4
invViewportTransp
;
uniform
float
viewportScale_z
;
uniform
float
viewportTransp_z
;
void
main
()
{
SG_FRAGMENT_BEGIN
;
// calculate fragment's position in eye-coordinates
// - scaled by w-component (not divided) because the fragment's projection (see below) is invariant to this
vec4
ndcPosition
=
invViewportScale
*
gl_FragCoord
+
invViewportTransp
;
vec3
ecScaledPosition
=
vec3
(
invProjection
*
ndcPosition
);
vec3
ecCenter
=
SG_INPUT_POSVS
.
xyz
;
// calculate projection in eye-coordinates of fragment's position along viewing direction onto plane described by splat's center and normal
// - equivalent to: ecProjection = (dot(ecCenter,ecNormal) / dot(ecPosition,ecNormal)) * ecPosition
vec3
ecProjection
=
ecScaledPosition
/
dot
(
ecScaledPosition
,
ecScaledNormal
);
// discard fragment if projection is too far away from splat's center
vec3
ecCenterToProj
=
ecProjection
-
ecCenter
;
if
(
dot
(
ecCenterToProj
,
ecCenterToProj
)
>
ecSquaredRadius
)
discard
;
// calculate depth of projection in normalized-device-coordinates
vec4
ccProjection
=
g_mP
*
vec4
(
ecProjection
,
1
.
0
);
float
ndcProjection_z
=
ccProjection
.
z
/
ccProjection
.
w
;
SG_FRAGMENT_END
;
// output depth of projection in window-coordinates
gl_FragDepth
=
viewportScale_z
*
ndcProjection_z
+
viewportTransp_z
;
}
Plugin-TypeSplatCloud/Shaders/SplatCloud_Splats/Vertex_shadergen.glsl
0 → 100644
View file @
6977a82a
#version 140
////////////////////////////////////////////////////////////////////////////////////////////
/**/
/**/
/**/
// WARNING: When modifying this file, modify file "PickVertex.glsl" accordingly! /**/
/**/
/**/
////////////////////////////////////////////////////////////////////////////////////////////
// splat shader version compatible with the ACG shader generator
// request common attributes
#define SG_REQUEST_POSVS
#define SG_REQUEST_NORMALOS
#define SG_REQUEST_NORMALVS
out
vec3
ecScaledNormal
;
out
float
ecSquaredRadius
;
uniform
float
pointsizeScale
=
1
.
0
;
uniform
bool
backfaceCulling
=
false
;
uniform
float
modelviewScale
;
uniform
float
viewportScaleFov_y
;
uniform
float
defaultPointsize
;
uniform
vec3
defaultNormal
;
void
main
()
{
#ifdef SG_INPUT_NORMALOS
vec3
splatNormal
=
SG_INPUT_NORMALOS
;
#else
vec3
splatNormal
=
defaultNormal
;
#endif
#ifdef SG_INPUT_TEXCOORD
float
splatPointSize
=
SG_INPUT_TEXCOORD
.
x
;
#else
float
splatPointSize
=
defaultPointsize
;
#endif
// cull if normal is pointing away from eye
if
(
backfaceCulling
&&
dot
(
SG_INPUT_POSOS
.
xyz
-
g_vCamPos
,
splatNormal
)
>
0
.
0
)
// second part is evaluated only if backfaceCulling is true
{
// discard vertex
gl_Position
.
w
=
0
.
0
;
}
else
{
SG_VERTEX_BEGIN
;
// pass splat's center in eye-coordinates to fragment-shader
vec3
ecCenter
=
sg_vPosVS
.
xyz
;
// pass normal in eye-coordinates to fragment-shader
// - scale so we do not have to do this in fragment-shader for every fragment
ecScaledNormal
=
sg_vNormalVS
/
dot
(
ecCenter
,
sg_vNormalVS
);
// calculate pointsize (SG_INPUT_TEXCOORD.x is the pointsize in model-coordinates)
float
ecPointsize
=
modelviewScale
*
pointsizeScale
*
splatPointSize
;
// pass squared radius (= (1/2 pointsize)^2) in eye-coordinates to fragment-shader
ecSquaredRadius
=
0
.
25
*
(
ecPointsize
*
ecPointsize
);
// output pointsize in window-coordinates
// - divided by gl_Position.w to shrink size by distance
// - divided by -normalize(ecCenter).z because splat could be oriented towards the eye (not necessarily parallel to near-plane)
// - multiply by viewportScaleFov_y to get window coordinates
gl_PointSize
=
max
(
ecPointsize
*
viewportScaleFov_y
/
(
-
normalize
(
ecCenter
).
z
*
gl_Position
.
w
),
1
.
0
);
SG_VERTEX_END
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment