ai.Get(AI_MATKEY_SHININESS, shininess);
ai.Get(AI_MATKEY_REFLECTIVITY, reflectivity);
ai.Get(AI_MATKEY_REFRACTI, refractiveIndex);
- ai.Get(AI_MATKEY_OPACITY, opacity);
+ if (ai.Get(AI_MATKEY_OPACITY, opacity) == aiReturn_FAILURE)
+ opacity = 1.f;
ai.Get(AI_MATKEY_COLOR_AMBIENT, ambient);
ai.Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
}
void Material::bind() const {
- glUniform4f(glGetUniformLocation(progId, "material.ambient"), ambient.r, ambient.g, ambient.b, ambient.a);
+ /* glUniform4f(glGetUniformLocation(progId, "material.ambient"), ambient.r, ambient.g, ambient.b, ambient.a); */
+ glUniform4f(glGetUniformLocation(progId, "material.ambient"), 0.2, 0.2, 0.2, 1);
glUniform4f(glGetUniformLocation(progId, "material.diffuse"), diffuse.r, diffuse.g, diffuse.b, diffuse.a);
glUniform4f(glGetUniformLocation(progId, "material.specular"), specular.r, specular.g, specular.b, specular.a);
glUniform1f(glGetUniformLocation(progId, "material.shininess"), shininess);
<author>Blender User</author>
<authoring_tool>Blender 2.79.0 commit date:2018-03-22, commit time:14:10, hash:f4dc9f9</authoring_tool>
</contributor>
- <created>2018-11-08T03:10:17</created>
- <modified>2018-11-08T03:10:17</modified>
+ <created>2018-11-13T12:14:34</created>
+ <modified>2018-11-13T12:14:34</modified>
<unit name="meter" meter="1"/>
<up_axis>Z_UP</up_axis>
</asset>
<image id="brickwall_normal_jpg" name="brickwall_normal_jpg">
<init_from>brickwall_normal.jpg</init_from>
</image>
+ <image id="brickwall_jpg" name="brickwall_jpg">
+ <init_from>brickwall.jpg</init_from>
+ </image>
</library_images>
<library_effects>
<effect id="Mirror-effect">
<shininess>
<float sid="shininess">50</float>
</shininess>
+ <reflective>
+ <color>1 1 1 1</color>
+ </reflective>
+ <reflectivity>
+ <float>1</float>
+ </reflectivity>
+ <index_of_refraction>
+ <float sid="index_of_refraction">1.6</float>
+ </index_of_refraction>
+ </phong>
+ <extra>
+ <technique profile="FCOLLADA">
+ <bump>
+ <texture texture="brickwall_normal_jpg-sampler" texcoord="UVMap"/>
+ </bump>
+ </technique>
+ </extra>
+ </technique>
+ </profile_COMMON>
+ </effect>
+ <effect id="Glass-effect">
+ <profile_COMMON>
+ <technique sid="common">
+ <phong>
+ <emission>
+ <color sid="emission">0 0 0 1</color>
+ </emission>
+ <ambient>
+ <color sid="ambient">0 0 0 1</color>
+ </ambient>
+ <diffuse>
+ <color sid="diffuse">0.64 0.64 0.64 1</color>
+ </diffuse>
+ <specular>
+ <color sid="specular">0.5 0.5 0.5 1</color>
+ </specular>
+ <shininess>
+ <float sid="shininess">50</float>
+ </shininess>
<transparent opaque="A_ONE">
- <color>1 1 1 0.2</color>
+ <color>1 1 1 0.04907978</color>
</transparent>
+ <index_of_refraction>
+ <float sid="index_of_refraction">1.1</float>
+ </index_of_refraction>
+ </phong>
+ </technique>
+ </profile_COMMON>
+ </effect>
+ <effect id="Brick_wall-effect">
+ <profile_COMMON>
+ <newparam sid="brickwall_jpg-surface">
+ <surface type="2D">
+ <init_from>brickwall_jpg</init_from>
+ </surface>
+ </newparam>
+ <newparam sid="brickwall_jpg-sampler">
+ <sampler2D>
+ <source>brickwall_jpg-surface</source>
+ </sampler2D>
+ </newparam>
+ <newparam sid="brickwall_normal_jpg-surface">
+ <surface type="2D">
+ <init_from>brickwall_normal_jpg</init_from>
+ </surface>
+ </newparam>
+ <newparam sid="brickwall_normal_jpg-sampler">
+ <sampler2D>
+ <source>brickwall_normal_jpg-surface</source>
+ </sampler2D>
+ </newparam>
+ <technique sid="common">
+ <phong>
+ <emission>
+ <color sid="emission">0 0 0 1</color>
+ </emission>
+ <ambient>
+ <color sid="ambient">0 0 0 1</color>
+ </ambient>
+ <diffuse>
+ <texture texture="brickwall_jpg-sampler" texcoord="UVMap"/>
+ </diffuse>
+ <specular>
+ <color sid="specular">0.5 0.5 0.5 1</color>
+ </specular>
+ <shininess>
+ <float sid="shininess">50</float>
+ </shininess>
<index_of_refraction>
<float sid="index_of_refraction">1.6</float>
</index_of_refraction>
<material id="Mirror-material" name="Mirror">
<instance_effect url="#Mirror-effect"/>
</material>
+ <material id="Glass-material" name="Glass">
+ <instance_effect url="#Glass-effect"/>
+ </material>
+ <material id="Brick_wall-material" name="Brick_wall">
+ <instance_effect url="#Brick_wall-effect"/>
+ </material>
</library_materials>
<library_geometries>
<geometry id="Cube-mesh" name="Cube">
<vertices id="Suzanne-mesh-vertices">
<input semantic="POSITION" source="#Suzanne-mesh-positions"/>
</vertices>
- <triangles count="967">
+ <triangles material="Glass-material" count="967">
<input semantic="VERTEX" source="#Suzanne-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Suzanne-mesh-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Suzanne-mesh-map-0" offset="2" set="0"/>
</triangles>
</mesh>
</geometry>
+ <geometry id="Cube_001-mesh" name="Cube.001">
+ <mesh>
+ <source id="Cube_001-mesh-positions">
+ <float_array id="Cube_001-mesh-positions-array" count="24">1 1 -1 1 -1 -1 -1 -0.9999998 -1 -0.9999997 1 -1 1 0.9999995 1 0.9999994 -1.000001 1 -1 -0.9999997 1 -1 1 1</float_array>
+ <technique_common>
+ <accessor source="#Cube_001-mesh-positions-array" count="8" stride="3">
+ <param name="X" type="float"/>
+ <param name="Y" type="float"/>
+ <param name="Z" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="Cube_001-mesh-normals">
+ <float_array id="Cube_001-mesh-normals-array" count="36">0 0 -1 0 0 1 1 0 -2.38419e-7 0 -1 -4.76837e-7 -1 2.38419e-7 -1.49012e-7 2.68221e-7 1 2.38419e-7 0 0 -1 0 0 1 1 -5.96046e-7 3.27825e-7 -4.76837e-7 -1 0 -1 2.38419e-7 -1.19209e-7 2.08616e-7 1 0</float_array>
+ <technique_common>
+ <accessor source="#Cube_001-mesh-normals-array" count="12" stride="3">
+ <param name="X" type="float"/>
+ <param name="Y" type="float"/>
+ <param name="Z" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="Cube_001-mesh-map-0">
+ <float_array id="Cube_001-mesh-map-0-array" count="72">0 0 1 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 0 0 1 0 1 1 1 0 1 1 0 1</float_array>
+ <technique_common>
+ <accessor source="#Cube_001-mesh-map-0-array" count="36" stride="2">
+ <param name="S" type="float"/>
+ <param name="T" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <vertices id="Cube_001-mesh-vertices">
+ <input semantic="POSITION" source="#Cube_001-mesh-positions"/>
+ </vertices>
+ <triangles material="Brick_wall-material" count="12">
+ <input semantic="VERTEX" source="#Cube_001-mesh-vertices" offset="0"/>
+ <input semantic="NORMAL" source="#Cube_001-mesh-normals" offset="1"/>
+ <input semantic="TEXCOORD" source="#Cube_001-mesh-map-0" offset="2" set="0"/>
+ <p>0 0 0 2 0 1 3 0 2 7 1 3 5 1 4 4 1 5 4 2 6 1 2 7 0 2 8 5 3 9 2 3 10 1 3 11 2 4 12 7 4 13 3 4 14 0 5 15 7 5 16 4 5 17 0 6 18 1 6 19 2 6 20 7 7 21 6 7 22 5 7 23 4 8 24 5 8 25 1 8 26 5 9 27 6 9 28 2 9 29 2 10 30 6 10 31 7 10 32 0 11 33 3 11 34 7 11 35</p>
+ </triangles>
+ </mesh>
+ </geometry>
</library_geometries>
<library_controllers/>
<library_visual_scenes>
</node>
<node id="Suzanne" name="Suzanne" type="NODE">
<matrix sid="transform">1 0 0 2.692266 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
- <instance_geometry url="#Suzanne-mesh" name="Suzanne"/>
+ <instance_geometry url="#Suzanne-mesh" name="Suzanne">
+ <bind_material>
+ <technique_common>
+ <instance_material symbol="Glass-material" target="#Glass-material"/>
+ </technique_common>
+ </bind_material>
+ </instance_geometry>
+ </node>
+ <node id="Cube_001" name="Cube_001" type="NODE">
+ <matrix sid="transform">1 0 0 -2.993813 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
+ <instance_geometry url="#Cube_001-mesh" name="Cube_001">
+ <bind_material>
+ <technique_common>
+ <instance_material symbol="Brick_wall-material" target="#Brick_wall-material"/>
+ </technique_common>
+ </bind_material>
+ </instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
if (!material.hasNormalMap)
normal = defNormal;
+ vec4 ambient = material.ambient * texture(material.diffuseMap, texCoord);
+ if (!material.hasTexture)
+ ambient = material.ambient;
+
+ ambient = mix(ambient, reflection(), material.reflectivity);
+ ambient = mix(ambient, refraction(), 1 - material.opacity);
+
vec3 lightDir = normalize(lightPos - fragPos);
vec4 diffTex = texture(material.diffuseMap, texCoord);
diffTex = material.diffuse;
diffTex = mix(diffTex, reflection(), material.reflectivity);
-
diffTex = mix(diffTex, refraction(), 1 - material.opacity);
- vec4 ambient = material.ambient * diffTex;
-
vec4 diffuse = max(0, dot(lightDir, normal)) * diffTex;
vec3 viewDir = normalize(viewPos - fragPos);
vec4 specular = pow(max(0, dot(viewDir, reflectDir)), material.shininess) * specTex;
FragColor = (ambient + diffuse + specular) * lightColor;
-
}