View Issue Details

IDProjectCategoryView StatusLast Update
0002499DarkRadiantModelspublic05.02.2021 16:46
Reporterdersaidin Assigned Togreebo  
PrioritynormalSeveritynormalReproducibilityN/A
Status closedResolutionfixed 
Product Version1.5.0 
Target Version1.5.0Fixed in Version1.5.0 
Summary0002499: Xreal: Support MATERIAL_NAME shaders for ASE models
DescriptionXreal accepts ASE materials given in the MATERIAL_NAME identifier.

This is "a standard" (oxymoron? ;D) for ASE from ETQW. See: http://www.modwiki.net/wiki/Ase

It will try BITMAP first, just as before.
Additional InformationTheres a FIXME to use base folder name from the game.xml. Not important for xreal.

RenderablePicoSurface.cpp:97 is a bit hackish, afaik they should be the only paths shaders begin with. I think its acceptable - when theres so many "standards" what else can you do? :D
TagsNo tags attached.
Attached Files
darkradiant6254_asematerialname.patch (5,940 bytes)   
Index: include/irender.h
===================================================================
--- include/irender.h	(revision 6254)
+++ include/irender.h	(working copy)
@@ -337,6 +337,19 @@
 
 	/**
      * \brief
+     * Test if the the given shader is able to be captured.
+	 * Return true if the given shader is available.
+	 *
+	 * @param name
+	 * The name of the shader to test capture.
+	 *
+	 * @returns
+	 * bool, true if the shader is available.
+	 */
+	virtual bool canCapture(const std::string& name) = 0;
+
+	/**
+     * \brief
      * Capture the given shader, increasing its reference count and
 	 * returning a pointer to the Shader object.
      *
Index: plugins/model/RenderablePicoSurface.cpp
===================================================================
--- plugins/model/RenderablePicoSurface.cpp	(revision 6254)
+++ plugins/model/RenderablePicoSurface.cpp	(working copy)
@@ -22,47 +22,35 @@
 	// Get the shader from the picomodel struct. If this is a LWO model, use
 	// the material name to select the shader, while for an ASE model the
 	// bitmap path should be used.
-    picoShader_t* shader = PicoGetSurfaceShader(surf);
-    if (shader != 0) {
+	picoShader_t* shader = PicoGetSurfaceShader(surf);
+	std::string rawName = "";
+	if (shader != 0) {
 		if (fExt == "lwo")
-        {
-	    	_originalShaderName = PicoGetShaderName(shader);
+		{
+			_originalShaderName = PicoGetShaderName(shader);
 		}
 		else if (fExt == "ase")
-        {
+		{
+			rawName = PicoGetShaderName(shader);
 			std::string rawMapName = PicoGetShaderMapName(shader);
-			boost::algorithm::replace_all(rawMapName, "\\", "/");
+			_originalShaderName = cleanupShaderName(rawMapName);
+		}
+	}
 
-			// Take off the everything before "base/", and everything after
-			// the first period if it exists (i.e. strip off ".tga")
-			std::size_t basePos = rawMapName.find("base");
+	// If shader not found, fallback to alternative if available
+	// _originalShaderName is empty if the ase material has no BITMAP
+	// canCapture is false if _originalShaderName is not a valid shader
+	if((_originalShaderName.empty() ||
+		!GlobalRenderSystem().canCapture(_originalShaderName)) &&
+		!rawName.empty()) {
+		_originalShaderName = cleanupShaderName(rawName);
+	}
 
-			if (basePos != std::string::npos && basePos > 0)
-			{
-				std::size_t dotPos = rawMapName.find(".");
+	_mappedShaderName = _originalShaderName;
 
-				if (dotPos != std::string::npos)
-				{
-					_originalShaderName = rawMapName.substr(basePos + 5,
-															dotPos - basePos - 5);
-				}
-				else
-				{
-					_originalShaderName = rawMapName.substr(basePos + 5);
-				}
-			}
-			else {
-				// Unrecognised shader path
-				_originalShaderName = "";
-			}
-		}
-    }
+	// Capture the shader
+	_shader = GlobalRenderSystem().capture(_mappedShaderName);
 
-    _mappedShaderName = _originalShaderName; // no skin at this time
-
-    // Capture the shader
-    _shader = GlobalRenderSystem().capture(_originalShaderName);
-
     // Get the number of vertices and indices, and reserve capacity in our
     // vectors in advance by populating them with empty structs.
     int nVerts = PicoGetSurfaceNumVertexes(surf);
@@ -99,6 +87,47 @@
 	createDisplayLists();
 }
 
+std::string RenderablePicoSurface::cleanupShaderName(std::string mapName) {
+	const std::string baseFolder = "base";	//FIXME: should be from game.xml
+	std::size_t basePos;
+
+	boost::algorithm::replace_all(mapName, "\\", "/");
+
+	// for paths given relative, start from the beginning
+	if(mapName.substr(0,6) == "models" || mapName.substr(0,8) == "textures")
+	{
+		basePos = 0;
+	}
+	else
+	{
+		// Take off the everything before "base/", and everything after
+		// the first period if it exists (i.e. strip off ".tga")
+		basePos = mapName.find(baseFolder);
+		if (basePos == std::string::npos || basePos < 0)
+		{
+			// Unrecognised shader path, no base folder.
+			// Try the original incase it was already given relative.
+			basePos = 0;
+		}
+		else
+		{
+			// Increment for for the length of "base/", the / is the +1
+			basePos += (baseFolder.size() + 1);
+		}
+	}
+
+	std::size_t dotPos = mapName.find(".");
+
+	if (dotPos != std::string::npos)
+	{
+		return mapName.substr(basePos, dotPos - basePos);
+	}
+	else
+	{
+		return mapName.substr(basePos);
+	}
+}
+
 // Destructor. Release the GL display lists.
 RenderablePicoSurface::~RenderablePicoSurface()
 {
Index: plugins/model/RenderablePicoSurface.h
===================================================================
--- plugins/model/RenderablePicoSurface.h	(revision 6254)
+++ plugins/model/RenderablePicoSurface.h	(working copy)
@@ -71,6 +71,8 @@
     GLuint compileProgramList(ShaderLayer::VertexColourMode);
 	void createDisplayLists();
 
+	std::string RenderablePicoSurface::cleanupShaderName(std::string mapName);
+
 public:
 	/**
 	 * Constructor. Accepts a picoSurface_t struct and the file extension to determine
Index: radiant/render/OpenGLRenderSystem.cpp
===================================================================
--- radiant/render/OpenGLRenderSystem.cpp	(revision 6254)
+++ radiant/render/OpenGLRenderSystem.cpp	(working copy)
@@ -59,6 +59,12 @@
 	}
 }
 
+/* Test if the this can capture the given shader.
+ */
+bool OpenGLRenderSystem::canCapture(const std::string& name) {
+	return (_shaders.find(name) != _shaders.end());
+}
+
 /* Capture the given shader.
  */
 ShaderPtr OpenGLRenderSystem::capture(const std::string& name) {
Index: radiant/render/OpenGLRenderSystem.h
===================================================================
--- radiant/render/OpenGLRenderSystem.h	(revision 6254)
+++ radiant/render/OpenGLRenderSystem.h	(working copy)
@@ -50,6 +50,7 @@
 
     /* RenderSystem implementation */
 
+	bool canCapture(const std::string& name);
 	ShaderPtr capture(const std::string& name);
 	void render(RenderStateFlags globalstate,
 				const Matrix4& modelview,
asematerial_modified.patch (6,449 bytes)   
Index: include/irender.h
===================================================================
--- include/irender.h	(revision 6258)
+++ include/irender.h	(working copy)
@@ -337,6 +337,19 @@
 
 	/**
      * \brief
+     * Test if the the given shader is able to be captured.
+	 * Return true if the given shader is available.
+	 *
+	 * @param name
+	 * The name of the shader to test capture.
+	 *
+	 * @returns
+	 * bool, true if the shader is available.
+	 */
+	virtual bool canCapture(const std::string& name) = 0;
+
+	/**
+     * \brief
      * Capture the given shader, increasing its reference count and
 	 * returning a pointer to the Shader object.
      *
Index: plugins/model/RenderablePicoSurface.cpp
===================================================================
--- plugins/model/RenderablePicoSurface.cpp	(revision 6258)
+++ plugins/model/RenderablePicoSurface.cpp	(working copy)
@@ -22,47 +22,38 @@
 	// Get the shader from the picomodel struct. If this is a LWO model, use
 	// the material name to select the shader, while for an ASE model the
 	// bitmap path should be used.
-    picoShader_t* shader = PicoGetSurfaceShader(surf);
-    if (shader != 0) {
+	picoShader_t* shader = PicoGetSurfaceShader(surf);
+	std::string rawName = "";
+
+	if (shader != 0)
+	{
 		if (fExt == "lwo")
-        {
-	    	_originalShaderName = PicoGetShaderName(shader);
+		{
+			_originalShaderName = PicoGetShaderName(shader);
 		}
 		else if (fExt == "ase")
-        {
+		{
+			rawName = PicoGetShaderName(shader);
 			std::string rawMapName = PicoGetShaderMapName(shader);
-			boost::algorithm::replace_all(rawMapName, "\\", "/");
+			_originalShaderName = cleanupShaderName(rawMapName);
+		}
+	}
 
-			// Take off the everything before "base/", and everything after
-			// the first period if it exists (i.e. strip off ".tga")
-			std::size_t basePos = rawMapName.find("base");
+	// If shader not found, fallback to alternative if available
+	// _originalShaderName is empty if the ase material has no BITMAP
+	// canCapture is false if _originalShaderName is not a valid shader
+	if((_originalShaderName.empty() ||
+		!GlobalRenderSystem().canCapture(_originalShaderName)) &&
+		!rawName.empty())
+	{
+		_originalShaderName = cleanupShaderName(rawName);
+	}
 
-			if (basePos != std::string::npos && basePos > 0)
-			{
-				std::size_t dotPos = rawMapName.find(".");
+	_mappedShaderName = _originalShaderName;
 
-				if (dotPos != std::string::npos)
-				{
-					_originalShaderName = rawMapName.substr(basePos + 5,
-															dotPos - basePos - 5);
-				}
-				else
-				{
-					_originalShaderName = rawMapName.substr(basePos + 5);
-				}
-			}
-			else {
-				// Unrecognised shader path
-				_originalShaderName = "";
-			}
-		}
-    }
+	// Capture the shader
+	_shader = GlobalRenderSystem().capture(_mappedShaderName);
 
-    _mappedShaderName = _originalShaderName; // no skin at this time
-
-    // Capture the shader
-    _shader = GlobalRenderSystem().capture(_originalShaderName);
-
     // Get the number of vertices and indices, and reserve capacity in our
     // vectors in advance by populating them with empty structs.
     int nVerts = PicoGetSurfaceNumVertexes(surf);
@@ -99,6 +90,48 @@
 	createDisplayLists();
 }
 
+std::string RenderablePicoSurface::cleanupShaderName(std::string mapName)
+{
+	const std::string baseFolder = "base";	//FIXME: should be from game.xml
+	std::size_t basePos;
+
+	boost::algorithm::replace_all(mapName, "\\", "/");
+
+	// for paths given relative, start from the beginning
+	if(mapName.substr(0,6) == "models" || mapName.substr(0,8) == "textures")
+	{
+		basePos = 0;
+	}
+	else
+	{
+		// Take off the everything before "base/", and everything after
+		// the first period if it exists (i.e. strip off ".tga")
+		basePos = mapName.find(baseFolder);
+		if (basePos == std::string::npos)
+		{
+			// Unrecognised shader path, no base folder.
+			// Try the original incase it was already given relative.
+			basePos = 0;
+		}
+		else
+		{
+			// Increment for for the length of "base/", the / is the +1
+			basePos += (baseFolder.size() + 1);
+		}
+	}
+
+	std::size_t dotPos = mapName.find(".");
+
+	if (dotPos != std::string::npos)
+	{
+		return mapName.substr(basePos, dotPos - basePos);
+	}
+	else
+	{
+		return mapName.substr(basePos);
+	}
+}
+
 // Destructor. Release the GL display lists.
 RenderablePicoSurface::~RenderablePicoSurface()
 {
@@ -330,13 +363,13 @@
 
 const ArbitraryMeshVertex& RenderablePicoSurface::getVertex(int vertexIndex) const
 {
-	assert(vertexIndex >= 0 && vertexIndex < _vertices.size());
+	assert(vertexIndex >= 0 && vertexIndex < static_cast<int>(_vertices.size()));
 	return _vertices[vertexIndex];
 }
 
 ModelPolygon RenderablePicoSurface::getPolygon(int polygonIndex) const
 {
-	assert(polygonIndex >= 0 && polygonIndex*3 < _indices.size());
+	assert(polygonIndex >= 0 && polygonIndex*3 < static_cast<int>(_indices.size()));
 
 	ModelPolygon poly;
 
Index: plugins/model/RenderablePicoSurface.h
===================================================================
--- plugins/model/RenderablePicoSurface.h	(revision 6258)
+++ plugins/model/RenderablePicoSurface.h	(working copy)
@@ -71,6 +71,8 @@
     GLuint compileProgramList(ShaderLayer::VertexColourMode);
 	void createDisplayLists();
 
+	std::string cleanupShaderName(std::string mapName);
+
 public:
 	/**
 	 * Constructor. Accepts a picoSurface_t struct and the file extension to determine
Index: radiant/render/OpenGLRenderSystem.cpp
===================================================================
--- radiant/render/OpenGLRenderSystem.cpp	(revision 6258)
+++ radiant/render/OpenGLRenderSystem.cpp	(working copy)
@@ -59,6 +59,12 @@
 	}
 }
 
+/* Test if the this can capture the given shader.
+ */
+bool OpenGLRenderSystem::canCapture(const std::string& name) {
+	return (_shaders.find(name) != _shaders.end());
+}
+
 /* Capture the given shader.
  */
 ShaderPtr OpenGLRenderSystem::capture(const std::string& name) {
Index: radiant/render/OpenGLRenderSystem.h
===================================================================
--- radiant/render/OpenGLRenderSystem.h	(revision 6258)
+++ radiant/render/OpenGLRenderSystem.h	(working copy)
@@ -50,6 +50,7 @@
 
     /* RenderSystem implementation */
 
+	bool canCapture(const std::string& name);
 	ShaderPtr capture(const std::string& name);
 	void render(RenderStateFlags globalstate,
 				const Matrix4& modelview,
asematerial_modified.patch (6,449 bytes)   
darkradiant6258_asematerialname.patch (8,564 bytes)   
Index: include/irender.h
===================================================================
--- include/irender.h	(revision 6258)
+++ include/irender.h	(working copy)
@@ -337,6 +337,19 @@
 
 	/**
      * \brief
+     * Test if the the given shader is able to be captured.
+	 * Return true if the given shader is available.
+	 *
+	 * @param name
+	 * The name of the shader to test capture.
+	 *
+	 * @returns
+	 * bool, true if the shader is available.
+	 */
+	virtual bool canCapture(const std::string& name) = 0;
+
+	/**
+     * \brief
      * Capture the given shader, increasing its reference count and
 	 * returning a pointer to the Shader object.
      *
Index: include/ishaders.h
===================================================================
--- include/ishaders.h	(revision 6258)
+++ include/ishaders.h	(working copy)
@@ -100,6 +100,12 @@
 
     /**
      * \brief
+     * Return true if the editor image is no tex for this shader.
+     */
+    virtual bool isEditorImageNoTex() = 0;
+
+    /**
+     * \brief
      * Get the string name of this shader.
      */
     virtual std::string getName() const = 0;
Index: plugins/model/RenderablePicoSurface.cpp
===================================================================
--- plugins/model/RenderablePicoSurface.cpp	(revision 6258)
+++ plugins/model/RenderablePicoSurface.cpp	(working copy)
@@ -22,47 +22,38 @@
 	// Get the shader from the picomodel struct. If this is a LWO model, use
 	// the material name to select the shader, while for an ASE model the
 	// bitmap path should be used.
-    picoShader_t* shader = PicoGetSurfaceShader(surf);
-    if (shader != 0) {
+	picoShader_t* shader = PicoGetSurfaceShader(surf);
+	std::string rawName = "";
+
+	if (shader != 0)
+	{
 		if (fExt == "lwo")
-        {
-	    	_originalShaderName = PicoGetShaderName(shader);
+		{
+			_originalShaderName = PicoGetShaderName(shader);
 		}
 		else if (fExt == "ase")
-        {
+		{
+			rawName = PicoGetShaderName(shader);
 			std::string rawMapName = PicoGetShaderMapName(shader);
-			boost::algorithm::replace_all(rawMapName, "\\", "/");
+			_originalShaderName = cleanupShaderName(rawMapName);
+		}
+	}
 
-			// Take off the everything before "base/", and everything after
-			// the first period if it exists (i.e. strip off ".tga")
-			std::size_t basePos = rawMapName.find("base");
+	// If shader not found, fallback to alternative if available
+	// _originalShaderName is empty if the ase material has no BITMAP
+	// canCapture is false if _originalShaderName is not a valid shader
+	if((_originalShaderName.empty() ||
+		!GlobalRenderSystem().canCapture(_originalShaderName)) &&
+		!rawName.empty())
+	{
+		_originalShaderName = cleanupShaderName(rawName);
+	}
 
-			if (basePos != std::string::npos && basePos > 0)
-			{
-				std::size_t dotPos = rawMapName.find(".");
+	_mappedShaderName = _originalShaderName;
 
-				if (dotPos != std::string::npos)
-				{
-					_originalShaderName = rawMapName.substr(basePos + 5,
-															dotPos - basePos - 5);
-				}
-				else
-				{
-					_originalShaderName = rawMapName.substr(basePos + 5);
-				}
-			}
-			else {
-				// Unrecognised shader path
-				_originalShaderName = "";
-			}
-		}
-    }
+	// Capture the shader
+	_shader = GlobalRenderSystem().capture(_mappedShaderName);
 
-    _mappedShaderName = _originalShaderName; // no skin at this time
-
-    // Capture the shader
-    _shader = GlobalRenderSystem().capture(_originalShaderName);
-
     // Get the number of vertices and indices, and reserve capacity in our
     // vectors in advance by populating them with empty structs.
     int nVerts = PicoGetSurfaceNumVertexes(surf);
@@ -99,6 +90,48 @@
 	createDisplayLists();
 }
 
+std::string RenderablePicoSurface::cleanupShaderName(std::string mapName)
+{
+	const std::string baseFolder = "base";	//FIXME: should be from game.xml
+	std::size_t basePos;
+
+	boost::algorithm::replace_all(mapName, "\\", "/");
+
+	// for paths given relative, start from the beginning
+	if(mapName.substr(0,6) == "models" || mapName.substr(0,8) == "textures")
+	{
+		basePos = 0;
+	}
+	else
+	{
+		// Take off the everything before "base/", and everything after
+		// the first period if it exists (i.e. strip off ".tga")
+		basePos = mapName.find(baseFolder);
+		if (basePos == std::string::npos)
+		{
+			// Unrecognised shader path, no base folder.
+			// Try the original incase it was already given relative.
+			basePos = 0;
+		}
+		else
+		{
+			// Increment for for the length of "base/", the / is the +1
+			basePos += (baseFolder.size() + 1);
+		}
+	}
+
+	std::size_t dotPos = mapName.find(".");
+
+	if (dotPos != std::string::npos)
+	{
+		return mapName.substr(basePos, dotPos - basePos);
+	}
+	else
+	{
+		return mapName.substr(basePos);
+	}
+}
+
 // Destructor. Release the GL display lists.
 RenderablePicoSurface::~RenderablePicoSurface()
 {
@@ -330,13 +363,13 @@
 
 const ArbitraryMeshVertex& RenderablePicoSurface::getVertex(int vertexIndex) const
 {
-	assert(vertexIndex >= 0 && vertexIndex < _vertices.size());
+	assert(vertexIndex >= 0 && vertexIndex < static_cast<int>(_vertices.size()));
 	return _vertices[vertexIndex];
 }
 
 ModelPolygon RenderablePicoSurface::getPolygon(int polygonIndex) const
 {
-	assert(polygonIndex >= 0 && polygonIndex*3 < _indices.size());
+	assert(polygonIndex >= 0 && polygonIndex*3 < static_cast<int>(_indices.size()));
 
 	ModelPolygon poly;
 
Index: plugins/model/RenderablePicoSurface.h
===================================================================
--- plugins/model/RenderablePicoSurface.h	(revision 6258)
+++ plugins/model/RenderablePicoSurface.h	(working copy)
@@ -71,6 +71,8 @@
     GLuint compileProgramList(ShaderLayer::VertexColourMode);
 	void createDisplayLists();
 
+	std::string cleanupShaderName(std::string mapName);
+
 public:
 	/**
 	 * Constructor. Accepts a picoSurface_t struct and the file extension to determine
Index: plugins/shaders/CShader.cpp
===================================================================
--- plugins/shaders/CShader.cpp	(revision 6258)
+++ plugins/shaders/CShader.cpp	(working copy)
@@ -60,6 +60,11 @@
     return _editorTexture;
 }
 
+bool CShader::isEditorImageNoTex()
+{
+	return (getEditorImage() == GetTextureManager().getShaderNotFound());
+}
+
 // Return the falloff texture name
 std::string CShader::getFalloffName() const {
 	return _template->getLightFalloff()->getIdentifier();
Index: plugins/shaders/CShader.h
===================================================================
--- plugins/shaders/CShader.h	(revision 6258)
+++ plugins/shaders/CShader.h	(working copy)
@@ -48,6 +48,7 @@
     SortRequest getSortRequest() const;
     float getPolygonOffset() const;
 	TexturePtr getEditorImage();
+	bool isEditorImageNoTex();
 
 	// Return the light falloff texture (Z dimension).
 	TexturePtr lightFalloffImage();
Index: radiant/render/OpenGLRenderSystem.cpp
===================================================================
--- radiant/render/OpenGLRenderSystem.cpp	(revision 6258)
+++ radiant/render/OpenGLRenderSystem.cpp	(working copy)
@@ -59,6 +59,39 @@
 	}
 }
 
+/* Test if the this can capture the given shader.
+ */
+bool OpenGLRenderSystem::canCapture(const std::string& name) {
+	ShaderMap::const_iterator i = _shaders.find(name);
+	MaterialPtr mtr;
+
+	if(i != _shaders.end()) {
+		// Try to lock pointer, which will fail if the object has been
+		// deleted
+		OpenGLShaderPtr sp = i->second.lock();
+		if (sp) {
+			mtr = sp->getMaterial();
+		} else {
+			return false;
+		}
+	} else {
+		// Either the shader was not found, or the weak pointer failed to lock
+		// because the shader had been deleted. Either way, create a new shader
+		// and insert into the cache.
+		OpenGLShaderPtr shd(new OpenGLShader(*this));
+		_shaders[name] = shd;
+
+		// Realise the shader if the cache is realised
+		if (_realised) {
+			shd->realise(name);
+		}
+		mtr = shd->getMaterial();
+	}
+
+	// True if the editor image is not no tex
+	return (!mtr->isEditorImageNoTex());
+}
+
 /* Capture the given shader.
  */
 ShaderPtr OpenGLRenderSystem::capture(const std::string& name) {
Index: radiant/render/OpenGLRenderSystem.h
===================================================================
--- radiant/render/OpenGLRenderSystem.h	(revision 6258)
+++ radiant/render/OpenGLRenderSystem.h	(working copy)
@@ -50,6 +50,7 @@
 
     /* RenderSystem implementation */
 
+	bool canCapture(const std::string& name);
 	ShaderPtr capture(const std::string& name);
 	void render(RenderStateFlags globalstate,
 				const Matrix4& modelview,

Relationships

related to 0002658 closedgreebo Model shaders are showing as "Shader Not Found" on a regular basis 
related to 0004644 closedgreebo Use of BITMAP field in ASE differs from TDM 

Activities

greebo

greebo

11.01.2011 13:58

administrator   ~0003434

I can't confirm that the patch is still favouring the *BITMAP lines over *MATERIAL_NAME. I have an ASE model here with this block:

*MATERIAL 1 {
        *MATERIAL_NAME "aphrodite_diffusemap."
        *MATERIAL_CLASS "Standard"
        *MATERIAL_AMBIENT 0.0000 0.0000 0.0000
        *MATERIAL_DIFFUSE 0.5882 0.5882 0.5882
        *MATERIAL_SPECULAR 0.9000 0.9000 0.9000
        *MATERIAL_SHINE 0.1000
        *MATERIAL_SHINESTRENGTH 0.0000
        *MATERIAL_TRANSPARENCY 0.0000
        *MATERIAL_WIRESIZE 1.0000
        *MATERIAL_SHADING Blinn
        *MATERIAL_XP_FALLOFF 0.0000
        *MATERIAL_SELFILLUM 0.0000
        *MATERIAL_FALLOFF In
        *MATERIAL_XP_TYPE Filter
        *MAP_DIFFUSE {
            *MAP_NAME "aphrodite_diffusemap."
            *MAP_CLASS "Bitmap"
            *MAP_SUBNO 1
            *MAP_AMOUNT 1.0000
            *BITMAP "//base/tdm_statue_aphrodite"
            *MAP_TYPE Screen
            *UVW_U_OFFSET 0.0000

Yet the statue appears to carry the wrong shader "aphrodite_diffusemap" instead of "tdm_statue_aphrodite" in the model preview.
greebo

greebo

11.01.2011 14:00

administrator   ~0003435

As I've altered a few lines of your code changes, I'm attaching the current patch as "asematerial_modified.patch".
dersaidin

dersaidin

12.01.2011 03:36

reporter   ~0003440

Ah sorry.

The error was in canCapture(), if the shader being tested isn't already loaded (ie on renderer::OpenGLRenderSystem::_shaders) it won't try to load.
If you make a brush with the tdm_statue_aphrodite material, so its loaded, then reload the model it would work as expected.

Fix in progress.
dersaidin

dersaidin

13.01.2011 04:23

reporter   ~0003445

Updated patch.

It now checks the BITMAP value, if the editorTexture is No Tex it will fallback and try the MATERIAL_NAME.

One note, this is testing if the editorImage exists - not if the material exists.
If BITMAP exists as a valid material, but doesn't have a valid editor image, then it will fallback.
greebo

greebo

13.01.2011 06:06

administrator   ~0003446

Looks good now, thanks.
Serpentine

Serpentine

09.02.2011 21:15

updater   ~0003580

This change is quite broken.

It will result in default materials being assigned rather than the *BITMAP should two different models have *MATERIAL_NAME's that are matching. This only happens once the models are added to the map.

Once it occurs the model has the value of *MATERIAL_NAME rather than *BITMAP.

This option should also be per-game or at the very least as a non-default option rather than universal as it can result in unexpected results in the majority of current usecases.
dersaidin

dersaidin

11.02.2011 14:38

reporter   ~0003582

I wasn't able to reproduce your issue.

Could you please show me the models and shaders involved?
Serpentine

Serpentine

11.02.2011 15:38

updater   ~0003583

Last edited: 11.02.2011 15:41

If you have TDM available :
- Open DR
- Add model
- Expand the darkmod tree
- Search "fern" -> the material will show up as "default"
- Browse surrounding models and most of them will suffer from the same thing.

I'm a bit 'meh' about packaging all the models, materials, textures etc.

But even as it stands, there could be situations where this will break. I also think that editortexture may not refer to materials which don't specify an editorimage explicitly, but I cant say I look at DR internals much. This may very well be what causes the falling back to MATERIAL_NAME if it is the case.

Edit : Just checked re: material def editor image, it doesnt make a difference, scratch that idea.

Serpentine

Serpentine

17.02.2011 00:25

updater   ~0003596

Yeah I realised the ASE wasn't an ideal candidate after posting that... and then forgot to change it! buuut anyway.

I still get a lot of models reverting to material name randomly, even if they have perfectly valid editor images. For me, it triggers after randomly adding some of those plant models around fern, suddenly textures which were working perfectly will start using material names etc.
greebo

greebo

17.02.2011 06:45

administrator   ~0003597

Any steps to reproduce? Otherwise I'm hardly able to debug that problem.
Serpentine

Serpentine

21.02.2011 13:47

updater   ~0003623

It's a bit tricky to explain, I usually just open the model browser from a fresh launch, expand the darkmod folder with (shift+right arrow), type in something like "door" and press down arrow to scroll through the results. Soon after it starts going it'll start to replace a few materials with default. If I then close the browser and reopen it, many more of the materials on models that I've scrolled past will now also have been defaulted.

For example here's me scrolling for a second or two until I notice quite a few defaults:
http://syr.taaaki.za.net/tdm/bugs/asematerialbug.png
Now I close and reopen the model viewer:
http://syr.taaaki.za.net/tdm/bugs/asematerialbug2.png

Notice the material names list. grayman also reported the issue on the forums a while back.
greebo

greebo

26.02.2011 07:29

administrator   ~0003668

I can confirm the issues. Steps to reproduce are really simple, just add the models/darkmod/containers/openable/footlocker_wood.ase model to the map. It's showing fine in the ModelPreview, but as soon as it's added to the map its shaders are "not found".
greebo

greebo

26.02.2011 07:34

administrator   ~0003670

Set this to resolved again, the regression is tracked in item 0002658.

Issue History

Date Modified Username Field Change
24.12.2010 09:38 dersaidin New Issue
24.12.2010 09:38 dersaidin File Added: darkradiant6254_asematerialname.patch
11.01.2011 04:37 greebo Priority high => normal
11.01.2011 04:37 greebo Status new => acknowledged
11.01.2011 13:32 greebo Assigned To => greebo
11.01.2011 13:32 greebo Status acknowledged => assigned
11.01.2011 13:57 greebo Assigned To greebo =>
11.01.2011 13:57 greebo Status assigned => feedback
11.01.2011 13:58 greebo Note Added: 0003434
11.01.2011 14:00 greebo File Added: asematerial_modified.patch
11.01.2011 14:00 greebo Note Added: 0003435
12.01.2011 03:36 dersaidin Note Added: 0003440
12.01.2011 03:36 dersaidin Status feedback => new
13.01.2011 04:21 dersaidin File Added: darkradiant6258_asematerialname.patch
13.01.2011 04:23 dersaidin Note Added: 0003445
13.01.2011 06:04 greebo Assigned To => greebo
13.01.2011 06:04 greebo Status new => assigned
13.01.2011 06:06 greebo Note Added: 0003446
13.01.2011 06:06 greebo Status assigned => resolved
13.01.2011 06:06 greebo Fixed in Version => 1.5.0
13.01.2011 06:06 greebo Resolution open => fixed
13.01.2011 06:06 greebo Product Version => 1.5.0
13.01.2011 06:06 greebo Target Version => 1.5.0
09.02.2011 21:15 Serpentine Note Added: 0003580
09.02.2011 21:22 greebo Assigned To greebo =>
09.02.2011 21:22 greebo Status resolved => assigned
09.02.2011 21:22 greebo Resolution fixed => reopened
09.02.2011 21:22 greebo Status assigned => acknowledged
11.02.2011 14:38 dersaidin Note Added: 0003582
11.02.2011 15:38 Serpentine Note Added: 0003583
11.02.2011 15:41 Serpentine Note Edited: 0003583
17.02.2011 00:25 Serpentine Note Added: 0003596
17.02.2011 06:45 greebo Note Added: 0003597
21.02.2011 13:47 Serpentine Note Added: 0003623
26.02.2011 07:29 greebo Note Added: 0003668
26.02.2011 07:29 greebo Status acknowledged => confirmed
26.02.2011 07:32 greebo Relationship added related to 0002658
26.02.2011 07:34 greebo Note Added: 0003670
26.02.2011 07:34 greebo Status confirmed => resolved
26.02.2011 07:34 greebo Resolution reopened => fixed
26.02.2011 07:34 greebo Assigned To => greebo
24.09.2011 08:20 greebo Status resolved => closed
07.02.2012 13:19 hypov8 Tag Attached: detail
07.02.2012 13:20 hypov8 Tag Detached: detail
05.02.2021 16:46 greebo Relationship added related to 0004644