GLSL and Ray Tracing - take into account non-physical materials.
Move Ray Tracing test cases to v3d/raytrace grid.
};
// =======================================================================
-// function : OpenGl_Material
+// function : OpenGl_RaytraceMaterial
// purpose : Creates new default material
// =======================================================================
OpenGl_RaytraceMaterial::OpenGl_RaytraceMaterial()
{ }
// =======================================================================
-// function : OpenGl_Material
+// function : OpenGl_RaytraceMaterial
// purpose : Creates new material with specified properties
// =======================================================================
OpenGl_RaytraceMaterial::OpenGl_RaytraceMaterial (const OpenGl_RTVec4f& theAmbient,
}
// =======================================================================
-// function : OpenGl_Material
+// function : OpenGl_RaytraceMaterial
// purpose : Creates new material with specified properties
// =======================================================================
OpenGl_RaytraceMaterial::OpenGl_RaytraceMaterial (const OpenGl_RTVec4f& theAmbient,
}
// =======================================================================
-// function : OpenGl_Material
+// function : OpenGl_RaytraceMaterial
// purpose : Creates new material with specified properties
// =======================================================================
OpenGl_RaytraceMaterial::OpenGl_RaytraceMaterial (const OpenGl_RTVec4f& theAmbient,
theProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE),
theAspect->DistinguishingMode());
+ const float aDefSpecCol[4] = {1.0f, 1.0f, 1.0f, 1.0f};
OpenGl_Vec4 aParams[5];
for (Standard_Integer anIndex = 0; anIndex < 2; ++anIndex)
{
}
const OPENGL_SURF_PROP& aProps = (anIndex == 0) ? theAspect->IntFront() : theAspect->IntBack();
- const OpenGl_Vec4 anEmission (aProps.emscol.rgb[0] * aProps.emsv,
- aProps.emscol.rgb[1] * aProps.emsv,
- aProps.emscol.rgb[2] * aProps.emsv,
- aProps.emscol.rgb[3] * aProps.emsv);
- const OpenGl_Vec4 anAmbient (aProps.ambcol.rgb[0] * aProps.amb,
- aProps.ambcol.rgb[1] * aProps.amb,
- aProps.ambcol.rgb[2] * aProps.amb,
- aProps.ambcol.rgb[3] * aProps.amb);
- const OpenGl_Vec4 aDiffuse (aProps.difcol.rgb[0] * aProps.diff,
- aProps.difcol.rgb[1] * aProps.diff,
- aProps.difcol.rgb[2] * aProps.diff,
- aProps.difcol.rgb[3] * aProps.diff);
- const OpenGl_Vec4 aSpecular (aProps.speccol.rgb[0] * aProps.spec,
- aProps.speccol.rgb[1] * aProps.spec,
- aProps.speccol.rgb[2] * aProps.spec,
- aProps.speccol.rgb[3] * aProps.spec);
+ const float* aSrcEms = aProps.isphysic ? aProps.emscol.rgb : aProps.matcol.rgb;
+ const OpenGl_Vec4 anEmission (aSrcEms[0] * aProps.emsv,
+ aSrcEms[1] * aProps.emsv,
+ aSrcEms[2] * aProps.emsv,
+ 1.0f);
+ const float* aSrcAmb = aProps.isphysic ? aProps.ambcol.rgb : aProps.matcol.rgb;
+ const OpenGl_Vec4 anAmbient (aSrcAmb[0] * aProps.amb,
+ aSrcAmb[1] * aProps.amb,
+ aSrcAmb[2] * aProps.amb,
+ 1.0f);
+ const float* aSrcDif = aProps.isphysic ? aProps.difcol.rgb : aProps.matcol.rgb;
+ const OpenGl_Vec4 aDiffuse (aSrcDif[0] * aProps.diff,
+ aSrcDif[1] * aProps.diff,
+ aSrcDif[2] * aProps.diff,
+ 1.0f);
+ const float* aSrcSpe = aProps.isphysic ? aProps.speccol.rgb : aDefSpecCol;
+ const OpenGl_Vec4 aSpecular (aSrcSpe[0] * aProps.spec,
+ aSrcSpe[1] * aProps.spec,
+ aSrcSpe[2] * aProps.spec,
+ 1.0f);
+
aParams[0] = anEmission;
aParams[1] = anAmbient;
aParams[2] = aDiffuse;
// function : CreateMaterial
// purpose : Creates ray-tracing material properties
// =======================================================================
-void CreateMaterial (const OPENGL_SURF_PROP& theProp, OpenGl_RaytraceMaterial& theMaterial)
+void CreateMaterial (const OPENGL_SURF_PROP& theProp,
+ OpenGl_RaytraceMaterial& theMaterial)
{
- theMaterial.Ambient = OpenGl_RTVec4f (theProp.ambcol.rgb[0] * theProp.amb,
- theProp.ambcol.rgb[1] * theProp.amb,
- theProp.ambcol.rgb[2] * theProp.amb,
- 1.f);
-
- theMaterial.Diffuse = OpenGl_RTVec4f (theProp.difcol.rgb[0] * theProp.diff,
- theProp.difcol.rgb[1] * theProp.diff,
- theProp.difcol.rgb[2] * theProp.diff,
- 1.f);
-
- theMaterial.Specular = OpenGl_RTVec4f (theProp.speccol.rgb[0] * theProp.spec,
- theProp.speccol.rgb[1] * theProp.spec,
- theProp.speccol.rgb[2] * theProp.spec,
+ const float* aSrcAmb = theProp.isphysic ? theProp.ambcol.rgb : theProp.matcol.rgb;
+ theMaterial.Ambient = OpenGl_RTVec4f (aSrcAmb[0] * theProp.amb,
+ aSrcAmb[1] * theProp.amb,
+ aSrcAmb[2] * theProp.amb,
+ 1.0f);
+
+ const float* aSrcDif = theProp.isphysic ? theProp.difcol.rgb : theProp.matcol.rgb;
+ theMaterial.Diffuse = OpenGl_RTVec4f (aSrcDif[0] * theProp.diff,
+ aSrcDif[1] * theProp.diff,
+ aSrcDif[2] * theProp.diff,
+ 1.0f);
+
+ const float aDefSpecCol[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ const float* aSrcSpe = theProp.isphysic ? theProp.speccol.rgb : aDefSpecCol;
+ theMaterial.Specular = OpenGl_RTVec4f (aSrcSpe[0] * theProp.spec,
+ aSrcSpe[1] * theProp.spec,
+ aSrcSpe[2] * theProp.spec,
theProp.shine);
- theMaterial.Emission = OpenGl_RTVec4f (theProp.emscol.rgb[0] * theProp.emsv,
- theProp.emscol.rgb[1] * theProp.emsv,
- theProp.emscol.rgb[2] * theProp.emsv,
- 1.f);
+ const float* aSrcEms = theProp.isphysic ? theProp.emscol.rgb : theProp.matcol.rgb;
+ theMaterial.Emission = OpenGl_RTVec4f (aSrcEms[0] * theProp.emsv,
+ aSrcEms[1] * theProp.emsv,
+ aSrcEms[2] * theProp.emsv,
+ 1.0f);
// Note: Here we use sub-linear transparency function
// to produce realistic-looking transparency effect
{
if (aBufferType == Graphic3d_BT_RGBA)
{
- theDI << Quantity_Color::StringName (aColor.Name()) << " " << anAlpha << "\n";
+ theDI << Quantity_Color::StringName (aColor.Name()) << " " << anAlpha;
}
else
{
- theDI << Quantity_Color::StringName (aColor.Name()) << "\n";
+ theDI << Quantity_Color::StringName (aColor.Name());
}
}
else
{
if (toShowHls)
{
- theDI << aColor.Hue() << " " << aColor.Light() << " " << aColor.Saturation() << "\n";
+ theDI << aColor.Hue() << " " << aColor.Light() << " " << aColor.Saturation();
}
else
{
- theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << "\n";
+ theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue();
}
break;
}
case Graphic3d_BT_RGBA:
{
- theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " " << anAlpha << "\n";
+ theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " " << anAlpha;
break;
}
case Graphic3d_BT_Depth:
{
- theDI << aColor.Red() << "\n";
+ theDI << aColor.Red();
break;
}
}
FAILED /\bFaulty\b/ bad shape
IGNORE /^Error [23]d = [\d.-]+/ debug output of blend command
SKIPPED /Error: unsupported locale specification/ locale is unavailable on tested system
-SKIPPED /OCCT was compiled without OpenCL support!/
OK /Relative error of mass computation/ message from vprops
+++ /dev/null
-puts "TODO ?OCC24130 Debian60-64: OCCT was compiled without OpenCL support!"
-puts "TODO ?OCC24130 Windows: TKOpenGl | Type\: Error | ID\: 0 | Severity\: High | Message\:"
-
-puts "========"
-puts "OCC24130 Implementing ray tracing visualization core"
-puts "========"
-
-# custom shapes
-set aShape1 [locate_data_file occ/Top.brep]
-set aShape2 [locate_data_file occ/Bottom.brep]
-
-# setup 3D viewer content
-vinit name=View1 w=512 h=512
-vglinfo
-
-vvbo 0
-vsetdispmode 1
-vsetgradientbg 180 200 255 180 180 180 2
-restore $aShape1 s1
-restore $aShape2 s2
-vdisplay s1 s2
-vsetmaterial s1 Silver
-vsetmaterial s2 Pewter
-vfit
-
-# activate ray-tracing
-vraytrace 1
-vclinfo
-
-set aModeNum 0
-for { set aAAMode 0 } { $aAAMode <= 1 } { incr aAAMode } {
- for { set aReflMode 0 } { $aReflMode <= 1 } { incr aReflMode } {
- for { set aShadMode 0 } { $aShadMode <= 1 } { incr aShadMode } {
- vsetraytracemode shad=$aShadMode refl=$aReflMode aa=$aAAMode
- vdump $imagedir/${casename}_${aModeNum}.png
- incr aModeNum
- }
- }
-}
-
-vtextureenv on 5
-for { set aAAMode 0 } { $aAAMode <= 1 } { incr aAAMode } {
- for { set aShadMode 0 } { $aShadMode <= 1 } { incr aShadMode } {
- vsetraytracemode shad=$aShadMode refl=1 aa=$aAAMode
- vdump $imagedir/${casename}_${aModeNum}.png
- incr aModeNum
- }
-}
vlight clear
set color [vreadpixel 100 100 rgb]
-set black "0 0 0\n"
+set black "0 0 0"
if {[string equal $color $black] != 1} {error "Lights do not seems to be cleared!"}
--- /dev/null
+puts "========"
+puts "Per-pixel lighting using GLSL program (Phong shading), check plastic material"
+puts "========"
+
+# create box
+box b 1 2 3
+
+# draw box
+vinit View1
+vclear
+vsetdispmode 1
+vaxo
+vdisplay b
+vsetmaterial b PLASTIC
+vsetcolor b GREEN
+vfit
+vrotate 0.2 0.0 0.0
+
+# take snapshot with fixed pipeline
+vdump $::imagedir/${::casename}_OFF.png
+set aColorL [vreadpixel 150 250 rgb name]
+set aColorR [vreadpixel 250 250 rgb name]
+if { "$aColorL" != "GREEN3" || "$aColorR" != "GREEN4" } {
+ puts "Error: wrong color (fixed pipeline)!"
+}
+
+vshaderprog b phong
+set aColorL [vreadpixel 150 250 rgb name]
+set aColorR [vreadpixel 250 250 rgb name]
+if { "$aColorL" != "GREEN3" || "$aColorR" != "GREEN4" } {
+ puts "Error: wrong color (Phong shader)!"
+}
011 wire_solid
012 voxel
013 glsl
+014 raytrace
FAILED /\bFaulty\b/ error
-
+SKIPPED /OCCT was compiled without OpenCL support!/
+SKIPPED /OpenCL device info is unavailable!/
--- /dev/null
+puts "TODO ?OCC24130 Debian60-64: OCCT was compiled without OpenCL support!"
+puts "TODO ?OCC24130 Windows: TKOpenGl | Type\: Error | ID\: 0 | Severity\: High | Message\:"
+
+puts "========"
+puts "OCC24130 Implementing ray tracing visualization core"
+puts "========"
+
+# custom shapes
+set aShape1 [locate_data_file occ/Top.brep]
+set aShape2 [locate_data_file occ/Bottom.brep]
+
+# setup 3D viewer content
+vinit name=View1 w=512 h=512
+vglinfo
+
+vvbo 0
+vsetdispmode 1
+vsetgradientbg 180 200 255 180 180 180 2
+restore $aShape1 s1
+restore $aShape2 s2
+vdisplay s1 s2
+vsetmaterial s1 Silver
+vsetmaterial s2 Pewter
+vfit
+
+# activate ray-tracing
+vraytrace 1
+vclinfo
+
+set aModeNum 0
+for { set aAAMode 0 } { $aAAMode <= 1 } { incr aAAMode } {
+ for { set aReflMode 0 } { $aReflMode <= 1 } { incr aReflMode } {
+ for { set aShadMode 0 } { $aShadMode <= 1 } { incr aShadMode } {
+ vsetraytracemode shad=$aShadMode refl=$aReflMode aa=$aAAMode
+ vdump $imagedir/${casename}_${aModeNum}.png
+ incr aModeNum
+ }
+ }
+}
+
+vtextureenv on 5
+for { set aAAMode 0 } { $aAAMode <= 1 } { incr aAAMode } {
+ for { set aShadMode 0 } { $aShadMode <= 1 } { incr aShadMode } {
+ vsetraytracemode shad=$aShadMode refl=1 aa=$aAAMode
+ vdump $imagedir/${casename}_${aModeNum}.png
+ incr aModeNum
+ }
+}
--- /dev/null
+puts "========"
+puts "Ray Tracing - check lighting on Plastic material"
+puts "========"
+
+# create box
+box b 1 2 3
+
+# draw box
+vinit View1
+vclear
+vsetdispmode 1
+vaxo
+vdisplay b
+vsetmaterial b PLASTIC
+vsetcolor b GREEN
+vfit
+vrotate 0.2 0.0 0.0
+
+# take snapshot with fixed pipeline
+vdump $::imagedir/${::casename}_OFF.png
+set aColorL [vreadpixel 150 250 rgb name]
+set aColorR [vreadpixel 250 250 rgb name]
+if { "$aColorL" != "GREEN3" || "$aColorR" != "GREEN4" } {
+ puts "Error: wrong color (fixed pipeline)!"
+}
+
+vraytrace 1
+vclinfo
+set aColorL [vreadpixel 150 250 rgb name]
+set aColorR [vreadpixel 250 250 rgb name]
+#if { "$aColorL" != "GREEN3" || "$aColorR" != "GREEN4" } {
+# puts "Error: wrong color (Ray Tracing)!"
+#}