java - How do I make a 1D shadow map from an Occlusion Map? Mine becomes white -


i'v been working time in gpu post processing effects game, i'v come issue seems unsolvable, trying achieve top-down directional light.

i have generated occlude map scene, , trying create height map shader inspired pixel perfect shadows tutorial libgdx:

varying vec2 vtexcoord0;  uniform sampler2d u_texture; uniform vec2 ts; // occlusion texture size  void main(void) {     float dst = 1.0;     (float y=0.0; y<ts.y; y+=1.0) {         float d = y/ts.y;         vec2 coord = vec2(vtexcoord0.x, dst);         vec4 data = texture2d(u_texture, coord);          if (data.r > 0.0) {             dst = min(dst, d);         }     }     gl_fragcolor = vec4(dst); } 

the input texture sinus wave minimum of 0 , maximum of 100% of texture. (i cannot post pic yet, need more reputation) texture opaque on sine wave(if not flipped after fbo rendered)and transparent there air.

the java render code one:

public void makeshadowmap() {          cam2.settoortho(false, shadowmapfbo.getwidth(), shadowmapfbo.getheight());         //cam2.position.set(vector3.zero);         cam2.update();          shadowmapshader.setuniformf("ts", alpha.getwidth(),alpha.getheight());          shadowmapfbo.begin();          gdx.gl20.glclearcolor(0f, 0f, 0f, 0f);         gdx.gl20.glclear(gl20.gl_color_buffer_bit);         gdx.gl20.glenable(gl20.gl_blend);         gdx.gl20.glblendfuncseparate(gl20.gl_src_alpha, gl20.gl_one_minus_src_alpha, gl20.gl_one, gl20.gl_one);          batch.setprojectionmatrix(cam2.combined);         batch.setshader(shadowmapshader);         batch.begin();          batch.draw(alpha.getcolorbuffertexture(),0,0, shadowmapfbo.getwidth(), shadowmapfbo.getheight()); // alpha occlusion fbo          batch.end();          shadowmapfbo.end();         gdx.gl20.gldisable(gl20.gl_blend);         gdx.gl20.glblendfunc(gl20.gl_src_alpha, gl20.gl_one_minus_src_alpha);      } 

but shader, generates 1d shadow map white, if there nothing on occlusion map. i'v tried flipping occlusion map, i'v looked in error log of shader, , theoretically fine.

what did wrong? there alternative way generate 1d shadow map?

the issue here uniform not set because forgot call begin , end before , after.

shadowmapshader.begin(); shadowmapshader.setuniformf("ts", alpha.getwidth(),alpha.getheight()); shadowmapshader.end(); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -