List of usage examples for org.lwjgl.opengl ARBShaderObjects glUniform4fARB
public static native void glUniform4fARB(@NativeType("GLint") int location, @NativeType("GLfloat") float v0, @NativeType("GLfloat") float v1, @NativeType("GLfloat") float v2, @NativeType("GLfloat") float v3);
From source file:com.a2client.corex.ShaderUniform.java
License:Open Source License
public void setValue(Vec4f data) { if (ID != -1) { if (Type == Const.SHADER_UNIFORM_TYPE.utVec4) ARBShaderObjects.glUniform4fARB(ID, data.x, data.y, data.z, data.w); else//from www.ja va 2 s.c om Log.error("shader unifrorm set wrong val" + Type + " must be utVec4"); } }
From source file:com.ardor3d.scene.state.lwjgl.shader.LwjglShaderUtil.java
License:Open Source License
private static void updateShaderUniform(final ShaderVariableFloat4 shaderUniform) { ARBShaderObjects.glUniform4fARB(shaderUniform.variableID, shaderUniform.value1, shaderUniform.value2, shaderUniform.value3, shaderUniform.value4); }
From source file:com.mtbs3d.minecrift.VRRenderer.java
License:LGPL
private void doDistortionAndSuperSample() { int FBWidth = this.mc.displayFBWidth; int FBHeight = this.mc.displayFBHeight; if (this.mc.vrSettings.useDistortion || this.mc.vrSettings.useSupersample || this.mc.vrSettings.useFXAA) { // Setup ortho projection GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();// w w w . j ava 2 s .c om GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -0.7f); } if (this.mc.vrSettings.useSupersample) { FBWidth = (int) ceil(this.mc.displayFBWidth * this.mc.vrSettings.superSampleScaleFactor); FBHeight = (int) ceil(this.mc.displayFBHeight * this.mc.vrSettings.superSampleScaleFactor); } if (mc.vrSettings.useDistortion) { //mc.checkGLError("Before distortion"); preDistortionFBO.bindTexture(); if (this.mc.vrSettings.useFXAA) { //chain into the FXAA FBO fxaaFBO.bindRenderTarget(); } else if (this.mc.vrSettings.useSupersample) { //chain into the superSample FBO postDistortionFBO.bindRenderTarget(); } else { unbindFBORenderTarget(); } GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.5f); GL11.glClearDepth(1.0D); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black // Render onto the entire screen framebuffer GL11.glViewport(0, 0, FBWidth, FBHeight); // Set the distortion shader as in use ARBShaderObjects.glUseProgramObjectARB(_Distortion_shaderProgramId); // Set up the fragment shader uniforms ARBShaderObjects.glUniform1iARB(_DistortionShader_RenderTextureUniform, 0); if (this.mc.vrSettings.useDistortionTextureLookupOptimisation) { distortParams.bindTexture_Unit1(); ARBShaderObjects.glUniform1iARB(_DistortionShader_DistortionMapUniform, 1); } ARBShaderObjects.glUniform1iARB(_DistortionShader_half_screenWidthUniform, distortParams.half_screenWidth); ARBShaderObjects.glUniform2fARB(_DistortionShader_LeftLensCenterUniform, distortParams.leftLensCenterX, distortParams.leftLensCenterY); ARBShaderObjects.glUniform2fARB(_DistortionShader_RightLensCenterUniform, distortParams.rightLensCenterX, distortParams.rightLensCenterY); ARBShaderObjects.glUniform2fARB(_DistortionShader_LeftScreenCenterUniform, distortParams.leftScreenCenterX, distortParams.leftScreenCenterY); ARBShaderObjects.glUniform2fARB(_DistortionShader_RightScreenCenterUniform, distortParams.rightScreenCenterX, distortParams.rightScreenCenterY); ARBShaderObjects.glUniform2fARB(_DistortionShader_ScaleUniform, distortParams.scaleX, distortParams.scaleY); ARBShaderObjects.glUniform2fARB(_DistortionShader_ScaleInUniform, distortParams.scaleInX, distortParams.scaleInY); ARBShaderObjects.glUniform4fARB(_DistortionShader_HmdWarpParamUniform, distortParams.DistortionK[0], distortParams.DistortionK[1], distortParams.DistortionK[2], distortParams.DistortionK[3]); ARBShaderObjects.glUniform4fARB(_DistortionShader_ChromAbParamUniform, distortParams.ChromaticAb[0], distortParams.ChromaticAb[1], distortParams.ChromaticAb[2], distortParams.ChromaticAb[3]); drawQuad(); // Stop shader use ARBShaderObjects.glUseProgramObjectARB(0); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); //mc.checkGLError("After distortion"); } if (this.mc.vrSettings.useFXAA) { fxaaFBO.bindTexture(); if (this.mc.vrSettings.useSupersample) { //chain into the superSample FBO postDistortionFBO.bindRenderTarget(); } else { unbindFBORenderTarget(); } GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.5f); GL11.glClearDepth(1.0D); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black // Render onto the entire screen framebuffer GL11.glViewport(0, 0, FBWidth, FBHeight); // Set the distortion shader as in use ARBShaderObjects.glUseProgramObjectARB(_FXAA_shaderProgramId); // Set up the fragment shader uniforms ARBShaderObjects.glUniform1iARB(_FXAA_RenderTextureUniform, 0); ARBShaderObjects.glUniform2fARB(_FXAA_RenderedTextureSizeUniform, (float) FBWidth, (float) FBHeight); drawQuad(); // Stop shader use ARBShaderObjects.glUseProgramObjectARB(0); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); //ShaderHelper.checkGLError("After fxaa"); } if (this.mc.vrSettings.useSupersample) { // Now switch to 1st pass target framebuffer postSuperSampleFBO.bindRenderTarget(); // Bind the FBO postDistortionFBO.bindTexture(); GL11.glClearColor(0.0f, 0.0f, 1.0f, 0.5f); GL11.glClearDepth(1.0D); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black // Render onto the entire screen framebuffer GL11.glViewport(0, 0, this.mc.displayFBWidth, FBHeight); // Set the downsampling shader as in use ARBShaderObjects.glUseProgramObjectARB(_Lanczos_shaderProgramId); // Set up the fragment shader uniforms ARBShaderObjects.glUniform1fARB(_LanczosShader_texelWidthOffsetUniform, 1.0f / (3.0f * (float) this.mc.displayFBWidth)); ARBShaderObjects.glUniform1fARB(_LanczosShader_texelHeightOffsetUniform, 0.0f); ARBShaderObjects.glUniform1iARB(_LanczosShader_inputImageTextureUniform, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // Pass 1 drawQuad(); // mc.checkGLError("After Lanczos Pass1"); // Pass 2 // Now switch to 2nd pass screen framebuffer unbindFBORenderTarget(); postSuperSampleFBO.bindTexture(); GL11.glViewport(0, 0, this.mc.displayFBWidth, this.mc.displayFBHeight); GL11.glClearColor(0.0f, 0.0f, 1.0f, 0.5f); GL11.glClearDepth(1.0D); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Bind the texture GL13.glActiveTexture(GL13.GL_TEXTURE0); // Set up the fragment shader uniforms for pass 2 ARBShaderObjects.glUniform1fARB(_LanczosShader_texelWidthOffsetUniform, 0.0f); ARBShaderObjects.glUniform1fARB(_LanczosShader_texelHeightOffsetUniform, 1.0f / (3.0f * (float) this.mc.displayFBHeight)); ARBShaderObjects.glUniform1iARB(_LanczosShader_inputImageTextureUniform, 0); drawQuad(); // Stop shader use ARBShaderObjects.glUseProgramObjectARB(0); // mc.checkGLError("After Lanczos Pass2"); } }
From source file:flash.display.Shader.java
License:Open Source License
public void JITB$bind(double x, double y, double width, double height, boolean flipY) { if (ShaderUtil.shaderSupport()) { ARBShaderObjects.glUseProgramObjectARB(programId()); final int location = ARBShaderObjects.glGetUniformLocationARB(programId(), "PB_OFFSET"); if (flipY) { ARBShaderObjects.glUniform4fARB(location, (float) x, (float) y, (float) height, -1.0f); } else {/* w ww.j a va 2 s.c om*/ ARBShaderObjects.glUniform4fARB(location, (float) x, (float) y, 0.0f, 1.0f); } if (null != data()) { data().JITB$applyParameters(programId()); } } else { throw new RuntimeException("Sorry, no shaders supported on your system."); } }
From source file:flash.display.ShaderParameter.java
License:Open Source License
public void JITB$applyParameter(final int programId) { final int location = ARBShaderObjects.glGetUniformLocationARB(programId, name()); if (_type.equals(ShaderParameterType.FLOAT)) { ARBShaderObjects.glUniform1fARB(location, getFloat(0)); } else if (_type.equals(ShaderParameterType.FLOAT2)) { ARBShaderObjects.glUniform2fARB(location, getFloat(0), getFloat(1)); } else if (_type.equals(ShaderParameterType.FLOAT3)) { ARBShaderObjects.glUniform3fARB(location, getFloat(0), getFloat(1), getFloat(2)); } else if (_type.equals(ShaderParameterType.FLOAT4)) { ARBShaderObjects.glUniform4fARB(location, getFloat(0), getFloat(1), getFloat(2), getFloat(3)); }// w w w . j a v a 2s. co m }
From source file:lessur.util.shader.ShaderManager.java
License:GNU General Public License
/** * /*from w w w .j a v a 2 s . c o m*/ * @param program ID/index of the program * @param name Name of the variable * @param value Value to set the variable */ public void setUniformFloatArray(int program, String name, float values[]) { if (has_opengl2) { int loc = GL20.glGetUniformLocation(program, name); checkVariableLocation(loc, name); if (values.length == 1) GL20.glUniform1f(loc, values[0]); if (values.length == 2) GL20.glUniform2f(loc, values[0], values[1]); else if (values.length == 3) GL20.glUniform3f(loc, values[0], values[1], values[2]); else if (values.length == 4) GL20.glUniform4f(loc, values[0], values[1], values[2], values[3]); } else if (has_arb) { int loc = ARBShaderObjects.glGetUniformLocationARB(program, name); checkVariableLocation(loc, name); if (values.length == 1) ARBShaderObjects.glUniform1fARB(loc, values[0]); if (values.length == 2) ARBShaderObjects.glUniform2fARB(loc, values[0], values[1]); else if (values.length == 3) ARBShaderObjects.glUniform3fARB(loc, values[0], values[1], values[2]); else if (values.length == 4) ARBShaderObjects.glUniform4fARB(loc, values[0], values[1], values[2], values[3]); } }
From source file:zildo.fwk.gfx.PixelShaders.java
License:Open Source License
/** * Set pixel shader parameter./* w w w.ja va 2 s .com*/ * @param pixelShaderId * @param uniformName * @param color */ public void setParameter(int pixelShaderIndex, String uniformName, Vector4f color) { ByteBuffer name = toByteString(uniformName, true); int psId = tabPixelShaders[pixelShaderIndex]; int location = ARBShaderObjects.glGetUniformLocationARB(psId, name); ARBShaderObjects.glUniform4fARB(location, color.x, color.y, color.z, color.w); }
From source file:zildo.platform.opengl.LwjglPixelShaders.java
License:Open Source License
@Override protected void doSetParameter(int psId, ByteBuffer name, Vector4f color) { int location = ARBShaderObjects.glGetUniformLocationARB(psId, name); ARBShaderObjects.glUniform4fARB(location, color.x, color.y, color.z, color.w); }