Common comes from JME. MatDefs is local (assets/MatDefs)… and I don’t recognize the BillboardPreShadow as any standard JME thing.
Oh sh*t, yes! I’m sorry, put these instead, those come with JME3 as I intended… I just forgot I duplicated those a long time ago and assumed they were the original ones, so put this instead and it will work:
Common/MatDefs/Shadow/PreShadow.vert
Common/MatDefs/Shadow/PreShadow.frag
@.Ben. said: Oh sh*t, yes! I'm sorry, put these instead, those come with JME3 as I intended... I just forgot I duplicated those a long time ago and assumed they were the original ones, so put this instead and it will work:Common/MatDefs/Shadow/PreShadow.vert
Common/MatDefs/Shadow/PreShadow.frag
still does not appear on the grass terrain …
GrassBase.j3md
MaterialDef Grass {
MaterialParameters {
//Fading parameters (don't set these manually).
Float FadeEnd
Float FadeRange
Boolean FadeEnabled
//Is the grass swaying or not?
Boolean Swaying
//The wind vector (determines direction and amplitude of the swaying function).
Vector2 Wind
//Combined vector for various fading data.
//x = The swaying frequency
//y = The swaying variation (how the offset varies between patches)
//z = Maximum swaying distance (grass beyond this distance does not move).
Vector3 SwayData
//Use lighting
Boolean VertexLighting
//Use vertex colors (requires a colormap provided to the grassloader).
Boolean VertexColors
//Use grass self-shadowing.
Boolean SelfShadowing
//The texture
Texture2D ColorMap
//The perlin noise for stipple fading.
Texture2D AlphaNoiseMap
//When texture alpha is below this value, the pixel is discarded
Float AlphaThreshold
Float opacity
//Used internally.
Int NumLights
}
Technique {
LightMode SinglePass
VertexShader GLSL100: Resources/Grass.vert //my file
FragmentShader GLSL100: Resources/Grass.frag // my file
WorldParameters {
WorldViewProjectionMatrix
WorldMatrix
ModelViewMatrix
ProjectionMatrix
ViewMatrix
ModelViewProjectionMatrix
WorldViewMatrix
CameraPosition
Time
}
Defines {
SWAYING : Swaying
FADE_ENABLED : FadeEnabled
VERTEX_LIGHTING : VertexLighting
VERTEX_COLORS : VertexColors
SELF_SHADOWING : SelfShadowing
NUM_LIGHTS : NumLights
}
}
Technique PreShadow {
VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert //jme3 library
FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag //jme3 library
WorldParameters {
WorldViewProjectionMatrix
WorldViewMatrix
ProjectionMatrix
}
Defines {
DIFFUSEMAP_ALPHA : DiffuseMap
}
RenderState {
FaceCull Off
DepthTest On
DepthWrite On
PolyOffset 5 0
ColorWrite Off
}
}
Technique PreNormalPass {
VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert //jme3 library
FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag //jme3 library
WorldParameters {
WorldViewProjectionMatrix
WorldViewMatrix
NormalMatrix
}
Defines {
SWAYING : Swaying
FADE_ENABLED : FadeEnabled
}
RenderState {
}
}
}
I used class control in this topic …
and the main write this:
Node map = (Node)assetManager.loadModel("Models/terrain.j3o");
map.addControl(new SimpleGrassControl(assetManager,“Textures/FlowerA_D.png”));
rootNode.attachChild(map);
It would be very convenient for me to have working code.
Thanks again for your patience!
At that point, I don’t know. Maybe the author can answer better. Are you sure you put the “FlowerA_D.png” file in the assets/Textures folder? I mean, at this point, are you seeing an exception thrown message or is the app running without crashing?
@.Ben. said: At that point, I don't know. Maybe the author can answer better. Are you sure you put the "FlowerA_D.png" file in the assets/Textures folder? I mean, at this point, are you seeing an exception thrown message or is the app running without crashing?
Thanks for the reply… App running without crashing but does not appear any grass on the ground…
FlowerA_D.png in the directory asset/Textures https://www.dropbox.com/s/ig4jc6vr1nr00fe/Screenshot%202014-10-23%2014.10.15.png?dl=0
app while running Dropbox - Screenshot 2014-10-23 14.11.46.png - Simplify your life
OK good, then you must be close to making it work, I guess. Can you dropbox a ZIP of your project? I’ll test it and find why it doesn’t work.
@.Ben. said: OK good, then you must be close to making it work, I guess. Can you dropbox a ZIP of your project? I'll test it and find why it doesn't work.https://dl.dropboxusercontent.com/u/51602590/GrassControl.zip
thanks again
Hi, the flowers are underneath the terrain. Try to go under the terrain, you will see them.
EDIT: OK, change your line 147 to account for the terrain scaling, note that this is a rough number, you might want to programmatically get this real value or something, because getHeight() might not take the scaling into account. Maybe it’s because you made your terrain, scaled it and saved it to a j3o object file, the scaling might not be possible to get precisely through the code, but I don’t know about this, just a guess. Anyhow, here’s what I got just by modifying line 147, see the “* 5.1f”:
candidateGrassPatchLocation.set(x+grassPatchRandomOffset.x, terrain.getHeight(new Vector2f(x+grassPatchRandomOffset.x,z+grassPatchRandomOffset.y)) * 5.1f, z+grassPatchRandomOffset.y);
@.Ben. said: Hi, the flowers are underneath the terrain. Try to go under the terrain, you will see them.
EDIT: You have anticipated me!
I edited my last post, please check underneath the image, there’s a fix you will want to try
This is what I see with the Y=40 solution you just mentionned. Also, you do know that with your current code, flowers are only going to appear on the first half of the terrain right? Zoom out the camera to see the whole terrain, you will see the flowers on one side.
@.Ben. said: I edited my last post, please check underneath the image, there's a fix you will want to try ;-)
why does not work?
upload, again my code!
https://dl.dropboxusercontent.com/u/51602590/GrassControl2.zip
uppp
I tried to run the same code on mac and pc 32bit and works … On my pc 64-bit doesn’t work … I don’t know why … any ideas?
@GluckOs said: I tried to run the same code on mac and pc 32bit and works ... On my pc 64-bit doesn't work .. I don't know why .. any ideas?
I hope someone is listening… if I comment
faceMat.setBoolean("FadeEnabled", true);
the code work…
maybe if I can not make it work, but someone with the same problem can start from here … any advice is welcome…
i just tried on pc 32bit… and it work even without that line!
@vvishmaster Please, can you tell me what kind of Map model are you using and what width and height of it? I am asking because in scene composer I added terrain with size 512 and patch size 64, apllied alpha map on it from jme-test-data library.
Then my program crushed with IllegalArgumentException at the line buf.position( position );
Probably it is caused by float inc = 80;
so I increased value of inc, but there is no grass on terrain (I think beacause dense is too small)
Oh and one more think that texture parameter AlphaMap is not defined, only Alpha works for me. Not sure if it is necessary to use AlphaMap parameter.
I know is is a long time this topic exits but I hope I will get response