Glass material

How to make a transparent material with visible specular (not reflections like water) and refraction? Is there a standard feature in engine for this, or is need to write a shader?

i tried so:
GlassTechnique.xml

<technique vs="LitSolid" ps="LitSolid" vsdefines="NOUV" >
    <pass name="litalpha" depthwrite="false" blend="addalpha" />
</technique>

glass.xml

<?xml version="1.0"?>
<material>
	<technique name="Techniques/GlassTechnique.xml"/>
	<parameter name="MatDiffColor" value="0.2 0.2 0.2 1"/>
	<parameter name="MatSpecColor" value="1 1 1 300"/>
</material>
Screenshot

<?xml version="1.0"?>
<material>
	<technique name="Techniques/GlassTechnique.xml"/>
	<parameter name="MatDiffColor" value="0.0 0.0 0.0 1"/>
	<parameter name="MatSpecColor" value="1 1 1 300"/>
</material>
Screenshot

but without refraction it look nonrealistic.

Another question. It is possible in Urho mix (blending) two materials? Like youtube.com/watch?v=OlxfJlNK1RM

Hi,

Sure but you need to source refraction from somewhere:
https://github.com/urho3d/Urho3D/blob/master/bin/CoreData/RenderPaths/Forward.xml
Pretty sure the water shader grabs the environment texture unit from this pass.
https://github.com/urho3d/Urho3D/blob/master/bin/CoreData/Techniques/Water.xml
https://github.com/urho3d/Urho3D/blob/master/bin/CoreData/Shaders/GLSL/Water.glsl
Yep. But I think it’s an inverted camera matrix maybe, so it’s only good for perfectly flat horizontal water. You might need to re-jig the renderpath to just source the whole framebuffer result into a texture and then distort it with the normals of the sphere, yay refraction.

For reflection you’ll need some cube map, maybe bound to the zone’s texture unit slot.

I combined water and specular and receive interesting result

GlassTechnique.xml

<technique vs="Water" ps="Water" >
    <pass name="refract" />
    <pass name="litalpha" depthwrite="false" blend="addalpha" vs="LitSolid" ps="LitSolid" vsdefines="NOUV" />
</technique>

Glass.xml

<?xml version="1.0"?>
<material>

    <parameter name="NoiseSpeed" value="0 0" />
    <parameter name="NoiseTiling" value="50" />
    <parameter name="NoiseStrength" value="0.02" />
    <parameter name="FresnelPower" value="5" />
    <parameter name="WaterTint" value="1 1 1" />

    <parameter name="MatDiffColor" value="0.12 0.12 0.12 1"/>
    <parameter name="MatSpecColor" value="1 1 1 300"/>

    <technique name="Techniques/GlassTechnique.xml"/>

</material>

But there is a strange bug: when near on front scene is object with water material refraction switched off


I fix the problem: necessarily need to set any empty normal texture:

Glass.xml

<?xml version="1.0"?>
<material>

    <texture unit="normal" name="Textures/UrhoDecalAlpha.dds" />
    <parameter name="NoiseSpeed" value="0 0" />
    <parameter name="NoiseTiling" value="50" />
    <parameter name="NoiseStrength" value="0.02" />
    <parameter name="FresnelPower" value="5" />
    <parameter name="WaterTint" value="1 1 1" />

    <parameter name="MatDiffColor" value="0.12 0.12 0.12 1"/>
    <parameter name="MatSpecColor" value="1 1 1 300"/>

    <technique name="Techniques/GlassTechnique.xml"/>

</material>

Edit: The glass object can not be seen through the other glass object
http://s018.radikal.ru/i525/1508/48/06560a3801a9.jpg

Oh, my bad dream - RenderPath, i’m still do not know how it all works.
But try this tech
glassTech.xml

<technique vs="Water" ps="Water" >
    <pass name="postopaque" depthwrite="false" blend="addalpha" />
    <pass name="light" depthwrite="false" blend="addalpha" vs="LitSolid" ps="LitSolid" vsdefines="NOUV" />
    <pass name="refract" />    
</technique>

  • You are also must to play with alpha value in matDiffColor in material

It seems that this technique refract specularity

Without light sources look strange

I got the same effect if normal map are was missed in slot, you need put to normal texture unit some texture maybe with 1x1 pixel with one flat normal vector within. Just for right calculations in shader.
I’m bake a simple flat normal map, try it (normal 128x128 )
rghost.net/66hYYljNC

Also I found if you try create copy of these glass-objects they are all missing at once from camera view.
So to solve this you may turn-off the “dynamic instancing” in editor preferences. I don’t know but I guess this some kind of render bug.

But then the refraction does not work

1x1 texture with color (132, 158, 247)

texture is white pixel - the same artifact

4 posts were split to a new topic: Non-moderators editing posts