Sign in to follow this  

TreeLib

This topic is 3302 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, It's been a while but i finally got got back to improving the library project 'TreeLib' which i started quite some time ago. As some may recall it renders trees in the following fashion: At this point the trees are still the same old trees i designed years ago, but the architecture changed quite drastically improving performance and visual quality. I added automatic imposter generation, better support for lighting and fog, normal mapping, anisotropic filtering, just to name a few things. I also made it fully freeware as i saw i really don't have the time to activly sell it. Or the time to improve it to commercial quality for that matter. This version now also includes full geometry export functionality as originally implemented for a non-public version. So if for some reason you hate how TreeLib renders the trees but do like the geometry then you can export and render them manually. Here's a screenshot to how the bark looks close up (using the provided textures): And here a shot at a gallery of 10000 instances of the same tree: Can you tell where geometrical trees end and imposters begin? (yes, the imposters use normal mapping if available) From this point on I will concentrate on adding new types of trees. I even have an idea for a script-like system for trees but I'll have to experiment with that before i can promise anything. For now it was more important to me to get the library back to usability in regards to visuals and performance. Finally you can download the library (including, manual) and/or a fully functioning demo application here: http://www.delta-works.org/download/?&details=TreeLib I'm open for criticism, complaints, requests, suggestions, whatever. So feel free to post your thoughts here :) And now i shall get back to make those blasted trees nicer. Regards :)

Share this post


Link to post
Share on other sites
wow! I think this is one of the best tree libraries I've seen (well, free one anyway, I wont go near paid for stuff :P) can't wait to see how this develops. Good luck!

EDIT: the impostor shader is failing:
(from shader_error.txt)


-- program construction --
Fragment info
-------------
Internal error: assembly compile error for fragment shader at offset 10250:
-- error message --
line 169, column 13: error: variable not valid as a source register
-- internal assembly text --
!!ARBfp1.0
OPTION NV_fragment_program2;
# cgc version 2.0.0018, build date May 16 2008 14:21:24
# command line args:
#vendor NVIDIA Corporation
#version 2.0.1.18
#profile fp40
#program main
#semantic texture
#semantic normal_map
#semantic gl_FrontMaterial : state.material.front
#semantic gl_LightSource : state.light
#var sampler2D texture : : texunit 1 : -1 : 1
#var sampler2D normal_map : : texunit 0 : -1 : 1
#var float3x3 tangent_space : $vin.TEX1 : TEX1, 3 : -1 : 1
#var float3 frag_coord : $vin.TEX4 : TEX4 : -1 : 0
#var float4 gl_TexCoord[0] : $vin.TEX0 : TEX0 : -1 : 1
#var float4 gl_TexCoord[1] : : : -1 : 0
#var float4 gl_TexCoord[2] : : : -1 : 0
#var float4 gl_TexCoord[3] : : : -1 : 0
#var float4 gl_TexCoord[4] : : : -1 : 0
#var float4 gl_TexCoord[5] : : : -1 : 0
#var float4 gl_TexCoord[6] : : : -1 : 0
#var float4 gl_TexCoord[7] : : : -1 : 0
#var float4 gl_FrontMaterial.emission : state.material.front.emission : : -1 : 0
#var float4 gl_FrontMaterial.ambient : state.material.front.ambient : : -1 : 0
#var float4 gl_FrontMaterial.diffuse : state.material.front.diffuse : : -1 : 0
#var float4 gl_FrontMaterial.specular : state.material.front.specular : : -1 : 0
#var float gl_FrontMaterial.shininess : state.material.front.shininess : c[0] : -1 : 0
#var float4 gl_FragColor : $vout.COLOR : COL : -1 : 1
#var float4 gl_LightSource[0].ambient : state.light[0].ambient : c[1] : -1 : 1
#var float4 gl_LightSource[0].diffuse : state.light[0].diffuse : c[2] : -1 : 1
#var float4 gl_LightSource[0].specular : state.light[0].specular : c[3] : -1 : 0
#var float4 gl_LightSource[0].position : state.light[0].position : c[4] : -1 : 1
#var float4 gl_LightSource[0].halfVector : state.light[0].half : : -1 : 0
#var float3 gl_LightSource[0].spotDirection : state.light[0].spot.direction : : -1 : 0
#var float gl_LightSource[0].spotExponent : state.light[0].attenuation.w : : -1 : 0
#var float gl_LightSource[0].spotCutoff : NONE : : -1 : 0
#var float gl_LightSource[0].spotCosCutoff : state.light[0].spot.direction.w : : -1 : 0
#var float gl_LightSource[0].constantAttenuation : state.light[0].attenuation.x : : -1 : 0
#var float gl_LightSource[0].linearAttenuation : state.light[0].attenuation.y : : -1 : 0
#var float gl_LightSource[0].quadraticAttenuation : state.light[0].attenuation.z : : -1 : 0
#var float4 gl_LightSource[1].ambient : state.light[1].ambient : : -1 : 0
#var float4 gl_LightSource[1].diffuse : state.light[1].diffuse : : -1 : 0
#var float4 gl_LightSource[1].specular : state.light[1].specular : : -1 : 0
#var float4 gl_LightSource[1].position : state.light[1].position : : -1 : 0
#var float4 gl_LightSource[1].halfVector : state.light[1].half : : -1 : 0
#var float3 gl_LightSource[1].spotDirection : state.light[1].spot.direction : : -1 : 0
#var float gl_LightSource[1].spotExponent : state.light[1].attenuation.w : : -1 : 0
#var float gl_LightSource[1].spotCutoff : NONE : : -1 : 0
#var float gl_LightSource[1].spotCosCutoff : state.light[1].spot.direction.w : : -1 : 0
#var float gl_LightSource[1].constantAttenuation : state.light[1].attenuation.x : : -1 : 0
#var float gl_LightSource[1].linearAttenuation : state.light[1].attenuation.y : : -1 : 0
#var float gl_LightSource[1].quadraticAttenuation : state.light[1].attenuation.z : : -1 : 0
#var float4 gl_LightSource[2].ambient : state.light[2].ambient : : -1 : 0
#var float4 gl_LightSource[2].diffuse : state.light[2].diffuse : : -1 : 0
#var float4 gl_LightSource[2].specular : state.light[2].specular : : -1 : 0
#var float4 gl_LightSource[2].position : state.light[2].position : : -1 : 0
#var float4 gl_LightSource[2].halfVector : state.light[2].half : : -1 : 0
#var float3 gl_LightSource[2].spotDirection : state.light[2].spot.direction : : -1 : 0
#var float gl_LightSource[2].spotExponent : state.light[2].attenuation.w : : -1 : 0
#var float gl_LightSource[2].spotCutoff : NONE : : -1 : 0
#var float gl_LightSource[2].spotCosCutoff : state.light[2].spot.direction.w : : -1 : 0
#var float gl_LightSource[2].constantAttenuation : state.light[2].attenuation.x : : -1 : 0
#var float gl_LightSource[2].linearAttenuation : state.light[2].attenuation.y : : -1 : 0
#var float gl_LightSource[2].quadraticAttenuation : state.light[2].attenuation.z : : -1 : 0
#var float4 gl_LightSource[3].ambient : state.light[3].ambient : : -1 : 0
#var float4 gl_LightSource[3].diffuse : state.light[3].diffuse : : -1 : 0
#var float4 gl_LightSource[3].specular : state.light[3].specular : : -1 : 0
#var float4 gl_LightSource[3].position : state.light[3].position : : -1 : 0
#var float4 gl_LightSource[3].halfVector : state.light[3].half : : -1 : 0
#var float3 gl_LightSource[3].spotDirection : state.light[3].spot.direction : : -1 : 0
#var float gl_LightSource[3].spotExponent : state.light[3].attenuation.w : : -1 : 0
#var float gl_LightSource[3].spotCutoff : NONE : : -1 : 0
#var float gl_LightSource[3].spotCosCutoff : state.light[3].spot.direction.w : : -1 : 0
#var float gl_LightSource[3].constantAttenuation : state.light[3].attenuation.x : : -1 : 0
#var float gl_LightSource[3].linearAttenuation : state.light[3].attenuation.y : : -1 : 0
#var float gl_LightSource[3].quadraticAttenuation : state.light[3].attenuation.z : : -1 : 0
#var float4 gl_LightSource[4].ambient : state.light[4].ambient : : -1 : 0
#var float4 gl_LightSource[4].diffuse : state.light[4].diffuse : : -1 : 0
#var float4 gl_LightSource[4].specular : state.light[4].specular : : -1 : 0
#var float4 gl_LightSource[4].position : state.light[4].position : : -1 : 0
#var float4 gl_LightSource[4].halfVector : state.light[4].half : : -1 : 0
#var float3 gl_LightSource[4].spotDirection : state.light[4].spot.direction : : -1 : 0
#var float gl_LightSource[4].spotExponent : state.light[4].attenuation.w : : -1 : 0
#var float gl_LightSource[4].spotCutoff : NONE : : -1 : 0
#var float gl_LightSource[4].spotCosCutoff : state.light[4].spot.direction.w : : -1 : 0
#var float gl_LightSource[4].constantAttenuation : state.light[4].attenuation.x : : -1 : 0
#var float gl_LightSource[4].linearAttenuation : state.light[4].attenuation.y : : -1 : 0
#var float gl_LightSource[4].quadraticAttenuation : state.light[4].attenuation.z : : -1 : 0
#var float4 gl_LightSource[5].ambient : state.light[5].ambient : : -1 : 0
#var float4 gl_LightSource[5].diffuse : state.light[5].diffuse : : -1 : 0
#var float4 gl_LightSource[5].specular : state.light[5].specular : : -1 : 0
#var float4 gl_LightSource[5].position : state.light[5].position : : -1 : 0
#var float4 gl_LightSource[5].halfVector : state.light[5].half : : -1 : 0
#var float3 gl_LightSource[5].spotDirection : state.light[5].spot.direction : : -1 : 0
#var float gl_LightSource[5].spotExponent : state.light[5].attenuation.w : : -1 : 0
#var float gl_LightSource[5].spotCutoff : NONE : : -1 : 0
#var float gl_LightSource[5].spotCosCutoff : state.light[5].spot.direction.w : : -1 : 0
#var float gl_LightSource[5].constantAttenuation : state.light[5].attenuation.x : : -1 : 0
#var float gl_LightSource[5].linearAttenuation : state.light[5].attenuation.y : : -1 : 0
#var float gl_LightSource[5].quadraticAttenuation : state.light[5].attenuation.z : : -1 : 0
#var float4 gl_LightSource[6].ambient : state.light[6].ambient : : -1 : 0
#var float4 gl_LightSource[6].diffuse : state.light[6].diffuse : : -1 : 0
#var float4 gl_LightSource[6].specular : state.light[6].specular : : -1 : 0
#var float4 gl_LightSource[6].position : state.light[6].position : : -1 : 0
#var float4 gl_LightSource[6].halfVector : state.light[6].half : : -1 : 0
#var float3 gl_LightSource[6].spotDirection : state.light[6].spot.direction : : -1 : 0
#var float gl_LightSource[6].spotExponent : state.light[6].attenuation.w : : -1 : 0
#var float gl_LightSource[6].spotCutoff : NONE : : -1 : 0
#var float gl_LightSource[6].spotCosCutoff : state.light[6].spot.direction.w : : -1 : 0
#var float gl_LightSource[6].constantAttenuation : state.light[6].attenuation.x : : -1 : 0
#var float gl_LightSource[6].linearAttenuation : state.light[6].attenuation.y : : -1 : 0
#var float gl_LightSource[6].quadraticAttenuation : state.light[6].attenuation.z : : -1 : 0
#var float4 gl_LightSource[7].ambient : state.light[7].ambient : : -1 : 0
#var float4 gl_LightSource[7].diffuse : state.light[7].diffuse : : -1 : 0
#var float4 gl_LightSource[7].specular : state.light[7].specular : : -1 : 0
#var float4 gl_LightSource[7].position : state.light[7].position : : -1 : 0
#var float4 gl_LightSource[7].halfVector : state.light[7].half : : -1 : 0
#var float3 gl_LightSource[7].spotDirection : state.light[7].spot.direction : : -1 : 0
#var float gl_LightSource[7].spotExponent : state.light[7].attenuation.w : : -1 : 0
#var float gl_LightSource[7].spotCutoff : NONE : : -1 : 0
#var float gl_LightSource[7].spotCosCutoff : state.light[7].spot.direction.w : : -1 : 0
#var float gl_LightSource[7].constantAttenuation : state.light[7].attenuation.x : : -1 : 0
#var float gl_LightSource[7].linearAttenuation : state.light[7].attenuation.y : : -1 : 0
#var float gl_LightSource[7].quadraticAttenuation : state.light[7].attenuation.z : : -1 : 0
#const c[5] = 2 1 0.5 0
#const c[6] = 0.60000002 0.54000002 0.80000001 0.2
PARAM c[7] = { program.local[0],
state.light[0].ambient,
state.light[0].diffuse,
program.local[3],
state.light[0].position,
{ 2, 1, 0.5, 0 },
{ 0.60000002, 0.54000002, 0.80000001, 0.2 } };
TEMP R0;
TEMP R1;
TEMP RC;
TEMP HC;
OUTPUT oCol = result.color;
TEX R0, fragment.texcoord[0], texture[0], 2D;
MADR R0.xyz, R0, c[5].x, -c[5].y;
MULR R1.xyz, R0.y, fragment.texcoord[2];
MADR R1.xyz, R0.x, fragment.texcoord[1], R1;
MADR R0.xyz, R0.z, fragment.texcoord[3], R1;
DP3R R1.x, R0, R0;
RSQR R1.x, R1.x;
SGTRC HC.x, R0.w, c[5].z;
MULR R0.xyz, R1.x, R0;
IF NE.x;
DP3R R0.x, R0, c[4];
MOVR R0.w, c[6].y;
MULR R1.xyz, R0.w, c[1];
MAXR R0.x, R0, c[5].w;
MULR R0.xyz, R0.x, c[2];
MOVR R0.w, c[5].y;
MADR R0.xyz, R0, c[6].x, R1;
MINR oCol, R0, c[5].y;
ELSE;
DP3R R0.x, R0, c[4];
MOVR R0.y, c[6].w;
MULR R1.xyz, R0.y, c[1];
MAXR R0.x, R0, c[5].w;
MULR R0.xyz, R0.x, c[2];
MADR oCol.xyz, R0, c[6].z, R1;
MOVR oCol.w, c[5].y;
ENDIF;
TEX R0, fragment.texcoord[0], texture[1], 2D;
MULR oCol, oCol, R0;
END
# 29 instructions, 2 R-regs, 0 H-regs

program link failed


Share this post


Link to post
Share on other sites
Yikes!

Tbh. I have absolutely no idea what kind of error that is other than what it says in the first line. It doesn't exactly give away what i need to fix though. Could you give me some info on what kind of hardware you're using to render?

Also did anyone by chance catch the text written in parenthesis when the error message popped up? That gives away which shader screwed up. I should put that into the file as well I guess.
Did it continue rendering anyway? All my shader using functions have fallback functionality to continue as best as possible.

Thanks for the info though. I only have one architecture to test on so unspected stuff like this is to be expected i guess ;)

* EDIT *

Hmm, it might be that the shader architecture your graphics card uses doesn't allow readback of values written into vertex shader output variables. I may have to check back where that is done anyway. But so far that's the only clue I have...


* EDIT *

Okay, after reading into this strange output a little more i believe that the problem is indeed a variable that that shader implementation there would like as write-only.
I have compiled an experimental dll which _might_ solve that problem. It also exports a much more detailed error file now (renamed it to 'shader_exception.txt').
Could the people that had the above error please download and try this dll:
http://www.delta-works.org/download/get.php?name=TreeLib&file=experimental dll&ext=zip
Replace the file treelib.dll (which comes with the demo) with the file in this zip file and execute the demo.

This is just an experimental version to figure out what the hell went wrong. Since I'm currently trying to revise the branch appearance, even implement wind, the trees in this version look slightly odd with not enough leaves.

Please let me know how it goes.

[Edited by - IronFox on October 26, 2008 2:32:41 PM]

Share this post


Link to post
Share on other sites
Well, whatever the case I have an update.
I reworked the core engine and added a s***load of attributes to specify how trees look. I _suspect_ that it's now possible to create a huge magnitude of different typed trees but I'm not certain. Might be that this is the only halfway usable tree form, who knows. It certainly still creates a lot of tree oddities.
If someone wants to play around with the attributes, be my guest.
Either way, i also added tree age, wind (which may need work) and (for my planetary engine) snow/ice:

The snow/ice can be specified as a float attribute from 0=no ice to 1=frozen over.

I updated the demo and added a version 0.85 zip file.
(Just a small notice about that: I added a feature to catch mouse up events outside the demo application window, using the evil windows hook feature. I have no idea if there's any other way but just in case any paranoid spyware warnings go off, i can assure you it only catches mouse up events ;P)

I noticed that there's a massive field of options, what to try, what works and what doesnt, regarding trees. I could probably make a second diploma subject out of this but i already got one so it's gonna stay the way it is now :)
I'll try to fix any bugs that you people dig up, though. I hope this new version fixes the previous errors but since there's been no replies i can't tell.

Share this post


Link to post
Share on other sites
Demo works perfectly, but when I try to add it to my project I get a popup with the following message:

Shader installation of object #6 failed
Stack-Underflow

False alarm. Shader is installed properly. The program may behave unstable from here on.

And then the tree no longer renders. Please note that for the first frame, I see the tree and then message pops up and pauses everything. When I close it is when it stops rendering the tree, but everything else continues to render okay.

And then shader_error.txt contains the following:

-------- scanning vertex shader --------
-------- scanning fragment shader --------
-------- scanning geometry shader --------
loading process finished gracefully.

-- shader(35633) construction --
(14) : error C1102: incompatible type for parameter #2 ("n")
(14) : warning C7011: implicit cast from "float4" to "float3"
(14) : warning C7011: implicit cast from "float4" to "float3"
internal error: shader did not compile

original source was:
--------------------------------
(1)
(2) vec4 shade(vec3 position, vec3 normal, vec3 reflected)
(3) {
(4) return vec4(1.0);
(5) }
(6)
(7)
(8) void main()
(9) {
(10) gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
(11) vec4 position = (gl_ModelViewMatrix*gl_Vertex)+vec4(gl_MultiTexCoord0.z,gl_MultiTexCoord0.w,0.0,0.0);
(12) gl_Position = gl_ProjectionMatrix*position;
(13) vec3 normal = (gl_NormalMatrix*gl_Normal);
(14) gl_FrontColor = shade(position,normal,reflect(position,normal));
(15) }
(16)
--------------------------------

-- shader(35632) construction --

original source was:
--------------------------------
(1)
(2) uniform sampler2D texture;
(3) void main()
(4) {
(5) gl_FragColor = gl_Color*texture2D(texture,gl_TexCoord[0].xy);
(6) }
--------------------------------
(shader-fragment(s) not set)



Any ideas?

Share this post


Link to post
Share on other sites

This topic is 3302 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this