OpenGL Water Tutorial 2: Frame Buffer Objects

  Рет қаралды 87,535

ThinMatrix

ThinMatrix

Күн бұрын

Tutorial series about programming 3D water using OpenGL!
Rendering to textures this week using FBOs.
Fame Buffer Object code:
www.dropbox.com/sh/h0a66jc0ml...
Rough Schedule (subject to change):
1. Introduction
2. Rendering to textures
3. Clipping planes
4. Du Dv Maps
5. Fresnel Effect
6. Lighting
7. More Lighting
8. Soft Edges
9. Depth Effects
Tumblr: / thinmatrix
Facebook Page: / thinmatrix
Instagram: / thin_matrix
Twitter: / thinmatrix
Check out my game on IndieDB: www.indiedb.com/games/socuwan
Contact me: thinmatrix@gmail.com
End of video music- Kai Engel, "Waking Stars":
freemusicarchive.org/music/Kai...

Пікірлер: 212
@sheikh813
@sheikh813 7 жыл бұрын
11:02 Warning: Do not try this at home! "It will create a horrible paradox and your comuter will explode"...
@krzysztof-ws9og
@krzysztof-ws9og 6 жыл бұрын
But just make sure, you are not rendering it onto anything gets rendered while you are rendering to that texture. You cannot render the texture onto something that then gets rendered to the texture that you are rendering onto something that gets ...
@huyvole9724
@huyvole9724 6 жыл бұрын
Can you show example code?
@fdc4810
@fdc4810 2 ай бұрын
Thank you for the articulated and crystal clear explanation on the concept of framebuffer. It frustrates me that most tutorials never cares to explain what it is and what it does, which takes no more than a few lines of articulation to do.
@Yan-mz3yh
@Yan-mz3yh 9 жыл бұрын
Thank you very much for taking time to make these tutorials !
@Arno18Production
@Arno18Production 6 жыл бұрын
you guy are an amazing man, All these Indie developers you are creating!
@AnD3rZe3N
@AnD3rZe3N 9 жыл бұрын
Ahhh I love this :D Great video as always ThinMatrix! I love the way you tell us how it works using paint :3
@ThinMatrix
@ThinMatrix 9 жыл бұрын
AnD3rZe3N Thanks :)
@tshichan
@tshichan 4 жыл бұрын
I know that I am late but, thanks from the bottom of my heart for explaining "FBOs"!!
@SuperGastrocnemius
@SuperGastrocnemius Ай бұрын
Really great tutorial, thank you! Loving the simple animations
@r8Rusoski
@r8Rusoski 7 жыл бұрын
Hahahaha that little "both with depth buffer" is a crazy one!
@elijahjns81
@elijahjns81 5 жыл бұрын
Such a beast! Way to stick with this channel.
@DlcEnergy
@DlcEnergy 8 жыл бұрын
"Both with depth buffer..." LOL
@black_squall
@black_squall 7 жыл бұрын
Such a seemingly easy thing to say until you try it!
@NeilRoy
@NeilRoy 5 жыл бұрын
LMAO, love the ending. :) Nice video as always.
@pantherproductions2502
@pantherproductions2502 9 жыл бұрын
Thanks for the tutorials! This channel continues to be a great resource for Java developers!
@knoxzavier7554
@knoxzavier7554 2 жыл бұрын
sorry to be off topic but does anyone know of a way to log back into an instagram account?? I stupidly lost the account password. I love any tricks you can give me!
@landryzaid6913
@landryzaid6913 2 жыл бұрын
@Knox Zavier instablaster :)
@knoxzavier7554
@knoxzavier7554 2 жыл бұрын
@Landry Zaid Thanks for your reply. I found the site through google and Im trying it out atm. Takes a while so I will reply here later with my results.
@knoxzavier7554
@knoxzavier7554 2 жыл бұрын
@Landry Zaid it did the trick and I finally got access to my account again. I am so happy! Thanks so much, you really help me out :D
@landryzaid6913
@landryzaid6913 2 жыл бұрын
@Knox Zavier glad I could help :D
@oreonengine9444
@oreonengine9444 8 жыл бұрын
after render into own framebuffer it's important to use glfinish(), otherwise u could get issues with compute shaders and unexpected results in the attached textures
@HugoIetsGaming
@HugoIetsGaming 8 жыл бұрын
Nice tutorial!
@dsakbb8071
@dsakbb8071 9 жыл бұрын
First of all, great tutorials! I was wondering what's your primary source of information about OpenGL is? (Is it a book, website, or something else?)
@yangyangcui9150
@yangyangcui9150 4 жыл бұрын
Great picture explanation.
@angelofadeath
@angelofadeath 7 жыл бұрын
Great tutorial. Many thanx :)
@BastiaanOlij
@BastiaanOlij 7 жыл бұрын
Just a suggestion, I don't know if this would work when you are rendering your main scene to an MSAA FBO however you could add an extra color output and do a simple Z check while rendering so you only need to render the scene twice, not three times and save a bit of performance. The other downside is having to use your main depth buffer however as the water is the last thing you render you could either turn off writing to the depth buffer or quickly blit the depth buffer which is likely faster then rendering the whole scene. (I turned off writing to the depth buffer as I don't use it for any post processing and I currently don't use an MSAA output yet)
@mitchyouker1439
@mitchyouker1439 9 жыл бұрын
Awesome tutorial this will help me so much! I'm still trying to ray pick a entity using a a rest for collision between a ray and a AABB. The problem I face is how to get the direction of the ray. I assume the origin of the ray is the calculateMouseRay(); method you provided correct?
@Joern290
@Joern290 9 жыл бұрын
Great tutorial!!
@black_squall
@black_squall 7 жыл бұрын
ThinMatrix, if I were to want to implement a GUI over my 3D world, would it be a smart idea to render all UI elements to a frame buffer and then overlay that on the scene?
@AgentM124
@AgentM124 7 жыл бұрын
if you render something in the scene that gets rendered in the scene, don't you get an inception just like some video editing software has?
@ExemptAK
@ExemptAK 8 жыл бұрын
Nice ending to this video. :)
@adamtaborowski
@adamtaborowski 3 жыл бұрын
Great video. Thanks !
@TheJohnBrower
@TheJohnBrower 7 жыл бұрын
For any reason the reflection framebuffer messes up with the depth test, i can only see the skybox and if i comment it out there are more depth problems with the other entities. For refraction it works perfectly... Any ideas? :)
@st1nger13
@st1nger13 9 жыл бұрын
Thank you, man :)
@Kabodanki
@Kabodanki 7 жыл бұрын
I got some semantic satiation with that video lol
@thebuizelclub
@thebuizelclub 7 жыл бұрын
instead would I use glTexSubImage2d for editing a terrain texture because glTexImage2d creates the hole image over which is not that fast and not what I'm looking to do
@legoman7041
@legoman7041 6 жыл бұрын
Any help? I created the FBOs but they don't seem to update and come up as little square repeats along the length of the quad I have.
@AdelaarGD
@AdelaarGD 9 жыл бұрын
I really like that Island thing. Curious how you did it? Is it just a terrain object with an entity under it? If so do you have the entity model anywhere? And the terrain height map as well?
@ThinMatrix
@ThinMatrix 9 жыл бұрын
Mastre Ceef Yep, just a terrain with an entity underneath. Here's the res: www.dropbox.com/sh/ga7gv1of5hu5ffh/AAANAkXss1cCzeHaBokxPOnwa?dl=0 The heightmap is called "heightmap.png" and the rocks are "rocks.obj" with the "rocks.png" texture
@fishingbadboys
@fishingbadboys 7 жыл бұрын
Ok ive done every optimazation reconmendation but all of them wont work. It still laggs the game without me haveing any entitys or objects in the game
@smackerlacker8708
@smackerlacker8708 7 жыл бұрын
I think I lost track after the 14th color buffer render buffer attachment buffer, created by the glgenbuffer renderbuffer method for fbo's.... or something.
@bonbonpony
@bonbonpony 4 жыл бұрын
What might be the uses of a depth buffer attachment when rendering to a texture as the render target? Using the colour data from the texture seems pretty obvious to me, but I don't quite get what the depth data might be useful for.
@jackdavenport5011
@jackdavenport5011 5 ай бұрын
For the water an example could be to make the water look more murky the deeper it is. To be able to do that you need a way of working out how far the terrain is from the water surface, which you can do with the depth texture. Another example might be if you were making a post processing effect which adds fog to the scene, you could achieve that by putting a filter on the screen and using the depth information to tell how foggy each pixel should be.
@therailgun8880
@therailgun8880 7 жыл бұрын
How do you make the guis?
@markod.234
@markod.234 3 жыл бұрын
I did everything like in the tutorial but it doesn't work. When I render to my GUI I get some weird black quads. Can anyone help me with this?
@Andy.o52
@Andy.o52 Жыл бұрын
It always breaks me a little bit when you say "you can copy the code in the description!", when I'm following the tutorial in Python. :')
@Sarthakz99
@Sarthakz99 3 жыл бұрын
I'm updating my FBO fine but its texture that is being rendered on some other object is not updating and showing only the first frame. anyone has any clue?
@DemonicGaming15
@DemonicGaming15 9 жыл бұрын
Like it, nice quick tutorial, can't wait for the next one! What heightmap are you using there?
@ThinMatrix
@ThinMatrix 9 жыл бұрын
DemonicGaming15 Thanks :) Here's the height map: www.dropbox.com/s/2rryxrruoox9aqs/heightmap.png?dl=0
@ryklin1
@ryklin1 8 жыл бұрын
+ThinMatrix It seems to me that the height map you provide isn't exactly the same as the one you use in the tutorial videos. This height map has much less variation in height. It's almost as if the contrast was reduced. I ignored that at first thinking something was perhaps off with my sun's position. After getting the refraction texture working I definitely realized that something looks a lot different. I tried different height maps, including the one you provided in the beginners tutorial, and the height variations are much more reasonable. So, I thought I'd post it here as a warning. As usual, I might be doing something wrong =). I also am using your blend map, dirt texture and rocks in order to match up the scene as closely as possible. The height map is the only thing that looks to be a little bit off.
@kim15742
@kim15742 6 жыл бұрын
FBOs are fucking awesome! They are called `RenderTexture`s in SFML for anyone wondering
@smackerlacker8708
@smackerlacker8708 7 жыл бұрын
So, if you're rendering the scene two extra times for the water texture, shouldn't the framerate be reduced by 2/3rds?
@ThinMatrix
@ThinMatrix 7 жыл бұрын
If you render the entire scene each time at full resolution it would definitely not be good for the framerate, but there are many optimizations that you can make to avoid that. Firstly, the smaller you make the dimensions of the refraction and reflection FBOs, the more efficient it will be (because the fragment shader won't have to run as many times). Of course, that does decrease the quality of the reflection/refraction, so it's a trade off as always. Also, when rendering the refraction texture you only need to render things in the scene that are going to appear underwater, such as the terrain, and rocks, etc. And when rendering the reflection texture you only need to render things that you need to be reflected, so there's probably no need to render small objects like grass and flowers, especially if they're far away from the camera. You can also do more complex things such as using simpler shader programs when rendering the refraction/reflection passes, such as shaders with no specular lighting, no normal mapping (if you have it), no shadows, only per vertex lighting, etc. You could even use simpler versions of the models/textures.
@Mustaffaa9
@Mustaffaa9 7 жыл бұрын
Thank you.
@GieneqAD
@GieneqAD 9 жыл бұрын
Is it possible tu use frameBuffer with JFrame in order to have some simple buttons changing the skycolor, etc.. ?
@ThinMatrix
@ThinMatrix 9 жыл бұрын
GieneqAD You don't really need to use FBOs for that, you can just put a normal LWJGL Display into a JFrame and use it to change the sky colour and stuff like that. That's what I'm using for the editors for my game.
@MarkABorkowski
@MarkABorkowski 9 жыл бұрын
is there anyway to get it to render in the correct orientation, i modified the code, and was able to rotate the gui 180 degrees but that still left the gui horizontally flipped, i tried changing the scaling part of the matrix to -x,y,1f but then the gui doesn't render the framebuffer at all
@ThinMatrix
@ThinMatrix 9 жыл бұрын
Mark Borkowski All you need to do is inverse the y texture coordinate in the shader code, so that it's 1-y. I think we already calculated is as 1-something in the vertex shader code, so just remove the 1-
@MrNicolasrnk
@MrNicolasrnk 6 жыл бұрын
Hello there.... if any one can share some light on my quad problem would be much appreciated :) it appears my gui2 which is the quad rendering the reflection seem to not render the reflection or refraction which ever one I use its just black. Now why would this be? my other gui is work fine. List guis = new ArrayList(); GuiTexture gui1 = new GuiTexture(loader.loadTexture("zarquan"), new Vector2f(0.5f, 0.5f), new Vector2f(0.25f, 0.25f)); GuiTexture gui2 = new GuiTexture(fbos.getReflectionTexture(), new Vector2f(-0.5f, 0.5f), new Vector2f(0.25f, 0.25f)); guis.add(gui1); guis.add(gui2); then while we frolic in the while loop...... while(!Display.isCloseRequested()){ //*******GAME SOUNDS*******\\ AudioMaster.setListenerData(playerShip.getPosition().x,playerShip.getPosition().y, playerShip.getPosition().z); source.setPostition(finalWheel1.getPosition().x, finalWheel1.getPosition().y, finalWheel1.getPosition().z); source2.setPostition(finalship5.getPosition().x, finalship5.getPosition().y, finalship5.getPosition().z); source3.setPostition(finalglobe1.getPosition().x, finalglobe1.getPosition().y, finalglobe1.getPosition().z); source4.setPostition(playerShip.getPosition().x, playerShip.getPosition().y, playerShip.getPosition().z); //*****************THE REST*********************\\ camera.cameraMove(); renderer.render(lights, camera); playerShip.move(terrainlist); renderer.processEntity(playerShip); fbos.bindReflectionFrameBuffer(); renderer.rnederScene(entities, terrainlist, lights, camera); fbos.unbindCurrentFrameBuffer(); renderer.rnederScene(entities, terrainlist, lights, camera); waterRenderer.render(waters, camera); //*******GUI RENDERER********\\ guiRenderer.render(guis); //*************THE END**********************\\ DisplayManager.displayCloser(); DisplayManager.updateDisplay(); } fbos.cleanUp(); source2.delete(); waterShader.cleanUp(); AudioMaster.cleanUp(); guiRenderer.cleanUp(); renderer.cleanUp(); loader.cleanUp(); DisplayManager.closeDisplay(); }
@robbeandredstone7344
@robbeandredstone7344 5 жыл бұрын
My FBO just ignores the terrain, it can see right through it
@kanikabhatia9865
@kanikabhatia9865 3 жыл бұрын
In the description, you wrote "Fame buffer".
@GeneralTuki
@GeneralTuki 9 жыл бұрын
Just curiously playing around with the code and was trying to get the depth texture to appear instead of the colored texture, though just a solid red texture appears. Anyone have any idea why? I believe it has something to do with GL11.glDrawBuffer(GL30.GL_COLOR_ATTACHMENT0); though I replaced it with GL_NONE and still red.
@ThinMatrix
@ThinMatrix 9 жыл бұрын
GeneralTuki It's fine, it should be red. The depth buffer doesn't represent the distances linearly as you might expect, so you have to do some scaling before you see anything useful. You'd have to get really close to an object before you see any slight difference in that red texture. I'll cover it in detail in future tutorials though :)
@winterroberts8402
@winterroberts8402 8 жыл бұрын
Will this series work with LWJGL 2.9?
@ThinMatrix
@ThinMatrix 8 жыл бұрын
+Winter Roberts Yes it will :)
@DzoniGO
@DzoniGO 9 жыл бұрын
When you read "Red Book for opengl", that book is in C++, but you translate it to Java, can you make video how do you do that or something. Becuse C++ OpenGL is very different from OpenGL in Java.
@ThinMatrix
@ThinMatrix 9 жыл бұрын
Blagoje I don't have any clue about C++, but I haven't had any problems with the book. There's hardly any c++ code in there; it's all just explanations of concepts, OpenGL functions, and shader code, and all of that is the same for whatever language you're programming in.
@balrog232
@balrog232 9 жыл бұрын
For those whose are developing for more GL versions (older ), like me. Cs i have one laptop with GT750 which support 4.5 but i have work laptop with HD 3000 wich support only 3.1 too. So: glFrameBufferTexture was include in 3.2 but dont panic cs GL30.glFramebufferTexture2D is included in 3.0. So only if you hardware dont support version greater than 3.1 but 3.0 or 3.1 use GL30.glFramebufferTexture2D instead GL32.glFrameBufferTexture if you want really really stupid test for this: (for me and testing is fine) if(GL11.glGetString(GL11.GL_VERSION).substring(0, 3).equals("3.1")){ use GL30.. } else { GL32.... }
@balrog232
@balrog232 9 жыл бұрын
***** of course how i wrote: like a really really ugly code: if(GL11.glGetString(GL11.GL_VERSION).substring(0, 3).equals("3.1")){ GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT , GL11.GL_TEXTURE_2D, texture, 0); } else { GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, texture, 0); } for GL_COLOR_ATTACHMENT0 change DEPTH_.... to GL_COLOR_ATTACHMENT0
@naviov773
@naviov773 9 жыл бұрын
Hello ***** I have been watching your videos for some time now. I'd just like to ask where did you learn java from?
@ThinMatrix
@ThinMatrix 9 жыл бұрын
navio V I learnt at university where I studied Electronic Engineering & Computer Science
@MohammedPlaysMC
@MohammedPlaysMC 8 жыл бұрын
Can I ask what happens if you dont do the clean up method as my game can open and close if I dont use it?
@ThinMatrix
@ThinMatrix 8 жыл бұрын
+Mohammed Qureshi Not much probably, the memory should be automatically cleaned up when the game closes, but it's just good practice to delete memory when you're finished using it :)
@MohammedPlaysMC
@MohammedPlaysMC 8 жыл бұрын
***** Oh cool and I guess it makes it more reliable :D
@banscheygrey7436
@banscheygrey7436 5 жыл бұрын
Make sure that your buffer has been cleaned glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@P4cX
@P4cX 5 жыл бұрын
Thanks m8
@davidcf7195
@davidcf7195 8 жыл бұрын
+ThinMatrix , I have a problem, when i create the FBO, and i render the scene in the FBO, it renders onto the screen too, why this happens? i didnt even create a gui
@ThinMatrix
@ThinMatrix 8 жыл бұрын
Are you definitely binding that FBO before rendering? If you do create a GUI and display the FBO texture in it can you see the scene rendered to it, or is it empty?
@davidcf7195
@davidcf7195 8 жыл бұрын
+ThinMatrix i bind it, the problem is that the texture appears black :/
@jasperconnery453
@jasperconnery453 7 жыл бұрын
Are you adding the reflection texture to the gui, or the refraction? If you add the refRAction texture, it will come out black.
@davidcf7195
@davidcf7195 7 жыл бұрын
+Jasper Connery dont worry, it already works, now im having trouble when i create the depth fbo, it shows red :/ can you help me?
@jasperconnery453
@jasperconnery453 7 жыл бұрын
I'm running through the tutorials the same as you....but I'll help if I can. Have you changed anything compared to the code ThinMatrix provided/showed?
@blunderchips
@blunderchips 6 жыл бұрын
Is there a reason you don't you GitHub?
@dbejarcaballero
@dbejarcaballero 8 жыл бұрын
Can we use the Depth Test for making shadows?
@ThinMatrix
@ThinMatrix 8 жыл бұрын
+DanielUnleashed Rendering to a depth texture is indeed part of shadow mapping! You would render the scene from the point of view of the light source and render to a depth texture using FBOs. Then when rendering the scene to the screen you can test each fragment with the depth texture to see if an object is blocking it from the light.
@dbejarcaballero
@dbejarcaballero 8 жыл бұрын
+ThinMatrix and for the shadows, do We use any texture or just the same scene but without colours?
@davidcf7195
@davidcf7195 8 жыл бұрын
Ñeñeñeññe
@rodolfito5555
@rodolfito5555 4 жыл бұрын
I love the outtakes.... :-D boudhwiddeppthwuadda
@johnythecarrot
@johnythecarrot 8 жыл бұрын
It says: Exception in thread "main" java.lang.IllegalStateException: Function is not supported. I'v had these problems alot. I also cannot do the reflection thing on terrain objects... How can i fix this? I have a ATI Radeon graphics card
@johnythecarrot
@johnythecarrot 8 жыл бұрын
+Tuur Martens Fixed
@johnythecarrot
@johnythecarrot 8 жыл бұрын
+2xxx2Games I don't remember i'll look it up. I'll post the source code of my Buffer class tomorrow
@johnythecarrot
@johnythecarrot 8 жыл бұрын
+2xxx2Games Good, nice you solved it. Cuz i forgot to check today.
@harleyracer2005
@harleyracer2005 8 жыл бұрын
anyone know how to flip the texture to face the correct orientation
@ThinMatrix
@ThinMatrix 8 жыл бұрын
+kevin Just invert the y texture coordinate (texCoord.y = 1 - texCoord.y) in the GUI shader. It will make all the other GUIs turn upside-down though.
@NterpriseCEO
@NterpriseCEO 9 жыл бұрын
I don't mean to be pushy but an AABB tutorial would be great at some point because trial and error just isn't working for me.
@ThinMatrix
@ThinMatrix 9 жыл бұрын
TheDude Alex Nuzum I'm not going to have time to make any other tutorials apart from these water ones before the Kickstarter I'm afraid, but if the Kickstarter is successful then I'll be able to continue making tutorials and I may cover this in the future :) However, until then here's a nice tutorial: hamaluik.com/posts/simple-aabb-collision-using-the-minkowski-difference/
@NterpriseCEO
@NterpriseCEO 9 жыл бұрын
AH it's ok anyway, I'm think about looking into JBullet because it has everything i need
@hoojikee
@hoojikee 8 жыл бұрын
Boast with depth puffer
@fishingbadboys
@fishingbadboys 7 жыл бұрын
My game is really laggy and i just have my terrain. I have a decent computer with should run everything just fine?? My terrain is 2000 big
@ThinMatrix
@ThinMatrix 7 жыл бұрын
Make sure that you're not loading any models/textures or creating any FBO inside the main while loop, that stuff should all be done once when the game loads. Also, how high poly is your terrain? What vertex count value have you chosen? Basically the more you render the slower it's going to be. If you're rendering many high poly terrains and loads of models 3 times every frame things are going to get slow. Try to limit the amount that you render, so for example during the reflection render pass only render big objects that need to be reflected in the water. During the refraction pass you only need to render stuff that might be seen underwater. And just in general, only render things that are near to the camera, and in front of it. There are also many other possible optimizations you could make, such as rendering object in less detail when they're further away or during the reflection/refraction passes. As a rule of thumb, the less you render and the more simple you render them, the faster your game will run.
@fishingbadboys
@fishingbadboys 7 жыл бұрын
And just in general, only render things that are near to the camera, and in front of it. How would i do that??
@fishingbadboys
@fishingbadboys 7 жыл бұрын
ive set it in the terrain fragment to 100 i think
@fishingbadboys
@fishingbadboys 7 жыл бұрын
Outlinger I'll check buts that's probably not it
@samsnowball
@samsnowball 7 жыл бұрын
i know this was 3 months ago, but I had this problem as well. if you have a 2048x2048 2d terrain grid, then thats 4.2million vertices that your shader is processing every frame, you need to cut down the amount of vertices you send to the shader for processing.
@eliaspr8124
@eliaspr8124 9 жыл бұрын
i pressed F5 and it said "uploaded 53 seconds ago" :) ehm, great tutorial man!
@ThinMatrix
@ThinMatrix 9 жыл бұрын
***** Thanks :)
@eliaspr8124
@eliaspr8124 9 жыл бұрын
***** I did all of the work shown in the tutorial, but bad news: I don't know if I see a black texture in my GUI or even no texture, i think it's a black texture, because other textures worked. I messed a little bit around with the code, but it did not work. I searched in the reference pages of OpenGL and found the glCheckFramebufferState() method. I used it to check the framebuffer state, and it returned 36055 - GL_FRAMEBUFFER_INVALID_NO_ATTACHMENT or something like that.
@ThinMatrix
@ThinMatrix 9 жыл бұрын
***** Send me your code to thinmatrix@gmail.com, I'll take a look at it :)
@cosmic_gate476
@cosmic_gate476 7 жыл бұрын
Was it ever figured out? I have the same issue, trying to debug it right now.
@eliaspr8124
@eliaspr8124 7 жыл бұрын
I think I forgot to clear the buffers every frame (glClear()) but I'm not exactly sure if that was my issue...
@looijmansje
@looijmansje 8 жыл бұрын
I am currently making a screenshot class, to, as the name suggests, make screenshots. I am using FBOs for this. But how would I turn a FBO into a image? (Like a .PNG file, that you can just access from your computer)
@johnythecarrot
@johnythecarrot 8 жыл бұрын
+Koen Looijmans Try this. try { try { Robot robot = new Robot(); String format = "png"; String fileName = "Screenshot" + "[" + screenshotnum + "]" + "." + format; screenshotnum++; Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); BufferedImage screenFullImage = robot.createScreenCapture(screenRect); ImageIO.write(screenFullImage, format, new File(fileName)); System.out.println("Screenshot saved as " + fileName); } catch (AWTException | IOException ex) { System.err.println(ex); } //Desktop.getDesktop().open(new File()); } catch (HeadlessException e2) { e2.printStackTrace(); }
@looijmansje
@looijmansje 8 жыл бұрын
+Tuur Martens thanks! I don't have time to try it now, but I'll certainly try it!
@johnythecarrot
@johnythecarrot 8 жыл бұрын
+Koen Looijmans No problem ;). Used it in my code too.
@johnythecarrot
@johnythecarrot 8 жыл бұрын
+Koen Looijmans Are you, by any chance, Dutch?
@looijmansje
@looijmansje 8 жыл бұрын
+Tuur Martens toevallig wel ja
@balkancode3399
@balkancode3399 9 жыл бұрын
I want to program OpenGL games, and i don't know what language is best for OpenGL C++ or Java. Java is slow, but he have very good networking. C++ is very fast, but he have bad networking. what to chose?
@balkancode3399
@balkancode3399 9 жыл бұрын
I'am know Java better, and I love Java.
@MadClownGames
@MadClownGames 9 жыл бұрын
NikolaDevlog Also Java is not slow, not anymore :)
@balkancode3399
@balkancode3399 9 жыл бұрын
What about minecraft and Android?
@balkancode3399
@balkancode3399 9 жыл бұрын
I can play GTA V, but i can't play Minecraft with Shader mod.
@MadClownGames
@MadClownGames 9 жыл бұрын
I never developed anything for Android but I am a Java developer for a local company. Anyone here is welcome to correct me if I got something wrong :) You really cannot compare GTAV's engine which has gone through years of optimizations and development to a possibly unoptimized shader, combinations of mods. I can play both GTAV and Minecraft smoothly. Former in 1440p, latter in 2160p. Sure Java is still slow in many things, but with JNI you can do nearly the same as you can with C/C++. The 'java is slow' is an old belief from times when Java took just damn long to start up the JVM. There is a reason why Java is the language of choice for banking/financial systems. Did you take a look at the 2 available compilers for Java? Each tailored to do different things. You can read more about JIT compiler here: en.wikipedia.org/wiki/Just-in-time_compilation or here: stackoverflow.com/questions/95635/what-does-a-just-in-time-jit-compiler-do The alternative and to be used in different scenarios is explained here: en.wikipedia.org/wiki/HotSpot Java is a memory hog, well at least it requires more memory than your other favourite language. Everyone knows this, but with GC and proper thinking while writing the code, this is not really an issue. Also a lot has changed in the past year or two for Java game development. LWJGL3 is a great example of how much has changed. Things are starting to move in the Java 3D game scene and if executed right, Java can become another language of choice for a game developer. The downside is that current engines for Java are either very weak or use, now, obsolete API or generally not very intuitive as some of the greats are (CryEngine, Unreal, Unity, etc...). The thorough pros and cons of Java speed are written here: stackoverflow.com/questions/2163411/is-java-really-slow Also you can join us at /r/java if you wish to take this to a next level and have a detailed conversations with Java professionals all over the world :)
@ThatBulgarian
@ThatBulgarian 9 жыл бұрын
So when I try to bind the texture to my water, it is completely black, can someone help me? (hopefully before the end of tomorrow)
@ThatBulgarian
@ThatBulgarian 9 жыл бұрын
***** I do have the texture coordinates set, i can put a normal file texture on there just fine >.>
@ThatBulgarian
@ThatBulgarian 9 жыл бұрын
***** drive.google.com/file/d/0BzKmTVdrnbAhMG5OMjk3ZHVrM2M/view?usp=sharing Heres the whole project. *Couple of comments on it, it will be red on top of what ever texture is on it(this way I can see wether it is working or not. Also, press shift and then space to move down and just space to move up. The lines on the ground are normals
@ThatBulgarian
@ThatBulgarian 9 жыл бұрын
***** If you manage to help me get it working, I will mention you in the report
@ThatBulgarian
@ThatBulgarian 9 жыл бұрын
***** what have you changed? Can you send it anyway please. What my problem was is that the reflection texture is black and I don't know how to fix it
@ThatBulgarian
@ThatBulgarian 9 жыл бұрын
Codeditor King while that does fix it being black, it is still transparent black. Regardless something weird happened just now and I dont have any more fucks to give postimg.org/image/ghrfi9hed/ Where did this texture come from now? It isnt in the folder anywhere! I'll just hand my coursework in without the reflective water and wait for ***** to finish his series :)
@lookencykouadioseri8410
@lookencykouadioseri8410 4 жыл бұрын
Merci.
@Jacob_Mango
@Jacob_Mango 9 жыл бұрын
I would have liked it if you went more indepth. Eg, writing the code as you say it. Oh well. I still liked it. Since I now know how to do this I can now do more with the game.
@ThinMatrix
@ThinMatrix 9 жыл бұрын
Jacob RAWR I don't think I'd have said anything differently if I'd written the code at the same time; I really put everything I know about this topic into the video. Showing me programming the code would have only made the video slower and longer, and people would have been starting and stopping my explanations as they tried to copy down the code instead of listening to the explanations uninterrupted, which I felt was important for a totally new concept like this. This was just a one off though, I'll be programming and talking through the next tutorials as usual.
@Jacob_Mango
@Jacob_Mango 9 жыл бұрын
***** Yea but with pasting the code in the description they kinda can just copy it down. See with me I like to watch a person type it out first in front of me while describing it. I find it much easier to understand + i also write it. I think I have the gist of fbo's now though. I do understand what you mean by it would be longer. It would also take up your time. You could do something to what TheChernoProject does in his 2D game engine where he has a basic idea on what he is doing and records it all in one take. I like that type of recording as I find I learn more, + longer videos mean more people would watch and actually learn. You would lose some viewers but mostly gain more. This is just my 2 cents though. Alot of I's in this....
@ThinMatrix
@ThinMatrix 9 жыл бұрын
Jacob RAWR I would love to be able to do that kind of video, but I simply can't, it would end up being awful. I'm a pretty slow typer so the video would be soooo long, and usually I speed up the footage in my videos quite a lot to keep it short. Also I'm really not good at being able to talk about a topic and remember what to say without any prompts, so I like to script as much of my tutorial videos as possible to ensure that I explain everything in the best way I can, which I spend hours planning in advance, instead of stumbling through badly structured explanations as I would be if I was doing it all in one take. Plus I would be trying to program everything correctly at the same time. It just would be a disaster if I tried to do that kind of video, trust me :P Did you watch to the very very end of this video? That's what the whole video would be like if I did it all in one take! =P But as you know, I don't usually allow people to simply copy and paste the code, and as I said this was just a one off. The video would have been over 20 minutes if I hadn't and I don't feel like I would have been able to add any more information into the video, so I felt for this video it wouldn't be too much of a problem. Plus it made it easier for me (you wouldn't believe the number of takes I usually do when recording myself programming!) But I'll be back to using my usual format for future tutorials :)
@Jacob_Mango
@Jacob_Mango 9 жыл бұрын
***** i tried recording myself program once and I failed. Even when I normally program I always stuff up and backtrack a hour. So I agree with you about how many takes you do. I never knew you typed slowly. I thought you were a fast typer. What is your words per minute? Good to know you will be back to your usual tutorials. Also since you said you don't know how to do shadows you should watch ***** as he has a great tutorial on shadow mapping. Is your game going to have dedicated servers similar to dayz or one server that everyone connects to. Anyway, nice to know about the tutorials and thanks for doing them. Also would your (forgot name) video log game be covering both two weeks or just the one you are doing it on? Cause last week you only did the one.
@ThinMatrix
@ThinMatrix 9 жыл бұрын
Jacob RAWR I have no idea what my words per minute is, but I type about 25% slower than I appear to type in the tutorials ;) As for the servers there will be one (or more, depending on how popular the game is!) server that everyone would join. The BTS devlog will cover the 2 weeks since the last one, although I'm not sure if I'll always do that. A lot of people were asking for me to go into more depth when I talk about what I've been working on, and if I do that over two weeks the video will end up being like 30 mins long. I'm not really sure what's better: having 2 weeks covered in depth and it being a 30 min+ video, covering 2 weeks briefly and it being a shorter 15 minute video, or covering just one of the weeks in depth, and it being a shorter 15 minute video. I'll probably ask people what they would prefer at the end of next week's video :)
@runaan3195
@runaan3195 7 жыл бұрын
i thought i got a good computer but after playing my own game with the fbos and before too... i think my computer, graphics-card, programm or lwjgl/OpenGL is shit... because minecraft: 200fps, LoL:120fps, Overwatch: 80fps and my game only gots 90 fps atm i dont think my game is nearly as complex as overwatch more minecraft/10 but i dont get around 2000 fps. I started at 200 fps then 120 after some tuts and now around 80 after the fbos... can you do sth to "fix" it
@runaan3195
@runaan3195 7 жыл бұрын
found a big part of the problem... 9 terrains -> 4 terrains and turned 800 entities down to 200 way better now but how do you handle these terrains then less vertex tiles?
@PigIncorp
@PigIncorp 7 жыл бұрын
Geomipmapping for the terrain and add LODs to your entities
@runaan3195
@runaan3195 7 жыл бұрын
Thanks now I just need to understand that and im good to go. Thx
@krzysztof-ws9og
@krzysztof-ws9og 6 жыл бұрын
But just make sure, you are not rendering it onto anything gets rendered while you are rendering to that texture. You cannot render the texture onto something that then gets rendered to the texture that you are rendering onto something that gets ... It will create a horrible paradox and your comuter will explode that gets what?
@ThinMatrix
@ThinMatrix 6 жыл бұрын
...that gets rendered to the texture that you are rendering onto something that get rendered to the texture that you are rendering onto something etc. etc. Basically don't render to a texture and try sampling it at the same time.
@ashrblx1392
@ashrblx1392 7 жыл бұрын
"Slightly low resolution"(When it's like 120 x 128) - ThinMatrix 2015
@BenWiser
@BenWiser 7 жыл бұрын
Mmh, I've been using this for a little while now. I wanted to try put SSAO into my game so I started by quickly trying to render out the depth buffer texture but it's completely white. Have any idea what could be causing that?
@MohammedPlaysMC
@MohammedPlaysMC 9 жыл бұрын
Im not to sure why im getting this error Sat May 02 19:08:32 BST 2015 INFO:Use Java PNG Loader = true Exception in thread "main" java.lang.IllegalStateException: Function is not supported at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58) at org.lwjgl.opengl.GL32.glFramebufferTexture(GL32.java:389) at water.WaterFrameBuffers.createTextureAttachment(WaterFrameBuffers.java:103) at water.WaterFrameBuffers.initialiseReflectionFrameBuffer(WaterFrameBuffers.java:68) at water.WaterFrameBuffers.(WaterFrameBuffers.java:28) at mainGame.GameLoop.main(GameLoop.java:253)
@ThinMatrix
@ThinMatrix 9 жыл бұрын
Mohammed Qureshi It just says that the function isn't supported for you. Did you set up an OpenGL 3.2 context in the DisplayManager class with the ContextAttribs? Your code for creating the display should look like this: public static void createDisplay(){ ContextAttribs attribs = new ContextAttribs(3,2) .withForwardCompatible(true) .withProfileCore(true); try { Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT)); Display.create(new PixelFormat(), attribs); Display.setTitle("Our First Display!"); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glViewport(0,0, WIDTH, HEIGHT); lastFrameTime = getCurrentTime(); }
@MohammedPlaysMC
@MohammedPlaysMC 9 жыл бұрын
Remember i told you it gives me that error when i do this. So i had to remove te context attribs 3.2
@ThinMatrix
@ThinMatrix 9 жыл бұрын
Mohammed Qureshi Try copying in that code above into your createDisplay() method, can you tell me exactly what the error says when you run it then?
@MohammedPlaysMC
@MohammedPlaysMC 9 жыл бұрын
org.lwjgl.LWJGLException: Could not create context (WGL_ARB_create_context) at org.lwjgl.opengl.WindowsContextImplementation.nCreate(Native Method) at org.lwjgl.opengl.WindowsContextImplementation.create(WindowsContextImplementation.java:50) at org.lwjgl.opengl.ContextGL.(ContextGL.java:132) at org.lwjgl.opengl.Display.create(Display.java:850) at org.lwjgl.opengl.Display.create(Display.java:797) at renderEngine.DisplayManager.createDisplay(DisplayManager.java:51) at mainGame.GameLoop.main(GameLoop.java:37) Exception in thread "main" java.lang.RuntimeException: No OpenGL context found in the current thread. at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) at org.lwjgl.opengl.GL11.glViewport(GL11.java:3261) at renderEngine.DisplayManager.createDisplay(DisplayManager.java:57) at mainGame.GameLoop.main(GameLoop.java:37)
@MohammedPlaysMC
@MohammedPlaysMC 9 жыл бұрын
I think it maybe because of my graphics only support 3.1 opengl and if so i guess i cant carry on with the tutorials please say it isnt.
@PumpReactivationProject
@PumpReactivationProject 5 жыл бұрын
Guys, I'm a time traveller and I'm coming here to warn myself. ALWAYS REMEMBER ABOUT SETTING TEXTURE'S FILTERING OR TO GENERATE MIPMAPS, OTHERWISE YOUR TEXTURE WILL BE BLACK AND YOU'LL BE RIPPING YOUR HAIR OFF YOUR HEAD. Hope I helped some of you :)
@cemgecgel4284
@cemgecgel4284 3 жыл бұрын
Lol, I just couple of hours ago I wasted my time with that. I tought my gpu can't run mipmaps.
@porktek
@porktek 9 жыл бұрын
It is just blue could you help me?
@porktek
@porktek 9 жыл бұрын
kk: package main; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Timer; import java.util.TimerTask; import javax.imageio.ImageIO; import misc.*; import models.RawModel; import models.texturedModel; import objects.Sky; import objects.Sun; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.openal.AL; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL30; import org.lwjgl.util.vector.Vector2f; import org.lwjgl.util.vector.Vector3f; import org.newdawn.slick.opengl.ImageIOImageData; import chemicals.Chemical; import chemicals.Hydrogen; import chemicals.compounds.Compound; import IODat.HeightMap; import attribTools.TileAttrib; import audio.Music; import entity.Entity; import entity.Light; import entity.ReflCam; import entity.camera; import entity.player.Player; import fbos.FBO; import fbos.FrameBufferObject; import guis.Gui; import guis.GuiTexture; import guis.HUD; import guis.Inventory; import guis.Startup; import render.*; import shaders.StaticShader; import shaders.TerrarinShader; import terrarin.Terrain; import textures.modelTexture; import toolbox.OBJLoader; import toolbox.XLoader; import water.WaterFrameBuffers; public class MainGameLoop { public static StaticShader shader; static int FPS = 0; public static void main(String[] args) { // System.setProperty("user.dir" ,new File( "C:/Users/" + System.getProperty("user.name") + "/AppData/.VerteX/").getAbsolutePath()); List lights = new ArrayList(); EntityRenderer r5; try { boolean b = false; if(args[0] == "CmdMode"){ b = true; } } catch (Exception e1) { e1.printStackTrace(); } try { // libman.loadNativeLibraries(true); Display.setIcon(new ByteBuffer[] { new ImageIOImageData().imageToByteBuffer(ImageIO.read(new File("res/Icon.png")), false, false, null), new ImageIOImageData().imageToByteBuffer(ImageIO.read(new File("res/Icon.png")), false, false, null) }); } catch (Exception e1) { e1.printStackTrace(); } DisplayManager.createDisplay(); System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION)); Loader loader = new Loader(); GuiRenderer gr = new GuiRenderer(loader); List guies = new ArrayList(); GuiTexture gui = new GuiTexture(loader.loadtexture("guis/Loading")); guies.add(gui); gr.render(guies); DisplayManager.updateDisplay(); Music[] bgm = { new Music("Enchanted Valley"), new Music("Lord of the Land"), null }; Player plr = new Player("porkchopmod",new Vector3f(0, 0, -0),loader,1,1); //DisplayManager.updateDisplay(); HeightMap h = new HeightMap();//h.eGenHightMap("img"); Vector3f selvec = new Vector3f(0,0,-1); Sun s = new Sun(); Inventory i = new Inventory(loader); MasterRenderer r4 = new MasterRenderer(); TileAttrib t = new TileAttrib(); t = new TileAttrib(); camera cam = new camera(); Chemical.loadChemicals(); Compound.Setup(); RawModel mod = toolbox.OBJLoader.loadobj("copper", loader); texturedModel m = new texturedModel(mod, new modelTexture(loader.loadtexture("CopperOre1"))); Entity copperore = new Entity(m, new Vector3f(1,1,1), 0, 0, 0, 1); Sky sky = new Sky(loader,cam); Entity Skie = sky.GetSky(); Entity fab = new Entity(new texturedModel(OBJLoader.loadobj("Fabricator", loader),new modelTexture( loader.loadtexture("Fabricator"))),new Vector3f(188, 12, -188), 0, 0, 0, 1); // Entity e = new Entity(new texturedModel(XLoader.GetX("tst4", 1), new modelTexture(loader.loadtexture("Flint"))), new Vector3f(188, 12, -188), 0, 0, 0, 5); t.SetVar("hai", 1); Time time = new Time(); gr.clear(); guies.clear(); HUD Hud = new HUD(loader); GL11.glEnable(GL30.GL_FRAMEBUFFER); GL11.glEnable(GL11.GL_DEPTH_TEST); guies = new ArrayList(); gr = new GuiRenderer(loader); int r =new Random().nextInt(2); // bgm[r].Play(); boolean ison = false; guies.clear(); gr.clear(); gr = new GuiRenderer(loader); // guies.add(new Startup(loader).getGuiTexture()); gr.render(guies); DisplayManager.updateDisplay(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); boolean menu = true; cam.SetPos(plr.GetPos()); List guis = new ArrayList(); Mouse.setGrabbed(true); Light sun = new Light(new Vector3f(), new Vector3f(1,1,1),new Vector3f(1,1,1)); lights.add(sun); List grasses = new ArrayList(); WaterFrameBuffers bfrs = new WaterFrameBuffers(); ReflCam cam2 = new ReflCam(cam); FBO fbo = new FBO(320, 500); //FBO view = new FBO(Display.getWidth(), Display.getHeight()); System.out.println("z"); FrameBufferObject obj = new FrameBufferObject(320, 130); guies.add(new GuiTexture(bfrs.getReflectionTexture(),new Vector2f(-0.5f,-0.5f), new Vector2f(0.5f,0.5f))); System.out.println("y"); Terrain t1 = new Terrain(-1, 0, loader, new modelTexture(loader.loadtexture("Grass"))); while(!Display.isCloseRequested()){ Display.sync(60); cam.Move(plr,t1); cam2.Move(plr, t1); bfrs.bindReflectionFrameBuffer(); r4.render(lights, cam); bfrs.unbindCurrentFrameBuffer(); if(Keyboard.isKeyDown(Keyboard.KEY_E)){ ison = true; } if(ison){ guis.add(i); }else{ } if(Keyboard.next()){ if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !ison){ ison = false; guies.clear(); break; }if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && ison){ ison = false; Mouse.setGrabbed(true); guis.clear(); } } time.AddTimePerTick(30); s.update(); Skie.setPos(new Vector3f(cam.getPos().x,-475,cam.getPos().z)); r4.processTerrain(cam.testTerrain(t1)); r4.processEntity(Skie); bfrs.unbindCurrentFrameBuffer(); r4.render(lights, cam); gr.renderGuis(guis); gr.render(guies); DisplayManager.updateDisplay(); } bfrs.cleanUp(); fbo.cleanUp(); // view.cleanUp(); gr.clear(); obj.cleanUp(); r4.cleanUp(); AL.destroy(); loader.cleanUp(); DisplayManager.closeDisplay(); System.exit(0); } }
@porktek
@porktek 9 жыл бұрын
no
@porktek
@porktek 9 жыл бұрын
yes
@porktek
@porktek 9 жыл бұрын
i forgot to re-process all of the entitys
@johnsmith5776
@johnsmith5776 7 жыл бұрын
Gooey. GOOEY. G U I sounds like something you contract from a bit of promiscuity. :P
@huyvole9724
@huyvole9724 6 жыл бұрын
No. You should program and explain at the same time then watcher'll understand a easy way. Because we'll dizziness when read your all code.
@alekibisevic1750
@alekibisevic1750 2 жыл бұрын
There is so much which isn’t said that to someone who doesn’t know resource management how processors work how graphics hardware works , how graphics programming software/hardware works and interacts with processors and OpenGL works , seems confusing and redundant, for example some people don’t understand what it means to continuously redraw or rasterise into screen from vertices a 3D model or some effect especially for large games with tonnes of 3D models or tonnes of open space shaders and on and on or whatever else the game does , and how it’s overwhelming the system, and why drawing models and effects to textures frame buffers and other functionality and tools OpenGL offers ,saves time ,memory management and resource and power etc these tutorials are always poorly done and poorly explained very poorly,why even make an tutorial if your going to cover 5% of the information just don’t do it Just don’t make tutorials if your not going to even bother to explain even half the things ,you’re just loitering and littering KZbin with useless information only those who already know OpenGL well enough can use
@rachit7645
@rachit7645 2 жыл бұрын
r/ihadastroke
OpenGL Water Tutorial 3: Clipping Planes
13:37
ThinMatrix
Рет қаралды 54 М.
When Steve And His Dog Don'T Give Away To Each Other 😂️
00:21
BigSchool
Рет қаралды 14 МЛН
Чай будешь? #чайбудешь
00:14
ПАРОДИИ НА ИЗВЕСТНЫЕ ТРЕКИ
Рет қаралды 2,7 МЛН
КАРМАНЧИК 2 СЕЗОН 6 СЕРИЯ
21:57
Inter Production
Рет қаралды 523 М.
How I Implemented Shadows in my Game Engine
7:45
ThinMatrix
Рет қаралды 93 М.
OpenGL - Framebuffer Objects
14:37
Brian Will
Рет қаралды 20 М.
Making a Game With C++ and SDL2
5:34
Goodgis
Рет қаралды 580 М.
Homegrown Devlog - New Design for the Shops!
12:45
ThinMatrix
Рет қаралды 58 М.
Basic Shadow Mapping // OpenGL Tutorial #35
16:54
OGLDEV
Рет қаралды 19 М.
How Games Fake Water
22:52
Acerola
Рет қаралды 188 М.
Coding with Notch (from Minecraft: The Story of Mojang)
3:57
2PlayerProductions
Рет қаралды 6 МЛН
Қорқынышты Майнкрафт - 5 бөлім ✅
32:10