Really cool grass shader

Discussion about everything. New games, 3d math, development tips...
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Really cool grass shader

Post by bitplane »

It doesn't look too hard to implement, doesn't alter the rendering pipeline, and the effect looks really good. The only down-side is that it requires quite a fast GPU, but it totally kicks the crap out of my mesh-based grass for draw distance, (not for realism though)

I thought I'd post this here in case it inspires someone to implement a nice free version :)

http://www.youtube.com/watch?v=yBIHr8kI3XA%20
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

cool, but when you look from the sky you can notice all the grids...
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

It does look pretty cool from a shallow angle, obviously from above it's pretty terrible but most uses of grass will be from a shallow angle i guess...

Although if you're walking through it then you would see it from above as well if you looked near your feet... Maybe you could do some extra calculations so if it's a deep angle you're looking at then it would render differently...
Image Image Image
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

It looks cool - maybe we can use the ground's normal vector to make the grass semi-transparent depending on your angle of view. Speaking of normal-vectors, is it even possible to implement on a curved surface (ie. not flat)?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

After following a few links I got to the HLSL version of the shader: http://www.cg.tuwien.ac.at/research/pub ... hader.HLSL

Might give it a go :D
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Ok, heres an early test version for all you that can't wait :lol: (Requires PS 3.0)

http://irrlichtirc.g0dsoft.com/BlindSide/grass.zip

Screeny:
Image
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

didnt work for me, said it couldnt create the shader, i guess i don't have ps3!
Image Image Image
sRc
Posts: 431
Joined: Thu Jul 28, 2005 1:44 am
Location: Salt Lake City, Utah
Contact:

Post by sRc »

BlindSide wrote:Ok, heres an early test version for all you that can't wait :lol: (Requires PS 3.0)

http://irrlichtirc.g0dsoft.com/BlindSide/grass.zip

Screeny:
*snip*
Just tried it, looks pretty good :) the grid lines in the distance are a little distracting tho
The Bard sRc

Blog | Twitter
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Yeah looks really nice apart from the edges, I fixed it like this-

Code: Select all

// line 177
			float4 biased;
			biased.xy = orthoLookup;
			biased.z = 0;
			biased.w = -100.0;
  			 
 	 		color += (1.0-color.w)*tex2Dbias(grassblades,biased);//orthoLookup);
But I doubt that's the best way to fix it! (still a shader newbie at the moment)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Yeah those grid lines are getting a little bit annoying, I agree. Great shader though BlindSide! Keep up the good work.

I would like to maybe recommend doing an alpha blend pass, or maybe a blur pass to make the edges a little bit better.

*Halifax needs to learn how to do shaders, and get a better graphics card. :/
TheQuestion = 2B || !2B
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Yay, thanks for fixing the edges. Im not sure how you did that or what tex2Dbias does, but its looking great, heres a screenshot for Halifax and JP:



Image


EDIT: Hmmm, It has to do with the mipmap levels eh? Lemme try disabling mipmaps on texture creation in the application itself...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Ok I updated the demo. I fixed the grid lines thing by disabling mipmaps on the "grassblades" image and I also added the choice for per-pixel lighting and how many ray-passes.

Same download link: http://irrlichtirc.g0dsoft.com/BlindSide/grass.zip

Screenshot of per-pixel lighting in action:

Image
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

You are fast! :D
sRc
Posts: 431
Joined: Thu Jul 28, 2005 1:44 am
Location: Salt Lake City, Utah
Contact:

Post by sRc »

woah that made it freak out :shock:

Image

color-changing where the texture starts freaking out (and that moves and changes when you move the camera), but the highlight is the console is absolutely wigging out with that error something like every frame!
The Bard sRc

Blog | Twitter
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Ok I fixed it... Same link.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply