Jump to content
  • Advertisement

blizzblang

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

107 Neutral

About blizzblang

  • Rank
    Newbie
  1. blizzblang

    LWJGL OpenGL Light cutoff

    Here's my main class source package main.game; import static org.lwjgl.opengl.GL11.*; import java.awt.Shape; import java.io.File; import java.nio.FloatBuffer; import main.Interactive.Shape.ShapeType; import main.game.VBO.RenderType; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GLContext; import org.lwjgl.util.glu.GLU; import org.lwjgl.util.vector.Matrix4f; import org.newdawn.slick.Color; public class Main { public static KeyInput keyin = new KeyInput(); public static GameLoop MainLoop = new GameLoop(); public static TexLoader Texdr = new TexLoader(); public static void main(String[] args) { Main start = new Main(); start.preLoopSetup(); start.StartLoop(); } public void preLoopSetup() { Data.getSystemUsage(); OpenGL.setupDisplay(800, 600, false); OpenGL.create(); OpenGL.initOpenGL(); OpenGL.clearBuffers(); Display.setVSyncEnabled(true); Mouse.setGrabbed(true); glFrontFace( GL_CW ); glCullFace(GL_FRONT); glEnable(GL_CULL_FACE); } public void StartLoop() { Camera c = new Camera(2, 2, 5.0f, keyin, 90); Model mod = new Model(new File("models/monkey.obj"),new double[]{0,0,0}); Model floor = new Model(new File("models/floor.obj"),new double[]{0,0,0}); c.applyPerspectiveMatrix(); glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(2.5f, 0f); glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glLightModel(GL_LIGHT_MODEL_AMBIENT,asFlippedFloatBuffer(new float[]{0.5f, 0.5f, 0.5f, 0f})); glLight(GL_LIGHT1,GL_DIFFUSE,asFlippedFloatBuffer(new float[]{1.0f, 1.0f, 1.0f, 1f})); glLight(GL_LIGHT1, GL_POSITION, asFlippedFloatBuffer(new float[]{0, 0, 5, 1})); glLightf(GL_LIGHT1,GL_SPOT_CUTOFF,45f); glLightf(GL_LIGHT1,GL_SPOT_EXPONENT,0.0f); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glShadeModel(GL_FLAT); float a=-1; float[] LightDir = new float[]{1,0,0,0}; float[] LightPos = new float[]{0,0,0,1}; while(!Display.isCloseRequested()) { OpenGL.clearBuffers(); c.update(); c.rotateView(); glLight(GL_LIGHT1,GL_SPOT_DIRECTION,asFlippedFloatBuffer(LightDir)); glLight(GL_LIGHT1,GL_POSITION,asFlippedFloatBuffer(LightPos)); keyin.Update(); floor.render(); Display.update(); Display.sync(30); } } public static FloatBuffer asFlippedFloatBuffer(float[] values) { FloatBuffer buffer = BufferUtils.createFloatBuffer(values.length); buffer.put(values); buffer.flip(); return buffer; } }
  2. blizzblang

    LWJGL OpenGL Light cutoff

    To remove any idea that it has to do with bad normals, I've made a sphere with inverted normals, and put the light inside. The light will rotate with GL_SPOTLIGHT_DIRECTION normal, but when the vector ( GL_SPOTLIGHT_DIRECTION ) points anywhere to the positive Z axis, it clips, cuts, ignores ( don't know what to call it ) the light it should produce there. Both images are taken outside the radius of the sphere, and the only difference between them is the GL_SPOTLIGHT_DIRECTION vector.  The 1st one ( looks normal ) is set to {0,0,-1,0} https://www.dropbox.com/s/qz2kyybplzimb4d/Proof_1.jpg?dl=0 The 2nd one ( looks cut off ) is set too {1,0,0,0}  https://www.dropbox.com/s/58pyt1x1g2uve2y/Proof_2.jpg?dl=0 If the light where to be set to {anynumber,anynumber , anynumber > 0 , 0 } it wont draw any light whatsoever. 
  3. blizzblang

    LWJGL OpenGL Light cutoff

    It says that in the post... "Without per-pixel shader" , and "with per-pixel shader". I'm more concerned why my spotlights are limited to half a circle
  4. blizzblang

    LWJGL OpenGL Light cutoff

    Sadly no, I made the plane in blender, and checked the normals. I've also made an inverted sphere, with the same results.
  5. Trying to get a spotlight to work in OpenGL, no matter what I do it only draws the light within a 180 degree semi-circle, the picture shows the light on the border. Lighting Inilization code:   glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glLightModel(GL_LIGHT_MODEL_AMBIENT,asFlippedFloatBuffer(new float[]{0.5f, 0.5f, 0.5f, 1f})); glLight(GL_LIGHT0,GL_DIFFUSE,asFlippedFloatBuffer(new float[]{1.0f, 1.0f, 1.0f, 1f})); glLight(GL_LIGHT0, GL_POSITION, asFlippedFloatBuffer(new float[]{0, 0, 5, 1})); glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,45f); glLightf(GL_LIGHT0,GL_SPOT_EXPONENT,0.0f); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glShadeModel(GL_SMOOTH); Code ran every loop:   glLight(GL_LIGHT0,GL_SPOT_DIRECTION,asFlippedFloatBuffer(LightDir)); glLight(GL_LIGHT0,GL_POSITION,asFlippedFloatBuffer(LightPos)); Misc:   float[] LightDir = new float[]{0,-1,0,1}; float[] LightPos = new float[]{0,5,0,1}; Heres what it looks like: Without per-pixel shader with per-pixel shader Has anyone seen this before? What needs to be done to fix. I haven't gotten it to successfully work at all
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!