mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 13:41:03 +00:00 
			
		
		
		
	add 3D textures
This commit is contained in:
		
							parent
							
								
									5a5614e8ad
								
							
						
					
					
						commit
						b4d3f541e7
					
				
					 23 changed files with 817 additions and 144 deletions
				
			
		|  | @ -123,6 +123,12 @@ const char *ShaderLanguage::token_names[TK_MAX] = { | |||
| 	"TYPE_SAMPLER2D", | ||||
| 	"TYPE_ISAMPLER2D", | ||||
| 	"TYPE_USAMPLER2D", | ||||
| 	"TYPE_SAMPLER2DARRAY", | ||||
| 	"TYPE_ISAMPLER2DARRAY", | ||||
| 	"TYPE_USAMPLER2DARRAY", | ||||
| 	"TYPE_SAMPLER3D", | ||||
| 	"TYPE_ISAMPLER3D", | ||||
| 	"TYPE_USAMPLER3D", | ||||
| 	"TYPE_SAMPLERCUBE", | ||||
| 	"INTERPOLATION_FLAT", | ||||
| 	"INTERPOLATION_NO_PERSPECTIVE", | ||||
|  | @ -257,6 +263,12 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = { | |||
| 	{ TK_TYPE_SAMPLER2D, "sampler2D" }, | ||||
| 	{ TK_TYPE_ISAMPLER2D, "isampler2D" }, | ||||
| 	{ TK_TYPE_USAMPLER2D, "usampler2D" }, | ||||
| 	{ TK_TYPE_SAMPLER2DARRAY, "sampler2DArray" }, | ||||
| 	{ TK_TYPE_ISAMPLER2DARRAY, "isampler2DArray" }, | ||||
| 	{ TK_TYPE_USAMPLER2DARRAY, "usampler2DArray" }, | ||||
| 	{ TK_TYPE_SAMPLER3D, "sampler3D" }, | ||||
| 	{ TK_TYPE_ISAMPLER3D, "isampler3D" }, | ||||
| 	{ TK_TYPE_USAMPLER3D, "usampler3D" }, | ||||
| 	{ TK_TYPE_SAMPLERCUBE, "samplerCube" }, | ||||
| 	{ TK_INTERPOLATION_FLAT, "flat" }, | ||||
| 	{ TK_INTERPOLATION_NO_PERSPECTIVE, "noperspective" }, | ||||
|  | @ -660,6 +672,12 @@ bool ShaderLanguage::is_token_datatype(TokenType p_type) { | |||
| 			p_type == TK_TYPE_SAMPLER2D || | ||||
| 			p_type == TK_TYPE_ISAMPLER2D || | ||||
| 			p_type == TK_TYPE_USAMPLER2D || | ||||
| 			p_type == TK_TYPE_SAMPLER2DARRAY || | ||||
| 			p_type == TK_TYPE_ISAMPLER2DARRAY || | ||||
| 			p_type == TK_TYPE_USAMPLER2DARRAY || | ||||
| 			p_type == TK_TYPE_SAMPLER3D || | ||||
| 			p_type == TK_TYPE_ISAMPLER3D || | ||||
| 			p_type == TK_TYPE_USAMPLER3D || | ||||
| 			p_type == TK_TYPE_SAMPLERCUBE); | ||||
| } | ||||
| 
 | ||||
|  | @ -731,6 +749,12 @@ String ShaderLanguage::get_datatype_name(DataType p_type) { | |||
| 		case TYPE_SAMPLER2D: return "sampler2D"; | ||||
| 		case TYPE_ISAMPLER2D: return "isampler2D"; | ||||
| 		case TYPE_USAMPLER2D: return "usampler2D"; | ||||
| 		case TYPE_SAMPLER2DARRAY: return "sampler2DArray"; | ||||
| 		case TYPE_ISAMPLER2DARRAY: return "isampler2DArray"; | ||||
| 		case TYPE_USAMPLER2DARRAY: return "usampler2DArray"; | ||||
| 		case TYPE_SAMPLER3D: return "sampler3D"; | ||||
| 		case TYPE_ISAMPLER3D: return "isampler3D"; | ||||
| 		case TYPE_USAMPLER3D: return "usampler3D"; | ||||
| 		case TYPE_SAMPLERCUBE: return "samplerCube"; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -1802,6 +1826,12 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { | |||
| 	{ "textureSize", TYPE_IVEC2, { TYPE_SAMPLER2D, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC2, { TYPE_ISAMPLER2D, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC2, { TYPE_USAMPLER2D, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC3, { TYPE_SAMPLER2DARRAY, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC3, { TYPE_ISAMPLER2DARRAY, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC3, { TYPE_USAMPLER2DARRAY, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC3, { TYPE_SAMPLER3D, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC3, { TYPE_ISAMPLER3D, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC3, { TYPE_USAMPLER3D, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "textureSize", TYPE_IVEC2, { TYPE_SAMPLERCUBE, TYPE_INT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texture", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC2, TYPE_VOID } }, | ||||
|  | @ -1813,6 +1843,24 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { | |||
| 	{ "texture", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC2, TYPE_VOID } }, | ||||
| 	{ "texture", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texture", TYPE_VEC4, { TYPE_SAMPLER2DARRAY, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "texture", TYPE_VEC4, { TYPE_SAMPLER2DARRAY, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texture", TYPE_UVEC4, { TYPE_USAMPLER2DARRAY, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "texture", TYPE_UVEC4, { TYPE_USAMPLER2DARRAY, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texture", TYPE_IVEC4, { TYPE_ISAMPLER2DARRAY, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "texture", TYPE_IVEC4, { TYPE_ISAMPLER2DARRAY, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texture", TYPE_VEC4, { TYPE_SAMPLER3D, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "texture", TYPE_VEC4, { TYPE_SAMPLER3D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texture", TYPE_UVEC4, { TYPE_USAMPLER3D, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "texture", TYPE_UVEC4, { TYPE_USAMPLER3D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texture", TYPE_IVEC4, { TYPE_ISAMPLER3D, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "texture", TYPE_IVEC4, { TYPE_ISAMPLER3D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texture", TYPE_VEC4, { TYPE_SAMPLERCUBE, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "texture", TYPE_VEC4, { TYPE_SAMPLERCUBE, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
|  | @ -1831,15 +1879,38 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { | |||
| 	{ "textureProj", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureProj", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "textureProj", TYPE_VEC4, { TYPE_SAMPLER3D, TYPE_VEC4, TYPE_VOID } }, | ||||
| 	{ "textureProj", TYPE_VEC4, { TYPE_SAMPLER3D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "textureProj", TYPE_IVEC4, { TYPE_ISAMPLER3D, TYPE_VEC4, TYPE_VOID } }, | ||||
| 	{ "textureProj", TYPE_IVEC4, { TYPE_ISAMPLER3D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "textureProj", TYPE_UVEC4, { TYPE_USAMPLER3D, TYPE_VEC4, TYPE_VOID } }, | ||||
| 	{ "textureProj", TYPE_UVEC4, { TYPE_USAMPLER3D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "textureLod", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_VEC4, { TYPE_SAMPLER2DARRAY, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_IVEC4, { TYPE_ISAMPLER2DARRAY, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_UVEC4, { TYPE_USAMPLER2DARRAY, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_VEC4, { TYPE_SAMPLER3D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_IVEC4, { TYPE_ISAMPLER3D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_UVEC4, { TYPE_USAMPLER3D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureLod", TYPE_VEC4, { TYPE_SAMPLERCUBE, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texelFetch", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_IVEC2, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "texelFetch", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_IVEC2, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "texelFetch", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_IVEC2, TYPE_INT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texelFetch", TYPE_VEC4, { TYPE_SAMPLER2DARRAY, TYPE_IVEC3, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "texelFetch", TYPE_IVEC4, { TYPE_ISAMPLER2DARRAY, TYPE_IVEC3, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "texelFetch", TYPE_UVEC4, { TYPE_USAMPLER2DARRAY, TYPE_IVEC3, TYPE_INT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "texelFetch", TYPE_VEC4, { TYPE_SAMPLER3D, TYPE_IVEC3, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "texelFetch", TYPE_IVEC4, { TYPE_ISAMPLER3D, TYPE_IVEC3, TYPE_INT, TYPE_VOID } }, | ||||
| 	{ "texelFetch", TYPE_UVEC4, { TYPE_USAMPLER3D, TYPE_IVEC3, TYPE_INT, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "textureProjLod", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 	{ "textureProjLod", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } }, | ||||
| 
 | ||||
|  | @ -1852,6 +1923,12 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { | |||
| 	{ "textureGrad", TYPE_VEC4, { TYPE_SAMPLER2D, TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_IVEC4, { TYPE_ISAMPLER2D, TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_UVEC4, { TYPE_USAMPLER2D, TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_VEC4, { TYPE_SAMPLER2DARRAY, TYPE_VEC3, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_IVEC4, { TYPE_ISAMPLER2DARRAY, TYPE_VEC3, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_UVEC4, { TYPE_USAMPLER2DARRAY, TYPE_VEC3, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_VEC4, { TYPE_SAMPLER3D, TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_IVEC4, { TYPE_ISAMPLER3D, TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_UVEC4, { TYPE_USAMPLER3D, TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, | ||||
| 	{ "textureGrad", TYPE_VEC4, { TYPE_SAMPLERCUBE, TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, | ||||
| 
 | ||||
| 	{ "dFdx", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } }, | ||||
|  | @ -2139,7 +2216,16 @@ bool ShaderLanguage::is_scalar_type(DataType p_type) { | |||
| 
 | ||||
| bool ShaderLanguage::is_sampler_type(DataType p_type) { | ||||
| 
 | ||||
| 	return p_type == TYPE_SAMPLER2D || p_type == TYPE_ISAMPLER2D || p_type == TYPE_USAMPLER2D || p_type == TYPE_SAMPLERCUBE; | ||||
| 	return p_type == TYPE_SAMPLER2D || | ||||
| 		   p_type == TYPE_ISAMPLER2D || | ||||
| 		   p_type == TYPE_USAMPLER2D || | ||||
| 		   p_type == TYPE_SAMPLER2DARRAY || | ||||
| 		   p_type == TYPE_ISAMPLER2DARRAY || | ||||
| 		   p_type == TYPE_USAMPLER2DARRAY || | ||||
| 		   p_type == TYPE_SAMPLER3D || | ||||
| 		   p_type == TYPE_ISAMPLER3D || | ||||
| 		   p_type == TYPE_USAMPLER3D || | ||||
| 		   p_type == TYPE_SAMPLERCUBE; | ||||
| } | ||||
| 
 | ||||
| void ShaderLanguage::get_keyword_list(List<String> *r_keywords) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thomas Herzog
						Thomas Herzog