Quote:Original post by Dragon_Strike
man... i rly like u ;)... thx again
I really appreciate. [smile]
Quote:yea it doesnt work very well.. im still trying to figure out how to do this... i could use ur cylinder way but that only seems harder... im having problems with how to calculate the intersection with the shadow mask...
I think that you would have more accurate results with the cylinder and it is easy and cheap to compute. I guessed you looked on the video on my website, it shows the results with a light rotating around the scene. I do not know if it would work well with your method.
First, transform the light vector in the space of the grass blade (with Y being the vertical axis in my case). A point (x,y,z) on the ray going from the current vertex you are processing (Vx,Vy,Vz) in the direction (Rx,Ry,Rz) can be expressed like this:
x = Vx + t.Rx (1)y = Vy + t.Ry (2)z = Vz + t.Rz (3)
where t >= 0 is unknown.
Each point (x,y,z) on a vertical cylinder of radius R can be expressed like this:
x^2 + z^2 = R^2 (4)
Just substitute x and z from equation (4) by the equations (1) and (3). Solve to get t, with the condition that t >= 0. Then, use the resulting t in equations (1), (2) and (3) to get the intersection point that you convert in texture coordinates. Clamp the T coordinate in [0,1]. Fill the bottom row of your shadow mask with black and the top row with white in a preprocess.
Solving the equations give a really simple analytic form that is fast to evaluate in the GPU, since parts of the equations can be vectorized.
Quote:
basicly i simple repeat the shadowmask over the patch.. like slices.. i put em 0.5 in fron of each blade and the cast a ray to it to get the tex coords..
How do you choose the orientation of the slice ? If you use constant orientation, that means you need several slices, so it looks expensive to choose the one you need, and you will have distortions when far from the center of teh shadow mask. If you rotate the slice depending on the light direction, you cannot really get the shadow effect since the slice has to be the same along a blade (and so, for several vertices).
Quote:here is a better pic showing the shadows... since im only using the sun as light source this should be simplier and faster calc than using a cylinder.. i think
I am using the cylinder FOR the lighting from the sun (diffuse term). I manage shadowing from the environment (ambient term) using ambient occlusion.
Quote:
Quote:
Also, you are reading my research report (thanks by the way), but be careful. It is a version that I wrote for Siggraph in June, so it is not totally updated. After this report, I increased a lot the quality of the rendering, managed non flat terrains and improved a lot the density management. Unfortunately I cannot give details for the moment, the research paper is submitted in a research journal, and I have to wait for the answer before giving details.
ill be waiting
I should get the answer for the paper in late December or in January. After, it should be available online if it is accepted.
Quote:yea i might not be using the best rendering method... as i said i cant use VBO cuzz for some strange reason my comp crashes... im using triangle strips in a displaylist... i dont even use degenerates... i start a new strip for each triangle... so what do u recommend?
It is really too bad for the vertex buffer objects, it really accelerate the rendering (more than twice). But I do not know anyone that have VBOs crashing. I think you should really deeply check your code for a potential bug. It the crash happens when you call a rendering function, the problem comes probably from the data pointers (like NULL or arrays that are too short, the latter being difficult to debug but it happened to me, also check that the sizes you give are in number of vertices, float numbers or bytes, VBOs allocation being in number of bytes).
I do not use degenerate triangles, I use multi draw arrays. Since the rasterized primitive has to be restarted for each grass blade, glDrawArrays() should be called for each grass blades. By using multi draw arrays, I have a single draw call for an entire grass patch of about 3000 grass blades, and made the rendering speed multiplied by 5. This works with regular vertex arrays and for VBOs (but the speed up is really important with the VBOs).
Do not use indices, they are not really useful since each vertex is used once when rendering quad strips for grass blades.
Quote:well im using the texture that was in ur report... but im mixing it with the color green-yellow like mix(texcolor, grasscolor, 0.5). and yea mipmaping might also be a factor
That explains many things. You are making the texture "half visible" with your mixing method. I advise you to multiply the texture instead. Multiply the texture color by (1,1,1) to get the original color, about (1,1.1,1) for a more greenish color, (1,1,0.8) for a more yellowish color, etc. The values I gave you are arbitrary, use the ones you want, but keep in mind they have to be close to 1 to stay realistic.
I have seen on your picture that you change the color per vertex. The gradients that appear look a bit unrealistic. I have seen from observation of real grass that the color should be defined per blade rather than per vertex. Just choose a color randomly (see previous paragraph) and attributer the same color to each vertex.
Quote:
i dont rly understand.. could u explain this a bit more in detail?
Translucency is a bit expensive to compute. So I use a non-physically based approximation that gives convincing results. It is a slightly visible low-frequency effect but scenes look more realistic.
I use the diffuse term of the Phong BRDF to compute the reflected light:
materialColor * max(N . L, 0)
N is the normal of the blade on the side you are looking (I use two-sided lighting), L is the light direction. For transmitted light, I add the following component:
materialColor * (0.8,1.2,0.8) * max(-N . L, 0)
That means I am using a kind of Phong BRDF for the other side of the blade, and I multiply the value by (0.8,1.2,0.8) (you can tweak these values) to make it look more greenish.
When light is behind the viewer, the grass blades look blueish (due to ambient lighting particularly) and yellowish (due to the sun). When light is in front of the viewer, the grass blades look more greenish, which is the desired behavior.
Quote:do u have any ideas how it would be possible to animate the grass?
You can look at my previous post.
Quote:
and in ur demo how many grass blades do u have per 1x1... i have to use 300-600 blades (i think its 600 in the pic) to make it look dense... that means that the pic above has... 153600 blades
For the screenshot I gave, I use about 15,000 grass blades per square meter, with about 8 cm tall grass blades.