Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfParticleSphereShader.h
1/*******************************************************************************
2 * This file is part of Tissue Forge.
3 * Copyright (c) 2022-2024 T.J. Sego
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19
20/*
21Derived from Magnum with the following notice:
22
23 Original authors — credit is appreciated but not required:
24
25 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 —
26 Vladimír Vondruš <mosra@centrum.cz>
27 2019 — Nghia Truong <nghiatruong.vn@gmail.com>
28
29 This library is free software; you can redistribute it and/or
30 modify it under the terms of the GNU Lesser General Public
31 License as published by the Free Software Foundation; either
32 version 2.1 of the License, or (at your option) any later version.
33
34 This library is distributed in the hope that it will be useful,
35 but WITHOUT ANY WARRANTY; without even the implied warranty of
36 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37 Lesser General Public License for more details.
38 */
39
40#ifndef _SOURCE_SHADERS_TFPARTICLESPHERESHADER_H_
41#define _SOURCE_SHADERS_TFPARTICLESPHERESHADER_H_
42
43#include <tf_port.h>
44#include <Magnum/GL/AbstractShaderProgram.h>
45#include <Magnum/Math/Vector3.h>
46
47
48using namespace Magnum;
49
50
51namespace TissueForge::shaders {
52
53
54 class CAPI_EXPORT ParticleSphereShader: public GL::AbstractShaderProgram {
55 public:
56
57 struct Vertex {
58 Magnum::Vector3 pos;
59 Magnum::Int index;
60 Magnum::Float radius;
61 };
62
63 typedef Magnum::GL::Attribute<0, Magnum::Vector3> Position;
64 typedef Magnum::GL::Attribute<1, Magnum::Int> Index;
65 typedef Magnum::GL::Attribute<2, Magnum::Float> Radius;
66
67
68 enum ColorMode {
69 UniformDiffuseColor = 0,
70 RampColorById,
71 ConsistentRandom
72 };
73
74 explicit ParticleSphereShader();
75
76 ParticleSphereShader& setNumParticles(Int numParticles);
77
78 ParticleSphereShader& setPointSizeScale(Float scale);
79 ParticleSphereShader& setColorMode(Int colorMode);
80 ParticleSphereShader& setAmbientColor(const Color3& color);
81 ParticleSphereShader& setDiffuseColor(const Color3& color);
82 ParticleSphereShader& setSpecularColor(const Color3& color);
83 ParticleSphereShader& setShininess(Float shininess);
84
85 ParticleSphereShader& setViewport(const Vector2i& viewport);
86 ParticleSphereShader& setViewMatrix(const Matrix4& matrix);
87 ParticleSphereShader& setProjectionMatrix(const Matrix4& matrix);
88 ParticleSphereShader& setLightDirection(const Vector3& lightDir);
89
90 private:
91 Int _uNumParticles,
92 _uPointSizeScale,
93 _uColorMode,
94 _uAmbientColor,
95 _uDiffuseColor,
96 _uSpecularColor,
97 _uShininess,
98 _uViewMatrix,
99 _uProjectionMatrix,
100 _uLightDir;
101 };
102
103}
104
105#endif // _SOURCE_SHADERS_TFPARTICLESPHERESHADER_H_
Definition tfParticleSphereShader.h:54
Tissue Forge shaders.
Definition tfFlat3D.h:57
Definition tfParticleSphereShader.h:57