Skip to content

Commit 8c9e204

Browse files
committed
Update circular point effect
- Remove radius parameter from create_points function.
1 parent 82f3410 commit 8c9e204

File tree

9 files changed

+30
-9
lines changed

9 files changed

+30
-9
lines changed

render_pipeline/rpcore/util/primitives.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace rpcore {
88

99
RENDER_PIPELINE_DECL NodePath create_points(const std::string& name, const std::vector<LPoint3f>& positions,
10-
float radius=1.0f, GeomEnums::UsageHint buffer_hint=Geom::UsageHint::UH_static);
10+
GeomEnums::UsageHint buffer_hint=Geom::UsageHint::UH_static);
1111

1212
RENDER_PIPELINE_DECL NodePath create_cube(const std::string& name);
1313
RENDER_PIPELINE_DECL NodePath create_sphere(const std::string& name, unsigned int latitude, unsigned int longitude);

resources/effects/circular_points.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ vertex:
88
99
post_transform: |
1010
gl_PointSize = point_radius * WINDOW_WIDTH * p3d_ProjectionMatrix[0][0] / -(p3d_ModelViewMatrix * p3d_Vertex).z;
11-
12-
// override normal
13-
vOutput.normal = normalize((p3d_ModelMatrix * vec4(0, -1, 0, 0)).xyz);
11+
vOutput.normal = vec3((gl_Position.xy / gl_Position.w + vec2(1.0f)) / 2.0f * SCREEN_SIZE,
12+
gl_PointSize / 2.0f);
1413
1514
1615
fragment:
16+
inout: |
17+
vec2 circular_points_unit_coord;
18+
19+
pretest: |
20+
circular_points_unit_coord = (gl_FragCoord.xy - vOutput.normal.xy) / vOutput.normal.z;
21+
const float sphere_radius_square = dot(circular_points_unit_coord, circular_points_unit_coord);
22+
if (sphere_radius_square > 1.0f) discard;
23+
24+
material: |
25+
m.normal.xy = circular_points_unit_coord;
26+
m.normal.z = sqrt(1.0f - dot(circular_points_unit_coord, circular_points_unit_coord));

resources/rpcore/shader/templates/envmap.frag.glsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
layout(location = 0) out vec4 result;
4242

4343
void main() {
44+
45+
%pretest%
46+
4447
vec2 texcoord = vOutput.texcoord;
4548
MaterialBaseInput mInput = get_input_from_p3d(p3d_Material);
4649

resources/rpcore/shader/templates/forward.frag.glsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ layout(location = 0) out vec4 color_result;
7676

7777
void main() {
7878

79+
%pretest%
80+
7981
MaterialBaseInput mInput = get_input_from_p3d(p3d_Material);
8082

8183
vec2 texcoord = vOutput.texcoord;

resources/rpcore/shader/templates/gbuffer.frag.glsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ uniform Panda3DMaterial p3d_Material;
6868

6969
void main() {
7070

71+
%pretest%
72+
7173
MaterialBaseInput mInput = get_input_from_p3d(p3d_Material);
7274

7375
vec2 texcoord = vOutput.texcoord;

resources/rpcore/shader/templates/shadow.frag.glsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ uniform sampler2D p3d_Texture0;
4141
#endif
4242

4343
void main() {
44+
45+
%pretest%
46+
4447
#if OPT_ALPHA_TESTING
4548

4649
// Alpha tested shadows. This seems to be quite expensive, so we are

resources/rpcore/shader/templates/voxelize.frag.glsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ uniform writeonly image3D RESTRICT VoxelGridDest;
4343
#pragma include "includes/nonviewspace_shading_pipeline.inc.glsl"
4444

4545
void main() {
46+
47+
%pretest%
48+
4649
vec2 texcoord = vOutput.texcoord;
4750
MaterialBaseInput mInput = get_input_from_p3d(p3d_Material);
4851

src/rpcore/util/circular_points_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct CircularPointsNode::Impl
3333
CircularPointsNode::Impl::Impl(const std::string& name, const std::vector<LPoint3f>& positions, float radius,
3434
const std::string& effect_path, GeomEnums::UsageHint buffer_hint)
3535
{
36-
points_np_ = create_points(name, positions, radius);
36+
points_np_ = create_points(name, positions);
3737
positions_ = positions;
3838

3939
// Load the effect

src/rpcore/util/primitives.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static NodePath create_geom_node(const std::string& name, Geom* geom)
2323
return np;
2424
}
2525

26-
NodePath create_points(const std::string& name, const std::vector<LPoint3f>& positions, float radius, GeomEnums::UsageHint buffer_hint)
26+
NodePath create_points(const std::string& name, const std::vector<LPoint3f>& positions, GeomEnums::UsageHint buffer_hint)
2727
{
2828
const size_t count = positions.size();
2929

@@ -46,9 +46,7 @@ NodePath create_points(const std::string& name, const std::vector<LPoint3f>& pos
4646
PT(Geom) geom = new Geom(vdata);
4747
geom->add_primitive(prim);
4848

49-
NodePath np = create_geom_node(name, geom);
50-
np.set_render_mode_thickness(radius);
51-
return np;
49+
return create_geom_node(name, geom);
5250
}
5351

5452
NodePath create_cube(const std::string& name)

0 commit comments

Comments
 (0)