OpenGL 3D Game Tutorial 12: Specular Lighting HD

28.09.2014
LWJGL tutorial series on how to create a 3D Java game with OpenGL! This week we add per-pixel specular lighting to the game, allowing for shiny looking materials! Stanford Dragon Model: https://www.dropbox.com/sh/gscenjij7ny3xz1/AADQ3u6Ve96PP3ajyJP81ETSa?dl=0 Source: Stanford University Computer Graphics Laboratory Vector maths basics: http://www.bbc.co.uk/bitesize/higher/maths/geometry/vectors/revision/1/ Dot product: http://betterexplained.com/articles/vector-calculus-understanding-the-dot-product/ Common Problems: -Watch to the end of the tutorial! Quite a lot of people missed out the bit where I multiplied in the "reflectivity" variable. - Make sure that you are calling bindAttributes() *before* glLinkProgram() in the ShaderProgram constructor. Also, check that you spelled the "in" variable names correctly in the "bindAttributes()" method in the StaticShader class. -If your dragon seems to have lots of white and black patches then it could be one of 2 problems: 1. Your texture dimensions might not be powers of 2 (64x64, 128x128, 256x256 etc.) 2. If they are powers of 2 then try adding the following lines to the end of the loadTexture() method, just before returning the texture ID: GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); Support the series on Patreon: https://www.patreon.com/thinmatrix Facebook Page: https://www.facebook.com/thinmatrix Tumblr: http://thinmatrix.tumblr.com/ Instagram: http://instagram.com/thin_matrix Twitter: https://twitter.com/ThinMatrix Check out my game on IndieDB: http://www.indiedb.com/games/equilinox End of video music- Kai Engel, "Waking Stars": http://freemusicarchive.org/music/Kai_Engel/Evening_Colors/01_-_Waking_Stars

Похожие видео

Показать еще