Jump to content

Search the Community

Showing results for tags '2.2.9'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. First, i know that 2.2.9 is pretty outdated, but it's what i have to work with. I'm currently trying to achieve 2d lighting by using this tutorial: https://github.com/mattdesl/lwjgl-basics/wiki/2D-Pixel-Perfect-Shadows Rendering the occlusion map is trivial and i can theoretically create the 1D shadowmap, but it seems to ignore pixels, that are too far away from the center. This is my fragment shader: new PIXI.AbstractFilter([ '#define PI 3.14', 'precision mediump float;', 'varying vec2 vTextureCoord;', 'uniform sampler2D uSampler;', 'const float h = 400.0;', 'void main(void) {', ' if((vTextureCoord.y * h) > 1.0) {', ' gl_FragColor = vec4(0.0);', ' return;', ' }', ' float distance = 1.0;', ' for(float y = 0.0; y < h; y += 1.0) {', ' float dst = y / h;', ' vec2 norm = vec2(vTextureCoord.x, dst) * 2.0 - 1.0;', ' float theta = PI + norm.x * PI;', ' float r = (1.0 + norm.y) * 0.5;', ' vec2 coord = vec2(-r * sin(theta), -r * cos(theta)) / 2.0 + 0.5;', ' if(texture2D(uSampler, coord).a > 0.0) {', ' distance = dst;', ' break;', ' }', ' }', ' gl_FragColor = vec4(vec3(distance), 1.0);', '}' ]); I'm currently hardcoding the height of the occlusion map, because i can't use uniforms as loop boundaries. I have to admit, my math isn't good enough to completely understand, what's going on in the transformation, but it seems to work as long as the occluder is near enough to the light. I tried increasing the occlusion map by adding empty space, but it didn't help. Has someone attempted something like this and can point me in the right direction? Sure, i could try to create the 1D map on CPU, but that's going to be really slow, when i have to include moving objects and need to recalculate often.
×
×
  • Create New...