Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (753) Games in Android Showcase (228) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Passing vectors from Vertex to Fragment  (Read 2717 times) 0 Members and 1 Guest are viewing this topic.
Spacebeans
 « Posted 2014-05-23 01:24:15 »

I'm trying to find a way to implement ray-casing completely by GLSL, and I was thinking of maybe getting the vertices from the vertex shader into the fragment shader. Then using some kind of algorithm for calculating a shadow.

light.fs;
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19 `#version 150uniform vec2 lightLocation;uniform vec3 lightColor;uniform vec3 ambientLight;vec3 baseColor = vec3(1.0, 1.0, 1.0);void main() {    vec4 light = vec4(ambientLight, 1);   vec4 color = vec4(baseColor,1);   float distance = length(lightLocation - gl_FragCoord.xy);   float attenuation = 1.0 / distance;   vec4 lColor = vec4(attenuation, attenuation, attenuation, pow(attenuation, 3.0)) * vec4(lightColor, 1);   color += lColor;   gl_FragColor = color * light;}`

light.vs
 1  2  3  4  5 `#version 150void main(){      gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;}`
Riven

« JGO Overlord »

Medals: 1336
Projects: 4
Exp: 16 years

 « Reply #1 - Posted 2014-05-23 06:38:14 »

old: varying
new: in & out

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Spacebeans
 « Reply #2 - Posted 2014-05-23 19:20:30 »

Thanks!, but is there a good example of this somewhere? Because everywhere I look I find some complicated-C++ stuff.

theagentd
 « Reply #3 - Posted 2014-05-23 22:31:27 »

The C++ code isn't relevant, just look at GLSL examples?

Myomyomyo.
Spacebeans
 « Reply #4 - Posted 2014-05-23 22:49:54 »

Alright, will do!
jmguillemette
 « Reply #5 - Posted 2014-05-26 13:32:07 »

here is a bit of an example...
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20 `#version 410uniform mat4    in_projectionMatrix;uniform mat4    in_cameraMatrix;uniform mat4    in_modelMatrix;layout(location = 0) in vec3 vp;layout(location = 1) in vec3 np;out vec3 pass_normal;out mat4 pass_cameraMatrix;void main () {    vec4 vertex = vec4(vp, 1.0);    gl_Position =    in_projectionMatrix * in_cameraMatrix * in_modelMatrix * vertex;    pass_normal = np;    pass_cameraMatrix = in_cameraMatrix;       }`

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19 `#version 410in  vec3 pass_normal;in  mat4 pass_cameraMatrix;out vec4 frag_colour;void main(){   //frag_colour = vec4(0.5, 0.0, 0.5, 1.0);   vec4 colour = vec4(pass_normal, 1) * pass_cameraMatrix;   //frag_colour = vec4(0.1,0.1,0.1,1) * colour;   frag_colour = colour;   }`

-=Like a post.. give the author a medal!=-
Pages: [1]
 ignore  |  Print

 ivj94 (582 views) 2018-03-24 14:47:39 ivj94 (46 views) 2018-03-24 14:46:31 ivj94 (374 views) 2018-03-24 14:43:53 Solater (61 views) 2018-03-17 05:04:08 nelsongames (108 views) 2018-03-05 17:56:34 Gornova (150 views) 2018-03-02 22:15:33 buddyBro (692 views) 2018-02-28 16:59:18 buddyBro (91 views) 2018-02-28 16:45:17 xxMrPHDxx (493 views) 2017-12-31 17:17:51 xxMrPHDxx (730 views) 2017-12-31 17:15:51
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 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