Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

111 Neutral

About Bogo

  • Rank
  1. umm.. what is FFP blanding ?  and how comes I don't actually render the scene if I use the sample in the shader and I can see it under the light ?
  2. changed ambient to (1, 1, 1, 1) ... Didn't make any difference :P by the way I have noticed that the screen is black because I set the background to black(a very dark gray actually), by glClearColor ... But still the same story.. ( of course changing the background color filled the screen with that color and the light point stayed the same)
  3. yep... changing the ambient to (1,1,1) didnt make any difference.. (by the way, nor did (0,0,0)  ), As it was before, the ambient had an effect only where there was light.. the rest of the screen is black.
  4. Yeah I understand, but as I said the ambient light has no effect on the scene wherever there is no light from the light point... ( even after adding instead of multiplying , and uncommenting the clamp line)
  5. thank you very much  haegarr Well, I have revised my shaders and followed your instructions.. and actually, I think I'm now closer to something cool     As you can see I have a light point that follows my mouse, and it lights up a circular area, in a color that I pass as a uniform, however, now I've got another problem Obviously, the entire scene is completely dark, and I don't know why... (my ambient color is like a dark blue, and I've checked, it is applied only where there is light from the light point...).. What's wrong ?   Here is my fragment shader as of now : #version 130 in vec2 fragmentPosition; in vec4 fragmentColor; in vec2 fragmentUV; uniform sampler2D texture; uniform vec4 ambientColor; uniform vec2 lightPos; uniform vec3 lightIntensity; void main() { vec4 temp = texture2D(texture, fragmentUV); float distance = length(lightPos - fragmentPosition); vec3 lightColor = vec3(lightIntensity.rgb - distance); vec3 ambient = ambientColor.rgb * ambientColor.a; vec3 final = lightColor * ambient; //final = clamp(final, 0, 1); gl_FragColor = vec4(final * temp.rgb, 1); } The clamping is commented out.. however, when I clamp between e.g 0.1 and 1, some light does shine through in the scene and it is not completely dark.. what do you mean by saying I should clamp to 1, 1, 1 ?    
  6. haha wow yeah it's a typo right here, In the shader that's a vec4 of course.
  7. hy :) Thanks haegarr... For your question - In the scene vertex Shader I have  in vec2 vertexColor; out vec2 fragmentColor; void main(){ .... gl_Position stuff fragmentColor = vertexColor; } I think vertexColor gets to the shader from the vbo (right? I'm not keen enough to be sure)...   Now, Ive tried to unify both fragment shaders into one (the light shader and the scene).. doing the light calculations in the scene shader, and I got a really weired result: I have use small .png picuters of bricks, for walls and floor, and, every brick texture was fully lit (i.e in its original color) at its top tight, and completely dark in bottom left.. and was mixed in between - well i hope you know what i mean ...   No matter how I twist it and play with the shaders - I end up with either the original thing, or this, or a single light point on a black screen, or nothing at all..  I'm sure its not as complicated, Its just that something is wrong uh ? Which got me thinking, maybe its not a problem with the shaders, but with code I use in the game ? In my draw function I do ClearColor, Clear depth and color bits, get projection matrix from the camera, and then: shaderProgram.use(); get uniforms glActiveTexture() set uniforms spriteBatch.begin() draw map and people spriteBatch.end() spriteBatch.renderBatch() shaderProgram.unuse(); I have the same for the light (but now its commented out because I unified both shaders)  only difference is that for the light i use a different instance of shaderProgram, and ActiveTexture() is set to GL_TEXTURE1 ...   maybe thats wrong ?? like.. Im not sure what to ask 
  8. Hello again       haegarr, thanks for that. I have returned the colors of the scenery to its "initial" color and alpha.. As you had advised, I have changed my shaders so that the "main" shader now has a sampler2D of both the light and of the original texture, however, I when I multiply the light with the initial color ... I get a completely black scene with nothing visible but a single light point that follows my mouse...   But, if i don't include the light sampler in the calculations, (thus the final calculation involved the original texture color, ambience, and the color passed from the vertex shader), then then i get the same result as in the screenshot in my previous post... why ??    anyway, as i said previously, i have a separate shader for this light point, and a separate one for the scene, so, in the scene shader -  I have tried to remove the light sampler, instead do the light point calculations inside the scene sahder, and include it in the calculation with the texture sampler .... again, playing around with it gave me either a completely black screen, a black screen with a single light point, or the original scene with strange artifacts and is was like as if this little light point was sitting inside every brick texture, I don't know I cant even explain ...   At the moment, that is how my shaders look:   scene.fs #version 130 in vec2 fragmentPosition; in vec4 fragmentColor; in vec2 fragmentUV; uniform sampler2D texture; // base texture uniform sampler2D lightMap; uniform vec4 ambientColor; // ambiemce void main() { vec3 ambient = ambientColor.rgb * ambientColor.a; vec4 temp = texture2D(texture, fragmentUV); vec4 textureColor = texture2D(lightMap, fragmentUV); gl_FragColor = temp * vec4(ambient, 1) * fragmentColor; } pointLight.fs #version 130 in vec2 fragmentPosition; in vec4 fragmentColor; in vec2 fragmentUV; //uniform vec2 lightLocation; //uniform sampler2D texture; void main() { float distance = length(fragmentUV); vec4 color = vec4(fragmentColor.rgb - distance, fragmentColor.a); gl_FragColor = color;// * fragmentColor; } with these two i get the same result as in the screenshot from the previous post.. and, If i make the ambient light completely dark, then again, the light has no effect on the scene ... And just a final question  -  In the video from the previous post, those completely dark areas - why are they dark ? I mean, is the original texture color black, or is it the ambient light that makes it look like that ? why then when light hits it, the original color is revealed, unlike in my case ?   I think I now understand less than before ?! 
  9. Hello everybody I've been following Ben Arnold's youtube channel tutorials (https://www.youtube.com/user/makinggameswithben) on making a game ( and a game engine ) ... He had a tutorial on making simple 2D lighting effects using shaders. However, after implementing that, it doesn't really satisfy me :/ , I mean, the light barely looks like it really "lights up" the scene, and, my biggest problem is that i want the scene to be completely black, and the light will shine through and "reveal" the real texture color of the walls and ground and everything. But, when i set the walls color to black, or its alpha value, the light has no affect on it.. Should it be like that ? I've tried so many modifications to my shaders and played with them but could not get what i want..   That is what I have at the moment:   As you can see, I do have a light that makes the surrounding bricks look brighter, but it doesn't look quite "correct", and also, as i have mentioned, if the entire scene is completely dark, the light wont make the texture light up in the darkness.   I want to achieve an effect similar to this: (for example pay attention to second 0:48 and forwards..)   Like in this video where if a place is dark, the light hits it and makes it visible in it colors again..   I have a separate shader for this light point and for the scene.. I can provide the code samples if needed ... any help with that would be greatly appreciated, I am thoroughly confused   p.s. I did actually check out the source code from github, of the game in the video, but it is like so much more complicated and different than what i am doing, plus a lot of the code and the comments are in croatian ...  
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!