WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Standard Texture setup (https://forum.worldviz.com/showthread.php?t=5628)

rawphl 02-04-2016 06:52 AM

Standard Texture setup
 
How do you apply a standard texture setup (diffuse, normal, specular) to a model in vizard? I know GLSL so I could write a shader (although the vizard documentation is unclear on a lot of things, e.g. how is the uv attribute/varying called? Or is it using the old gl_TexCoord?)
but I'm sure this is already integrated.

Can I get a code example? I played around with vizfx.addMaterialEffect (which also isn't documented) but vizard would normally just use the diffuse texture and ignore the rest.

Thanks in advance.

Jeff 02-05-2016 01:16 AM

I'll check with a developer and get back to you.

rawphl 02-08-2016 03:21 AM

1 Attachment(s)
I think I got this to work:

Code:

import viz
import vizcam
import vizshape
import vizfx

from vizfx.effect.material import BaseMaterial, Diffuse, Specular, Bump

viz.setMultiSample(8)
viz.fov(60)
viz.go()
viz.MainView.getHeadLight().remove()

pivot_nav = vizcam.PivotNavigate()
pivot_nav.rotateUp(60)
pivot_nav.setDistance(1)
viz.cam.setHandler(pivot_nav)

light1 = vizfx.addDirectionalLight(euler = (45, 45, 0))
vizfx.setAmbientColor([0, 0, 0])


box = vizfx.addChild('basketball.osgb')

diffuse_map = viz.addTexture("pattern_66_diffuse.png")
diffuse_map.wrap(viz.WRAP_T, viz.REPEAT)
diffuse_map.wrap(viz.WRAP_S, viz.REPEAT)
normal_map = viz.addTexture("pattern_66_normal.png")
normal_map.wrap(viz.WRAP_T, viz.REPEAT)
normal_map.wrap(viz.WRAP_S, viz.REPEAT)
specular_map = viz.addTexture("pattern_66_specular.png")
specular_map.wrap(viz.WRAP_T, viz.REPEAT)
specular_map.wrap(viz.WRAP_S, viz.REPEAT)
material = vizfx.addMaterialEffect(
    Diffuse(diffuse_map, 0), Bump(normal_map, 1), Specular(specular_map, 2)
)
box.apply(material)

The textures are too big to upload to the forum, but the gist should be clear, see screenshot for the result.

I would still like to know if this is the intended way to do it ;)


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

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