Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (800)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  shader not working on my machine  (Read 13289 times)
0 Members and 1 Guest are viewing this topic.
Offline minigame

Senior Devvie


Medals: 14
Projects: 1


LWJGLException


« Posted 2015-02-21 20:43:28 »

Before you tell me to update my drivers, I have. And the highest my machine will update to is:
OpenGL Version: 2.1.0 - Build 8.15.10.2086

Here's the vertex shader code.. it just wont compile for me
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
attribute vec3 vertex;
attribute vec2 texturecoordinate;
uniform vec3 rotation;
uniform vec3 translation;
uniform vec3 rotation_centre;
void main() {

   vec3 adjusted = vertex + translation;
   
   if (rotation.x != 0 || rotation.y != 0 || rotation.z != 0) {
      adjusted -= rotation_centre;
      float cosx = cos(rotation.x);
      float sinx = sin(rotation.x);
      float cosy = cos(rotation.y);
      float siny = sin(rotation.y);
      float cosz = cos(rotation.z);
      float sinz = sin(rotation.z);
      float nx = adjusted.x;
      float ny = (adjusted.y * cosx) - (adjusted.z * sinx);
      float nz = (adjusted.y * sinx) + (adjusted.z * cosx);
      float cz = (nz * cosy) - (nx * siny);
      float cx = (nz * siny) + (nx * cosy);
      float cy = ny;
      nx = (cx * cosz) - (cy * sinz);
      ny = (cx * sinz) + (cy * cosz);
      nz = cz;
      adjusted = vec3(nx,ny,nz) + rotation_centre;
   }
   
   vec4 mvv = gl_ModelViewMatrix * vec4(adjusted, 1.0);
   gl_Position = gl_ProjectionMatrix *  mvv;
   
}


Here is the error when I try to compile the vertex shader using RenderMonkey

Direct image link: http://i.imgur.com/wZ0vvWk.jpg

while (!deadFromWork) {
    if (hasItem("Dry Erase Board")) {
        chanceOfSuccess++;// Based on a true story..
    }
}
Offline HeroesGraveDev

JGO Kernel


Medals: 383
Projects: 11
Exp: 4 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #1 - Posted 2015-02-21 20:46:44 »

The most important part of the error message is cut off in your screenshot but you could try replacing the
0
s with
0.0
s.

Offline pitbuller
« Reply #2 - Posted 2015-02-21 21:00:16 »

Why you are doing uniform transform matrix math manually per vertex? Build up one mat4 at cpu containing all transformations and concanate that with view projection.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lcass
« Reply #3 - Posted 2015-02-21 21:06:34 »

Why you are doing uniform transform matrix math manually per vertex? Build up one mat4 at cpu containing all transformations and concanate that with view projection.
There is a method that functions like that , this is for testing. The error message says != is not supported
Offline minigame

Senior Devvie


Medals: 14
Projects: 1


LWJGLException


« Reply #4 - Posted 2015-02-21 21:46:28 »

The most important part of the error message is cut off in your screenshot but you could try replacing the
0
s with
0.0
s.

That actually helped with 1 of 2 Eclipse debug errors. I'll run the code through RenderMonkey and get a full screen shot of the error too for you:

Direct img url: http://i.imgur.com/noXZ3iW.jpg

Sorry if the error is completely amateur I really don't know much about shaders at all. I've always paid people to write them for my programs due to lack of study time...

Updated shader code, all that's different is the 0 are now 0.0
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
attribute vec3 vertex;
attribute vec2 texturecoordinate;
uniform vec3 rotation;
uniform vec3 translation;
uniform vec3 rotation_centre;

void main() {

   vec3 adjusted = vertex + translation;
   
   if (rotation.x != 0.0 || rotation.y != 0.0 || rotation.z != 0.0) {
      adjusted -= rotation_centre;
      float cosx = cos(rotation.x);
      float sinx = sin(rotation.x);
      float cosy = cos(rotation.y);
      float siny = sin(rotation.y);
      float cosz = cos(rotation.z);
      float sinz = sin(rotation.z);
      float nx = adjusted.x;
      float ny = (adjusted.y * cosx) - (adjusted.z * sinx);
      float nz = (adjusted.y * sinx) + (adjusted.z * cosx);
      float cz = (nz * cosy) - (nx * siny);
      float cx = (nz * siny) + (nx * cosy);
      float cy = ny;
      nx = (cx * cosz) - (cy * sinz);
      ny = (cx * sinz) + (cy * cosz);
      nz = cz;
      adjusted = vec3(nx,ny,nz) + rotation_centre;
   }
   
   vec4 mvv = gl_ModelViewMatrix * vec4(adjusted, 1.0);
   gl_Position = gl_ProjectionMatrix *  mvv;
   
}

while (!deadFromWork) {
    if (hasItem("Dry Erase Board")) {
        chanceOfSuccess++;// Based on a true story..
    }
}
Offline pitbuller
« Reply #5 - Posted 2015-02-21 21:58:24 »

Now your shader compile fine. Rest of bugs are from render monkey.
Offline minigame

Senior Devvie


Medals: 14
Projects: 1


LWJGLException


« Reply #6 - Posted 2015-02-21 22:08:04 »

Now your shader compile fine. Rest of bugs are from render monkey.

In my Eclipse project I am still getting one error, but I'm not sure if this is something the general public could help with since lcass is the author of my wrapper.
But this still prints in my console: "Unable to link shader program:"

Source of error printing:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
   /**
    * Link the shader program to the GPU , must be done before attaching to a
    * Vbo
    */

   public void link() {
      glLinkProgram(programID);
      if (glGetProgrami(programID, GL_LINK_STATUS) == GL_FALSE) {
         System.err.println("Unable to link shader program:");
         dispose();
      }
   }


I'm a bit confused as to how to fix this, since I really don't understand the code itself.

while (!deadFromWork) {
    if (hasItem("Dry Erase Board")) {
        chanceOfSuccess++;// Based on a true story..
    }
}
Offline HeroesGraveDev

JGO Kernel


Medals: 383
Projects: 11
Exp: 4 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #7 - Posted 2015-02-21 22:26:24 »

If you don't understad the code then you either need to put more time into learning it, or use a library that handles it for you.

Offline minigame

Senior Devvie


Medals: 14
Projects: 1


LWJGLException


« Reply #8 - Posted 2015-02-21 22:34:59 »

If you don't understad the code then you either need to put more time into learning it, or use a library that handles it for you.

I only have free time from my job to study programming during the winter season.. the rest of the year I travel to a lot of different states AND I have a toddler. I'm kind of tired of getting "learn what it does, use libgdx, etc etc"... No offence.
There's a reason I'm paying $100s USD to other developers to create a solid foundation for me.. If I had the time I did when I was a teenager, I'd love to learn the background code. But I simply can't..
There's nothing wrong with paying people to write a library and developer tools to my exact specifications. I'd much rather invest money and enjoy the little free time I have writing game play than spending my 1 or 2 days every other week stressing over background code and making 0 progress.

while (!deadFromWork) {
    if (hasItem("Dry Erase Board")) {
        chanceOfSuccess++;// Based on a true story..
    }
}
Offline HeroesGraveDev

JGO Kernel


Medals: 383
Projects: 11
Exp: 4 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #9 - Posted 2015-02-21 22:49:23 »

So... you don't have the time to learn to use OpenGL directly, yet for some reason you don't want to use a library that abstracts that away and would rather waste hours looking for other programmers who can be bothered to do it for you, and then pay them $100s to give you an inferior product to what already exists for free.

It doesn't add up at all.

I get that you don't have a lot of free time, but you're still contradicting yourself.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline minigame

Senior Devvie


Medals: 14
Projects: 1


LWJGLException


« Reply #10 - Posted 2015-02-21 23:01:07 »

So... you don't have the time to learn to use OpenGL directly, yet for some reason you don't want to use a library that abstracts that away and would rather waste hours looking for other programmers who can be bothered to do it for you, and then pay them $100s to give you an inferior product to what already exists for free.

It doesn't add up at all.

I've used libraries such as LibGDX, jPCT, other small stuff from the net/githubs, etc.
I want something extremely lightweight, well documented, and written to MY EXACT specifications so that I can read and understand each and every single function at a later date when I have the available free time.
This isn't a spontaneous idea I came up with over night. I have responsibilities in the real world and I'm doing things a certain way for very specific reasons. My personal library will be able to produce the assets I will need for my upcoming game - saving me money in the long run when it comes to needing models and certain textures.
It is what it is and I'm not really sure why anybody would be concerned about how my project is developed or why I'm doing things the way I do them....  Clueless

Also if I wanted top notch quality I would use a game engine and mitigate the manual coding process completely. This is a part of my life that I do for fun. I'm not trying to create a number one MORPG or knock off of some other game. People spend money on stuff like drugs all the time, if I want to spend money on an inferior lwjgl product, so be it. I'm enjoying myself. Smiley

while (!deadFromWork) {
    if (hasItem("Dry Erase Board")) {
        chanceOfSuccess++;// Based on a true story..
    }
}
Offline HeroesGraveDev

JGO Kernel


Medals: 383
Projects: 11
Exp: 4 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #11 - Posted 2015-02-21 23:22:41 »

Imagine walking in the jungle along next (but not to close) to a crocodile/piranha-infested river. You've just passed a newly constructed bridge with 2 lanes for cars and a footpath for pedestrians.

You come along a guy trying to build bridge out of fallen trees and stuff. You tell him there's a bridge just around the bend but he says he's trying to learn how to build bridges. You find that acceptable, so you resume walking down the river.

You come across another guy who jumps in the river and swims across to the other side, amazingly making it unharmed. You tell him there was a bridge just around the corner but he says it doesn't matter because he's already made it across. He's right so you resume walking further down without further argument.

You then come across a guy who asks you if you can help him build a bridge across the river. You notify him that there is a bridge just around the bend, but he says he wants a bridge here, and with only a footpath for pedestrians. You tell him a guy down the river has been building his own bridge where he wanted it but the guy responds that he doesn't have the time. You have places to be and other things to do so you just resume walking down the river.

You come back the next day and find the first guy has nearly finished his bridge. You then continue down the river and come across the same guy who has just finished asking to another guy to help him build a bridge. He appears to have been unsuccessful. You tell him that he could have been across the river yesterday if he just used the already existing bridge, or that if he starting building the bridge himself he would be almost finished. You even mention the guy who just swam across but he just sticks to his idea that he wants someone to build a bridge for him. Sick of arguing, you continue your walk along the river.

Over the next month, the first guy finishes his bridge, another five people come along and build their own bridges, and a few more lucky people swim across unharmed. You've stopped bothering to talk to the guy who wants a bridge built, but one day you see he has found a few people to build a bridge for him. You congratulate him but continue on your way regardless.

The next week you come back and see the guy standing on the other side of his new bridge, asking the people who built the bridge for him to help him cut a path through the jungle and back to the main road.

The moral of the story is that I have too much spare time and need to stop procrastinating and get back to my work.

Offline minigame

Senior Devvie


Medals: 14
Projects: 1


LWJGLException


« Reply #12 - Posted 2015-02-22 19:47:17 »

... now that my thread has been saturated with stupid pointless annoying messages. I'm still having the same problem with the shader

while (!deadFromWork) {
    if (hasItem("Dry Erase Board")) {
        chanceOfSuccess++;// Based on a true story..
    }
}
Offline KaiHH

JGO Kernel


Medals: 783



« Reply #13 - Posted 2015-02-22 20:04:14 »

Source of error printing:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
   /**
    * Link the shader program to the GPU , must be done before attaching to a
    * Vbo
    */

   public void link() {
      glLinkProgram(programID);
      if (glGetProgrami(programID, GL_LINK_STATUS) == GL_FALSE) {
         System.err.println("Unable to link shader program:");
         dispose();
      }
   }


That code should've not only checked the link status of the program but also any log messages generated by the driver upon linking the program.
Since compiling the individual shader objects seemed to have succeeded but the linker now complaining about something (maybe some varyings not fitting together), the error messages produced by the linker would now be very useful.
If you can, add (or have it added by the original author) the following right after the invocation of glLinkProgram, and see what gets printed:
1  
2  
String log = glGetProgramInfoLog(programID, 1024);
System.err.println("Linkage log: " + log);

That would give more insight into what goes wrong there.
Offline minigame

Senior Devvie


Medals: 14
Projects: 1


LWJGLException


« Reply #14 - Posted 2015-02-22 23:32:03 »

Source of error printing:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
   /**
    * Link the shader program to the GPU , must be done before attaching to a
    * Vbo
    */

   public void link() {
      glLinkProgram(programID);
      if (glGetProgrami(programID, GL_LINK_STATUS) == GL_FALSE) {
         System.err.println("Unable to link shader program:");
         dispose();
      }
   }


That code should've not only checked the link status of the program but also any log messages generated by the driver upon linking the program.
Since compiling the individual shader objects seemed to have succeeded but the linker now complaining about something (maybe some varyings not fitting together), the error messages produced by the linker would now be very useful.
If you can, add (or have it added by the original author) the following right after the invocation of glLinkProgram, and see what gets printed:
1  
2  
String log = glGetProgramInfoLog(programID, 1024);
System.err.println("Linkage log: " + log);

That would give more insight into what goes wrong there.

Thank you! Finally I'm on the right path.. The console error says:
Linkage log: Fragment shader uses varying vecdata but vertex shader does not write to it.
I'm going to toy around with the shaders myself but I'm not sure if I'll be able to solve this.

while (!deadFromWork) {
    if (hasItem("Dry Erase Board")) {
        chanceOfSuccess++;// Based on a true story..
    }
}
Offline pitbuller
« Reply #15 - Posted 2015-02-23 00:06:13 »

Show the fragment shader code if you want some help with it?
Offline lcass
« Reply #16 - Posted 2015-02-23 17:02:33 »

The fragment shader currently does not implement that , hold on ill send you an update.
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (351 views)
2019-09-04 15:33:17

hadezbladez (5154 views)
2018-11-16 13:46:03

hadezbladez (2038 views)
2018-11-16 13:41:33

hadezbladez (5405 views)
2018-11-16 13:35:35

hadezbladez (1124 views)
2018-11-16 13:32:03

EgonOlsen (4546 views)
2018-06-10 19:43:48

EgonOlsen (5409 views)
2018-06-10 19:43:44

EgonOlsen (3087 views)
2018-06-10 19:43:20

DesertCoockie (3981 views)
2018-05-13 18:23:11

nelsongames (4555 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!