🎮 3D Game Shaders For Beginners

3D Game Shaders For Beginners

3D Game Shaders For Beginners

Interested in adding textures, lighting, shadows, normal maps, glowing objects, ambient occlusion, reflections, refractions, and more to your 3D game? Great! Below is a collection of shading techniques that will take your game visuals to new heights. I've explained each technique in such a way that you can take what you learn here and apply/port it to whatever stack you use—be it Godot, Unity, Unreal, or something else. For the glue in between the shaders, I've chosen the fabulous Panda3D game engine and the OpenGL Shading Language (GLSL). So if that is your stack, then you'll also get the benefit of learning how to use these shading techniques with Panda3D and OpenGL specifically.

Table Of Contents

License

The included license applies only to the software portion of 3D Game Shaders For Beginners— specifically the .cxx, .vert, and .frag source code files. No other portion of 3D Game Shaders For Beginners has been licensed for use.

Attributions

Copyright

(C) 2019 David Lettier
lettier.com

Comments
  • Unable to create executable with macOS Mojave 10.14.4

    Unable to create executable with macOS Mojave 10.14.4

    I am able to compile the source code into an object file.

    But I failed at creating the executable by running this: (The directory to Panda3D library is correct)

    clang++
    3d-game-shaders-for-beginners.o
    -o 3d-game-shaders-for-beginners
    -L/Developer/Panda3D/lib
    -lp3framework
    -lpanda
    -lpandafx
    -lpandaexpress
    -lp3dtoolconfig
    -lp3dtool
    -lp3pystub
    -lp3direct
    -lpthread

    The full error log is:

    Undefined symbols for architecture x86_64: "AmbientLight::AmbientLight(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: generateLights(NodePath, bool) in 3d-game-shaders-for-beginners.o "InternalName::append(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: PointerTo InternalName::make<16>(char const (&) [16]) in 3d-game-shaders-for-beginners.o PointerTo InternalName::make<14>(char const (&) [14]) in 3d-game-shaders-for-beginners.o PointerTo InternalName::make<8>(char const (&) [8]) in 3d-game-shaders-for-beginners.o PointerTo InternalName::make<6>(char const (&) [6]) in 3d-game-shaders-for-beginners.o PointerTo InternalName::make<15>(char const (&) [15]) in 3d-game-shaders-for-beginners.o PointerTo InternalName::make<12>(char const (&) [12]) in 3d-game-shaders-for-beginners.o PointerTo InternalName::make<11>(char const (&) [11]) in 3d-game-shaders-for-beginners.o ... "InternalName::InternalName(InternalName*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: InternalName::get_root() in 3d-game-shaders-for-beginners.o "TypeRegistry::register_type(TypeHandle&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: PointerToBase::update_type(ReferenceCount*) in 3d-game-shaders-for-beginners.o NodeReferenceCount::init_type() in 3d-game-shaders-for-beginners.o AsyncTaskManager::init_type() in 3d-game-shaders-for-beginners.o TypedReferenceCount::init_type() in 3d-game-shaders-for-beginners.o WindowFramework::init_type() in 3d-game-shaders-for-beginners.o TypedWritableReferenceCount::init_type() in 3d-game-shaders-for-beginners.o TypedWritable::init_type() in 3d-game-shaders-for-beginners.o ... "TypeRegistry::record_alternate_name(TypeHandle, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: TypedWritableReferenceCount::init_type() in 3d-game-shaders-for-beginners.o TypedWritable::init_type() in 3d-game-shaders-for-beginners.o "TypeRegistry::register_dynamic_type(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: CopyOnWriteObj1<ov_multiset<PandaNode::DownConnection, std::__1::lessPandaNode::DownConnection, pvectorPandaNode::DownConnection >, TypeHandle>::init_type() in 3d-game-shaders-for-beginners.o CopyOnWriteObj1<ov_set<PandaNode::UpConnection, std::__1::lessPandaNode::UpConnection, pvectorPandaNode::UpConnection >, TypeHandle>::init_type() in 3d-game-shaders-for-beginners.o "ButtonRegistry::find_button(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: isButtonDown(WindowFramework*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >) in 3d-game-shaders-for-beginners.o "GraphicsEngine::make_output(GraphicsPipe*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, int, FrameBufferProperties const&, WindowProperties const&, int, GraphicsStateGuardian*, GraphicsOutput*)", referenced from: generateHighPrecisionFramebufferTextureForScene(PointerTo, PointerTo, PointerTo, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >) in 3d-game-shaders-for-beginners.o "GraphicsOutput::make_texture_buffer(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, int, int, Texture*, bool, FrameBufferProperties*)", referenced from: generateFramebufferTextureForImage(PointerTo, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, LVecBase4f) in 3d-game-shaders-for-beginners.o generateFramebufferTextureForScene(PointerTo, PointerTo, PointerTo, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, LVecBase4f) in 3d-game-shaders-for-beginners.o "DirectionalLight::DirectionalLight(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: generateLights(NodePath, bool) in 3d-game-shaders-for-beginners.o "GenericAsyncTask::GenericAsyncTask(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, AsyncTask::DoneStatus ()(GenericAsyncTask, void*), void*)", referenced from: _main in 3d-game-shaders-for-beginners.o "Fog::Fog(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: _main in 3d-game-shaders-for-beginners.o "Camera::Camera(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, Lens*)", referenced from: generateFramebufferTextureForImage(PointerTo, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, LVecBase4f) in 3d-game-shaders-for-beginners.o "PandaNode::PandaNode(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: _main in 3d-game-shaders-for-beginners.o NodePath::NodePath(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, Thread*) in 3d-game-shaders-for-beginners.o "Spotlight::Spotlight(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)", referenced from: generateWindowLight(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, NodePath, LVecBase3f, bool) in 3d-game-shaders-for-beginners.o "NodePath::find(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) const", referenced from: _main in 3d-game-shaders-for-beginners.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

    I am on macOS Mojave 10.14.4

  • Shader version 150 not supported on MacOS

    Shader version 150 not supported on MacOS

    I can compile and run the demo program on MacOS 10.15.5 Catalina, but it doesn't render anything to the window, and it produces the following log message:

    Known pipe types:
      CocoaGraphicsPipe
    (all display modules loaded.)
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert:
    ERROR: shaders/vertex/base.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/geometry-buffer-0.frag:
    ERROR: shaders/fragment/geometry-buffer-0.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert:
    ERROR: shaders/vertex/base.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/geometry-buffer-1.frag:
    ERROR: shaders/fragment/geometry-buffer-1.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert:
    ERROR: shaders/vertex/base.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/geometry-buffer-2.frag:
    ERROR: shaders/fragment/geometry-buffer-2.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/ssao.frag:
    ERROR: shaders/fragment/ssao.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/screen-space-refraction.frag:
    ERROR: shaders/fragment/screen-space-refraction.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/screen-space-reflection.frag:
    ERROR: shaders/fragment/screen-space-reflection.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/foam.frag:
    ERROR: shaders/fragment/foam.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/fog.frag:
    ERROR: shaders/fragment/fog.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/kuwahara-filter.frag:
    ERROR: shaders/fragment/kuwahara-filter.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert:
    ERROR: shaders/vertex/base.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/base.frag:
    ERROR: shaders/fragment/base.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/refraction.frag:
    ERROR: shaders/fragment/refraction.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/reflection-color.frag:
    ERROR: shaders/fragment/reflection-color.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/box-blur.frag:
    ERROR: shaders/fragment/box-blur.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/reflection.frag:
    ERROR: shaders/fragment/reflection.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/base-combine.frag:
    ERROR: shaders/fragment/base-combine.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/sharpen.frag:
    ERROR: shaders/fragment/sharpen.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/posterize.frag:
    ERROR: shaders/fragment/posterize.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/bloom.frag:
    ERROR: shaders/fragment/bloom.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/scene-combine.frag:
    ERROR: shaders/fragment/scene-combine.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/dilation.frag:
    ERROR: shaders/fragment/dilation.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/depth-of-field.frag:
    ERROR: shaders/fragment/depth-of-field.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/outline.frag:
    ERROR: shaders/fragment/outline.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/pixelize.frag:
    ERROR: shaders/fragment/pixelize.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/motion-blur.frag:
    ERROR: shaders/fragment/motion-blur.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/film-grain.frag:
    ERROR: shaders/fragment/film-grain.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/lookup-table.frag:
    ERROR: shaders/fragment/lookup-table.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert:
    ERROR: shaders/vertex/basic.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/gamma-correction.frag:
    ERROR: shaders/fragment/gamma-correction.frag:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/discard.vert:
    ERROR: shaders/vertex/discard.vert:6: '' :  version '150' is not supported
    :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/discard.frag:
    ERROR: shaders/fragment/discard.frag:6: '' :  version '150' is not supported
    

    I tried to change the shaders to version 330, but it is not supported either.

    Is there any way to get around this?

  • Convert bam model to better supported formats

    Convert bam model to better supported formats

    As mentioned in https://github.com/lettier/3d-game-shaders-for-beginners/issues/15 , using BAM files in any other engine than Panda3D is pretty much impossible. In order to make it more accessible to people who wish to follow this tutorial using their own custom engine (my use case), I converted the models to more widely supported formats (blender + gltf).

  • shader compile error on macOS mojave 10.14.5

    shader compile error on macOS mojave 10.14.5

    Known pipe types: CocoaGraphicsPipe (all display modules loaded.) :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert: ERROR: shaders/vertex/base.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/position.frag: ERROR: shaders/fragment/position.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert: ERROR: shaders/vertex/base.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/normal.frag: ERROR: shaders/fragment/normal.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert: ERROR: shaders/vertex/base.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/material-diffuse.frag: ERROR: shaders/fragment/material-diffuse.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert: ERROR: shaders/vertex/base.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/material-specular.frag: ERROR: shaders/fragment/material-specular.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert: ERROR: shaders/vertex/base.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/foam-mask.frag: ERROR: shaders/fragment/foam-mask.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/ssao.frag: ERROR: shaders/fragment/ssao.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/blur.frag: ERROR: shaders/fragment/blur.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/ssr.frag: ERROR: shaders/fragment/ssr.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/base.vert: ERROR: shaders/vertex/base.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/base.frag: ERROR: shaders/fragment/base.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/fog.frag: ERROR: shaders/fragment/fog.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/refraction.frag: ERROR: shaders/fragment/refraction.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/outline.frag: ERROR: shaders/fragment/outline.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/foam.frag: ERROR: shaders/fragment/foam.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/reflection.frag: ERROR: shaders/fragment/reflection.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/base-combine.frag: ERROR: shaders/fragment/base-combine.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/sharpen.frag: ERROR: shaders/fragment/sharpen.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/posterize.frag: ERROR: shaders/fragment/posterize.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/bloom.frag: ERROR: shaders/fragment/bloom.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/scene-combine.frag: ERROR: shaders/fragment/scene-combine.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/depth-of-field.frag: ERROR: shaders/fragment/depth-of-field.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/pixelize.frag: ERROR: shaders/fragment/pixelize.frag:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader shaders/vertex/basic.vert: ERROR: shaders/vertex/basic.vert:6: '' : version '140' is not supported :display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/fragment/film-grain.frag: ERROR: shaders/fragment/film-grain.frag:6: '' : version '140' is not supported

  • Get Linkers for panda

    Get Linkers for panda

    When I run """ g++ 3d-game-shaders-for-beginners.o -o 3d-game-shaders-for-beginners -L/usr/lib/panda3d -lp3framework -lpanda
    -lpandafx -lpandaexpress -lpandaphysics -lp3dtoolconfig -lp3dtool -lp3pystub -lp3direct -lpthread """

    I get

    /usr/bin/ld: cannot find -lp3framework /usr/bin/ld: cannot find -lpanda /usr/bin/ld: cannot find -lpandafx /usr/bin/ld: cannot find -lpandaexpress /usr/bin/ld: cannot find -lpandaphysics /usr/bin/ld: cannot find -lp3dtoolconfig /usr/bin/ld: cannot find -lp3dtool /usr/bin/ld: cannot find -lp3pystub /usr/bin/ld: cannot find -lp3direct collect2: error: ld returned 1 exit status

    I have downloaded panda3d

  • can't find p3pystub

    can't find p3pystub

    Trying to build demo, get this error from linker:

    /usr/bin/ld: cannot find -lp3pystub
    collect2: error: ld returned 1 exit status
    

    I have version 1.11.0 of panda3d installed on arch with samples working. I can't find p3pystub library anywhere.

    thanks for any help.

  • Added build-for-mac.sh script in demo/ for macOS Catalina

    Added build-for-mac.sh script in demo/ for macOS Catalina

    As Panda3D couldn't be installed from the installer in macOS Catalina these days, I wrote this build script to clone the repository down, build Panda3D, then build this project. It might be buggy and it requires the current workdir to be in demo/.

    Prerequisite

    You need to have the following stuffs installed:

    • Xcode Command Line Tools (xcode-select --install)
    • Python3
    • sed
    • clang++ (and its alias g++ - GNU/G++ might not work.)

    How can I use this?

    Simply cd into demo and run, ignoring all errors all the way (if there are any):

    cd demo
    sh build-for-macos.sh
    

    The executable will be named main. So to execute:

    ./main
    

    This script is quite ugly and I am just making it work right now. If there are any bugs or improvements to be made, please tell me! Thanks!

    Here's a screenshot of it actually running. There are a bunch of warnings, but it works!:

    Capture d’écran 2019-12-23 à 11 44 38 PM
  • Running Demo in Windows

    Running Demo in Windows

    Dear David Lettier, I am trying to run your demo on the windows platform but it seems to be not good as that shown in your readme.md. (I have added my running result as follows) Can you please explain more specific methods to run your code in windows platform? I only delete the <unistd.h> to run the code successfully Thank you very much for your precious time and efforts Best,

    image

  • compile error on win10

    compile error on win10

    @lettier Hi, bro. I have just followed the Panda3D tutorial to install and setup the development environment and everything was okay when I ran the "Panda Hello World" program. However, when I replaced the code with the main.cxx, I met something strange as following which means it can not recognise the defined symbols. I have no idea how to deal with this, please help me. And the program was ran on win10, vs2015. image

  • Crash on Manjaro KDE

    Crash on Manjaro KDE

    device:

    Manjaro(5.10.36-2-MANJARO), 
    KDE, 
    X11, 
    all software and dependencies are the newest in 5.10.36-2-MANJARO version 
    

    when run this to build executable file

    g++ \
      3d-game-shaders-for-beginners.o \
      -o 3d-game-shaders-for-beginners \
      -L/usr/lib/panda3d \
      -lp3framework \
      -lpanda \
      -lpandafx \
      -lpandaexpress \
      -lpandaphysics \
      -lp3dtoolconfig \
      -lp3dtool \
      -lp3pystub \
      -lp3direct \
      -lpthread
    

    the build will error, and it tell me that p3pystub cannot be found. It seems that the panda3d don't have p3pystub any more in later version. So I remove -lp3pystub in the command, it will generate executable file successfully. But when I run it, my KDE desktop will crash, and show blurred screen.

  • update readme to mention python 2.7

    update readme to mention python 2.7

    My setup with conda env, panda3d were for python 3 until I read further down and the build instructions assume python 2.7. I think it is worth mentioning python 2.7 up front as a dependency.

  • How to configure builds for Windows users

    How to configure builds for Windows users

    There are probably still people who want to run this project on Windows. So I tell you how I tried

    It works in VS2022 (msvc v143), so it works in most cases

    1. Clone this project and install Panda3D(1.10.9)
      git clone https://github.com/lettier/3d-game-shaders-for-beginners.git
      
    2. Open the visual studio
    3. Create new c++ empty project
      • project name: whatever you want
      • location: {cloned directory}\demonstration
      • check "place solution and project in the same directory"
    4. Move demonstration\src\main.cxx to the project directoy
    5. Add to the project by 'Add Existing File'
    6. Open main.cxx and comment out #include <unistd.h>
    7. Change "Debug" to "Release" below the menu bar
    8. Open up the project configuration pages
    9. Change output directory to $(SolutionDir)..\ in the General tab
    10. Add PATH=C:\Panda3D-1.10.9-x64\bin;%PATH% in the Debugging tab -> Environment
    11. Add C:\Panda3D-1.10.9-x64\include in the VC++ directory tab -> External include directoies
    12. Add C:\Panda3D-1.10.9-x64\lib in the VC++ directories tab -> Library directories
    13. Add the path below in the Linker tab -> input -> Additional Dependencies
      C:\Panda3D-1.10.9-x64\lib\libp3framework.lib
      C:\Panda3D-1.10.9-x64\lib\libpanda.lib
      C:\Panda3D-1.10.9-x64\lib\libpandaexpress.lib
      C:\Panda3D-1.10.9-x64\lib\libp3dtool.lib
      C:\Panda3D-1.10.9-x64\lib\libpandaphysics.lib
      C:\Panda3D-1.10.9-x64\lib\libp3dtoolconfig.lib
      C:\Panda3D-1.10.9-x64\lib\libp3openal_audio.lib
      
    14. Build the project
    15. Execute the binary file (.exe) created in {cloned directory}\demonstration
  • How to run on Windows visual studio 2019 since panda3d isnt supported on mingw g++

    How to run on Windows visual studio 2019 since panda3d isnt supported on mingw g++

    Set up the project by importing the files to src folder in console application and included the header and lib paths. Even fixed the unistd.h issue but still it throws about 130 errors about unresolved external symbols

    Screenshot 2021-11-26 134826 .

  • osx compile error

    osx compile error

    os: mac big sur i have installed the panda3D from the official pkg file. However there is an error when i run the ./3d-game-shaders-for-beginners: dyld: Library not loaded: @loader_path/../lib/libp3framework.1.10.dylib

  • Demo crash on M1 macbook

    Demo crash on M1 macbook

    I refer to the article to compile demo.

    clang++ \
      -c ./src/main.cxx \
      -o ./3d-game-shaders-for-beginners.o \
      -std=gnu++11 \
      -g \
      -O2 \
      -I/opt/homebrew/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/include \
      -I/Users/xxx/repositories/panda3d/built/include
    
    clang++ \
      ./3d-game-shaders-for-beginners.o \
      -o ./3d-game-shaders-for-beginners \
      -L/Users/xxx/repositories/panda3d/built/lib \
      -lp3framework \
      -lpanda \
      -lpandafx \
      -lpandaexpress \
      -lpandaphysics \
      -lp3dtoolconfig \
      -lp3dtool \
      -lp3direct \
      -lpthread
    

    Here I use the Panda3D SDK compiled from the source code.

    It looks good when I run it, and I can switch between different framebuffer textures.

    But once I use the mouse to move the view, the program crashes in a few frames.

    demonstration % ./3d-game-shaders-for-beginners
    Warning: unable to auto-locate config files in directory named by "<auto>etc".
    :audio: NullAudioManager
    :util: Reading /Users/xxx/repositories/3d-game-shaders-for-beginners/demonstration/panda3d-prc-file.prc
    :util(error): Unable to make directory /panda3d, caching disabled.
    Known pipe types:
      CocoaGraphicsPipe
    (all display modules loaded.)
    :display:gsg:glgsg(warning): Shader shaders/fragment/geometry-buffer-0.frag produced the following warnings:
    WARNING: Output of vertex shader 'vertexInShadowSpaces' not read by fragment shader
    WARNING: Output of vertex shader 'vertexColor' not read by fragment shader
    WARNING: Output of vertex shader 'diffuseCoord' not read by fragment shader
    WARNING: Could not find fragment shader output 'p3d_FragData' to match FragDataBinding request.
    
    :display:gsg:glgsg(warning): Shader shaders/fragment/geometry-buffer-1.frag produced the following warnings:
    WARNING: Output of vertex shader 'vertexInShadowSpaces' not read by fragment shader
    WARNING: Output of vertex shader 'vertexColor' not read by fragment shader
    WARNING: Could not find fragment shader output 'p3d_FragData' to match FragDataBinding request.
    
    :display:gsg:glgsg(warning): Shader shaders/fragment/geometry-buffer-2.frag produced the following warnings:
    WARNING: Output of vertex shader 'normalCoord' not read by fragment shader
    WARNING: Output of vertex shader 'vertexNormal' not read by fragment shader
    WARNING: Output of vertex shader 'binormal' not read by fragment shader
    WARNING: Output of vertex shader 'tangent' not read by fragment shader
    WARNING: Output of vertex shader 'vertexInShadowSpaces' not read by fragment shader
    WARNING: Could not find fragment shader output 'p3d_FragData' to match FragDataBinding request.
    
    2021-05-18 21:04:01.081 3d-game-shaders-for-beginners[14248:12635934] GLDRendererMetal command buffer completion error: Error Domain=MTLCommandBufferErrorDomain Code=2 "Caused GPU Hang Error (IOAF code 3)" UserInfo={NSLocalizedDescription=Caused GPU Hang Error (IOAF code 3)}
    2021-05-18 21:04:04.464 3d-game-shaders-for-beginners[14248:12635929] GLDRendererMetal command buffer completion error: Error Domain=MTLCommandBufferErrorDomain Code=2 "Caused GPU Hang Error (IOAF code 3)" UserInfo={NSLocalizedDescription=Caused GPU Hang Error (IOAF code 3)}
    2021-05-18 21:04:04.467 3d-game-shaders-for-beginners[14248:12635929] GLDRendererMetal command buffer completion error: Error Domain=MTLCommandBufferErrorDomain Code=4 "Ignored (for causing prior/excessive GPU errors) (IOAF code 4)" UserInfo={NSLocalizedDescription=Ignored (for causing prior/excessive GPU errors) (IOAF code 4)}
    zsh: abort      ./3d-game-shaders-for-beginners
    
  • Can't open the final package

    Can't open the final package

    I run into this black screen with no way of seeing the output, is there anyway I can see logs/debug this?

    ./3d-game-shaders-for-beginners Known pipe types: glxGraphicsPipe (all display modules loaded.)'

    Screenshot from 2021-04-27 14-04-46

Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World.
Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World.

OpenXRay OpenXRay is an improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World. S

Jun 18, 2022
Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve external game process read/write with minimum footprint.
Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve external game process read/write with minimum footprint.

Launcher Abuser Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve ex

May 8, 2022
Game Boy, Game Boy Color, and Game Boy Advanced Emulator
Game Boy, Game Boy Color, and Game Boy Advanced Emulator

SkyEmu SkyEmu is low level cycle accurate GameBoy, GameBoy Color and Game Boy Advance emulator that I have been developing in my spare time. Its prima

Jun 19, 2022
A cycle-accurate Game Boy and Game Boy Color Emulator, with rewind feature.
A cycle-accurate Game Boy and Game Boy Color Emulator, with rewind feature.

Azayaka is a free and open-source Game Boy and Game Boy Color emulator written in C++. Features Cycle-Accurate emulation. Console based Debugg

Dec 16, 2021
The Game Boy ROM of the Game Boy bitcoin miner!

game-boy-bitcoin-miner The Game Boy ROM of the Game Boy bitcoin miner! To build this, currently this patch needs to be applied to GBDK: https://gist.g

May 29, 2022
CLUSEK-RT is a complex game engine written in C++ and the successor of the CLUSEK game engine
CLUSEK-RT is a complex game engine written in C++ and the successor of the CLUSEK game engine

CLUSEK-RT is a complex game engine written in C++ and the successor of the CLUSEK game engine. This engine has been designed with a cross-platform design in mind. Thanks to Vulkan API it delivers a next-gen experience with ray tracing to both Linux and Windows platforms

Jun 12, 2022
Ground Engine is an easy to use Game Engine for 3D Game Development written in C++
Ground Engine is an easy to use Game Engine for 3D Game Development written in C++

Ground Engine is an easy to use Game Engine Framework for 3D Game Development written in C++. It's currently under development and its creation will b

Jun 10, 2022
Minetest is an open source voxel game engine with easy modding and game creation

Minetest is an open source voxel game engine with easy modding and game creation

Jun 22, 2022
A game made for the Game (Engineless) Jam using Raylib
A game made for the Game (Engineless) Jam using Raylib

Fastest Pizza Delivery A fun little 3D game made for the Game (Engineless) Jam. It is still is development but the basic gameplay is something l

Apr 3, 2022
SameBoy DX is a Qt-based interface of SameBoy, a free, highly accurate Game Boy and Game Boy Color emulator.

SameBoy DX SameBoy DX is a Qt-based interface of SameBoy, a free, highly accurate Game Boy and Game Boy Color emulator. Build requirements: CMake Pyth

Jun 4, 2022
To recreate the board game Scotland yard and enable a single player to play the game by letting one of the roles being played by the computer based on written algorithm
To recreate the board game Scotland yard and  enable a single player to play the game by letting one of the roles being played by the computer based on written algorithm

Scotland Yard GAME OF SCOTLAND YARD This is a custom version of the classic board game, Scotland Yard .The game uses the London map used in the origin

Nov 11, 2021
Ncurses based omok game, execute omok game in your terminal
Ncurses based omok game, execute omok game in your terminal

omok_game execute omok game in your terminal Omok game played by two people. 한국어 버전(korean version)

Dec 6, 2021
Slender Man Returns is a game inspired by the original indie game Slender

Slender Man Returns is a game inspired by the original indie game Slender: The Eight Pages, but redesigned to run on the popular Unity game engine. Ported to PSVita. Original project by Rosario Terranova.

Feb 21, 2022
A Game Boy game that rewards you for playing it on several console models!
A Game Boy game that rewards you for playing it on several console models!

GB Corp. A Game Boy game for the Game Boy Competition 2021 by Dr. Ludos (2021) This is the source code, you can get a precompiled rom from here: https

Oct 21, 2021
GB Studio is a quick and easy to use retro adventure game creator for Game Boy available for Mac, Linux and Windows
GB Studio is a quick and easy to use retro adventure game creator for Game Boy available for Mac, Linux and Windows

GB Studio is a quick and easy to use retro adventure game creator for Game Boy available for Mac, Linux and Windows

Jun 21, 2022
A high speed C++17 Vulkan game engine
A high speed C++17 Vulkan game engine

Acid is an open-source, cross-platform game engine written in modern C++17 and structured to be fast, simple, and extremely modular. Vulkan is the sol

Jun 22, 2022
Pure C Game Engine

Corange game engine Version 0.8.0 Written in Pure C, SDL and OpenGL. Running Corange is a library, but to take a quick look at some of the things it d

Jun 18, 2022
The flexible game engine.
The flexible game engine.

The flexible game engine. Crown is a general purpose and data-driven game engine, written in orthodox C++ with a minimalistic and data-oriented design

Jun 17, 2022
Open-source, cross-platform, C++ game engine for creating 2D/3D games.

GamePlay v3.0.0 GamePlay is an open-source, cross-platform, C++ game framework/engine for creating 2D/3D mobile and desktop games. Website Wiki API De

Jun 17, 2022