WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 03-30-2011, 06:18 PM
Zhi Zhi is offline
Member
 
Join Date: Mar 2011
Posts: 49
3D grass shader to mimic large grass field

Hi all,

I am new to Vizard. I used Virtools previously. There are some sample compositions in the Virtools forum, using shader to create mimic grass field effect. Some 3d model software, such as the 3ds max, also support online rendering of grass/fur effect. I am curious whether anyone has used shader in Vizard to mimic large field of grass land. Is there any link or script that we can share on this topic?

Thank you.
Zhi
Reply With Quote
  #2  
Old 04-02-2011, 01:55 PM
Zhi Zhi is offline
Member
 
Join Date: Mar 2011
Posts: 49
Never mind. I found a way to use 2D texture to create a wonderul large grass land effect.

Close the thread.
Zhi
Reply With Quote
  #3  
Old 04-13-2011, 12:56 AM
JvdBosch JvdBosch is offline
Member
 
Join Date: Sep 2006
Posts: 36
Quote:
Originally Posted by Zhi View Post
Never mind. I found a way to use 2D texture to create a wonderul large grass land effect.
Please share this with the rest of us. Did you use the shell technique?
Reply With Quote
  #4  
Old 04-13-2011, 10:21 AM
Zhi Zhi is offline
Member
 
Join Date: Mar 2011
Posts: 49
I do not use any shell technique. I simply found a very nice seamless grass texture (as attached) and applied it to the ground. To get rid of the regular pattern due to the repeated tiling of the grass patch (which gives a strong linear perspective cue). I 'blend' the detailed grass ground with a huge noise texture surface. The visual effect of such a grass field looks pretty good, even though it is still 2D textured. Here is the code:

grass = viz.addTexture('Grass.jpg') #Create the detailed grassland with about 100 m in diameter
for x in range(-51, 52, 2):
for z in range(-51, 52, 2):
if (x*x + z*z) < 52*52:
ground = viz.addTexQuad()
ground.setScale([2,2,1])
ground.setPosition([x, 0, z])
ground.setEuler([0, 90, 0])
ground.texture(grass) # Wrap texture on quad

BK = viz.addTexture('Noise.jpg') #Blend the detailed grassland with a low frequency noise map 100 m x 100 m
BKGrnd = viz.addTexQuad()
BKGrnd.setScale([100,100,1])
BKGrnd.setPosition([0, 0, 0])
BKGrnd.setEuler([0, 90, 0])
BKGrnd.texture(BK)
BKGrnd.zoffset(-1)
BKGrnd.alpha(0.2)
Attached Thumbnails
Click image for larger version

Name:	Grass.jpg
Views:	25562
Size:	1.05 MB
ID:	416   Click image for larger version

Name:	Noise.JPG
Views:	1992
Size:	768.7 KB
ID:	417  
Reply With Quote
  #5  
Old 04-14-2011, 05:05 AM
JvdBosch JvdBosch is offline
Member
 
Join Date: Sep 2006
Posts: 36
You can also put the same texture in another map channel and repeat it on a larger scale, possible even rotated.

Code:
                    tex = node.getTexture(unit=0)
                    node.texture(tex,unit=1)
                    node.texblend(0.2,unit=1)
                    trans = viz.Transform()
                    trans.setScale([0.2,0.2,0.2])
                    trans.setAxisAngle(vizmat.EulerToAxisAngle(0,0,45))
                    node.texmat(trans,unit=1)
Reply With Quote
  #6  
Old 04-14-2011, 10:35 AM
Zhi Zhi is offline
Member
 
Join Date: Mar 2011
Posts: 49
Hi JvdBosch,

What does the trans.setScale([0.2,0.2,0.2]) do. Does it rescale the node or the texture map?

In my code, I have more than 2000 small ground patches (2m x 2m) with the same texture. I have another huge ground patch (100m x 100m) which has a different texture. My question is whether I can blend the two textures as if they were applied to the same node (i.e. the 100m x 100m patch), using the texblend function you suggest?
Reply With Quote
  #7  
Old 04-18-2011, 06:38 AM
JvdBosch JvdBosch is offline
Member
 
Join Date: Sep 2006
Posts: 36
The setScale indeed rescales the copy of the texture, to be re-applied to the node and blended with the original texture.

I don't get your second question... Could you clarify it?
Reply With Quote
  #8  
Old 04-18-2011, 09:03 AM
Zhi Zhi is offline
Member
 
Join Date: Mar 2011
Posts: 49
Quote:
Originally Posted by JvdBosch View Post
The setScale indeed rescales the copy of the texture, to be re-applied to the node and blended with the original texture.

I don't get your second question... Could you clarify it?
My understanding of the node.texblend() method is that it blends the two texture layers of the same entity. In my case, it is the ground. If the ground is only a single entity, this might work. However, the grass texture I have only matches 2 m x 2 m area (if you apply it to a larger area, it looks not real). To have a larger area of grass field, I have to repeat the ground patch (in my case, more than 2000 repeats). Although the texture itself is seamless (it is amazingly made), it contains both high spatial frequency and low spatial frequency components. The high spatial frequency component will make the repeated ground contain noticeable linear perspective cue. It is trivial for most VR applications, such as games. But, it is not good for some spatial perception experiments, because the real grass field do not have such a strong linear perspective cue. The trick I used here is to superimpose a huge texture (the 100m x 100m patch), which only contains low frequency component. This will substantially reduce the noticeable linear perspective cure. See the attached screen shots for comparison. To do this, I used the node.alpha() method. My question is whether the node.texblend() method can accomplish it as well.
Attached Thumbnails
Click image for larger version

Name:	linearperspective.JPG
Views:	1566
Size:	46.6 KB
ID:	418   Click image for larger version

Name:	less linear perspective.JPG
Views:	1557
Size:	52.8 KB
ID:	419  

Last edited by Zhi; 04-18-2011 at 09:06 AM.
Reply With Quote
  #9  
Old 04-21-2011, 07:34 AM
JvdBosch JvdBosch is offline
Member
 
Join Date: Sep 2006
Posts: 36
What happens if you use my code on your grass node, without superimposing this other texture?
Another option is a blend-shader which blends according to the distance to the viewpoint, to keep close sharpness.
Reply With Quote
  #10  
Old 04-22-2011, 02:43 PM
Zhi Zhi is offline
Member
 
Join Date: Mar 2011
Posts: 49
Seems not help with your code (see attached screen shot). I assumed the "node" in your code is the "ground" in my code.
Attached Thumbnails
Click image for larger version

Name:	Test.JPG
Views:	8054
Size:	167.9 KB
ID:	420  
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a nice grass field? Xianshi Xie Vizard 1 07-01-2009 12:26 PM
Multiple Textures for Diffuse and Specularity Shader Issue shivanangel Vizard 1 05-11-2009 10:44 AM


All times are GMT -7. The time now is 03:57 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC