Jump to content

Rendering sometimes too dark, changes with camera angle


Reika

Recommended Posts

When I render things with OpenGL directly, sometimes they render too dark, like my GLcolor command was set to about 70% the given values. It is a function of the camera angle and position, and if I move carefully, I can reproduce it on demand once discovering a "trigger angle". Is this related to how sometimes my TileEntities render as if they were in full blackness, often controlled by the same thing? For what it is worth, disabling GLBlend makes it ALWAYS too dark.

 

My code:

            		ModLoader.getMinecraftInstance().entityRenderer.disableLightmap(1);
            	        GL11.glPushMatrix();
            	        GL11.glTranslated(p2, p4+2, p6+1);
            	        GL11.glScalef(1.0F, -1.0F, -1.0F);
            	        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
            	        GL11.glPopMatrix(); 
            	    	GL11.glDisable(GL11.GL_LIGHTING);
            	    	GL11.glEnable(GL11.GL_BLEND);
            	    	GL11.glDisable(GL11.GL_TEXTURE_2D);
            	    	GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            	    	GL11.glEnable(GL11.GL_CULL_FACE);
            	    	GL11.glDisable(GL11.GL_DEPTH_TEST);
            	    	GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
            	    	//GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
            			GL11.glPointSize(2F);
            			GL11.glBegin(GL11.GL_POINTS);
            			double[] color = new double[3];
            			int sc = 16;
            			int a = Math.abs(i);
            			int b = Math.abs(j);
            			int c = Math.abs(k);
            			//ReikaJavaLibrary.pConsole(i+"   "+j+"   "+k);
            			color[0] = (a%sc)/(double)sc;
            			color[1] = (b%sc)/(double)sc;
            			color[2] = (c%sc)/(double)sc;
            			if (ReikaArrayHelper.sumArray(color) < 0.25) {
            				color[0] *= 4;
            				color[1] *= 4;
            				color[2] *= 4;
            			}
            			if (ReikaArrayHelper.sumArray(color) < 0.5) {
            				color[0] *= 2;
            				color[1] *= 2;
            				color[2] *= 2;
            			}
            			GL11.glColor3d(color[0], color[1], color[2]);
            			GL11.glVertex3d(p2+i, p4+j, p6+k);
            			double spread = 0*0.03125/8;
            			if (spread > 0) {
            			for (double m = -spread; m <= spread; m+= spread/2D) {
                			for (double l = -spread; l <= spread; l+= spread/2D) {
                    			for (double n = -spread; n <= spread; n+= spread/2D) {
                    				GL11.glVertex3d(p2+i+m, p4+j+l, p6+k+n);
                    			}
                			}
            			}
            			}
            			GL11.glEnd();
            			GL11.glEnable(GL11.GL_TEXTURE_2D);
            	    	        GL11.glEnable(GL11.GL_DEPTH_TEST);
            			ModLoader.getMinecraftInstance().entityRenderer.enableLightmap(1);

 

Desired Colors:

wsImLs1.png

 

Dark rendering (notice the slight turn to the right):

sRWBtXP.png

Link to comment
Share on other sites

I hope that will help.

        float f = block.getBlockBrightness(world, i, j, k);
        tessellator.setColorOpaque_F(f, f, f);
        
        int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2); 

Don't forget pressing "Thank you" if it does...

 

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Link to comment
Share on other sites

No replies, and less than 20 views, even after 3 days? Does noone have any ideas?

 

Did you already try RenderHelper.disableStandardItemLighting(); before you render your stuff?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

@Naitenne:

That code assumes I am using the Tessellator, which I am not (due to overhead reasons). I am using OpenGL directly. Also, I want full brightness all the time, not one calculated based on other lighting.

 

No replies, and less than 20 views, even after 3 days? Does noone have any ideas?

Did you already try RenderHelper.disableStandardItemLighting(); before you render your stuff?

I used disableEntityLighting as the render code is found in my TileEntity render file, but disabling Item Lighting as well seems to have fixed the problem. Why would item lighting be relevant when rendering a TileEntity?

Thank you for helping me nonetheless. :D

Link to comment
Share on other sites

@Naitenne:

That code assumes I am using the Tessellator, which I am not (due to overhead reasons). I am using OpenGL directly. Also, I want full brightness all the time, not one calculated based on other lighting.

 

No replies, and less than 20 views, even after 3 days? Does noone have any ideas?

Did you already try RenderHelper.disableStandardItemLighting(); before you render your stuff?

I used disableEntityLighting as the render code is found in my TileEntity render file, but disabling Item Lighting as well seems to have fixed the problem. Why would item lighting be relevant when rendering a TileEntity?

Thank you for helping me nonetheless. :D

 

Did you look what the method does? It just disables some OpenGL stuff regarding lightning. So don't get confused by that name ^^

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

That code assumes I am using the Tessellator, which I am not (due to overhead reasons). I am using OpenGL directly. Also, I want full brightness all the time, not one calculated based on other lighting.
Okay, just use second part of that.

int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2);  

Also, you can write Tessellator tessellator = Tessellator.instance; and still use your OGL renderer.

And as renderer updates frequently, you will have dynamic lighting. Trust me.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Link to comment
Share on other sites

That code assumes I am using the Tessellator, which I am not (due to overhead reasons). I am using OpenGL directly. Also, I want full brightness all the time, not one calculated based on other lighting.
Okay, just use second part of that.

int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2);  

Also, you can write Tessellator tessellator = Tessellator.instance; and still use your OGL renderer.

And as renderer updates frequently, you will have dynamic lighting. Trust me.

Again:

[*]The tessellator slows everything down when you need to render 40000 points

[*]I want no lighting at all - permanent full brightness no matter what

[*]My problem is not lighting that is controlled by the environment, but that which seems controlled by camera relative angle and position alone

Also, as above, SAP's solution seems to be working.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.