mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
025306: Visualization, TKOpenGl - support texturing within RayTracing
Fix bug with overlay OpenGL text.
This commit is contained in:
parent
f82a9555dc
commit
25ef750e44
@ -153,3 +153,7 @@ OpenGl_BVHTreeSelector.hxx
|
||||
OpenGl_BVHTreeSelector.cxx
|
||||
OpenGl_BVHClipPrimitiveSet.cxx
|
||||
OpenGl_BVHClipPrimitiveSet.hxx
|
||||
OpenGl_ArbTexBindless.hxx
|
||||
Handle_OpenGl_Sampler.hxx
|
||||
OpenGl_Sampler.hxx
|
||||
OpenGl_Sampler.cxx
|
||||
|
24
src/OpenGl/Handle_OpenGl_Sampler.hxx
Normal file
24
src/OpenGl/Handle_OpenGl_Sampler.hxx
Normal file
@ -0,0 +1,24 @@
|
||||
// Created on: 2014-10-17
|
||||
// Created by: Denis BOGOLEPOV
|
||||
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Handle_OpenGl_Sampler_HeaderFile
|
||||
#define _Handle_OpenGl_Sampler_HeaderFile
|
||||
|
||||
#include <OpenGl_Resource.hxx>
|
||||
|
||||
class OpenGl_Sampler;
|
||||
DEFINE_STANDARD_HANDLE(OpenGl_Sampler, OpenGl_Resource)
|
||||
|
||||
#endif
|
47
src/OpenGl/OpenGl_ArbTexBindless.hxx
Normal file
47
src/OpenGl/OpenGl_ArbTexBindless.hxx
Normal file
@ -0,0 +1,47 @@
|
||||
// Created on: 2014-10-07
|
||||
// Created by: Denis BOGOLEPOV
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _OpenGl_ArbTexBindless_H__
|
||||
#define _OpenGl_ArbTexBindless_H__
|
||||
|
||||
#include <OpenGl_GlFunctions.hxx>
|
||||
|
||||
//! Provides bindless textures.
|
||||
//! This extension allows OpenGL applications to access texture objects in
|
||||
//! shaders without first binding each texture to one of a limited number of
|
||||
//! texture image units.
|
||||
struct OpenGl_ArbTexBindless : protected OpenGl_GlFunctions
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
using OpenGl_GlFunctions::glGetTextureHandleARB;
|
||||
using OpenGl_GlFunctions::glGetTextureSamplerHandleARB;
|
||||
using OpenGl_GlFunctions::glMakeTextureHandleResidentARB;
|
||||
using OpenGl_GlFunctions::glMakeTextureHandleNonResidentARB;
|
||||
using OpenGl_GlFunctions::glGetImageHandleARB;
|
||||
using OpenGl_GlFunctions::glMakeImageHandleResidentARB;
|
||||
using OpenGl_GlFunctions::glMakeImageHandleNonResidentARB;
|
||||
using OpenGl_GlFunctions::glUniformHandleui64ARB;
|
||||
using OpenGl_GlFunctions::glUniformHandleui64vARB;
|
||||
using OpenGl_GlFunctions::glProgramUniformHandleui64ARB;
|
||||
using OpenGl_GlFunctions::glProgramUniformHandleui64vARB;
|
||||
using OpenGl_GlFunctions::glIsTextureHandleResidentARB;
|
||||
using OpenGl_GlFunctions::glIsImageHandleResidentARB;
|
||||
using OpenGl_GlFunctions::glVertexAttribL1ui64ARB;
|
||||
using OpenGl_GlFunctions::glVertexAttribL1ui64vARB;
|
||||
using OpenGl_GlFunctions::glGetVertexAttribLui64vARB;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // _OpenGl_ArbTexBindless_H__
|
@ -24,7 +24,9 @@
|
||||
#include <OpenGl_ArbDbg.hxx>
|
||||
#include <OpenGl_ArbFBO.hxx>
|
||||
#include <OpenGl_ExtGS.hxx>
|
||||
#include <OpenGl_ArbTexBindless.hxx>
|
||||
#include <OpenGl_GlCore20.hxx>
|
||||
#include <OpenGl_Sampler.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
|
||||
#include <Message_Messenger.hxx>
|
||||
@ -79,6 +81,8 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
core20fwd (NULL),
|
||||
core32 (NULL),
|
||||
core32back (NULL),
|
||||
core33 (NULL),
|
||||
core33back (NULL),
|
||||
core41 (NULL),
|
||||
core41back (NULL),
|
||||
core42 (NULL),
|
||||
@ -96,7 +100,10 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
hasTexRGBA8(Standard_True),
|
||||
#endif
|
||||
arbNPTW (Standard_False),
|
||||
arbTexRG (Standard_False),
|
||||
arbTexBindless (NULL),
|
||||
arbTBO (NULL),
|
||||
arbTboRGB32 (Standard_False),
|
||||
arbIns (NULL),
|
||||
arbDbg (NULL),
|
||||
arbFBO (NULL),
|
||||
@ -170,6 +177,12 @@ OpenGl_Context::~OpenGl_Context()
|
||||
mySharedResources.Nullify();
|
||||
myDelayed.Nullify();
|
||||
|
||||
// release sampler object
|
||||
if (!myTexSampler.IsNull())
|
||||
{
|
||||
myTexSampler->Release (this);
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (arbDbg != NULL
|
||||
&& caps->contextDebug
|
||||
@ -844,6 +857,8 @@ void OpenGl_Context::init()
|
||||
core20fwd = NULL;
|
||||
core32 = NULL;
|
||||
core32back = NULL;
|
||||
core33 = NULL;
|
||||
core33back = NULL;
|
||||
core41 = NULL;
|
||||
core41back = NULL;
|
||||
core42 = NULL;
|
||||
@ -853,6 +868,7 @@ void OpenGl_Context::init()
|
||||
core44 = NULL;
|
||||
core44back = NULL;
|
||||
arbTBO = NULL;
|
||||
arbTboRGB32 = Standard_False;
|
||||
arbIns = NULL;
|
||||
arbDbg = NULL;
|
||||
arbFBO = NULL;
|
||||
@ -1723,6 +1739,7 @@ void OpenGl_Context::init()
|
||||
{
|
||||
arbTBO = (OpenGl_ArbTBO* )(&(*myFuncs));
|
||||
}
|
||||
arbTboRGB32 = CheckExtension ("GL_ARB_texture_buffer_object_rgb32");
|
||||
|
||||
// initialize hardware instancing extension (ARB)
|
||||
if (!has31
|
||||
@ -1747,6 +1764,28 @@ void OpenGl_Context::init()
|
||||
extGS = (OpenGl_ExtGS* )(&(*myFuncs));
|
||||
}
|
||||
|
||||
// initialize bindless texture extension (ARB)
|
||||
if (CheckExtension ("GL_ARB_bindless_texture")
|
||||
&& FindProcShort (glGetTextureHandleARB)
|
||||
&& FindProcShort (glGetTextureSamplerHandleARB)
|
||||
&& FindProcShort (glMakeTextureHandleResidentARB)
|
||||
&& FindProcShort (glMakeTextureHandleNonResidentARB)
|
||||
&& FindProcShort (glGetImageHandleARB)
|
||||
&& FindProcShort (glMakeImageHandleResidentARB)
|
||||
&& FindProcShort (glMakeImageHandleNonResidentARB)
|
||||
&& FindProcShort (glUniformHandleui64ARB)
|
||||
&& FindProcShort (glUniformHandleui64vARB)
|
||||
&& FindProcShort (glProgramUniformHandleui64ARB)
|
||||
&& FindProcShort (glProgramUniformHandleui64vARB)
|
||||
&& FindProcShort (glIsTextureHandleResidentARB)
|
||||
&& FindProcShort (glIsImageHandleResidentARB)
|
||||
&& FindProcShort (glVertexAttribL1ui64ARB)
|
||||
&& FindProcShort (glVertexAttribL1ui64vARB)
|
||||
&& FindProcShort (glGetVertexAttribLui64vARB))
|
||||
{
|
||||
arbTexBindless = (OpenGl_ArbTexBindless* )(&(*myFuncs));
|
||||
}
|
||||
|
||||
if (!has12)
|
||||
{
|
||||
myGlVerMajor = 1;
|
||||
@ -1822,6 +1861,12 @@ void OpenGl_Context::init()
|
||||
myGlVerMinor = 2;
|
||||
return;
|
||||
}
|
||||
core33 = (OpenGl_GlCore33* )(&(*myFuncs));
|
||||
core33back = (OpenGl_GlCore33Back* )(&(*myFuncs));
|
||||
|
||||
// initialize sampler object
|
||||
myTexSampler = new OpenGl_Sampler();
|
||||
myTexSampler->Init (*this);
|
||||
|
||||
if (!has40)
|
||||
{
|
||||
@ -1829,6 +1874,7 @@ void OpenGl_Context::init()
|
||||
myGlVerMinor = 3;
|
||||
return;
|
||||
}
|
||||
arbTboRGB32 = Standard_True; // in core since OpenGL 4.0
|
||||
|
||||
if (!has41)
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <Aspect_Display.hxx>
|
||||
#include <Aspect_RenderingContext.hxx>
|
||||
#include <Handle_OpenGl_Context.hxx>
|
||||
#include <Handle_OpenGl_Sampler.hxx>
|
||||
#include <Handle_OpenGl_ShaderManager.hxx>
|
||||
#include <Handle_OpenGl_ShaderProgram.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
@ -44,6 +45,7 @@ struct OpenGl_ArbIns;
|
||||
struct OpenGl_ArbDbg;
|
||||
struct OpenGl_ArbFBO;
|
||||
struct OpenGl_ExtGS;
|
||||
struct OpenGl_ArbTexBindless;
|
||||
|
||||
template<typename theBaseClass_t> struct OpenGl_TmplCore12;
|
||||
typedef OpenGl_TmplCore12<OpenGl_GlCore11> OpenGl_GlCore12;
|
||||
@ -441,6 +443,12 @@ public: //! @name methods to alter or retrieve current state
|
||||
return myActiveProgram;
|
||||
}
|
||||
|
||||
//! @return OpenGL sampler object used to override default texture parameters
|
||||
const Handle(OpenGl_Sampler)& TextureSampler()
|
||||
{
|
||||
return myTexSampler;
|
||||
}
|
||||
|
||||
//! Bind specified program to current context,
|
||||
//! or unbind previous one when NULL specified.
|
||||
//! @return true if some program is bound to context
|
||||
@ -473,6 +481,8 @@ public: //! @name core profiles
|
||||
OpenGl_GlCore20Fwd* core20fwd; //!< OpenGL 2.0 without deprecated entry points
|
||||
OpenGl_GlCore32* core32; //!< OpenGL 3.2 core profile
|
||||
OpenGl_GlCore32Back* core32back; //!< OpenGL 3.2 backward compatibility profile
|
||||
OpenGl_GlCore33* core33; //!< OpenGL 3.3 core profile
|
||||
OpenGl_GlCore33Back* core33back; //!< OpenGL 3.3 backward compatibility profile
|
||||
OpenGl_GlCore41* core41; //!< OpenGL 4.1 core profile
|
||||
OpenGl_GlCore41Back* core41back; //!< OpenGL 4.1 backward compatibility profile
|
||||
OpenGl_GlCore42* core42; //!< OpenGL 4.2 core profile
|
||||
@ -490,7 +500,9 @@ public: //! @name extensions
|
||||
Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
|
||||
Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two
|
||||
Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg
|
||||
OpenGl_ArbTexBindless* arbTexBindless; //!< GL_ARB_bindless_texture
|
||||
OpenGl_ArbTBO* arbTBO; //!< GL_ARB_texture_buffer_object
|
||||
Standard_Boolean arbTboRGB32; //!< GL_ARB_texture_buffer_object_rgb32 (3-component TBO), in core since 4.0
|
||||
OpenGl_ArbIns* arbIns; //!< GL_ARB_draw_instanced
|
||||
OpenGl_ArbDbg* arbDbg; //!< GL_ARB_debug_output
|
||||
OpenGl_ArbFBO* arbFBO; //!< GL_ARB_framebuffer_object
|
||||
@ -553,6 +565,7 @@ private: // context info
|
||||
private: //! @name fields tracking current state
|
||||
|
||||
Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program
|
||||
Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object
|
||||
Standard_Integer myRenderMode; //!< value for active rendering mode
|
||||
Standard_Integer myDrawBuffer; //!< current draw buffer
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
|
||||
typedef double GLdouble;
|
||||
typedef double GLclampd;
|
||||
typedef uint64_t GLuint64;
|
||||
#define GL_NONE 0
|
||||
|
||||
// OpenGL ES 3.0+ or GL_OES_element_index_uint extension
|
||||
@ -1384,6 +1385,25 @@ public: //! @name GL_EXT_geometry_shader4
|
||||
|
||||
PFNGLPROGRAMPARAMETERIEXTPROC glProgramParameteriEXT;
|
||||
|
||||
public: //! @name GL_ARB_bindless_texture
|
||||
|
||||
PFNGLGETTEXTUREHANDLEARBPROC glGetTextureHandleARB;
|
||||
PFNGLGETTEXTURESAMPLERHANDLEARBPROC glGetTextureSamplerHandleARB;
|
||||
PFNGLMAKETEXTUREHANDLERESIDENTARBPROC glMakeTextureHandleResidentARB;
|
||||
PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC glMakeTextureHandleNonResidentARB;
|
||||
PFNGLGETIMAGEHANDLEARBPROC glGetImageHandleARB;
|
||||
PFNGLMAKEIMAGEHANDLERESIDENTARBPROC glMakeImageHandleResidentARB;
|
||||
PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC glMakeImageHandleNonResidentARB;
|
||||
PFNGLUNIFORMHANDLEUI64ARBPROC glUniformHandleui64ARB;
|
||||
PFNGLUNIFORMHANDLEUI64VARBPROC glUniformHandleui64vARB;
|
||||
PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC glProgramUniformHandleui64ARB;
|
||||
PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC glProgramUniformHandleui64vARB;
|
||||
PFNGLISTEXTUREHANDLERESIDENTARBPROC glIsTextureHandleResidentARB;
|
||||
PFNGLISIMAGEHANDLERESIDENTARBPROC glIsImageHandleResidentARB;
|
||||
PFNGLVERTEXATTRIBL1UI64ARBPROC glVertexAttribL1ui64ARB;
|
||||
PFNGLVERTEXATTRIBL1UI64VARBPROC glVertexAttribL1ui64vARB;
|
||||
PFNGLGETVERTEXATTRIBLUI64VARBPROC glGetVertexAttribLui64vARB;
|
||||
|
||||
#if defined(_WIN32)
|
||||
public: //! @name wgl extensions
|
||||
|
||||
|
133
src/OpenGl/OpenGl_Sampler.cxx
Normal file
133
src/OpenGl/OpenGl_Sampler.cxx
Normal file
@ -0,0 +1,133 @@
|
||||
// Created on: 2014-10-08
|
||||
// Created by: Denis BOGOLEPOV
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <OpenGl_Sampler.hxx>
|
||||
#include <OpenGl_GlCore33.hxx>
|
||||
#include <Standard_Assert.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE (OpenGl_Sampler, OpenGl_Resource)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Sampler, OpenGl_Resource)
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_Sampler
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_Sampler::OpenGl_Sampler()
|
||||
: mySamplerID (NO_SAMPLER)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ~OpenGl_Sampler
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_Sampler::~OpenGl_Sampler()
|
||||
{
|
||||
Release (NULL);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Release
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Sampler::Release (OpenGl_Context* theContext)
|
||||
{
|
||||
if (isValidSampler())
|
||||
{
|
||||
// application can not handle this case by exception - this is bug in code
|
||||
Standard_ASSERT_RETURN (theContext != NULL,
|
||||
"OpenGl_Sampler destroyed without GL context! Possible GPU memory leakage...",);
|
||||
|
||||
if (theContext->IsValid())
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0) || defined(GL_ES_VERSION_3_0)
|
||||
theContext->core33->glDeleteSamplers (1, &mySamplerID);
|
||||
#endif
|
||||
}
|
||||
|
||||
mySamplerID = NO_SAMPLER;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose : Initializes sampler object
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Sampler::Init (OpenGl_Context& theContext)
|
||||
{
|
||||
if (theContext.core33 == NULL)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (isValidSampler())
|
||||
{
|
||||
Release (&theContext);
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0) || defined(GL_ES_VERSION_3_0)
|
||||
theContext.core33->glGenSamplers (1, &mySamplerID);
|
||||
return Standard_True;
|
||||
#else
|
||||
return Standard_False;
|
||||
#endif
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Bind
|
||||
// purpose : Binds sampler object to the given texture unit
|
||||
// =======================================================================
|
||||
void OpenGl_Sampler::Bind (OpenGl_Context& theContext,
|
||||
const GLuint theUnit)
|
||||
{
|
||||
if (isValidSampler())
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0) || defined(GL_ES_VERSION_3_0)
|
||||
theContext.core33->glBindSampler (theUnit, mySamplerID);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Unbind
|
||||
// purpose : Unbinds sampler object from the given texture unit
|
||||
// =======================================================================
|
||||
void OpenGl_Sampler::Unbind (OpenGl_Context& theContext,
|
||||
const GLuint theUnit)
|
||||
{
|
||||
if (isValidSampler())
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0) || defined(GL_ES_VERSION_3_0)
|
||||
theContext.core33->glBindSampler (theUnit, NO_SAMPLER);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetParameter
|
||||
// purpose : Sets sampler parameters
|
||||
// =======================================================================
|
||||
void OpenGl_Sampler::SetParameter (OpenGl_Context& theContext,
|
||||
const GLenum theParam,
|
||||
const GLint theValue)
|
||||
{
|
||||
if (isValidSampler())
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0) || defined(GL_ES_VERSION_3_0)
|
||||
theContext.core33->glSamplerParameteri (mySamplerID, theParam, theValue);
|
||||
#endif
|
||||
}
|
||||
}
|
84
src/OpenGl/OpenGl_Sampler.hxx
Normal file
84
src/OpenGl/OpenGl_Sampler.hxx
Normal file
@ -0,0 +1,84 @@
|
||||
// Created on: 2014-10-08
|
||||
// Created by: Denis BOGOLEPOV
|
||||
// Copyright (c) 2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef OPENGL_SAMPLER_H
|
||||
#define OPENGL_SAMPLER_H
|
||||
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <Handle_OpenGl_Sampler.hxx>
|
||||
|
||||
//! Class implements OpenGL sampler object resource that
|
||||
//! stores the sampling parameters for a texture access.
|
||||
class OpenGl_Sampler : public OpenGl_Resource
|
||||
{
|
||||
public:
|
||||
|
||||
//! Helpful constant defining invalid sampler identifier
|
||||
static const GLuint NO_SAMPLER = 0;
|
||||
|
||||
public:
|
||||
|
||||
//! Creates new sampler object.
|
||||
Standard_EXPORT OpenGl_Sampler();
|
||||
|
||||
//! Releases resources of sampler object.
|
||||
Standard_EXPORT virtual ~OpenGl_Sampler();
|
||||
|
||||
//! Destroys object - will release GPU memory if any.
|
||||
Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
|
||||
|
||||
//! Initializes sampler object.
|
||||
Standard_EXPORT Standard_Boolean Init (OpenGl_Context& theContext);
|
||||
|
||||
//! Returns true if current object was initialized.
|
||||
Standard_Boolean IsValid() const
|
||||
{
|
||||
return isValidSampler();
|
||||
}
|
||||
|
||||
//! Binds sampler object to the given texture unit.
|
||||
Standard_EXPORT void Bind (OpenGl_Context& theContext, const GLuint theUnit = 0);
|
||||
|
||||
//! Unbinds sampler object from the given texture unit.
|
||||
Standard_EXPORT void Unbind (OpenGl_Context& theContext, const GLuint theUnit = 0);
|
||||
|
||||
//! Sets specific sampler parameter.
|
||||
Standard_EXPORT void SetParameter (OpenGl_Context& theContext, const GLenum theParam, const GLint theValue);
|
||||
|
||||
//! Returns OpenGL sampler ID.
|
||||
GLuint SamplerID() const
|
||||
{
|
||||
return mySamplerID;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Checks if sampler object is valid.
|
||||
Standard_Boolean isValidSampler() const
|
||||
{
|
||||
return mySamplerID != NO_SAMPLER;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
GLuint mySamplerID; //!< OpenGL sampler object ID
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(OpenGl_Sampler)
|
||||
|
||||
};
|
||||
|
||||
#endif // OPENGL_SAMPLER_H
|
@ -13,8 +13,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Standard_Assert.hxx>
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
// On Windows, function TryEnterCriticalSection has appeared in Windows NT
|
||||
// and is surrounded by #ifdef in MS VC++ 7.1 headers.
|
||||
@ -29,21 +27,20 @@
|
||||
|
||||
#include <OpenGl_SceneGeometry.hxx>
|
||||
|
||||
#include <OpenGl_ArbTexBindless.hxx>
|
||||
#include <OpenGl_PrimitiveArray.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
#include <Standard_Assert.hxx>
|
||||
|
||||
//! Use this macro to output BVH profiling info
|
||||
//#define BVH_PRINT_INFO
|
||||
|
||||
#ifdef BVH_PRINT_INFO
|
||||
#include <OSD_Timer.hxx>
|
||||
#endif
|
||||
// #define RAY_TRACE_PRINT_INFO
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Useful constant for null floating-point 4D vector.
|
||||
static const BVH_Vec4f ZERO_VEC_4F;
|
||||
};
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_RaytraceMaterial
|
||||
@ -131,13 +128,51 @@ OpenGl_RaytraceLight::OpenGl_RaytraceLight (const BVH_Vec4f& theDiffuse,
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Box
|
||||
// purpose : Returns AABB of primitive set
|
||||
// =======================================================================
|
||||
OpenGl_TriangleSet::BVH_BoxNt OpenGl_TriangleSet::Box() const
|
||||
{
|
||||
const BVH_Transform<Standard_ShortReal, 4>* aTransform =
|
||||
dynamic_cast<const BVH_Transform<Standard_ShortReal, 4>* > (Properties().operator->());
|
||||
|
||||
BVH_BoxNt aBox = BVH_PrimitiveSet<Standard_ShortReal, 3>::Box();
|
||||
|
||||
if (aTransform != NULL)
|
||||
{
|
||||
BVH_BoxNt aTransformedBox;
|
||||
|
||||
for (Standard_Integer aX = 0; aX <= 1; ++aX)
|
||||
{
|
||||
for (Standard_Integer aY = 0; aY <= 1; ++aY)
|
||||
{
|
||||
for (Standard_Integer aZ = 0; aZ <= 1; ++aZ)
|
||||
{
|
||||
BVH_Vec4f aCorner = aTransform->Transform() * BVH_Vec4f (
|
||||
aX == 0 ? aBox.CornerMin().x() : aBox.CornerMax().x(),
|
||||
aY == 0 ? aBox.CornerMin().y() : aBox.CornerMax().y(),
|
||||
aZ == 0 ? aBox.CornerMin().z() : aBox.CornerMax().z(),
|
||||
1.f);
|
||||
|
||||
aTransformedBox.Add (reinterpret_cast<BVH_Vec3f&> (aCorner));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aTransformedBox;
|
||||
}
|
||||
|
||||
return aBox;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Clear
|
||||
// purpose : Clears ray-tracing geometry
|
||||
// =======================================================================
|
||||
void OpenGl_RaytraceGeometry::Clear()
|
||||
{
|
||||
BVH_Geometry<Standard_ShortReal, 4>::BVH_Geometry::Clear();
|
||||
BVH_Geometry<Standard_ShortReal, 3>::BVH_Geometry::Clear();
|
||||
|
||||
std::vector<OpenGl_RaytraceLight,
|
||||
NCollection_StdAllocator<OpenGl_RaytraceLight> > anEmptySources;
|
||||
@ -154,9 +189,9 @@ void OpenGl_RaytraceGeometry::Clear()
|
||||
|
||||
struct OpenGL_BVHParallelBuilder
|
||||
{
|
||||
BVH_ObjectSet<Standard_ShortReal, 4>* Set;
|
||||
BVH_ObjectSet<Standard_ShortReal, 3>* Set;
|
||||
|
||||
OpenGL_BVHParallelBuilder (BVH_ObjectSet<Standard_ShortReal, 4>* theSet)
|
||||
OpenGL_BVHParallelBuilder (BVH_ObjectSet<Standard_ShortReal, 3>* theSet)
|
||||
: Set (theSet)
|
||||
{
|
||||
//
|
||||
@ -185,13 +220,13 @@ struct OpenGL_BVHParallelBuilder
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_RaytraceGeometry::ProcessAcceleration()
|
||||
{
|
||||
#ifdef BVH_PRINT_INFO
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
OSD_Timer aTimer;
|
||||
#endif
|
||||
|
||||
MarkDirty(); // force BVH rebuilding
|
||||
|
||||
#ifdef BVH_PRINT_INFO
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
aTimer.Reset();
|
||||
aTimer.Start();
|
||||
#endif
|
||||
@ -219,21 +254,21 @@ Standard_Boolean OpenGl_RaytraceGeometry::ProcessAcceleration()
|
||||
myBottomLevelTreeDepth = Max (myBottomLevelTreeDepth, aTriangleSet->BVH()->Depth());
|
||||
}
|
||||
|
||||
#ifdef BVH_PRINT_INFO
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
aTimer.Stop();
|
||||
|
||||
std::cout << "Updating bottom-level BVHs (sec): " <<
|
||||
aTimer.ElapsedTime() << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef BVH_PRINT_INFO
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
aTimer.Reset();
|
||||
aTimer.Start();
|
||||
#endif
|
||||
|
||||
NCollection_Handle<BVH_Tree<Standard_ShortReal, 4> > aBVH = BVH();
|
||||
NCollection_Handle<BVH_Tree<Standard_ShortReal, 3> > aBVH = BVH();
|
||||
|
||||
#ifdef BVH_PRINT_INFO
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
aTimer.Stop();
|
||||
|
||||
std::cout << "Updating high-level BVH (sec): " <<
|
||||
@ -285,7 +320,7 @@ Standard_Boolean OpenGl_RaytraceGeometry::ProcessAcceleration()
|
||||
// =======================================================================
|
||||
Standard_Integer OpenGl_RaytraceGeometry::AccelerationOffset (Standard_Integer theNodeIdx)
|
||||
{
|
||||
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 4> >& aBVH = BVH();
|
||||
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 3> >& aBVH = BVH();
|
||||
|
||||
if (theNodeIdx >= aBVH->Length() || !aBVH->IsOuter (theNodeIdx))
|
||||
return INVALID_OFFSET;
|
||||
@ -299,7 +334,7 @@ Standard_Integer OpenGl_RaytraceGeometry::AccelerationOffset (Standard_Integer t
|
||||
// =======================================================================
|
||||
Standard_Integer OpenGl_RaytraceGeometry::VerticesOffset (Standard_Integer theNodeIdx)
|
||||
{
|
||||
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 4> >& aBVH = BVH();
|
||||
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 3> >& aBVH = BVH();
|
||||
|
||||
if (theNodeIdx >= aBVH->Length() || !aBVH->IsOuter (theNodeIdx))
|
||||
return INVALID_OFFSET;
|
||||
@ -313,7 +348,7 @@ Standard_Integer OpenGl_RaytraceGeometry::VerticesOffset (Standard_Integer theNo
|
||||
// =======================================================================
|
||||
Standard_Integer OpenGl_RaytraceGeometry::ElementsOffset (Standard_Integer theNodeIdx)
|
||||
{
|
||||
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 4> >& aBVH = BVH();
|
||||
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 3> >& aBVH = BVH();
|
||||
|
||||
if (theNodeIdx >= aBVH->Length() || !aBVH->IsOuter (theNodeIdx))
|
||||
return INVALID_OFFSET;
|
||||
@ -327,7 +362,7 @@ Standard_Integer OpenGl_RaytraceGeometry::ElementsOffset (Standard_Integer theNo
|
||||
// =======================================================================
|
||||
OpenGl_TriangleSet* OpenGl_RaytraceGeometry::TriangleSet (Standard_Integer theNodeIdx)
|
||||
{
|
||||
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 4> >& aBVH = BVH();
|
||||
const NCollection_Handle<BVH_Tree<Standard_ShortReal, 3> >& aBVH = BVH();
|
||||
|
||||
if (theNodeIdx >= aBVH->Length() || !aBVH->IsOuter (theNodeIdx))
|
||||
return NULL;
|
||||
@ -339,6 +374,120 @@ OpenGl_TriangleSet* OpenGl_RaytraceGeometry::TriangleSet (Standard_Integer theNo
|
||||
aBVH->NodeInfoBuffer().at (theNodeIdx).x() - 1).operator->());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AcquireTextures
|
||||
// purpose : Makes the OpenGL texture handles resident
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_RaytraceGeometry::AcquireTextures (const Handle(OpenGl_Context)& theContext) const
|
||||
{
|
||||
if (theContext->arbTexBindless == NULL)
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
for (Standard_Integer anIdx = 0; anIdx < myTextures.Size(); ++anIdx)
|
||||
{
|
||||
theContext->arbTexBindless->glMakeTextureHandleResidentARB (myTextureHandles[anIdx]);
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
std::cout << "Error: Failed to make OpenGL texture resident" << std::endl;
|
||||
#endif
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ReleaseTextures
|
||||
// purpose : Makes the OpenGL texture handles non-resident
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_RaytraceGeometry::ReleaseTextures (const Handle(OpenGl_Context)& theContext) const
|
||||
{
|
||||
if (theContext->arbTexBindless == NULL)
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
for (Standard_Integer anIdx = 0; anIdx < myTextures.Size(); ++anIdx)
|
||||
{
|
||||
theContext->arbTexBindless->glMakeTextureHandleNonResidentARB (myTextureHandles[anIdx]);
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
std::cout << "Error: Failed to make OpenGL texture non-resident" << std::endl;
|
||||
#endif
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddTexture
|
||||
// purpose : Adds new OpenGL texture to the scene and returns its index
|
||||
// =======================================================================
|
||||
Standard_Integer OpenGl_RaytraceGeometry::AddTexture (const Handle(OpenGl_Texture)& theTexture)
|
||||
{
|
||||
NCollection_Vector<Handle (OpenGl_Texture)>::iterator anIter =
|
||||
std::find (myTextures.begin(), myTextures.end(), theTexture);
|
||||
|
||||
if (anIter == myTextures.end())
|
||||
{
|
||||
if (myTextures.Size() >= MAX_TEX_NUMBER)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
myTextures.Append (theTexture);
|
||||
}
|
||||
|
||||
return static_cast<Standard_Integer> (anIter - myTextures.begin());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : UpdateTextureHandles
|
||||
// purpose : Updates unique 64-bit texture handles to use in shaders
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_RaytraceGeometry::UpdateTextureHandles (const Handle(OpenGl_Context)& theContext)
|
||||
{
|
||||
if (theContext->arbTexBindless == NULL)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myTextureHandles.clear();
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
for (Standard_Integer anIdx = 0; anIdx < myTextures.Size(); ++anIdx)
|
||||
{
|
||||
const GLuint64 aHandle = theContext->arbTexBindless->glGetTextureHandleARB (
|
||||
myTextures.Value (anIdx)->TextureId());
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
#ifdef RAY_TRACE_PRINT_INFO
|
||||
std::cout << "Error: Failed to get 64-bit handle of OpenGL texture" << std::endl;
|
||||
#endif
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myTextureHandles.push_back (aHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
namespace OpenGl_Raytrace
|
||||
{
|
||||
// =======================================================================
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include <BVH_Geometry.hxx>
|
||||
#include <BVH_Triangulation.hxx>
|
||||
#include <NCollection_StdAllocator.hxx>
|
||||
#include <OpenGl_TextureBufferArb.hxx>
|
||||
#include <OpenGl_Texture.hxx>
|
||||
|
||||
class OpenGl_Element;
|
||||
struct OpenGl_ElementNode;
|
||||
@ -67,6 +69,9 @@ public:
|
||||
//! Material transparency.
|
||||
BVH_Vec4f Transparency;
|
||||
|
||||
//! Texture transformation matrix.
|
||||
BVH_Mat4f TextureTransform;
|
||||
|
||||
public:
|
||||
|
||||
//! Creates new default material.
|
||||
@ -125,7 +130,7 @@ public:
|
||||
};
|
||||
|
||||
//! Triangulation of single OpenGL primitive array.
|
||||
class OpenGl_TriangleSet : public BVH_Triangulation<Standard_ShortReal, 4>
|
||||
class OpenGl_TriangleSet : public BVH_Triangulation<Standard_ShortReal, 3>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -136,7 +141,7 @@ public:
|
||||
|
||||
//! Creates new OpenGL element triangulation.
|
||||
OpenGl_TriangleSet (const Standard_Size theArrayID)
|
||||
: BVH_Triangulation<Standard_ShortReal, 4>(),
|
||||
: BVH_Triangulation<Standard_ShortReal, 3> (),
|
||||
myArrayID (theArrayID)
|
||||
{
|
||||
//
|
||||
@ -158,37 +163,30 @@ public:
|
||||
Standard_Integer MaterialIndex() const
|
||||
{
|
||||
if (Elements.size() == 0)
|
||||
{
|
||||
return INVALID_MATERIAL;
|
||||
}
|
||||
|
||||
return Elements.front().w();
|
||||
}
|
||||
|
||||
//! Sets material index for entire triangle set.
|
||||
void SetMaterialIndex (Standard_Integer aMatID)
|
||||
void SetMaterialIndex (Standard_Integer theMatID)
|
||||
{
|
||||
for (Standard_Size anIdx = 0; anIdx < Elements.size(); ++anIdx)
|
||||
Elements[anIdx].w() = aMatID;
|
||||
{
|
||||
Elements[anIdx].w() = theMatID;
|
||||
}
|
||||
}
|
||||
|
||||
//! Returns AABB of primitive set.
|
||||
BVH_BoxNt Box() const
|
||||
{
|
||||
const BVH_Transform<Standard_ShortReal, 4>* aTransform =
|
||||
dynamic_cast<const BVH_Transform<Standard_ShortReal, 4>* > (Properties().operator->());
|
||||
|
||||
BVH_BoxNt aBox = BVH_PrimitiveSet<Standard_ShortReal, 4>::Box();
|
||||
|
||||
if (aTransform)
|
||||
{
|
||||
return aTransform->Apply (aBox);
|
||||
}
|
||||
|
||||
return aBox;
|
||||
}
|
||||
BVH_BoxNt Box() const;
|
||||
|
||||
public:
|
||||
|
||||
BVH_Array4f Normals; //!< Array of vertex normals.
|
||||
BVH_Array3f Normals; //!< Array of vertex normals.
|
||||
|
||||
BVH_Array2f TexCrds; //!< Array of vertex UV coords.
|
||||
|
||||
private:
|
||||
|
||||
@ -197,13 +195,19 @@ private:
|
||||
};
|
||||
|
||||
//! Stores geometry of ray-tracing scene.
|
||||
class OpenGl_RaytraceGeometry : public BVH_Geometry<Standard_ShortReal, 4>
|
||||
class OpenGl_RaytraceGeometry : public BVH_Geometry<Standard_ShortReal, 3>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Value of invalid offset to return in case of errors.
|
||||
static const Standard_Integer INVALID_OFFSET = -1;
|
||||
|
||||
//! Maximum number of textures used in ray-tracing shaders.
|
||||
//! This is not restriction of the solution implemented, but
|
||||
//! rather the reasonable limit of the number of textures in
|
||||
//! various applications (can be increased if needed).
|
||||
static const Standard_Integer MAX_TEX_NUMBER = 32;
|
||||
|
||||
public:
|
||||
|
||||
//! Array of properties of light sources.
|
||||
@ -221,7 +225,7 @@ public:
|
||||
|
||||
//! Creates uninitialized ray-tracing geometry.
|
||||
OpenGl_RaytraceGeometry()
|
||||
: BVH_Geometry<Standard_ShortReal, 4>(),
|
||||
: BVH_Geometry<Standard_ShortReal, 3>(),
|
||||
myHighLevelTreeDepth (0),
|
||||
myBottomLevelTreeDepth (0)
|
||||
{
|
||||
@ -234,9 +238,6 @@ public:
|
||||
//
|
||||
}
|
||||
|
||||
//! Clears ray-tracing geometry.
|
||||
void Clear();
|
||||
|
||||
//! Clears only ray-tracing materials.
|
||||
void ClearMaterials()
|
||||
{
|
||||
@ -244,9 +245,14 @@ public:
|
||||
NCollection_StdAllocator<OpenGl_RaytraceMaterial> > anEmptyMaterials;
|
||||
|
||||
Materials.swap (anEmptyMaterials);
|
||||
|
||||
myTextures.Clear();
|
||||
}
|
||||
|
||||
public:
|
||||
//! Clears ray-tracing geometry.
|
||||
void Clear();
|
||||
|
||||
public: //! @name methods related to acceleration structure
|
||||
|
||||
//! Performs post-processing of high-level scene BVH.
|
||||
Standard_Boolean ProcessAcceleration();
|
||||
@ -271,6 +277,34 @@ public:
|
||||
//! @note Can be used after processing acceleration structure.
|
||||
OpenGl_TriangleSet* TriangleSet (Standard_Integer theNodeIdx);
|
||||
|
||||
public: //! @name methods related to texture management
|
||||
|
||||
//! Adds new OpenGL texture to the scene and returns its index.
|
||||
Standard_Integer AddTexture (const Handle(OpenGl_Texture)& theTexture);
|
||||
|
||||
//! Updates unique 64-bit texture handles to use in shaders.
|
||||
Standard_Boolean UpdateTextureHandles (const Handle(OpenGl_Context)& theContext);
|
||||
|
||||
//! Makes the OpenGL texture handles resident (must be called before using).
|
||||
Standard_Boolean AcquireTextures (const Handle(OpenGl_Context)& theContext) const;
|
||||
|
||||
//! Makes the OpenGL texture handles non-resident (must be called after using).
|
||||
Standard_Boolean ReleaseTextures (const Handle(OpenGl_Context)& theContext) const;
|
||||
|
||||
//! Returns array of texture handles.
|
||||
const std::vector<GLuint64>& TextureHandles() const
|
||||
{
|
||||
return myTextureHandles;
|
||||
}
|
||||
|
||||
//! Checks if scene contains textured objects.
|
||||
Standard_Integer HasTextures() const
|
||||
{
|
||||
return !myTextures.IsEmpty();
|
||||
}
|
||||
|
||||
public: //! @name auxiliary methods
|
||||
|
||||
//! Returns depth of high-level scene BVH from last build.
|
||||
Standard_Integer HighLevelTreeDepth() const
|
||||
{
|
||||
@ -285,6 +319,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_Vector<Handle(OpenGl_Texture)> myTextures; //!< Array of texture maps shared between rendered objects
|
||||
std::vector<GLuint64> myTextureHandles; //!< Array of unique 64-bit texture handles obtained from OpenGL
|
||||
Standard_Integer myHighLevelTreeDepth; //!< Depth of high-level scene BVH from last build
|
||||
Standard_Integer myBottomLevelTreeDepth; //!< Maximum depth of bottom-level scene BVHs from last build
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <OpenGl_Context.hxx>
|
||||
#include <OpenGl_ShaderProgram.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
#include <OpenGl_ArbTexBindless.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE (OpenGl_ShaderProgram, OpenGl_Resource)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderProgram, OpenGl_Resource)
|
||||
@ -784,6 +785,70 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUniform
|
||||
// purpose : Specifies the value of the 64-bit unsigned uniform variable
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName,
|
||||
GLuint64 theValue)
|
||||
{
|
||||
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUniform
|
||||
// purpose : Specifies the value of the 64-bit unsigned uniform variable
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theLocation,
|
||||
GLuint64 theValue)
|
||||
{
|
||||
if (theCtx->arbTexBindless == NULL || myProgramID == NO_PROGRAM || theLocation == INVALID_LOCATION)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
theCtx->arbTexBindless->glUniformHandleui64ARB (theLocation, theValue);
|
||||
#endif
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUniform
|
||||
// purpose : Specifies the value of the 64-bit unsigned uniform array
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName,
|
||||
const GLsizei theCount,
|
||||
const GLuint64* theValue)
|
||||
{
|
||||
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theCount, theValue);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUniform
|
||||
// purpose : Specifies the value of the 64-bit unsigned uniform array
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theLocation,
|
||||
const GLsizei theCount,
|
||||
const GLuint64* theValue)
|
||||
{
|
||||
if (theCtx->arbTexBindless == NULL || myProgramID == NO_PROGRAM || theLocation == INVALID_LOCATION)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
theCtx->arbTexBindless->glUniformHandleui64vARB (theLocation, theCount, theValue);
|
||||
#endif
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUniform
|
||||
// purpose : Specifies the value of the floating-point uniform variable
|
||||
@ -980,6 +1045,36 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUniform
|
||||
// purpose : Specifies the value of the floating-point uniform 4x4 matrix
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName,
|
||||
const OpenGl_Mat4& theValue,
|
||||
GLboolean theTranspose)
|
||||
{
|
||||
return SetUniform (theCtx, GetUniformLocation (theCtx, theName), theValue, theTranspose);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUniform
|
||||
// purpose : Specifies the value of the floating-point uniform 4x4 matrix
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theLocation,
|
||||
const OpenGl_Mat4& theValue,
|
||||
GLboolean theTranspose)
|
||||
{
|
||||
if (myProgramID == NO_PROGRAM || theLocation == INVALID_LOCATION)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniformMatrix4fv (theLocation, 1, theTranspose, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUniform
|
||||
// purpose : Specifies the value of the floating-point uniform 4x4 matrix
|
||||
|
@ -350,6 +350,30 @@ public:
|
||||
GLint theLocation,
|
||||
const OpenGl_Vec4i& theValue);
|
||||
|
||||
public:
|
||||
|
||||
//! Specifies the value of the 64-bit unsigned integer uniform variable.
|
||||
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName,
|
||||
GLuint64 theValue);
|
||||
|
||||
//! Specifies the value of the 64-bit unsigned integer uniform variable.
|
||||
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theLocation,
|
||||
GLuint64 theValue);
|
||||
|
||||
//! Specifies the value of the 64-bit unsigned integer uniform array.
|
||||
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName,
|
||||
const GLsizei theCount,
|
||||
const GLuint64* theValue);
|
||||
|
||||
//! Specifies the value of the 64-bit unsigned integer uniform array.
|
||||
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theLocation,
|
||||
const GLsizei theCount,
|
||||
const GLuint64* theValue);
|
||||
|
||||
public:
|
||||
|
||||
//! Specifies the value of the float uniform variable.
|
||||
@ -394,6 +418,18 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
//! Specifies the value of the float uniform 4x4 matrix.
|
||||
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName,
|
||||
const OpenGl_Mat4& theValue,
|
||||
GLboolean theTranspose = GL_FALSE);
|
||||
|
||||
//! Specifies the value of the float uniform 4x4 matrix.
|
||||
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theLocation,
|
||||
const OpenGl_Mat4& theValue,
|
||||
GLboolean theTranspose = GL_FALSE);
|
||||
|
||||
//! Specifies the value of the float uniform 4x4 matrix.
|
||||
Standard_EXPORT Standard_Boolean SetUniform (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLchar* theName,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
#include <OpenGl_ShaderProgram.hxx>
|
||||
#include <OpenGl_ShaderStates.hxx>
|
||||
#include <OpenGl_Sampler.hxx>
|
||||
#include <OpenGl_Text.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
@ -379,8 +380,12 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
const OpenGl_AspectText* aTextAspect = theWorkspace->AspectText (Standard_True);
|
||||
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
|
||||
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
const Handle(OpenGl_Sampler)& aSampler = aCtx->TextureSampler();
|
||||
if (!aSampler.IsNull())
|
||||
{
|
||||
aSampler->Unbind (*aCtx);
|
||||
}
|
||||
|
||||
if (aCtx->IsGlGreaterEqual (2, 0))
|
||||
{
|
||||
@ -418,6 +423,10 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
}
|
||||
|
||||
// restore aspects
|
||||
if (!aSampler.IsNull())
|
||||
{
|
||||
aSampler->Bind (*aCtx);
|
||||
}
|
||||
if (!aPrevTexture.IsNull())
|
||||
{
|
||||
theWorkspace->EnableTexture (aPrevTexture);
|
||||
@ -722,6 +731,13 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
|
||||
theCtx->core15fwd->glActiveTexture (GL_TEXTURE0);
|
||||
}
|
||||
|
||||
// unbind current OpenGL sampler
|
||||
const Handle(OpenGl_Sampler)& aSampler = theCtx->TextureSampler();
|
||||
if (!aSampler.IsNull() && aSampler->IsValid())
|
||||
{
|
||||
aSampler->Unbind (*theCtx);
|
||||
}
|
||||
|
||||
// extra drawings
|
||||
switch (theTextAspect.DisplayType())
|
||||
{
|
||||
@ -808,5 +824,11 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
|
||||
// revert OpenGL state
|
||||
glPopAttrib(); // enable bit
|
||||
glPopMatrix(); // model view matrix was modified
|
||||
|
||||
// revert custom OpenGL sampler
|
||||
if (!aSampler.IsNull() && aSampler->IsValid())
|
||||
{
|
||||
aSampler->Bind (*theCtx);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -99,13 +99,17 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLfloat* theData)
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (theComponentsNb != 1
|
||||
&& theComponentsNb != 2
|
||||
&& theComponentsNb != 4)
|
||||
if (theComponentsNb < 1
|
||||
|| theComponentsNb > 4)
|
||||
{
|
||||
// unsupported format
|
||||
return false;
|
||||
}
|
||||
else if (theComponentsNb == 3
|
||||
&& !theGlCtx->arbTboRGB32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!Create (theGlCtx)
|
||||
|| !OpenGl_VertexBuffer::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
|
||||
{
|
||||
@ -116,7 +120,7 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
{
|
||||
case 1: myTexFormat = GL_R32F; break;
|
||||
case 2: myTexFormat = GL_RG32F; break;
|
||||
//case 3: myTexFormat = GL_RGB32F; break; // GL_ARB_texture_buffer_object_rgb32
|
||||
case 3: myTexFormat = GL_RGB32F; break; // GL_ARB_texture_buffer_object_rgb32
|
||||
case 4: myTexFormat = GL_RGBA32F; break;
|
||||
}
|
||||
|
||||
@ -141,14 +145,17 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
|
||||
const GLuint* theData)
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (theComponentsNb != 1
|
||||
&& theComponentsNb != 2
|
||||
&& theComponentsNb != 3
|
||||
&& theComponentsNb != 4)
|
||||
if (theComponentsNb < 1
|
||||
|| theComponentsNb > 4)
|
||||
{
|
||||
// unsupported format
|
||||
return false;
|
||||
}
|
||||
else if (theComponentsNb == 3
|
||||
&& !theGlCtx->arbTboRGB32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!Create (theGlCtx)
|
||||
|| !OpenGl_VertexBuffer::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
|
||||
{
|
||||
|
@ -438,19 +438,10 @@ const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const H
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void OpenGl_View::GetMatrices (TColStd_Array2OfReal& theMatOrient,
|
||||
TColStd_Array2OfReal& theMatMapping) const
|
||||
void OpenGl_View::GetMatrices (OpenGl_Mat4& theOrientation,
|
||||
OpenGl_Mat4& theViewMapping) const
|
||||
{
|
||||
const Graphic3d_Mat4d& aProj = myCamera->ProjectionMatrix();
|
||||
const Graphic3d_Mat4d& aOrient = myCamera->OrientationMatrix();
|
||||
|
||||
for (Standard_Integer aRow = 0; aRow < 4; ++aRow)
|
||||
{
|
||||
for (Standard_Integer aCol = 0; aCol < 4; ++aCol)
|
||||
{
|
||||
theMatOrient (aRow, aCol) = aOrient.GetValue (aRow, aCol);
|
||||
theMatMapping (aRow, aCol) = aProj .GetValue (aRow, aCol);
|
||||
}
|
||||
}
|
||||
theViewMapping = myCamera->ProjectionMatrixF();
|
||||
theOrientation = myCamera->OrientationMatrixF();
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
@ -204,8 +204,9 @@ class OpenGl_View : public MMgt_TShared
|
||||
//! marks primitive set for rebuild.
|
||||
void InvalidateBVHData (const Standard_Integer theLayerId);
|
||||
|
||||
void GetMatrices (TColStd_Array2OfReal& theMatOrient,
|
||||
TColStd_Array2OfReal& theMatMapping) const;
|
||||
//! Returns view-mapping and orientation matrices.
|
||||
void GetMatrices (OpenGl_Mat4& theOrientation,
|
||||
OpenGl_Mat4& theViewMapping) const;
|
||||
|
||||
//! Returns list of immediate structures rendered on top of main presentation
|
||||
const OpenGl_SequenceOfStructure& ImmediateStructures() const
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <OpenGl_Element.hxx>
|
||||
#include <OpenGl_FrameBuffer.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_Sampler.hxx>
|
||||
#include <OpenGl_Texture.hxx>
|
||||
#include <OpenGl_View.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
@ -144,6 +145,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_GraphicDriver)& theDrive
|
||||
//
|
||||
myComputeInitStatus (OpenGl_RT_NONE),
|
||||
myIsRaytraceDataValid (Standard_False),
|
||||
myIsRaytraceWarnTextures (Standard_False),
|
||||
myViewModificationStatus (0),
|
||||
myLayersModificationStatus (0),
|
||||
//
|
||||
@ -435,6 +437,9 @@ void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)&
|
||||
}
|
||||
#endif
|
||||
|
||||
// get active sampler object to override default texture parameters
|
||||
const Handle(OpenGl_Sampler)& aSampler = myGlContext->TextureSampler();
|
||||
|
||||
// setup texture filtering and wrapping
|
||||
//if (theTexture->GetParams() != theParams)
|
||||
const GLenum aFilter = (aParams->Filter() == Graphic3d_TOTF_NEAREST) ? GL_NEAREST : GL_LINEAR;
|
||||
@ -443,10 +448,20 @@ void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)&
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
case GL_TEXTURE_1D:
|
||||
{
|
||||
if (aSampler.IsNull() || !aSampler->IsValid())
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, aFilter);
|
||||
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, aFilter);
|
||||
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, aWrapMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSampler->SetParameter (*myGlContext, GL_TEXTURE_MAG_FILTER, aFilter);
|
||||
aSampler->SetParameter (*myGlContext, GL_TEXTURE_MIN_FILTER, aFilter);
|
||||
aSampler->SetParameter (*myGlContext, GL_TEXTURE_WRAP_S, aWrapMode);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -469,37 +484,58 @@ void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)&
|
||||
{
|
||||
// setup degree of anisotropy filter
|
||||
const GLint aMaxDegree = myGlContext->MaxDegreeOfAnisotropy();
|
||||
GLint aDegree;
|
||||
switch (aParams->AnisoFilter())
|
||||
{
|
||||
case Graphic3d_LOTA_QUALITY:
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aMaxDegree);
|
||||
aDegree = aMaxDegree;
|
||||
break;
|
||||
}
|
||||
case Graphic3d_LOTA_MIDDLE:
|
||||
{
|
||||
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (aMaxDegree <= 4) ? 2 : (aMaxDegree / 2));
|
||||
aDegree = (aMaxDegree <= 4) ? 2 : (aMaxDegree / 2);
|
||||
break;
|
||||
}
|
||||
case Graphic3d_LOTA_FAST:
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2);
|
||||
aDegree = 2;
|
||||
break;
|
||||
}
|
||||
case Graphic3d_LOTA_OFF:
|
||||
default:
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
|
||||
aDegree = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (aSampler.IsNull() || !aSampler->IsValid())
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aDegree);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSampler->SetParameter (*myGlContext, GL_TEXTURE_MAX_ANISOTROPY_EXT, aDegree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aSampler.IsNull() || !aSampler->IsValid())
|
||||
{
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, aFilterMin);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, aFilter);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, aWrapMode);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, aWrapMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSampler->SetParameter (*myGlContext, GL_TEXTURE_MIN_FILTER, aFilterMin);
|
||||
aSampler->SetParameter (*myGlContext, GL_TEXTURE_MAG_FILTER, aFilter);
|
||||
aSampler->SetParameter (*myGlContext, GL_TEXTURE_WRAP_S, aWrapMode);
|
||||
aSampler->SetParameter (*myGlContext, GL_TEXTURE_WRAP_T, aWrapMode);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
@ -563,6 +599,15 @@ Handle(OpenGl_Texture) OpenGl_Workspace::EnableTexture (const Handle(OpenGl_Text
|
||||
myTextureBound->Bind (myGlContext);
|
||||
setTextureParams (myTextureBound, theParams);
|
||||
|
||||
// If custom sampler object is available it will be
|
||||
// used for overriding default texture parameters
|
||||
const Handle(OpenGl_Sampler)& aSampler = myGlContext->TextureSampler();
|
||||
|
||||
if (!aSampler.IsNull() && aSampler->IsValid())
|
||||
{
|
||||
aSampler->Bind (*myGlContext);
|
||||
}
|
||||
|
||||
return aPrevTexture;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ struct OpenGl_Material
|
||||
|
||||
DEFINE_STANDARD_HANDLE (OpenGl_RaytraceFilter, OpenGl_RenderFilter)
|
||||
|
||||
//! Graphical raytracing filter.
|
||||
//! Graphical ray-tracing filter.
|
||||
//! Filters out all raytracable structures.
|
||||
class OpenGl_RaytraceFilter : public OpenGl_RenderFilter
|
||||
{
|
||||
@ -307,29 +307,26 @@ protected:
|
||||
OpenGl_RT_uOriginLB,
|
||||
OpenGl_RT_uOriginRT,
|
||||
OpenGl_RT_uOriginRB,
|
||||
|
||||
OpenGl_RT_uDirectLT,
|
||||
OpenGl_RT_uDirectLB,
|
||||
OpenGl_RT_uDirectRT,
|
||||
OpenGl_RT_uDirectRB,
|
||||
OpenGl_RT_uInvModelProj,
|
||||
OpenGl_RT_uUnviewMat,
|
||||
|
||||
OpenGl_RT_uSceneRad,
|
||||
OpenGl_RT_uSceneEps,
|
||||
|
||||
OpenGl_RT_uLightAmbnt,
|
||||
OpenGl_RT_uLightCount,
|
||||
|
||||
OpenGl_RT_uShadEnabled,
|
||||
OpenGl_RT_uReflEnabled,
|
||||
|
||||
OpenGl_RT_uInputTexture,
|
||||
OpenGl_RT_uEnvMapEnable,
|
||||
|
||||
OpenGl_RT_uOffsetX,
|
||||
OpenGl_RT_uOffsetY,
|
||||
OpenGl_RT_uSamples,
|
||||
|
||||
OpenGl_RT_uEnvironmentEnable,
|
||||
OpenGl_RT_uTextures,
|
||||
|
||||
OpenGl_RT_NbVariables // special field
|
||||
};
|
||||
@ -347,19 +344,20 @@ protected:
|
||||
|
||||
OpenGl_RT_GeometryVertexTexture = 6,
|
||||
OpenGl_RT_GeometryNormalTexture = 7,
|
||||
OpenGl_RT_GeometryTriangTexture = 8,
|
||||
OpenGl_RT_GeometryTexCrdTexture = 8,
|
||||
OpenGl_RT_GeometryTriangTexture = 9,
|
||||
|
||||
OpenGl_RT_EnvironmentMapTexture = 9,
|
||||
OpenGl_RT_EnvironmentMapTexture = 10,
|
||||
|
||||
OpenGl_RT_RaytraceMaterialTexture = 10,
|
||||
OpenGl_RT_RaytraceLightSrcTexture = 11,
|
||||
OpenGl_RT_RaytraceMaterialTexture = 11,
|
||||
OpenGl_RT_RaytraceLightSrcTexture = 12,
|
||||
|
||||
OpenGl_RT_FSAAInputTexture = 12,
|
||||
OpenGl_RT_FSAAInputTexture = 13,
|
||||
|
||||
OpenGl_RT_SceneTransformTexture = 13,
|
||||
OpenGl_RT_SceneTransformTexture = 14,
|
||||
|
||||
OpenGl_RT_OpenGlColorTexture = 14,
|
||||
OpenGl_RT_OpenGlDepthTexture = 15
|
||||
OpenGl_RT_OpenGlColorTexture = 15,
|
||||
OpenGl_RT_OpenGlDepthTexture = 16
|
||||
};
|
||||
|
||||
//! Tool class for management of shader sources.
|
||||
@ -407,7 +405,7 @@ protected:
|
||||
};
|
||||
|
||||
//! Default ray-tracing depth.
|
||||
static const Standard_Integer THE_DEFAULT_RAY_DEPTH = 3;
|
||||
static const Standard_Integer THE_DEFAULT_NB_BOUNCES = 3;
|
||||
|
||||
//! Default size of traversal stack.
|
||||
static const Standard_Integer THE_DEFAULT_STACK_SIZE = 24;
|
||||
@ -419,7 +417,7 @@ protected:
|
||||
Standard_Integer StackSize;
|
||||
|
||||
//! Actual ray-tracing depth (number of ray bounces).
|
||||
Standard_Integer TraceDepth;
|
||||
Standard_Integer NbBounces;
|
||||
|
||||
//! Sets light propagation through transparent media.
|
||||
Standard_Boolean TransparentShadows;
|
||||
@ -427,7 +425,7 @@ protected:
|
||||
//! Creates default compile-time ray-tracing parameters.
|
||||
RaytracingParams()
|
||||
: StackSize (THE_DEFAULT_STACK_SIZE),
|
||||
TraceDepth (THE_DEFAULT_RAY_DEPTH),
|
||||
NbBounces (THE_DEFAULT_NB_BOUNCES),
|
||||
TransparentShadows (Standard_False)
|
||||
{
|
||||
//
|
||||
@ -442,8 +440,11 @@ protected: //! @name methods related to ray-tracing
|
||||
//! Checks to see if the structure is modified.
|
||||
Standard_Boolean CheckRaytraceStructure (const OpenGl_Structure* theStructure);
|
||||
|
||||
//! Creates ray-tracing material properties.
|
||||
Standard_Boolean CreateMaterial (const OpenGl_AspectFace* theAspect, OpenGl_RaytraceMaterial& theMaterial);
|
||||
|
||||
//! Updates 3D scene light sources for ray-tracing.
|
||||
Standard_Boolean UpdateRaytraceLightSources (const GLdouble theInvModelView[16]);
|
||||
Standard_Boolean UpdateRaytraceLightSources (const OpenGl_Mat4& theInvModelView);
|
||||
|
||||
//! Updates environment map for ray-tracing.
|
||||
Standard_Boolean UpdateRaytraceEnvironmentMap();
|
||||
@ -458,7 +459,7 @@ protected: //! @name methods related to ray-tracing
|
||||
|
||||
//! Adds OpenGL primitive array to ray-traced scene geometry.
|
||||
OpenGl_TriangleSet* AddRaytracePrimitiveArray (
|
||||
const OpenGl_PrimitiveArray* theArray, int theMatID, const Standard_ShortReal* theTrans);
|
||||
const OpenGl_PrimitiveArray* theArray, int theMatID, const OpenGl_Mat4* theTrans);
|
||||
|
||||
//! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
|
||||
Standard_Boolean AddRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
|
||||
@ -515,6 +516,9 @@ protected: //! @name methods related to ray-tracing
|
||||
//! Performs safe exit when shaders initialization fails.
|
||||
Standard_Boolean SafeFailBack (const TCollection_ExtendedString& theMessage);
|
||||
|
||||
//! Generates shader prefix based on current ray-tracing options.
|
||||
TCollection_AsciiString GenerateShaderPrefix();
|
||||
|
||||
//! Initializes OpenGL/GLSL shader programs.
|
||||
Standard_Boolean InitRaytraceResources (const Graphic3d_CView& theCView);
|
||||
|
||||
@ -529,11 +533,19 @@ protected: //! @name methods related to ray-tracing
|
||||
const Standard_Integer theSizeY);
|
||||
|
||||
//! Generates viewing rays for corners of screen quad.
|
||||
void UpdateCamera (const NCollection_Mat4<GLdouble>& theOrientation,
|
||||
const NCollection_Mat4<GLdouble>& theViewMapping,
|
||||
void UpdateCamera (const OpenGl_Mat4& theOrientation,
|
||||
const OpenGl_Mat4& theViewMapping,
|
||||
OpenGl_Vec3 theOrigins[4],
|
||||
OpenGl_Vec3 theDirects[4],
|
||||
NCollection_Mat4<GLdouble>& theInvModelProj);
|
||||
OpenGl_Mat4& theInvModelProj);
|
||||
|
||||
//! Sets uniform state for the given ray-tracing shader program.
|
||||
Standard_Boolean SetUniformState (const Graphic3d_CView& theCView,
|
||||
const OpenGl_Vec3* theOrigins,
|
||||
const OpenGl_Vec3* theDirects,
|
||||
const OpenGl_Mat4& theUnviewMat,
|
||||
const Standard_Integer theProgramIndex,
|
||||
Handle(OpenGl_ShaderProgram)& theRaytraceProgram);
|
||||
|
||||
//! Runs ray-tracing shader programs.
|
||||
Standard_Boolean RunRaytraceShaders (const Graphic3d_CView& theCView,
|
||||
@ -541,7 +553,7 @@ protected: //! @name methods related to ray-tracing
|
||||
const Standard_Integer theSizeY,
|
||||
const OpenGl_Vec3 theOrigins[4],
|
||||
const OpenGl_Vec3 theDirects[4],
|
||||
const OpenGl_Matrix& theInvModelProj,
|
||||
const OpenGl_Mat4& theUnviewMat,
|
||||
OpenGl_FrameBuffer* theFrameBuffer);
|
||||
|
||||
//! Redraws the window using OpenGL/GLSL ray-tracing.
|
||||
@ -561,6 +573,9 @@ protected: //! @name fields related to ray-tracing
|
||||
//! Is geometry data valid?
|
||||
Standard_Boolean myIsRaytraceDataValid;
|
||||
|
||||
//! Warning about missing extension GL_ARB_bindless_texture has been displayed?
|
||||
Standard_Boolean myIsRaytraceWarnTextures;
|
||||
|
||||
//! 3D scene geometry data for ray-tracing.
|
||||
OpenGl_RaytraceGeometry myRaytraceGeometry;
|
||||
|
||||
@ -607,6 +622,8 @@ protected: //! @name fields related to ray-tracing
|
||||
Handle(OpenGl_TextureBufferArb) myGeometryVertexTexture;
|
||||
//! Texture buffer of vertex normals.
|
||||
Handle(OpenGl_TextureBufferArb) myGeometryNormalTexture;
|
||||
//! Texture buffer of vertex UV coords.
|
||||
Handle(OpenGl_TextureBufferArb) myGeometryTexCrdTexture;
|
||||
//! Texture buffer of triangle indices.
|
||||
Handle(OpenGl_TextureBufferArb) myGeometryTriangTexture;
|
||||
|
||||
@ -639,10 +656,10 @@ protected: //! @name fields related to ray-tracing
|
||||
//! Cached locations of frequently used uniform variables.
|
||||
Standard_Integer myUniformLocations[2][OpenGl_RT_NbVariables];
|
||||
|
||||
//! Graphical raytracing filter to filter out all raytracable structures.
|
||||
//! Graphical ray-tracing filter to filter out all raytracable structures.
|
||||
Handle(OpenGl_RaytraceFilter) myRaytraceFilter;
|
||||
|
||||
//! Redraw the scene using OpenGL rasterization or raytracing?
|
||||
//! Redraw the scene using OpenGL rasterization or ray-tracing?
|
||||
Standard_Boolean myToRedrawGL;
|
||||
|
||||
protected: //! @name protected fields
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,7 @@
|
||||
#ifdef USE_TEXTURES
|
||||
#extension GL_ARB_bindless_texture : require
|
||||
#endif
|
||||
|
||||
//! Normalized pixel coordinates.
|
||||
in vec2 vPixel;
|
||||
|
||||
@ -20,7 +24,8 @@ uniform vec3 uDirectRT;
|
||||
uniform vec3 uDirectRB;
|
||||
|
||||
//! Inverse model-view-projection matrix.
|
||||
uniform mat4 uInvModelProj;
|
||||
uniform mat4 uUnviewMat;
|
||||
|
||||
//! Texture buffer of data records of high-level BVH nodes.
|
||||
uniform isamplerBuffer uSceneNodeInfoTexture;
|
||||
//! Texture buffer of minimum points of high-level BVH nodes.
|
||||
@ -41,6 +46,10 @@ uniform samplerBuffer uObjectMaxPointTexture;
|
||||
uniform samplerBuffer uGeometryVertexTexture;
|
||||
//! Texture buffer of vertex normals.
|
||||
uniform samplerBuffer uGeometryNormalTexture;
|
||||
#ifdef USE_TEXTURES
|
||||
//! Texture buffer of per-vertex UV-coordinates.
|
||||
uniform samplerBuffer uGeometryTexCrdTexture;
|
||||
#endif
|
||||
//! Texture buffer of triangle indices.
|
||||
uniform isamplerBuffer uGeometryTriangTexture;
|
||||
|
||||
@ -73,6 +82,11 @@ uniform float uSceneRadius;
|
||||
//! Scene epsilon to prevent self-intersections.
|
||||
uniform float uSceneEpsilon;
|
||||
|
||||
#ifdef USE_TEXTURES
|
||||
//! Unique 64-bit handles of OpenGL textures.
|
||||
uniform sampler2D uTextureSamplers[MAX_TEX_NUMBER];
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Specific data types
|
||||
|
||||
@ -108,7 +122,6 @@ struct SIntersect
|
||||
#define AXIS_Y vec3 (0.0f, 1.0f, 0.0f)
|
||||
#define AXIS_Z vec3 (0.0f, 0.0f, 1.0f)
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : MatrixRowMultiplyDir
|
||||
// purpose : Multiplies a vector by matrix
|
||||
@ -171,7 +184,6 @@ SRay GenerateRay (in vec2 thePixel)
|
||||
vec3 aDirection = normalize (mix (aD0, aD1, thePixel.y));
|
||||
|
||||
return SRay (mix (aP0, aP1, thePixel.y), aDirection);
|
||||
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -187,7 +199,7 @@ float ComputeOpenGlDepth (in SRay theRay)
|
||||
2.0f * vPixel.y - 1.0f,
|
||||
2.0f * anOpenGlDepth - 1.0f,
|
||||
1.0f);
|
||||
vec4 aFinal = uInvModelProj * aPoint;
|
||||
vec4 aFinal = uUnviewMat * aPoint;
|
||||
aFinal.xyz *= 1.f / aFinal.w;
|
||||
|
||||
return (anOpenGlDepth < 1.f) ? length (aFinal.xyz - theRay.Origin) : MAXFLOAT;
|
||||
@ -377,13 +389,16 @@ ivec4 ObjectNearestHit (in int theBVHOffset, in int theVrtOffset, in int theTrgO
|
||||
return aTriIndex;
|
||||
}
|
||||
|
||||
#define MATERIAL_AMBN(index) (7 * index + 0)
|
||||
#define MATERIAL_DIFF(index) (7 * index + 1)
|
||||
#define MATERIAL_SPEC(index) (7 * index + 2)
|
||||
#define MATERIAL_EMIS(index) (7 * index + 3)
|
||||
#define MATERIAL_REFL(index) (7 * index + 4)
|
||||
#define MATERIAL_REFR(index) (7 * index + 5)
|
||||
#define MATERIAL_TRAN(index) (7 * index + 6)
|
||||
#define MATERIAL_AMBN(index) (11 * index + 0)
|
||||
#define MATERIAL_DIFF(index) (11 * index + 1)
|
||||
#define MATERIAL_SPEC(index) (11 * index + 2)
|
||||
#define MATERIAL_EMIS(index) (11 * index + 3)
|
||||
#define MATERIAL_REFL(index) (11 * index + 4)
|
||||
#define MATERIAL_REFR(index) (11 * index + 5)
|
||||
#define MATERIAL_TRAN(index) (11 * index + 6)
|
||||
#define MATERIAL_TRS1(index) (11 * index + 7)
|
||||
#define MATERIAL_TRS2(index) (11 * index + 8)
|
||||
#define MATERIAL_TRS3(index) (11 * index + 9)
|
||||
|
||||
// =======================================================================
|
||||
// function : ObjectAnyHit
|
||||
@ -790,6 +805,23 @@ vec3 SmoothNormal (in vec2 theUV, in ivec4 theTriangle)
|
||||
aNormal0 * (1.0f - theUV.x - theUV.y));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SmoothUV
|
||||
// purpose : Interpolates UV coordinates across the triangle
|
||||
// =======================================================================
|
||||
#ifdef USE_TEXTURES
|
||||
vec2 SmoothUV (in vec2 theUV, in ivec4 theTriangle)
|
||||
{
|
||||
vec2 aTexCrd0 = texelFetch (uGeometryTexCrdTexture, theTriangle.x).st;
|
||||
vec2 aTexCrd1 = texelFetch (uGeometryTexCrdTexture, theTriangle.y).st;
|
||||
vec2 aTexCrd2 = texelFetch (uGeometryTexCrdTexture, theTriangle.z).st;
|
||||
|
||||
return aTexCrd1 * theUV.x +
|
||||
aTexCrd2 * theUV.y +
|
||||
aTexCrd0 * (1.0f - theUV.x - theUV.y);
|
||||
}
|
||||
#endif
|
||||
|
||||
// =======================================================================
|
||||
// function : Refract
|
||||
// purpose : Computes refraction ray (also handles TIR)
|
||||
@ -828,7 +860,7 @@ vec3 Refract (in vec3 theInput,
|
||||
|
||||
// =======================================================================
|
||||
// function : Radiance
|
||||
// purpose : Computes color of specified ray
|
||||
// purpose : Computes color along the given ray
|
||||
// =======================================================================
|
||||
vec4 Radiance (in SRay theRay, in vec3 theInverse)
|
||||
{
|
||||
@ -839,9 +871,7 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse)
|
||||
|
||||
float anOpenGlDepth = ComputeOpenGlDepth (theRay);
|
||||
|
||||
vec3 aViewDir = theRay.Direct;
|
||||
|
||||
for (int aDepth = 0; aDepth < TRACE_DEPTH; ++aDepth)
|
||||
for (int aDepth = 0; aDepth < NB_BOUNCES; ++aDepth)
|
||||
{
|
||||
SIntersect aHit = SIntersect (MAXFLOAT, vec2 (ZERO), ZERO);
|
||||
|
||||
@ -849,69 +879,47 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse)
|
||||
|
||||
if (aTriIndex.x == -1)
|
||||
{
|
||||
vec4 aColor = vec4 (0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (aWeight.w != 0.0f)
|
||||
{
|
||||
if (anOpenGlDepth < MAXFLOAT)
|
||||
{
|
||||
vec4 anOpenGlColor = ComputeOpenGlColor (theRay);
|
||||
aResult.xyz += aWeight.xyz * anOpenGlColor.xyz;
|
||||
aWeight.w *= anOpenGlColor.w;
|
||||
if (anOpenGlDepth != MAXFLOAT)
|
||||
aColor = ComputeOpenGlColor (theRay);
|
||||
}
|
||||
return vec4 (aResult.x,
|
||||
aResult.y,
|
||||
aResult.z,
|
||||
aWeight.w);
|
||||
}
|
||||
|
||||
if (bool(uEnvironmentEnable))
|
||||
else if (bool(uEnvironmentEnable))
|
||||
{
|
||||
float aTime = IntersectSphere (theRay, uSceneRadius);
|
||||
|
||||
aResult.xyz += aWeight.xyz * textureLod (uEnvironmentMapTexture,
|
||||
Latlong (theRay.Direct * aTime + theRay.Origin, uSceneRadius), 0.0f).xyz;
|
||||
aColor = textureLod (uEnvironmentMapTexture, Latlong (
|
||||
theRay.Direct * aTime + theRay.Origin, uSceneRadius), 0.0f);
|
||||
}
|
||||
|
||||
return vec4 (aResult.x,
|
||||
aResult.y,
|
||||
aResult.z,
|
||||
aWeight.w);
|
||||
return vec4 (aResult.xyz + aWeight.xyz * aColor.xyz, aWeight.w * aColor.w);
|
||||
}
|
||||
|
||||
aHit.Normal = normalize (aHit.Normal);
|
||||
|
||||
if (anOpenGlDepth != MAXFLOAT)
|
||||
{
|
||||
float aDepthSlope = dot (theRay.Direct, aHit.Normal);
|
||||
|
||||
// For polygons that are parallel to the screen plane, the depth slope
|
||||
// is equal to 1, resulting in small polygon offset. For polygons that
|
||||
// that are at a large angle to the screen, the depth slope tends to 1,
|
||||
// resulting in a larger polygon offset
|
||||
float aPolygonOffset = uSceneEpsilon * EPS_SCALE / max (MIN_SLOPE, abs (aDepthSlope));
|
||||
float aPolygonOffset = uSceneEpsilon * min (
|
||||
EPS_SCALE / abs (dot (theRay.Direct, aHit.Normal)), EPS_SCALE / MIN_SLOPE);
|
||||
|
||||
if (anOpenGlDepth - aPolygonOffset < aHit.Time)
|
||||
{
|
||||
vec4 aColor = ComputeOpenGlColor (theRay);
|
||||
|
||||
aResult.xyz += aWeight.xyz * aColor.xyz;
|
||||
aResult += aWeight.xyz * aColor.xyz;
|
||||
aWeight *= aColor.w;
|
||||
|
||||
if (all (lessThanEqual (aWeight.xyz, THRESHOLD)))
|
||||
{
|
||||
return vec4 (aResult.x,
|
||||
aResult.y,
|
||||
aResult.z,
|
||||
aWeight.w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vec3 aPoint = theRay.Direct * aHit.Time + theRay.Origin;
|
||||
|
||||
vec3 aAmbient = texelFetch (
|
||||
uRaytraceMaterialTexture, MATERIAL_AMBN (aTriIndex.w)).rgb;
|
||||
vec3 aDiffuse = texelFetch (
|
||||
uRaytraceMaterialTexture, MATERIAL_DIFF (aTriIndex.w)).rgb;
|
||||
vec4 aDiffuse = texelFetch (
|
||||
uRaytraceMaterialTexture, MATERIAL_DIFF (aTriIndex.w));
|
||||
vec4 aSpecular = texelFetch (
|
||||
uRaytraceMaterialTexture, MATERIAL_SPEC (aTriIndex.w));
|
||||
vec4 aOpacity = texelFetch (
|
||||
@ -919,12 +927,33 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse)
|
||||
vec3 aEmission = texelFetch (
|
||||
uRaytraceMaterialTexture, MATERIAL_EMIS (aTriIndex.w)).rgb;
|
||||
|
||||
vec3 aNormal = SmoothNormal (aHit.UV, aTriIndex);
|
||||
#ifdef USE_TEXTURES
|
||||
if (aDiffuse.w >= 0.f)
|
||||
{
|
||||
vec4 aTexCoord = vec4 (SmoothUV (aHit.UV, aTriIndex), 0.f, 1.f);
|
||||
|
||||
vec4 aTrsfRow1 = texelFetch (
|
||||
uRaytraceMaterialTexture, MATERIAL_TRS1 (aTriIndex.w));
|
||||
vec4 aTrsfRow2 = texelFetch (
|
||||
uRaytraceMaterialTexture, MATERIAL_TRS2 (aTriIndex.w));
|
||||
|
||||
aTexCoord.st = vec2 (dot (aTrsfRow1, aTexCoord),
|
||||
dot (aTrsfRow2, aTexCoord));
|
||||
|
||||
vec3 aTexColor = textureLod (
|
||||
uTextureSamplers[int(aDiffuse.w)], aTexCoord.st, 0.f).rgb;
|
||||
|
||||
aDiffuse.rgb *= aTexColor;
|
||||
aAmbient.rgb *= aTexColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 aInvTransf0 = texelFetch (uSceneTransformTexture, anObjectId * 4 + 0);
|
||||
vec4 aInvTransf1 = texelFetch (uSceneTransformTexture, anObjectId * 4 + 1);
|
||||
vec4 aInvTransf2 = texelFetch (uSceneTransformTexture, anObjectId * 4 + 2);
|
||||
|
||||
vec3 aNormal = SmoothNormal (aHit.UV, aTriIndex);
|
||||
|
||||
aNormal = normalize (MatrixRowMultiplyDir (
|
||||
aNormal, aInvTransf0, aInvTransf1, aInvTransf2));
|
||||
|
||||
@ -975,15 +1004,13 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse)
|
||||
float aRdotV = dot (reflect (aShadow.Direct, aNormal), theRay.Direct);
|
||||
|
||||
aResult.xyz += aWeight.xyz * (aOpacity.x * aVisibility) * aIntensity *
|
||||
(aDiffuse * aLdotN + aSpecular.xyz * pow (max (0.0f, aRdotV), aSpecular.w));
|
||||
(aDiffuse.rgb * aLdotN + aSpecular.xyz * pow (max (0.0f, aRdotV), aSpecular.w));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aResult.xyz += aWeight.xyz * uGlobalAmbient.xyz *
|
||||
aAmbient * aOpacity.x * max (abs (dot (aNormal, theRay.Direct)), 0.5f);
|
||||
|
||||
aResult.xyz += aWeight.xyz * aOpacity.x * aEmission;
|
||||
aResult.xyz += aWeight.xyz * aOpacity.x * (uGlobalAmbient.xyz *
|
||||
aAmbient * max (abs (dot (aNormal, theRay.Direct)), 0.5f) + aEmission);
|
||||
|
||||
if (aOpacity.x != 1.0f)
|
||||
{
|
||||
|
75
tests/v3d/raytrace/textures
Normal file
75
tests/v3d/raytrace/textures
Normal file
@ -0,0 +1,75 @@
|
||||
puts "========"
|
||||
puts "Ray Tracing - check refraction"
|
||||
puts "========"
|
||||
|
||||
vinit View1
|
||||
vclear
|
||||
vrenderparams -rasterization
|
||||
vsetdispmode 1
|
||||
vsetgradientbg 180 200 255 180 180 180 2
|
||||
|
||||
box wall1 1 8 8
|
||||
box wall2 1 8 8
|
||||
box wall3 16 8 1
|
||||
|
||||
psphere S1 1.5
|
||||
psphere S2 1.5
|
||||
psphere S3 1.5
|
||||
|
||||
box B1 -1.5 -1.5 -1.5 2.5 2 3
|
||||
box B2 -1.5 -1.5 -1.5 2.5 2 3
|
||||
box B3 -1.5 -1.5 -1.5 2.5 2 3
|
||||
|
||||
vdisplay S1
|
||||
vdisplay S2
|
||||
vdisplay S3
|
||||
|
||||
vdisplay B1
|
||||
vdisplay B2
|
||||
vdisplay B3
|
||||
|
||||
vdisplay wall1
|
||||
vdisplay wall2
|
||||
vdisplay wall3
|
||||
|
||||
vtexture S1 8
|
||||
vtexture S2 2
|
||||
vtexture S3 3
|
||||
|
||||
vtexture B1 4
|
||||
vtexture B2 5
|
||||
vtexture B3 6
|
||||
|
||||
vsetlocation S1 2 2 4
|
||||
vsetlocation S2 -2 2 4
|
||||
vsetlocation S3 -6 2 4
|
||||
|
||||
vsetlocation B1 2 6 4
|
||||
vsetlocation B2 -2 6 4
|
||||
vsetlocation B3 -6 6 4
|
||||
|
||||
vsetlocation wall1 -10 0 0
|
||||
vsetlocation wall2 5 0 0
|
||||
vsetlocation wall3 -10 0 -1
|
||||
|
||||
vsetmaterial S1 gold
|
||||
vsetmaterial S2 silver
|
||||
vsetmaterial S3 copper
|
||||
|
||||
vsetmaterial B1 steel
|
||||
vsetmaterial B2 pewter
|
||||
vsetmaterial B3 chrome
|
||||
|
||||
vsetmaterial wall1 stone
|
||||
vsetmaterial wall2 stone
|
||||
vsetmaterial wall3 pewter
|
||||
|
||||
vsetcolor wall1 red
|
||||
vsetcolor wall2 green
|
||||
|
||||
vright
|
||||
vturnview 0 -0.3 0
|
||||
vfit
|
||||
vlight change 0 pos 1 1 1
|
||||
vlight add directional
|
||||
vrenderparams -raytrace -raydepth 3 -shadows on -reflections -fsaa
|
Loading…
x
Reference in New Issue
Block a user