WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-27-2015, 11:11 AM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
Fading a PNG texture with alpha

I am trying to add a png file on a separate texture unit and fade it in and out. For some reason Vizard does not recognize the transparent part of PNG as having alpha 0 (100% transparent), but rather as completely black. Using texblend has also no impact on this area, neither does setting the appearance to different values.

What's the problem? And can you actually fade in/out a texture, keeping the underlying one (unit=0) totally opaque?
Reply With Quote
  #2  
Old 06-30-2015, 03:39 PM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
Still problems with texture replace or multi-texture

Any update on this?
I am also trying to apply a texture on another node that has a material pre-assigned in 3DS. No matter what image I use as a texture, only the color of the texture is applied and the actual texture is totally ignored. I am using again the "appearance" property with TEXREPLACE, but has no effect besides getting rid of the pre-exiting material.

I include my attempt. It shouldn't be that hard, but it doesn't work as the multi-texture example in the documentation with the Worldviz logo. What am I missing here?

Thanks.
Attached Files
File Type: zip replace-texture.zip (9.2 KB, 893 views)
Reply With Quote
  #3  
Old 07-01-2015, 05:51 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
For the first question, you could use a shader to multiply a blend value with the transparent texture and add that to the base texture. Here's an example:

Code:
import viz
viz.go()

viz.addChild('piazza.osgb')

quad = viz.addTexQuad(pos=[0,1.8,5])
texture = viz.addTexture('images/tile_grass.jpg')
texture2 = viz.addTexture('crosshair.png')
quad.texture(texture)
quad.texture(texture2,unit=1)

frag = """
uniform sampler2D map1;
uniform sampler2D map2;
uniform float blend;
void main()
{
	vec4 clr1 = texture2D(map1,gl_TexCoord[0].st);
	vec4 clr2 = texture2D(map2,gl_TexCoord[0].st);
	gl_FragColor = clr1+clr2*blend;
}
"""
shader = viz.addShader(frag=frag)
shader.attach(viz.addUniformInt('map1',0))
shader.attach(viz.addUniformInt('map2',1))
blend = viz.addUniformFloat('blend',0.0)
shader.attach(blend)
quad.apply(shader)

slider = viz.addSlider(pos=(0.5,0.1,0))
slider.set(0)

import vizact
vizact.onslider(slider,blend.set)
Please create a new thread for the second question for further assistance. The model does not seems to have texture coordinates.
Reply With Quote
  #4  
Old 07-06-2015, 02:50 PM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
Thanks Jeff. This was actually the solution I've been looking for but haven't worked with shaders before.

As for the second question, it's true indeed that there are no text coords; I admit I forgot about this, as it's been quite a while since I did some modelling. Can you tell me if I have the option to add them in Vizard (or Inspector) and how, or I need only use 3ds? I am actually trying to make this object look rusty (avoiding 3ds, if possible). I'd rather try to resolve this some more, before I repost in another thread, if this is an easy fix.

Thanks!

Last edited by tokola; 07-06-2015 at 02:57 PM.
Reply With Quote
Reply


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
OSG Exporter - Texture seams somehow have alpha JvdBosch Vizard 12 01-03-2013 03:02 PM
How to render a texture of the transparent object and then blur it whj Vizard 1 09-25-2012 03:15 PM
Avatar texture swaping sleiN13 Vizard 5 06-24-2011 12:48 AM
How to apply shader and render texture to an object whj Vizard 0 04-23-2010 12:23 PM
Translating a texture and its Alpha shivanangel Vizard 5 12-02-2008 04:52 PM


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


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