public void shader1f(GL2GL3 gl, float i, String name) { shader.use(gl); gl.glUniform1f(gl.glGetUniformLocation(shader.getID(), name), i); shadertess.use(gl); gl.glUniform1f(gl.glGetUniformLocation(shadertess.getID(), name), i); shadertess.unuse(gl); }
public void setShadowmapShaderTexture(GL2GL3 gl, TexBindSet tbs, String texname) { shadowmapshader.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadowmapshader.getID(), texname), tbs.texunit); shadowmapshadertess.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadowmapshadertess.getID(), texname), tbs.texunit); shadowmapshadertess.unuse(gl); }
public void setShadowmapShader1i(GL2GL3 gl, int i, String name) { shadowmapshader.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadowmapshader.getID(), name), i); shadowmapshadertess.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadowmapshadertess.getID(), name), i); shadowmapshadertess.unuse(gl); }
@Override public void render() { GL2GL3 gl = GLContext.getCurrentGL().getGL2GL3(); gl.glEnable(gl.GL_BLEND); gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA); super.render(); gl.glDisable(gl.GL_BLEND); }
public void updateligths(GL2GL3 gl, Shader shader) { updatelights( gl, gl.glGetUniformLocation(shader.getID(), "lightsview"), gl.glGetUniformLocation(shader.getID(), "lightsproj"), gl.glGetUniformLocation(shader.getID(), "lightscolor"), gl.glGetUniformLocation(shader.getID(), "lightsattr"), gl.glGetUniformLocation(shader.getID(), "lightcount_real_virtual")); }
public void setTessLevel(GL2GL3 gl, int level) { shadowmapshadertess.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadowmapshadertess.getID(), "tesslevel"), level); shadowmapshadertess.unuse(gl); shadertess.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadertess.getID(), "tesslevel"), level); shadertess.unuse(gl); }
public void updateModelMatrix(GL2GL3 gl, Shader shader, PMVMatrix model) { model.update(); // if(gl.glGetUniformLocation(shader.getID(), "model") == -1) // System.out.println("uniform model error"); gl.glUniformMatrix4fv( gl.glGetUniformLocation(shader.getID(), "model"), 1, false, model.glGetMatrixf(GL2.GL_MODELVIEW)); }
public void renderingToWindow( GL2GL3 gl, int offsetx, int offsety, int width, int height, boolean show) { gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, 0); // gl.glClearColor(1, 1, 1, 1); gl.glViewport(offsetx, offsety, width, height); renderingToWindow(gl, show); gl.glFlush(); }
public void shader1i(GL2GL3 gl, int i, String name) { shader.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shader.getID(), name), i); // gl.glUniform(new GLUniformData(name, i)); shadertess.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadertess.getID(), name), i); // GLUniformData tmp = new GLUniformData(name, i); // tmp.setLocation(gl.glGetUniformLocation(shadertess.getID(), name)); // gl.glUniform(tmp); shadertess.unuse(gl); }
public void init(GL2GL3 gl, Shader shader, Shader shadertess) { this.shader = shader; shader.use(gl); uniformview = gl.glGetUniformLocation(shader.getID(), "view"); uniformproj = gl.glGetUniformLocation(shader.getID(), "proj"); this.shadertess = shadertess; shadertess.use(gl); uniformviewtess = gl.glGetUniformLocation(shadertess.getID(), "view"); uniformprojtess = gl.glGetUniformLocation(shadertess.getID(), "proj"); shadertess.unuse(gl); }
public void renderingToFBO( GL2GL3 gl, FBO fbo, int offsetx, int offsety, int width, int height, boolean show) { shader.use(gl); fbo.bind(gl); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glViewport(offsetx, offsety, width, height); shader.use(gl); updateligths(gl, shader); scene(gl, shader, show); shadertess.use(gl); updateligths(gl, shadertess); scenetess((GL3) gl, shadertess); shadertess.unuse(gl); fbo.unbind(gl); gl.glFlush(); }
public void attachDepthRBO(GL2GL3 gl, int width, int height) { int[] id = new int[1]; gl.glGenRenderbuffers(1, id, 0); rboid = id[0]; gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, rboid); gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER, GL2.GL_DEPTH_COMPONENT, width, height); gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, 0); gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, fboid); gl.glFramebufferRenderbuffer( GL2.GL_FRAMEBUFFER, GL2.GL_DEPTH_ATTACHMENT, GL2.GL_RENDERBUFFER, rboid); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, 0); }
public void updatelights( GL2GL3 gl, int uniformlightsview, int uniformlightsproj, int uniformlightscolor, int uniformlightsattr, int uniformlightcount) { FloatBuffer lightspos = FloatBuffer.allocate(16 * realLightcount); FloatBuffer lightsproj = FloatBuffer.allocate(16 * realLightcount); FloatBuffer lightscolor = FloatBuffer.allocate(4 * realLightcount); IntBuffer lightsattr = IntBuffer.allocate(4 * realLightcount); for (int i = 0; i < realLightcount; i++) { FloatBuffer tmp = lights.get(i).getMatrixf(GL2.GL_MODELVIEW); // putするときにFloatBufferの位置が動いていけないのでmark()とreset()を行う。 tmp.mark(); lightspos.put(tmp); tmp.reset(); tmp = lights.get(i).getMatrixf(GL2.GL_PROJECTION); tmp.mark(); lightsproj.put(tmp); tmp.reset(); lightscolor.put(lights.get(i).color()); lightscolor.put((float) lights.get(i).intensity); lightsattr.put(lights.get(i).attr()); } lightspos.rewind(); lightsproj.rewind(); lightscolor.rewind(); lightsattr.rewind(); gl.glUniformMatrix4fv(uniformlightsview, realLightcount, false, lightspos); gl.glUniformMatrix4fv(uniformlightsproj, realLightcount, false, lightsproj); gl.glUniform2i(uniformlightcount, realLightcount, virtualLightcount); gl.glUniform4fv(uniformlightscolor, realLightcount, lightscolor); gl.glUniform4iv(uniformlightsattr, realLightcount, lightsattr); }
public void ShadowMap(GL2GL3 gl, boolean show) { smapfbo.bind(gl); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glViewport(0, 0, smapwidth, smapheight); shadowmapshadertess.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadowmapshadertess.getID(), "stage"), 0); smapupdatelightstess(gl); scenetess((GL4) gl, shadowmapshadertess); shadowmapshader.use(gl); gl.glUniform1i(gl.glGetUniformLocation(shadowmapshader.getID(), "stage"), 0); smapupdatelights(gl); scene(gl, shadowmapshader, show); gl.glFlush(); smapfbo.unbind(gl); Shader.unuse(gl); }
public FBO(GL2GL3 gl) { int[] id = new int[1]; gl.glGenFramebuffers(1, id, 0); fboid = id[0]; }
public void attachDepth(GL2GL3 gl, TextureBase tex) { gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, fboid); gl.glFramebufferTextureARB(GL2.GL_FRAMEBUFFER, GL2.GL_DEPTH_ATTACHMENT, tex.getTexID(), 0); gl.glEnable(GL2.GL_DEPTH_TEST); }
public void bind(GL2GL3 gl) { gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, fboid); gl.glDrawBuffers(attachcount, COLOR_ATTACHMENTS, 0); }
public static void unbind(GL2GL3 gl) { gl.glDrawBuffers(1, COLOR_ATTACHMENTS, 0); gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, 0); }
public void initShadowmap(GL2GL3 gl, int lightcount, int width, int height) { initLight(lightcount); Ctrlpanel.getInstance().addLightCtrl(realLightcount, this); smapwidth = width; smapheight = height; Tex2DArray shadowmap = new Tex2DArray( GL2.GL_RGB16, GL2.GL_RGB, GL.GL_FLOAT, smapwidth, smapheight, realLightcount, GL.GL_LINEAR, "shadowmap"); Tex2DArray shadowmapdepth = new Tex2DArray( GL2.GL_DEPTH_COMPONENT, GL2.GL_DEPTH_COMPONENT, GL.GL_FLOAT, smapwidth, smapheight, realLightcount, GL.GL_LINEAR, "shadowmapdepth"); shadowmap.init(gl); shadowmapdepth.init(gl); shadowmapB = tum.bind(gl, shadowmap); smapfbo = new FBO(gl); smapfbo.attachTexture(gl, shadowmapB); smapfbo.attachDepth(gl, shadowmapdepth); /*シャドウマップ*/ shadowmapshader = new Shader( "resources/ShaderSource/BaseShaders/Shadowmap/vertsimple.c", null, null, smapgsrc, smapfsrc); shadowmapshader.init(gl); shadowmapshader.use(gl); uniformlightsview = gl.glGetUniformLocation(shadowmapshader.getID(), "lightsview"); uniformlightsproj = gl.glGetUniformLocation(shadowmapshader.getID(), "lightsproj"); uniformlightscolor = gl.glGetUniformLocation(shadowmapshader.getID(), "lightscolor"); uniformlightsattr = gl.glGetUniformLocation(shadowmapshader.getID(), "lightsattr"); uniformlightcount = gl.glGetUniformLocation(shadowmapshader.getID(), "lightcount_real_virtual"); /*シャドウマップテッセレーション*/ shadowmapshadertess = new Shader(smapvsrc, smapcsrc, smapesrc, smapgsrc, smapfsrc); shadowmapshadertess.init(gl); shadowmapshadertess.use(gl); uniformlightsviewtess = gl.glGetUniformLocation(shadowmapshadertess.getID(), "lightsview"); uniformlightsprojtess = gl.glGetUniformLocation(shadowmapshadertess.getID(), "lightsproj"); uniformlightscolortess = gl.glGetUniformLocation(shadowmapshadertess.getID(), "lightscolor"); uniformlightsattrtess = gl.glGetUniformLocation(shadowmapshader.getID(), "lightsattr"); uniformlightcounttess = gl.glGetUniformLocation(shadowmapshadertess.getID(), "lightcount_real_virtual"); }
public void updatePVMatrixtess(GL2GL3 gl) { shadertess.use(gl); gl.glUniformMatrix4fv(uniformviewtess, 1, false, pvmat.glGetMatrixf(GL2.GL_MODELVIEW)); gl.glUniformMatrix4fv(uniformprojtess, 1, false, pvmat.glGetMatrixf(GL2.GL_PROJECTION)); Shader.unuse(gl); }
public void attachTexture(GL2GL3 gl, TexBindSet tbs) { gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, fboid); gl.glFramebufferTextureARB( GL2.GL_FRAMEBUFFER, COLOR_ATTACHMENTS[attachcount], tbs.tex.getTexID(), 0); attachcount++; }