www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Yerst on July 15, 2013, 05:42:03 pm

Title: How to set up Parallax mapping
Post by: Yerst on July 15, 2013, 05:42:03 pm
Hey!
I found the demo of Parallax mapping on youtube and also this topic in the forum: http://www.jpct.net/forum2/index.php/topic,2153.msg15839.htm
I do already have all the needed textures, but i don't know how to set up the shaders.
I found the wiki Page about shaders and tried setting it up with the GLSLShader class, but i don't know what setStaticUniform does or how i can use setRenderHook(shader) on android.
Is there a tutorial or a sample code out there?
Title: Re: How to set up Parallax mapping
Post by: EgonOlsen on July 15, 2013, 06:21:34 pm
The parallax mapping stuff should be part of the examples that come with jPCT-AE...
Title: Re: How to set up Parallax mapping
Post by: Wolf17 on July 15, 2013, 06:26:42 pm
    There is a helloshader example project in the jpct ae download file . I think It is the same example( stone face) you saw in the youtube vid.
Title: Re: How to set up Parallax mapping
Post by: Yerst on July 15, 2013, 08:54:26 pm
Ok, this is the code i'm using now:
Code: [Select]
InputStream vertexS = manager.open("vertex.glsl");
InputStream fragmentS = manager.open("fragment.glsl");
String vertex = Loader.loadTextFile(vertexS);
String fragment = Loader.loadTextFile(fragmentS);
GLSLShader shader = new GLSLShader(vertex,fragment);
shader.setUniform("heightScale", 1);
Texture height = new Texture(this.context.getResources().openRawResource(R.raw.earth_heightmap));
Texture normals = new Texture(this.context.getResources().openRawResource(R.raw.earth_normalmap));
Texture earth = new Texture(this.context.getResources().openRawResource(R.raw.earth));

TexelGrabber grabber = new TexelGrabber();
height.setEffect(grabber);
height.applyEffect();
int[] heighties = grabber.getAlpha();
AlphaMerger setter = new AlphaMerger(heighties);
normals.setEffect(setter);
normals.applyEffect();
tm.addTexture("earth_normalmap",normals);
tm.addTexture("earth",earth);
TextureInfo ti = new TextureInfo(TextureManager.getInstance().getTextureID("earth"));
ti.add(TextureManager.getInstance().getTextureID("earth_normalmap"),TextureInfo.MODE_BLEND);
planet.setTexture(ti);
planet.setShader(shader);
shader.setStaticUniform("invRadius", 0.0005f);

planet.build();
world.addObject(planet);
Now i have two other problems:
1.)My whole texture seems more dark. What could be the fault? The Normalmap?
2.)I can't see any Parallax mapping effect at all  :(
Here is a ingame screenshot:(http://img4.fotos-hochladen.net/uploads/screenshot2013it091dycza.png)
Title: Re: How to set up Parallax mapping
Post by: EgonOlsen on July 15, 2013, 10:57:38 pm
You might have to tweak the shader values. As it is, it's not meant to be used for objects that are far away from the viewer. In addition, try to enable specular lighting on the planet in case you haven't and you might want to post the textures you are using to make sure that they fit the purpose.
Title: Re: How to set up Parallax mapping
Post by: Yerst on July 15, 2013, 11:16:00 pm
Ok, here are my textures:
Normalmap:
(http://img4.fotos-hochladen.net/uploads/earthnormalmapfv608e214t.jpg)
Heightmap:
(http://img4.fotos-hochladen.net/uploads/earthheightmap8vf4s9tpei.jpg)
Blank texture:
(http://img4.fotos-hochladen.net/uploads/eartht7dsz2j0cn.jpg)
Title: Re: How to set up Parallax mapping
Post by: Thomas. on July 15, 2013, 11:21:48 pm
"Height map" is specular map ;)
Title: Re: How to set up Parallax mapping
Post by: Yerst on July 15, 2013, 11:37:26 pm
opps  :-[
I tried this texture now:
(http://img4.fotos-hochladen.net/uploads/earthheightmap5q3i2o7evb.jpg)
but there is no change at all...