PDA

View Full Version : Standard Texture setup


rawphl
02-04-2016, 06:52 AM
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
I think I got this to work:


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 ;)