Giter Site home page Giter Site logo

lettier / 3d-game-shaders-for-beginners Goto Github PK

View Code? Open in Web Editor NEW
17.1K 17.1K 1.3K 34 MB

๐ŸŽฎ A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.

Home Page: https://lettier.github.io/3d-game-shaders-for-beginners/index.html

Shell 0.33% PLSQL 0.66% GLSL 35.65% C++ 63.36%
3d 3d-graphics game-development gamedev glsl glsl-shader glsl-shaders godot graphics graphics-programming hlsl indiedev opengl panda3d shader shaders unity unity3d vulkan webgl

3d-game-shaders-for-beginners's People

Contributors

lettier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

3d-game-shaders-for-beginners's Issues

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

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

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

Windows๏ผŒ can't load shaders๏ผ

image

image

image

Hi๏ผŒ@lettier ๏ผŒ after builing the project ๏ผŒi ran the demo, i could hear the water and wheel sounds, but i could't load the shaders as above images show , don't know why... i just try both absolute and relative Paths ๏ผŒstill couldโ€™t load...

Do you or anybody ever meet similar problems ,or successfuly ran the demo on Windows ๏ผŸ I used the latest Panda SDK building the Demo.

Really good demos๏ผŒbut there are indeed some issues when building it on Windows ใ€‚ใ€‚ใ€‚

Be more beginners friendly !

Hi, this is really a nice work, this can become a greater tutorial but I think it needs some improvements because, I'm a beginner, and not everything is straightforward to understand. I have not yet completely read the whole article, I just stopped to first sections. The goal of this article is to be understandable for beginners but it uses a lot of terms not really introduced and therefore difficult for beginners to understand. Maybe because I have never used Panda3D and I'm extrapolating things with an OpenGL program.

Materials:

The first texture is the normal map and the second is the diffuse map.

You should introduce what is a normal map and a diffuse map. A least something that normal maps are textures holding mathematic vectors coded/shown as RGB colors. (R,G,B) = (X,Y,Z). I guess vectors are normalized and coding as a single byte.

If an object uses its vertex normals, a "flat blue" normal map is used.

Certainly! But because you did not say that vector == color it is difficult to get the point. By default with what color vectors are initialized to ? (0,0,1) ? I guess that if the Z axis is not used, the green component is never used => only red + blue are used so "flat blue"?

Then, why displaying a such big purpole figure ? Could be interessting to add a figure giving more informations like https://en.wikipedia.org/wiki/Normal_mapping#/media/File:Normal_map_example_with_scene_and_result.png by explaining goal of colors (ie. red -> shadow, green -> light).

By having the same maps in the same positions for all models, the shaders can be generalized and applied to the root node in the scene graph.

You should explain in few words what is a scene graph. As I guess it is, a graph structure where each node holds at least a change-basis matrix (from its parent node) and an optional 3d model. In your case, are nodes also hold shaders and are shaders of the parent nodes also applied to child nodes (like matrices)?

Concerning your computation:

round((0 * 0.5 + 0.5) * 255)

should not be simply round(0 * 255 + 0.5)? You should probably add a comment to say: for converting float to the clostest integer we use round(x + 0.5) coming from the fact float are converted to the lowest int and we want values in [0.0 ... 0.5[ rounded to 0.0 while values [0.5 .. 1.0[ rounded to 1.0.

round(255 / 255 * 2 - 1)

What is that? You should explain this formula. I had to go on Wiki to see that some axis are within -1 and 1 while other are within 0 and 1.

section GLSL

Instead of using the fixed-function pipeline, you'll be using the programmable GPU rendering pipeline.

Is this really a tutorial for beginners? :) I guess they probably never have programmed in Legacy OpenGL. I understand explaining again what is a non-fixed GPU pipeline is boring. Maybe you should only summarize it with fewer blocks diagrams and add links to tutorials explaining longer pipelines.

So a simple figure is enough:

      +-------------------+----------------------+
      |                   |                      |
      |                   V                      V
[Pand3D code] ==> [Vertex shader] ==> [Fragment shader] ==> [Framebuffer]

==> pipeline for shader attributes
--> pipeline for shader uniforms

This will also inroduce framebuffer for the next section.

Note the two keywords uniform and in... The in keyword means this global variable is being given to the shader.

Seems to me they are important elements of the shader, I would not define them inside a simple note but give to them a full paragraph of descriptions. And why defining out not with them? I would simplly introduce the input/output of shaders: the input of a fragment shader is the output of a vertex shader.

Render To Texture

Instead of rendering/drawing/painting directly to the screen

Technically, the screen is a framebuffer and it is the by-default bound framebuffer.

The textures bound to the framebuffer hold the vector(s) returned by the fragment shader. Typically these vectors are color vectors (r, g, b, a) but they could also be position or normal vectors (x, y, z, w).

Would be better placed when introducing normal maps in the 1st section.

each fragment shader in the example code has only one output. 

What is this output ?

texturing

Texturing involves mapping some color or some other kind of vector to a fragment using UV coordinates. 

In the figure just after you should display U and V axis in the picture and say that UV are the XY axis inside the texture frame.

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

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

Using it in Three.js

Hi everyone. This article series looks promising. Have someone implemented one of these in Three.js? I'm interested in the SSAO especially. In this case I would ask for details before doing it all myself.
Thanks.

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

focal length -> focal distance

Great tutorial! It clears up a lot of my questions about various effects.

Minor complaint: Focal length is size of the lens. Focal distance is the distance between the camera and the focal point.

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?

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.

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

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

:display:gsg:glgsg(warning): Project runs but shaders do not load correctly

After building the project and copying the binary to /Developer/Panda3D/bin as suggested in this post - https://discourse.panda3d.org/t/panda3d-c-not-working-on-os-x-10-11/15456/2, I get the following errors:

: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: Could not find vertex shader attribute 'vertex' to match BindAttributeLocation request.
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: Could not find vertex shader attribute 'vertex' to match BindAttributeLocation request.
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.

These are different warnings from the shader compile errors reported on macOS mojave 10.14.5 and I was wondering how to get round this?

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.

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

About the materials format.

Hi, the repo is awesome ! ๐ŸŽ‰
As I'm an iOS developer , and i would like to implement a Metal version with your tutorial.
But i have some problem with the materials , it's the Panda3D format like '.egg' , Could u provide the model file with the universal format (e.g. OBJ, FBX, 3DS, PLY, STL, etc.).

Demo run crash, Intel iris, Ubuntu 20.04

Hi! I have tried to run demo on my laptop msi prestige 14 using linux build instruction. I've installed panda3d with instruction from the biulding demo guide, compiled the whole project and tried to run - then my laptop runs out of resources and demo crashes with black screen after ~30 seconds.

I tried gdb this, got this output:

Starting program: /home/kikos/dev/3d-game-shaders-for-beginners/demonstration/3d-game-shaders-for-beginners 

Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)

Thread 11 "3d-game-:gdrv0" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffd5c4d700 (LWP 60388)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6df1859 in __GI_abort () at abort.c:79
#2  0x00007fffd5df9498 in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#3  0x00007fffd6e8b3a5 in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007fffd643f918 in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007fffd643f37a in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#6  0x00007fffd5e136ac in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#7  0x00007fffd5e131eb in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#8  0x00007ffff7315609 in start_thread (arg=<optimized out>)
    at pthread_create.c:477
#9  0x00007ffff6eee133 in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) 

So, as I understand, in has to be something with graphics drivers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.