Opengl: what is the basic "package" of shaders to create elements of a 3D scene

Asked

Viewed 322 times

1

At the moment, I am beginning to work with the Shaders concept of the most current versions of Opengl. My basic reference are the tutorials of the open.Gl site.

After having seen all the texts, and tested the available sample source code, my doubt is what basic set of shaders I should use to render each element of a scene (terrain, sky, constructions, vehicles, characters, etc)?

Note that for each element mentioned above there is one or more resource files added to the projects (with different formats); and for each file format, consider that the project has a class with methods that return the vertices and their attributes to each element.

  • There is no standard Shader for terrain, sky, etc... what shaders do is always a combination of texture and lighting. These types of algorithms are absurdly complex and often require several steps even for performance issues. If you want to look at examples of shaders: https://www.shadertoy.com/ or also look at the Unreal 4 source code.

  • @Alexandreborela yes, but how to choose which combination provided by a Shader to use for each element? I took a look at the website that you indicated, and saw that for each displayed Shader is available GLSL code. Assuming I choose 2 or 3 of these shaders, and having the vertices of a house for example, can I use a Shader for the roof and another for the walls? or it doesn’t work that way?

  • @Klebermota Yes, Voce can use each Shader for each object, the use of Shader is done from the moment of the call of the function glAttachShader, so just that you activate a Shader and render your object, then activate another Shader and render the other object, and so you will render each object with each appropriate Shader

1 answer

1

If the goal is to try to program an engine for learning purposes recommend Benny’s tutorials:

https://www.youtube.com/watch?v=0xcmTZPoJtM&list=PLEETnX-uPtBXP_B2yupUKlflXBznWIlL5

He even has a series where he teaches the physical engine:

https://www.youtube.com/watch?v=3Oay1YxkP5c&list=PLEETnX-uPtBXm1KEr_2zQ6K_0hoGH6JJ0

As I said, for learning purposes it is rather interesting to see these tutorials but if the goal is later to produce a game, Engines like Unreal 4, Unity 5, etc... are free and charge only a percentage on sales which is an absurdly lower cost than having to program the entire engine.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.