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
      1. Application: collision detection, animation, morphing, acceleration; quadtrees (2D), octrees (3D)
      2. Geometry: operations with polygons and vertices -> vertex shader
        1. model and camera transformation
        2. projection: to cube
          • world matrix * camera matrix * projection matrix
        3. lighting
        4. clipping
        5. window - viewport transformation
      3. 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

Open Inventor

GLUT

VirtualGL

  • usually used with dummy driver (to be able to run in background) but using hardware acceleration
  • Install
    • Mageia
      • sudo dnf install virtualgl
    • Alma
  • ...

Programari / Software

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)
      •  learn c++
    • 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
        1. wget https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage
        2. chmod +x UnityHub.AppImage
        3. ./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

Unity3D

Javascript

VRML

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