Java-Gaming.org
Java4K winners:
[
by our judges
|
by the community
]
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members
News
: Read the
Java Gaming Resources
, or peek at
the official Java tutorials
Home
Help
Search
Login
Register
Java-Gaming.org
>
Java Game APIs & Engines
>
OpenGL Development
>
JOGL Development
>
Shaders and JOGL
Pages: [
1
]
Print
Shaders and JOGL
(Read 1927 times)
0 Members and 2 Guests are viewing this topic.
a6767
JGO n00b
Posts: 39
Shaders and JOGL
«
on:
2007-08-01 16:14:51
»
I'm implementing shaders with glsl in my JOGL applet. Everything works fine, except textures. If I try to access to texture 1 (With MultiTexture activated) , my program access to texture 0. I pass the unit of texture as a uniform to texture2D function. There is no way to say to my fragment shader which texture I need to view.
The fragment shader is very simple:
uniform sampler2D colorMap;
uniform sampler2D envMap;
void main()
{
vec4 color = texture2D(colorMap,gl_TexCoord[0].st);
vec4 env = texture2D(envMap,gl_TexCoord[1].st);
gl_FragColor=color+env*0.4;
}
It gets colorMap=0, envMap=0 . I believe this, because it applies as colorMap texture0 and as envMap texture0
a6767
JGO n00b
Posts: 39
Re: Shaders and JOGL
«
Reply #1 on:
2007-08-01 16:42:06
»
I answer myself. Before calling glUniform you must call glActiveProgram
gouessej
JGO Kernel
Posts: 3560
Medals: 30
TUER
Re: Shaders and JOGL
«
Reply #2 on:
2007-08-03 07:29:21
»
Could you give me an example of shader to handle Phong model with textures please?
Julien Gouesse
Games published by our own members! Go get 'em!
lhkbob
JGO Neuromancer
Posts: 1174
Medals: 35
Re: Shaders and JOGL
«
Reply #3 on:
2007-08-03 10:09:53
»
It shouldn't be that hard to find a Phong implementation on the web and just add some texturing support. I would think all you need to do is calculate the phong lighting from before and then modulate it with the textures.
Ferox -
http://bitbucket.org/mludwig/ferox
Entreri -
http://bitbucket.org/mludwig/entreri
a6767
JGO n00b
Posts: 39
Re: Shaders and JOGL
«
Reply #4 on:
2007-08-06 02:39:13
»
gouessej, I haven't one. But there are many samples in the web. In any case, it is not hard to implement one.
Take a look at these tuts
http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir2
http://www.ozone3d.net/tutorials/glsl_lighting_phong.php
gouessej
JGO Kernel
Posts: 3560
Medals: 30
TUER
Re: Shaders and JOGL
«
Reply #5 on:
2007-08-08 07:34:37
»
Quote from: a6767 on
2007-08-06 02:39:13
gouessej, I haven't one. But there are many samples in the web. In any case, it is not hard to implement one.
Take a look at these tuts
http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir2
http://www.ozone3d.net/tutorials/glsl_lighting_phong.php
Thanks but the main difficulty is to adapt it to handle the textures.
Julien Gouesse
trbabb
JGO n00b
Posts: 4
Re: Shaders and JOGL
«
Reply #6 on:
2007-08-08 17:32:02
»
So, the lambertian term should be between 0 and 1. Multiply that value by the R, G, B sample you get from the texture. Then add the ambient to it. Then add the specular to it. Really, not difficult.
gouessej
JGO Kernel
Posts: 3560
Medals: 30
TUER
Re: Shaders and JOGL
«
Reply #7 on:
2007-08-13 07:43:04
»
Quote from: trbabb on
2007-08-08 17:32:02
So, the lambertian term should be between 0 and 1. Multiply that value by the R, G, B sample you get from the texture. Then add the ambient to it. Then add the specular to it. Really, not difficult.
Ok thank you very much. I'm a newbie in GLSL, sorry.
Julien Gouesse
Pages: [
1
]
Print
Jump to:
Please select a destination:
-----------------------------
Games Center
-----------------------------
=> Featured Games
=> Showcase
=> Contests
===> LWJGL16k - 2011
===> 4K Game Competition - 2012
===> JGO Comp Petite
===> Finished Contests
=====> 4K Game Competition - 2011
=====> 4K Game Competition - 2010
=====> 4K Game Competition - 2009
=====> 4K Game Competition - 2008
=====> 4K Game Competition - 2007
=====> 4K Game Competition - 2006
=====> 4K Game Competition - 2005
=====> Tiny Game 2010
=====> JGO Comp 2009
=====> 16K LWJGL Competition - 2005
=====> Java Technology Game Development Contest - 2004
-----------------------------
Discussions
-----------------------------
=> General Discussions
===> Suggestions
=> Business and Project Discussions
===> Jobs and Resumes
===> Community & Volunteer Projects
=> Miscellaneous Topics
-----------------------------
Game Development
-----------------------------
=> Newbie & Debugging Questions
=> Articles & tutorials
=> Game Play & Game Design
=> Game Mechanics
===> Artificial Intelligence
=> Networking & Multiplayer
=> Performance Tuning
=> Shared Code
-----------------------------
Java Game APIs & Engines
-----------------------------
=> Engines, Libraries and Tools
===> Java 3D
===> JInput
===> jMonkeyEngine
===> Xith3D Forums
===> Tools Discussion
=> Java 2D
===> JavaFX
=> OpenGL Development
===> JOGL Development
===> LWJGL Development
=> Java Sound & OpenAL
===> JOAL Development
=> Java on Mobile Devices
===> Android
===> J2ME
Loading...