Jump to content
  • Advertisement

WhiskyAndCode

Member
  • Content Count

    46
  • Joined

  • Last visited

Community Reputation

2 Neutral

About WhiskyAndCode

  • Rank
    Member

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. WhiskyAndCode

    Deferred Shading - light buffer in shadow mapping

    in fact, the sunlight is in the shadow mapping calculation, which is now in the pointlight shader. My pointlight shader is passed every time for each light. Then in the end I had my combination shader and there I did the shadow mapping calculation. But I think I'm going to give it up for now and continue to study learnopengl. Even so, thank you for the help and shared knowledge ChuckNovice. I hope you can help me with the next questions ๐Ÿ˜. Thank you
  2. WhiskyAndCode

    Deferred Shading - light buffer in shadow mapping

    I understand. I can not think how to put the lights and shadow mapping on my lighting shader. For I render "spheres" in separate lighting passes, according to my shader: out vec4 LightMap; uniform vec2 ScreenSize; uniform float LightRadius; uniform vec3 LightColor; uniform float LightIntensity; uniform vec3 LightCenter; uniform sampler2D PositionBuffer; uniform sampler2D NormalBuffer; void main() { vec2 texCoord = gl_FragCoord.xy / ScreenSize; vec3 pixelPos = texture2D(PositionBuffer,texCoord).xyz; vec3 pixelNormal = normalize(texture2D(NormalBuffer, texCoord).xyz); float alpha = length(pixelNormal); if(alpha < 0.1) { LightMap = vec4(0,0,0,0); return; } vec3 toLight = LightCenter - pixelPos; float attenuation = clamp(1.0 - length(toLight)/LightRadius,0.0,1.0); toLight = normalize(toLight); float nDotL = max(dot(pixelNormal, toLight),0.0); vec3 diffuseLight = LightColor * nDotL; LightMap = LightIntensity * attenuation * vec4(diffuseLight, alpha); } I tried to change, and.... the result: Now source of light: out vec4 LightMap; uniform vec2 ScreenSize; //..... uniform sampler2D PositionBuffer; uniform sampler2D NormalBuffer; uniform sampler2D DepthBufferShadow; uniform sampler2D TextCoordBuffer; uniform mat4 View; uniform mat4 Proj; uniform mat4 World; uniform vec3 lightPos; uniform vec3 viewPos; uniform mat4 lightSpaceMatrix; float ShadowCalculation(vec4 fragPosLightSpace) { vec2 TexCoord = gl_FragCoord.xy / ScreenSize; vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; projCoords = projCoords * 0.5 + 0.5; float closestDepth = texture(DepthBufferShadow, projCoords.xy).r; float currentDepth = projCoords.z; vec3 normal = normalize(texture2D(NormalBuffer, TexCoord).xyz); vec3 FragPos = texture(PositionBuffer, TexCoord).xyz; vec3 lightDir = normalize(lightPos - FragPos); float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005); float shadow = 0.0; vec2 texelSize = 1.0 / textureSize(DepthBufferShadow, 0); for(int x = -1; x <= 1; ++x){ for(int y = -1; y <= 1; ++y){ float pcfDepth = texture(DepthBufferShadow, projCoords.xy + vec2(x, y) * texelSize).r; shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0; } } shadow /= 9.0; if(projCoords.z > 1.0) shadow = 0.0; return shadow; } void main() { vec2 texCoord = gl_FragCoord.xy / ScreenSize; vec3 pixelPos = texture2D(PositionBuffer,texCoord).xyz; vec3 pixelNormal = normalize(texture2D(NormalBuffer, texCoord).xyz); float alpha = length(pixelNormal); if(alpha < 0.1){ LightMap = vec4(0,0,0,0); return; } vec3 toLight = LightCenter - pixelPos; float attenuation = clamp(1.0 - length(toLight)/LightRadius,0.0,1.0); toLight = normalize(toLight); float nDotL = max(dot(pixelNormal, toLight),0.0); vec3 diffuseLight = LightColor * nDotL; vec3 FragPos = texture(PositionBuffer, texCoord).xyz; vec4 FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0); float shadow = ShadowCalculation(FragPosLightSpace); LightMap = LightIntensity * attenuation * (vec4(diffuseLight, alpha)*vec4(vec3(1.0 - shadow), 1.0)); } my question would be how to put it together and compose my shadow and lights? Can u help me to change?
  3. WhiskyAndCode

    Deferred Shading - light buffer in shadow mapping

    Hello all. thank for reply. in fact, so far only the "sunlight" will cast shadow. These other lights were still only to give better effect on the particles (fires, shots and explosions). That is, my lighting shader will not cast shadow. Sorry for not talking to you before. Do you have any idea ?
  4. Hello everyone. I need help with my problem. In my framebuffer (deffered shading) I have my light attachment, albeto, normal and also my shadow mapping. In my "finalshader" I combine everything, but it seems that the shadow is overlapping and "erasing" the light: this is my light attachment: and my shadow (is still raw, with no filters or smoothing): What do I need to do so that light overlaps the shadow, and not the shadow overlapping the light? My final shader to combine: //summed up uniforms uniform sampler2D DiffuseBuffer; uniform sampler2D LightBuffer; uniform sampler2D DepthBufferShadow; uniform mat4 View; uniform mat4 Proj; uniform mat4 World; uniform vec3 lightPos; uniform vec3 viewPos; uniform mat4 lightSpaceMatrix; //the shadow calcs float ShadowCalculation(vec4 fragPosLightSpace) { vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; projCoords = projCoords * 0.5 + 0.5; float closestDepth = texture(DepthBufferShadow, projCoords.xy).r; float currentDepth = projCoords.z; vec3 normal = normalize(texture2D(NormalBuffer, TexCoord).xyz); vec3 FragPos = texture(PositionBuffer, TexCoord).xyz; vec3 lightDir = normalize(lightPos - FragPos); float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005); float shadow = 0.0; vec2 texelSize = 1.0 / textureSize(DepthBufferShadow, 0); for(int x = -1; x <= 1; ++x) { for(int y = -1; y <= 1; ++y) { float pcfDepth = texture(DepthBufferShadow, projCoords.xy + vec2(x, y) * texelSize).r; shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0; } } shadow /= 9.0; if(projCoords.z > 1.0) shadow = 0.0; return shadow; } ///...................... //in main vec3 FragPos = texture(PositionBuffer, TexCoord).xyz; vec4 FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0); float shadow = ShadowCalculation(FragPosLightSpace); FragColor = ((texture2D(DiffuseBuffer, TexCoord)*(vec4(vec3((1.0 - shadow)), 1.0)))) * texture2D(LightBuffer, TexCoord); Can someone help me ? thank
  5. WhiskyAndCode

    Questions About Shadow Mapping

    lol, nice job lol oh yeah, I'm using simple shadow (The first technique to learn). Well I'm following the learnopengl tutorial. And before I go on to the next chapter, I make some "experiences" to understand better. Thank you all for the information. Added Trophies: D
  6. WhiskyAndCode

    Questions About Shadow Mapping

    Thank u, i'll google about "Cascading Shadow Maps" ๐Ÿ˜„๐Ÿ‘ Yeah, well remembered about post processing. And i'm adding my lights in final using deferred shading. About u said "Your final pic doesn't look right but its so dark I cant tell.๏ปฟ" What u think about doesn't look right ?
  7. Hello everyone. I was studying and implementing a shadow mapping, then I had some doubts, for example: In my study (and everyone I saw in the tutorials) the distance is very short, I wanted to know how this is implemented in a biggest scenario, because if I use it as a vision of the sun, I think it would weigh heavily. So, correct me if I'm wrong, should I do my depth map / shadow mapping at a distance near the camera and follow it as I (the camera) walk? example (in scroll side): another doubt is the best way to add my shadow. Currently I have my framebuffer to implement deferred shading, and all information I save in a separate attachment (position, normal, light ....). But the shadow mapping I apply only in my final shader (combine final). I was wondering if the best way would be the same in my finalCombineShader or is it generating the shadow in a separate attachment as I'm rendering my models? (as I do with the position attachment, normal ...) This is my final result: Could someone get me those doubts? Thank
  8. Nice.. continue in dev Dont forget to record a new videos for us follow
  9. U will find here: http://www.humus.name/index.php?page=3D and http://www.3dcpptutorials.sk/index.php?id=14
  10. Why note a modern opengl ? https://learnopengl.com/
  11. Hello. it will be difficult to find in a single article all that you want. But, try: https://learnopengl.com/ https://itstillworks.com/12146966/how-do-arcade-games-work https://en.wikipedia.org/wiki/Atari_2600 https://en.wikipedia.org/wiki/Video_game
  12. Please, dont make double posts. https://www.gamedev.net/forums/topic/702016-gun-keeps-moving-away-from-camera-in-opengl-program/
  13. _WeirdCat_ is right. Post how you are drawing your weapon. But, you can find a good tutorial here: http://www.morrowland.com/apron/tut_gl.php (more old opengl, but can help you)
  14. WhiskyAndCode

    Opengl error drawing vertex (far)

    _Silence_, you're right! (and everyone who helped me) My scale is too high, I decreased the speed of my camera and now it makes more sense, and it lowers my terrain by 70%. ๐Ÿ˜ƒ Thank u for all
  15. WhiskyAndCode

    Opengl error drawing vertex (far)

    Hello _Silence_, changed, but did not work. My land is very big because I want to make an island with many "communities". if I lower my drawdistance the ground does not render completely. Tell me one thing, what are the most common values? I understand how dimensions of the world
  • 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!