Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
  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);
  }
Esempio n. 5
0
 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"));
 }
Esempio n. 6
0
 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));
 }
Esempio n. 7
0
  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();
  }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
  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);
  }
Esempio n. 10
0
  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();
  }
Esempio n. 11
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);
  }
Esempio n. 12
0
  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);
  }
Esempio n. 13
0
 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);
 }
Esempio n. 14
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");
  }