public void init(GLAutoDrawable drawable) { drawable.setGL(new DebugGL2(drawable.getGL().getGL2())); final GL2 gl = drawable.getGL().getGL2(); // drawable.getGL().getGL2(); gl.glViewport(0, 0, SCREENW, SCREENH); // Clear color buffer with black // gl.glClearColor(1.0f, 0.5f, 1.0f, 1.0f); gl.glClearColor(.0f, .0f, .0f, 1.0f); gl.glClearDepth(1.0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); gl.glCreateShader(GL2GL3.GL_VERTEX_SHADER); shader.init(gl); int programName = shader.getID(); gl.glBindAttribLocation(programName, Object3D.VERTEXPOSITION, "inposition"); gl.glBindAttribLocation(programName, Object3D.VERTEXCOLOR, "incolor"); gl.glBindAttribLocation(programName, Object3D.VERTEXNORMAL, "innormal"); gl.glBindAttribLocation(programName, Object3D.VERTEXTEXCOORD0, "intexcoord0"); shader.link(gl); uniformMat = gl.glGetUniformLocation(programName, "mat"); uniformLight = gl.glGetUniformLocation(programName, "lightdir"); gl.glUseProgram(programName); gl.glUniform3f(uniformLight, 0f, 10f, -10f); obj.init(gl, mats, programName); gl.glUseProgram(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 init(GL2GL3 gl) { timer.init(gl); smapfbo = new FBO(gl); texviewer = new TexViewer(); texviewer.init(gl); fxaa = new Filter("resources/ShaderSource/FXAA/vert.c", "resources/ShaderSource/FXAA/frag.c"); fxaa.init(gl); // String filepath = "/home/michael/zheng/Programs/WeatherData/2009100718/"; String filepath = "/home/michael/zheng/Programs/WeatherData/2009100818/"; // String filepath = "/home/michael/zheng/Programs/WeatherData/2008061418/"; // initTestData(gl); scene = new Scene1(); scene.initShadowmap(gl, 2, SHADOWMAPWIDTH, SHADOWMAPHEIGHT); for (int i = 0; i < scene.lightCount(); i++) { scene.lights.get(i).init(gl); // float angle = 2 * (float)Math.PI * i / (scene.lightCount() - 1); // //scene.lights.get(i).lookat(3, 3, i + 1, 0, 0, 0, 0, 1, 0); // scene.lights.get(i).lookat(6*(float)Math.sin(angle), 6*(float)Math.cos(angle), 8, // 0, 0, 0, 0, 1, 0); // scene.lights.get(i).perspectivef(120f, 1, 0.1f, 50f); } scene.lights.get(0).lookatd(4, 4, 10, 0, 0, 0, 0, 1, 0); // scene.lights.get(0).lookatd(0, 0, 50, 0, 0, 0, 0, 1, 0); scene.lights.get(0).orthof(-4, 4, -4, 4, 0, 60); scene.lights.get(0).setattr(0, 1); scene.lights.get(0).setintensity(1.25); // scene.lights.get(2).lookatd(4, 4, 10, 0, 0, 0, 0, 1, 0); // scene.lights.get(2).orthof(-5, 5, -5, 5, 0, 30); scene.lights.get(1).lookatd(4, -4, 10, 0, 0, 0, 0, 1, 0); scene.lights.get(1).orthof(-4, 4, -4, 4, 0, 100); // scene.lights.get(2).lookatd(0, 0, 50, 0, 0, 0, 0, 1, 0); // scene.lights.get(2).orthof(-5, 5, -5, 5, 0, 100); shader = new Shader( "resources/ShaderSource/BaseShaders/SimpleShader/vert.c", null, null, null, "resources/ShaderSource/BaseShaders/SimpleShader/frag.c"); shader.init(gl); shadowmapping = new Shader( "resources/ShaderSource/ShadowMapping/vert.c", null, null, "resources/ShaderSource/ShadowMapping/geom.c", "resources/ShaderSource/ShadowMapping/fragsimple.c"); shadowmapping.init(gl); shadowmapping.use(gl); // tess evalシェーダーはシャドウマップのものを使う shadowmappingtess = new Shader( "resources/ShaderSource/ShadowMapping/vert.c", "resources/ShaderSource/ShadowMapping/ctrl.c", "resources/ShaderSource/BaseShaders/Shadowmap/eval.c", "resources/ShaderSource/ShadowMapping/geom.c", "resources/ShaderSource/ShadowMapping/frag.c"); shadowmappingtess.init(gl); tex = new Tex2D( GL2.GL_RGBA, GL2.GL_RGBA, GL2.GL_FLOAT, 1024, 1024, GL2.GL_LINEAR, GL2.GL_REPEAT, GL2.GL_REPEAT, null, "testimage"); tex.init(gl); tbs = new TexBindSet(tex); tbs.bind(gl); // scene.updateligths(gl, shadowmapping); // scene.lookat(0, 0, 30, 0, 0, 0, 0, 1, 0); // scene.orthof(proj[0], proj[1], proj[2], proj[3], 0, 100); // initの場所はあとで調整 scene.init(gl, shadowmapping, shadowmappingtess); // 円柱オフ scene.shader1i(gl, 0, "offheight"); fbo = new FBO(gl); fbo.attachTexture(gl, tbs); fbo.attachDepthRBO(gl, 1024, 1024); // */ initSceneOrganizer(gl); Ctrlpanel.currentSO = currentSO; }