Jump to content

How to use billboard shader?


omid3098
 Share

Recommended Posts

I checked previous versions(since 2.14) but I could not make billboard shader work.. and actually I could not understand how auto billboard generator(used for vegetation system) use this shader..

so.. please help me!

Omid Saadat

OD Arts Blog

 

AMD Phenom II X4 940 - Geforce 8800GTS - 4GB RAM - XP x86

AMD 6000+ - Geforce 9800 GT - 2GB RAM - XP x86 (Home pc)

Intel Core i7 - Geforce 310M - 4GB Ram - Win7 x64 (Laptop)

Link to comment
Share on other sites

  • 1 month later...

I had posted this for CopperCircle last week, but its gone now...

 

First, unpack the shaders.pak, and change the mesh.vert to include these lines:

#ifdef LW_BILLBOARD
     	vertexcameraposition = (gl_ModelViewProjectionMatrix * mat[3]) + vec4(gl_Vertex.x,gl_Vertex.y*(buffersize.x/buffersize.y),0.0,0.0);
#endif

 

Place them after the sway if-defined statement right after the vertexcameraposition and before the textcoord0 statements:

...

...

#ifdef LW_SWAY

float seed = mod(apptime / 100.0 * 0.25,360.0);

seed += mat[3].x*33.0 + mat[3].y*67.8 + mat[3].z*123.5;

seed += gl_Vertex.x + gl_Vertex.y + gl_Vertex.z;

vec4 movement = vec4( vec3( gl_Color.x * gl_Normal * LW_SWAY * (sin(seed)+0.25*cos(seed*5.2+3.2)) ),0.0);

modelvertex += movement;

fragcolor = color;

#endif

 

vertexposition = modelvertex.xyz;

vertexcameraposition = gl_ModelViewProjectionMatrix * modelvertex;

 

#ifdef LW_BILLBOARD

vertexcameraposition = (gl_ModelViewProjectionMatrix * mat[3]) + vec4(gl_Vertex.x,gl_Vertex.y*(buffersize.x/buffersize.y),0.0,0.0);

#endif

 

 

texcoord0=gl_MultiTexCoord0.xy;

texcoord1=gl_MultiTexCoord1.xy;

...

...

 

Here is an example billboard that you can drop in the editor:

 

Note: Make sure you only have one mesh.vert inside your SDK or you cannot guarantee what file the engine will grab using the abstract file method.

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Thank you very much!

let me check it.. ;)

I found that lots of speedtree leaves have billboard shader. and as my trees are little **** right now(!) I have to check them with this technique.. :)

Omid Saadat

OD Arts Blog

 

AMD Phenom II X4 940 - Geforce 8800GTS - 4GB RAM - XP x86

AMD 6000+ - Geforce 9800 GT - 2GB RAM - XP x86 (Home pc)

Intel Core i7 - Geforce 310M - 4GB Ram - Win7 x64 (Laptop)

Link to comment
Share on other sites

For leaves on a tree, i do not think a billboard is what you want to use. A billboard makes the image always face the camera... a leaf doesn't do that.

 

You would want to use a plane mesh that has the leaf texture on it, and then use something like this for a material file:

texture0="abstract::oak_leaf.dds"
texture1="abstract::oak_leafdot3.dds"
bumpscale=0.3
cullface=0
shader="abstract::mesh_diffuse_bumpmap_sway.vert","abstract::mesh_diffuse_bumpmap_alphatest.frag"
shadowshader="abstract::mesh_shadow_sway.vert","abstract::mesh_shadow.frag"

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

yes, I know.. it's what I'm using right now.. but speedtree uses exactly billboards for leaves in some of its trees..I checked many tutorials about making trees and some of them used this technique too..

Omid Saadat

OD Arts Blog

 

AMD Phenom II X4 940 - Geforce 8800GTS - 4GB RAM - XP x86

AMD 6000+ - Geforce 9800 GT - 2GB RAM - XP x86 (Home pc)

Intel Core i7 - Geforce 310M - 4GB Ram - Win7 x64 (Laptop)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...