3D - OpenGL
|
Index
|
|
General
|
- 3DSite
- 3D
links (Rich Coutts)
- 3DGC
- 3D Graphics in MPEG-4
- Mark Kilgard Home
Page
- Graphics
resources (Zhar)
- Conceptes / Concepts
- Graphics
pileline / rendering pipeline: 3D -> 2D
- Application: collision detection, animation, morphing,
acceleration; quadtrees (2D), octrees (3D)
- Geometry: operations with polygons and vertices ->
vertex shader
- model and camera transformation
- projection: to cube
- world matrix * camera matrix * projection
matrix
- lighting
- clipping
- window - viewport transformation
- Rasterization
- Shaders
- "a shader is a computer program that calculates the
appropriate levels of light, darkness, and color during
the rendering of a 3D scene—a process known as shading."
- perform Shading
(depiction of depth perception in 3D models)
- shading techniques
- flat shading
- smooth shading
- Gouraud shading
- Phong shading
- deferred shading
- Info
- shading languages
- "Shading languages are used to program the GPU's
rendering pipeline, which has mostly superseded the
fixed-function pipeline of the past that only
allowed for common geometry transforming and
pixel-shading functions; with shaders, customized
effects can be used."
-
|
API |
shading language |
|
Khronos Group |
OpenGL |
OpenGL
Shading Language - GLSL |
|
|
Vulkan |
|
|
Microsoft |
Direct3D |
High Level Shader - HLS (Cg) |
|
Apple |
Metal framework |
Metal Shading Language |
|
- types
-
|
type |
introduced |
describes |
performs |
3D shaders:
act on 3D models |
vertex shader |
|
attributes of a vertex: position, texture
coordinates, colours... |
geometry is transformed |
|
geometry shader |
OpenGL 3.2 |
|
some changes of the geometries in the
scene are perfomed |
|
tessellation shader |
OpenGL 4.0 |
|
geometries are subdivided (and then
triangulated) |
|
primitive and mesh shaders |
|
|
|
|
ray tracing shader |
|
|
|
2D shaders:
act on digital images (textures) |
pixel shader /
fragment shader |
|
traits of a pixel: colour, z-depth, alpha
value |
fragment quads (after triangles have been
broken) are modified |
|
OpenGL
|
|
Mesa
|
- The Mesa 3-D graphics library
- Do
all intel gpu's use software rendering (Mesa) only?
glxinfo | fgrep direct
LIBGL_ALWAYS_SOFTWARE=1 glxinfo|grep
'\<renderer\>'
- Eines / Tools
- glxinfo
- glxinfo -B
glxinfo | fgrep direct
LIBGL_ALWAYS_SOFTWARE=1 glxinfo|grep
'\<renderer\>'
- Demos
- glxgears
- source
- freedesktop / mesa-demos / xdemos / glxgears.c
- dependències
- Mageia
sudo dnf install autoconf automake
libtool lib64glew-devel
- Alma 8
sudo dnf install glew-devel
- compilació / compilation
./autogen.sh
./configure
- make
- sudo
make install
- Problemes / Problems
configure.ac:38: error: possibly
undefined macro: AC_PROG_LIBTOOL
- install
- Mageia
sudo dnf install mesa-demos
- usage
glxgears
- DISPLAY=:0
glxgears
glxgears -display :0 -info -geometry
400x400+200+100
- disable vsync
- enable vsync
- ...
- problems
- vsync not honoured on AWS EC2 g4dn with nvidia
drivers
- glxspheres64
- install
- Mageia
sudo dnf install glxspheres
- Alma Linux
- usage
glxspheres
glxspheres64
- /opt/VirtualGL/bin/glxspheres64
|
Open Inventor
|
|
|
|
|
- usually used with dummy
driver (to be able to run in background) but using
hardware acceleration
- Install
- Mageia
sudo dnf install virtualgl
- Alma
- ...
|
|
-
- Modeladors / Modellers
- 3dPM
- AC3D
- Visualitzadors / Viewers
- CAD
- Arquitectura / Architecture
- Motors / Engines
- Mons virtuals / Virtual worlds
- File formats
- Collada
- VRML
- X3D (wp)
- DXF
- Used by:
- Documents
- Exemples
- recta / straight
- corba / curve
- API
- VTK
- Bullet 3D Game Multiphysics Library
- Ray-tracing
- OpenVDB
(DreamWorks): hierarchical data structure
- Framerate limiter
- libstrangle
- compilació
- dependències
- passos / steps
git clone
https://gitlab.com/torkel104/libstrangle.git
cd libstrangle
make 64-bit
sudo -i
make
install-common install-64
- echo
"/usr/local/lib/libstrangle/lib64"
>/etc/ld.so.conf.d/libstrangle.conf
- ldconfig
- ús
strangle 60 /path/to/game
|
Desenvolupament / Development
|
- OpenGL
- GLSL - OpenGL Shading Language
- Info
- molt semblant a C, però el compilador és un altre
i els binaris generats corren a la GPU
- OpenGL
Shading Language (wp)
- basat en la seva sintaxi existeix una biblioteca,
anomenada GLM,
que és per a C++ i aprofita les funcionalitats
bàsiques de GLSL
- Especificació / Specification
- GLM
- biblioteca basada en GLSL, però s'executa a la CPU i no a
la GPU
- OpenGL Mathematics (GLM) is a header only C++ mathematics
library for graphics software based on the OpenGL
Shading Language (GLSL) specifications.
- glm (openFramworks)
- implementacions
- exemples
- swizzle
operators
-
|
|
#define GLM_FORCE_SWIZZLE // Or defined
when building (e.g. -DGLM_FORCE_SWIZZLE)
#include <glm/glm.hpp>
void foo()
{
glm::vec3 const PositionA =
glm::vec3(1.0f, 0.5f, 0.0f);
glm::vec2 const PositionB =
PositionA.xy() * 2.0f;
} |
g++ -c swizzle_1.cpp -o swizzle_1.o
|
#define GLM_FORCE_SWIZZLE // Or defined
when building (e.g. -DGLM_FORCE_SWIZZLE)
#include <glm/glm.hpp>
void foo()
{
glm::vec3 const PositionA =
glm::vec3(1.0f, 0.5f, 0.0f);
glm::vec2 const PositionB =
PositionA.xy * 2.0f;
} |
g++ -c swizzle_2.cpp -o swizzle_2.o
swizzle_2.cpp: In function 'void
foo()':
swizzle_2.cpp:7:43: error: invalid use
of member function 'glm::vec<2, T,
Q> glm::vec<3, T, Q>::xy()
const [with T = float; glm::qualifier Q
= glm::packed_highp]' (did you forget
the '()' ?)
7
| glm::vec2
const PositionB = PositionA.xy * 2.0f;
|
~~~~~~~~~~^~
|
()
g++ ...
|
- compilació perquè no doni error: ...
- How
to compile C code with anonymous structs / unions?
- How
to achieve vector swizzling in C++?
- C
- C++
- anonymous union
- Constructors
and member initializer lists
#define GLM_FORCE_SWIZZLE
// Or defined when building (e.g.
-DGLM_FORCE_SWIZZLE)
#include <vector>
#include <glm/glm.hpp>
enum class VariantType { isUndef, isHeader, isInt,
isDouble, isStr, isVec3,
isVector,isLayer,isAngle,isDelimiter };
typedef struct SELECT_TYPE {
SELECT_TYPE() :type(VariantType::isUndef),
z_Editable(false), hasBase(false),label(nullptr),
header({0,0,nullptr,false,nullptr}) {};
VariantType type;
const char* label;
//int flags;
bool z_Editable;
bool hasBase;
union {
struct {
int id;
int layer;
char* title;
bool* base_z_set;
double* z;
} header;
glm::vec3* point;
std::vector<glm::vec3>*
pointlist;
const char* str;
int i;
double d;
};
} SELECT;
void foo()
{
glm::vec3 const PositionA = glm::vec3(1.0f,
0.5f, 0.0f);
glm::vec2 const PositionB = PositionA.xy()
* 2.0f;
}
- select.cpp: In constructor
'SELECT_TYPE::SELECT_TYPE()':
select.cpp:8:96: error: no matching function for
call to 'SELECT_TYPE::<unnamed
union>::<unnamed
struct>::._anon_95(<brace-enclosed initializer
list>)'
8 | SELECT_TYPE()
:type(VariantType::isUndef), z_Editable(false),
hasBase(false),label(nullptr),
header({0,0,nullptr,false,nullptr}) {};
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
select.cpp:15:12: note: candidate:
'SELECT_TYPE::<unnamed union>::<unnamed
struct>::<constructor>()'
15 | struct {
|
^
select.cpp:15:12: note: candidate
expects 0 arguments, 1 provided
select.cpp:15:12: note: candidate: 'constexpr
SELECT_TYPE::<unnamed union>::<unnamed
struct>::<constructor>(const
SELECT_TYPE::<unnamed union>::<unnamed
struct>&)'
select.cpp:15:12: note: no known
conversion for argument 1 from '<brace-enclosed
initializer list>' to 'const
SELECT_TYPE::<unnamed union>::<unnamed
struct>&'
select.cpp:15:12: note: candidate: 'constexpr
SELECT_TYPE::<unnamed union>::<unnamed
struct>::<constructor>(SELECT_TYPE::<unnamed
union>::<unnamed struct>&&)'
select.cpp:15:12: note: no known
conversion for argument 1 from '<brace-enclosed
initializer list>' to 'SELECT_TYPE::<unnamed
union>::<unnamed struct>&&'
- ...
- CUDA
- Video game development platforms (List
of game engines)
- Unity
- Unreal Engine
- Godot
- Unity3D
- Install
Unity3D on Linux
- Passos / Steps
wget
https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage
chmod +x UnityHub.AppImage
./UnityHub.AppImage
- Virtual display
- How
to run Unity on Amazon Cloud or without Monitor
- Running Unity app with graphics on a server
without monitor
- Running Unity app offscreen on your local machine
- Run Unity app with graphics on Amazon Cloud!
-
|
deps |
setup |
X
server |
launch unity |
Running Unity app with graphics on a
server without monitor |
xserver-xorg |
sudo nvidia-xconfig -a
--use-display-device=None
--virtual=1280x1024 |
sudo /usr/bin/X :0 & |
DISPLAY=:0 $your_unity_exec |
Running Unity app offscreen on your local
machine |
xorg-video-abi-15
x11-driver-video-dummy
virtualgl |
# xorg.conf from XDummy
wget http://xpra.org/xorg.conf . |
Xorg -noreset +extension GLX +extension
RENDER -logfile ./10.log -config ./xorg.conf
:10 |
DISPLAY=:10 vglrun $your_unity_exec |
Run Unity app with graphics on Amazon
Cloud (EC2: gxx) |
xserver-xorg
mesa-utils |
# disable nouveau
...
sudo nvidia-xconfig -a
--use-display-device=None
--virtual=1280x1024 |
sudo /usr/bin/X :0 & |
DISPLAY=:0 $your_unity_exec |
- ...
- Eines relacionades / Related tools
- Instruccions antigues / Old instructions
|
|
- Instal·lació / Installation
- Raspberry Pi
- Install
the Unity Hub and Editor
wget
https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubBeta.tar.gz
tar xvf UnityHubBeta.tar.gz
cd Unity\ Hub
chmod +x INSTALL.sh
- mkdir -p
~/.local/share/applications/
./INSTALL.sh
- Manual
- Problemes / Problems
- Ús / Usage
${HOME}/Applications/UnityHub.AppImage
- Plugins
- Video players (play a video from inside Unity)
- FEMTP
- WebRTC
- ...
|
Javascript
|
|
|
|
Impressió / Print
|
|
type |
format |
free |
examples |
comments |
GLpr (dwnld) |
vector |
PS, |
- |
|
It works with Inventor. |
PS
render |
vector |
PS |
× |
GLUT |
Not all the primitives are implemented. |
GLP |
vector |
PS |
× |
Mesa |
|
TGS (3D
Master Suite) |
2D vector |
PS |
- |
|
Not for 3D scenes. |
Iv2Ras |
bitmap |
PS, rgb |
× |
iv2ps |
bitmap |
PS |
× |
|
Ray-tracing, radiosity
|
|
Reconstrucció / Reconstruction
|
|
Mons virtuals / Virtual worlds
|
|
http://www.francescpinyol.cat/opengl.html
Primera versió: / First version:
Darrera modificació: 1 de juny de 2024 / Last update: 1st June
2024
Cap a casa / Back home |