www.jpct.net
jPCT-AE - a 3d engine for Android => Support => Topic started by: Thomas. on November 07, 2012, 02:09:13 pm
-
Egon, could you provide me Projector class or implement it into jPCT-AE? It would be useful for shadows... Thanks
-
Sure, no problem. This is how it looks:
package com.threed.jpct;
/**
* Projector is an extended Camera used for projecting textures into the scene.
*
* @see com.threed.jpct.Texture
*/
public class Projector extends Camera implements java.io.Serializable {
private static final long serialVersionUID = 1L;
}
...really, that's all there is. The actual projection magic lies in the renderer and that can't be ported to OpenGL ES, because it's missing all the required functionality. You have to do all the projection calculations in the shader. I would be grateful, if you could share some code/shaders if you have something that works, because i would like to add shadow support, but i don't have the time ATM to do this myself.
-
Thanks ;) Good news... Rendering of scene with per-pixel light, depth texture, motion vectors, depth of filed, distortion objects and shadow map (512) in one frame and my game running about 38fps. Without effects it is 60fps :)
-
Could you somehow extract the depth/shadow map part of it? It would really help me to add this feature, if i have a working example to study.
-
It is not completed ATM. Anyway my ShadowHelper is bundled with my LightController that generates shaders based on lights parameters. But I can provide you shader as soon as be the completed.
-
Take your time, i have plenty of other things to do... ;)
-
Is it possible to add the method GLGLShader.setUniform(String name, Texture texture)? If not, I have to somehow inject texture into shader, any idea how? Method getTexture() missing, but the creation of the TextureInfo is not a good idea IMHO...
-
I don't think so. I not aware of a way to use a texture in a shader by any other means than to assign it to a texture stage. If there were, texture stage count wouldn't be an issue and texture stages would be pointless anyway. Why would you want to?
-
Somewhere I should use the shadow map, the good place could be a shader :) I want to maximal compatibility... I could set texture using the String name, after that in ShadowHelper create the TextureInfo with the texture of object (anyway it needs getTexture() method) and shadow map. But I'd like to keep the possibility to change the texture of object...
-
You can still change it on the fly, you just have to make sure to include the depth map too...i fail to see the problem... ???
-
Yes, but I do not know which texture is applied on objects (missing getTexture() method), so I can not create TextureInfo. Is it possible, when I create TextureInfo in ShadowHelper and I would like to change texture at other place in the code by method setTexture(String name)?
edit:
I do not know how jPCT works inside. But would be nice this:
public void setTexture(String name){
int id = TextureManager.getInstance().getTextureID(name);
if(id != TextureInfo.TEXTURE_NOTFOUND){
if(textureInfo == null)
textureInfo = new TextureInfo(id);
else
textureInfo.set(id, 0, TextureInfo.MODE_ADD);
}
}
public void setTexture(TextureInfo ti){
textureInfo = ti;
}
public TextureInfo getTexture(){
return textureInfo;
}
Maybe jPCT works this way, so could you implement method getTexture()? :)
-
You have several getPolygonTexture() and addTexture() methods. Maybe they are sufficient? Just keep in mind that you can't use them on stripped objects, i.e. you have to setup the objects before stripping them or don't strip them at all.
Edit: ...in the PolygonManager...but i guess you already figured it out... ;)
-
Thanks, I had to miss this methods :)
-
What am I doing wrong? I get this error:
pm.addTexture(0, textureID, TextureInfo.MODE_ADD);
...
11-11 11:29:41.861: E/AndroidRuntime(29407): FATAL EXCEPTION: GLThread 4883
11-11 11:29:41.861: E/AndroidRuntime(29407): java.lang.RuntimeException: [ 1352629781671 ] - ERROR: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
11-11 11:29:41.861: E/AndroidRuntime(29407): at com.threed.jpct.PolygonManager.addTexture(PolygonManager.java:113)
edit: I whole code is not used strip() method...
-
Have you set Config.maxTextureLayers to 2 or something like that?
-
No, maxTextureLayers is set to 4
-
Strange then...it's this line that crashes:
myObj.multiTex[i][polyID] == TextureManager.TEXTURE_NOTFOUND
polyID is 0 in your case, so it can't be the problem. The length of multiTex should be maxTextureLayers-1, so if it crashes on index 1, it seems to me that the array has been created for only 2 texture layers. However, it's actually not supposed to crash...i've updated the beta jar with a version that should not crash but give a log output instead if it can't add another layer. It would be interesting to see what this prints out in your case.
-
Here is log. What is it mean?
11-11 12:05:12.101: I/jPCT-AE(15482): [ 1352631912106 ] - WARNING: No further texture stage available (2/1/4)!
11-11 12:05:12.101: I/jPCT-AE(15482): [ 1352631912106 ] - WARNING: No further texture stage available (2/3/4)!
-
It means that, while the config would allow for 4 stages, the actual arrays are smaller. Maybe i should modify the method to deal with this, but i would like to know the root cause. Are these serialized objects?
-
Particles and water-levels are created by code, everything else are serialized objects. 3DS and OBJ are no longer in use.
-
As a workaround, try to serialize them in unreduced, i.e. reduced set to false. I'll fix the method later to handle this case.
-
Oh, this is for testing purposes? Want to know if it will work? It is more than 50 objects. I'd rather wait for fix...
-
I've updated the beta, but haven't really tested the fix... ;) Please give it a try to see if it helps.
-
It works ;) but projected shadows are shifted, I have to look where is problem
edit: game can be started, but there is still this:
11-11 14:32:38.082: I/jPCT-AE(19080): [ 1352640758087 ] - WARNING: No further texture stage available (2/3/4)!
-
How many layers are you using...looks like as if you've exceeded the maximum of 4 at least for some objects.