Skip to content

Commit

Permalink
Main: TextureUnitState - alias EnvMapType to TexCoordCalcMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Aug 25, 2024
1 parent 27b69b1 commit a38da08
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 44 deletions.
14 changes: 8 additions & 6 deletions Docs/src/material-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1209,12 +1209,15 @@ Format: alpha\_op\_ex <op> <source1> <source2> \[<manualBle
@par
Format: env\_map <off|spherical|planar|cubic\_reflection|cubic\_normal>

@par
Default: env\_map off

Environment maps make an object look reflective by using automatic texture coordinate generation depending on the relationship between the objects vertices or normals and the eye.

<dl compact="compact">
<dt>spherical</dt> <dd>

@copybrief Ogre::TextureUnitState::ENV_CURVED
@copybrief Ogre::TEXCALC_ENVIRONMENT_MAP
Requires a single texture which is either a fish-eye lens view of the reflected scene, or some other texture which looks good as a spherical map (a texture of glossy highlights is popular especially in car sims). This effect is based on the relationship between the eye direction and the vertex normals of the object, so works best when there are a lot of gradually changing normals, i.e. curved objects.

</dd> <dt>planar</dt> <dd>
Expand All @@ -1225,16 +1228,15 @@ The effect is based on the position of the vertices in the viewport rather than

</dd> <dt>cubic\_reflection</dt> <dd>

@copybrief Ogre::TextureUnitState::ENV_REFLECTION
@copybrief Ogre::TEXCALC_ENVIRONMENT_MAP_REFLECTION
Uses a group of 6 textures making up the inside of a cube, each of which is a view if the scene down each axis. Works extremely well in all cases but has a higher technical requirement from the card than spherical mapping. Requires that you bind a [cubic texture](#texture) to this unit.

</dd> <dt>cubic\_normal</dt> <dd>
@copybrief Ogre::TextureUnitState::ENV_NORMAL
@copybrief Ogre::TEXCALC_ENVIRONMENT_MAP_NORMAL
Generates 3D texture coordinates containing the camera space normal vector from the normal information held in the vertex data. Again, use of this feature requires a [cubic texture](#texture).

</dd> </dl> <br>
@par
Default: env\_map off<br>
</dd> </dl>


<a name="scroll"></a><a name="scroll-1"></a>

Expand Down
1 change: 1 addition & 0 deletions OgreMain/include/Ogre.i
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ typedef uint8_t uint8;
%ignore Ogre::GpuConstantType;
%ignore Ogre::GpuProgramParameters::ElementType;
%ignore Ogre::Capabilities;
%ignore Ogre::TextureUnitState::EnvMapType;
%typemap(csbase) Ogre::SceneManager::QueryTypeMask "uint";
%csmethodmodifiers *::ToString "public override";
// wrong "override" because of multiple inheritance
Expand Down
11 changes: 8 additions & 3 deletions OgreMain/include/OgreRenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ THE SOFTWARE.
// Precompiler options
#include "OgrePrerequisites.h"

#include "OgreTextureUnitState.h"
#include "OgreCommon.h"
#include "OgreBlendMode.h"

#include "OgreRenderSystemCapabilities.h"
#include "OgreConfigOptionMap.h"
Expand All @@ -43,6 +43,9 @@ THE SOFTWARE.

namespace Ogre
{
class Sampler;
class TextureUnitState;

/** \addtogroup Core
* @{
*/
Expand All @@ -61,11 +64,13 @@ namespace Ogre
{
/// No calculated texture coordinates
TEXCALC_NONE,
/// Environment map based on vertex normals
/// 2D texture coordinates using spherical reflection mapping based on vertex normals.
TEXCALC_ENVIRONMENT_MAP,
/// Environment map based on vertex positions
/// 2D texture coordinates using view space position. Same as #TEXCALC_ENVIRONMENT_MAP on all backends.
TEXCALC_ENVIRONMENT_MAP_PLANAR,
/// 3D texture coordinates using the reflection vector.
TEXCALC_ENVIRONMENT_MAP_REFLECTION,
/// 3D texture coordinates using the normal vector.
TEXCALC_ENVIRONMENT_MAP_NORMAL,
/// Projective texture
TEXCALC_PROJECTIVE_TEXTURE
Expand Down
27 changes: 14 additions & 13 deletions OgreMain/include/OgreTextureUnitState.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ THE SOFTWARE.
#include "OgreMatrix4.h"
#include "OgreTexture.h"
#include "OgreHeaderPrefix.h"
#include "OgreRenderSystem.h"

namespace Ogre {
enum TexCoordCalcMethod : uint8;
Expand Down Expand Up @@ -264,17 +265,17 @@ namespace Ogre {

};

/// %Texture coordinate generation method for environment mapping.
enum EnvMapType
/// rather use @ref TexCoordCalcMethod
enum EnvMapType : uint8
{
/// 2D texture coordinates using view space position. Same as ENV_CURVED on all backends.
ENV_PLANAR,
/// 2D texture coordinates using spherical reflection mapping
ENV_CURVED,
/// Cubic texture coordinates using the reflection vector
ENV_REFLECTION,
/// Cubic texture coordinates using the normal vector
ENV_NORMAL
/// same as #TEXCALC_ENVIRONMENT_MAP_PLANAR
ENV_PLANAR = TEXCALC_ENVIRONMENT_MAP_PLANAR,
/// same as #TEXCALC_ENVIRONMENT_MAP
ENV_CURVED = TEXCALC_ENVIRONMENT_MAP,
/// same as #TEXCALC_ENVIRONMENT_MAP_REFLECTION
ENV_REFLECTION = TEXCALC_ENVIRONMENT_MAP_REFLECTION,
/// same as #TEXCALC_ENVIRONMENT_MAP_NORMAL
ENV_NORMAL = TEXCALC_ENVIRONMENT_MAP_NORMAL
};

/** Useful enumeration when dealing with procedural transforms.
Expand Down Expand Up @@ -863,7 +864,7 @@ namespace Ogre {
*/
void addEffect(TextureEffect effect);

/** Turns on/off texture coordinate effect that makes this layer an environment map.
/** Turns on/off texture coordinate generation for addressing an environment map.
Environment maps make an object look reflective by using the object's vertex normals relative
to the camera view to generate texture coordinates.
Expand All @@ -873,7 +874,7 @@ namespace Ogre {
for each side of the inside of a cube.
This effect works best if the object has lots of gradually changing normals. The texture also
has to be designed for this effect - see the example spheremap.png included with the sample
has to be designed for this effect - see the example @c spheremap.png included with the sample
application for a 2D environment map; a cubic map can be generated by rendering 6 views of a
scene to each of the cube faces with orthogonal views.
Expand All @@ -884,7 +885,7 @@ namespace Ogre {
True to enable, false to disable
@param texGenType texture coordinate generation type
*/
void setEnvironmentMap(bool enable, EnvMapType texGenType = ENV_CURVED);
void setEnvironmentMap(bool enable, int texGenType = TEXCALC_ENVIRONMENT_MAP);

/** Sets up an animated scroll for the texture layer.
Expand Down
19 changes: 2 additions & 17 deletions OgreMain/src/OgreTextureUnitState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ namespace Ogre {
return mAlphaBlendMode;
}
//-----------------------------------------------------------------------
void TextureUnitState::setEnvironmentMap(bool enable, EnvMapType envMapType)
void TextureUnitState::setEnvironmentMap(bool enable, int envMapType)
{
if (enable)
{
Expand Down Expand Up @@ -1226,22 +1226,7 @@ namespace Ogre {
switch (effi.second.type)
{
case ET_ENVIRONMENT_MAP:
if (effi.second.subtype == ENV_CURVED)
{
texCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP;
}
else if (effi.second.subtype == ENV_PLANAR)
{
texCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_PLANAR;
}
else if (effi.second.subtype == ENV_REFLECTION)
{
texCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_REFLECTION;
}
else if (effi.second.subtype == ENV_NORMAL)
{
texCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_NORMAL;
}
texCoordCalcMethod = (TexCoordCalcMethod)effi.second.subtype;
break;
case ET_UVSCROLL:
case ET_USCROLL:
Expand Down
2 changes: 1 addition & 1 deletion RenderSystems/Direct3D11/include/OgreD3D11Mappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE SOFTWARE.
#define __D3D11MAPPINGS_H__

#include "OgreD3D11Prerequisites.h"
#include "OgreTextureUnitState.h"
#include "OgreTexture.h"
#include "OgreRenderSystem.h"
#include "OgreHardwareIndexBuffer.h"

Expand Down
1 change: 1 addition & 0 deletions RenderSystems/Direct3D9/include/OgreD3D9Mappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ THE SOFTWARE.
#include "OgreRenderSystem.h"
#include "OgreHardwareBuffer.h"
#include "OgreHardwareIndexBuffer.h"
#include "OgreTexture.h"

namespace Ogre
{
Expand Down
8 changes: 4 additions & 4 deletions RenderSystems/Direct3D9/src/OgreD3D9Mappings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ namespace Ogre
{
switch( tam )
{
case TextureUnitState::TAM_WRAP:
case TAM_WRAP:
return D3DTADDRESS_WRAP;
case TextureUnitState::TAM_MIRROR:
case TAM_MIRROR:
return D3DTADDRESS_MIRROR;
case TextureUnitState::TAM_CLAMP:
case TAM_CLAMP:
return D3DTADDRESS_CLAMP;
case TextureUnitState::TAM_BORDER:
case TAM_BORDER:
if (devCaps.TextureAddressCaps & D3DPTADDRESSCAPS_BORDER)
return D3DTADDRESS_BORDER;
else
Expand Down
1 change: 1 addition & 0 deletions RenderSystems/Tiny/include/OgreTinyRenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "OgreRenderWindow.h"
#include "OgreRenderSystem.h"
#include "OgreImage.h"

namespace Ogre {
/** \addtogroup RenderSystems RenderSystems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ THE SOFTWARE.
#include "OgreShaderPrerequisites.h"
#ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
#include "OgreShaderSubRenderState.h"
#include "OgreTextureUnitState.h"

#define TAS_MAX_TEXTURES 4
namespace Ogre {
Expand Down

0 comments on commit a38da08

Please sign in to comment.