mirror of
https://github.com/godotengine/godot.git
synced 2025-10-29 04:34:39 +00:00
2D Shaders are working again using the new syntax, though all is buggy in general
This commit is contained in:
parent
850eaf7ed7
commit
1527cf8c0d
26 changed files with 1980 additions and 173 deletions
|
|
@ -712,6 +712,8 @@ bool ShaderLanguage::is_token_nonvoid_datatype(TokenType p_type) {
|
|||
|
||||
void ShaderLanguage::clear() {
|
||||
|
||||
current_function=StringName();
|
||||
|
||||
completion_type=COMPLETION_NONE;
|
||||
completion_block=NULL;
|
||||
completion_function=StringName();
|
||||
|
|
@ -2096,6 +2098,12 @@ bool ShaderLanguage::is_scalar_type(DataType p_type) {
|
|||
return p_type==TYPE_BOOL || p_type==TYPE_INT || p_type==TYPE_UINT || p_type==TYPE_FLOAT;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
|
||||
|
||||
Set<String> kws;
|
||||
|
|
@ -2122,6 +2130,27 @@ void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
|
|||
}
|
||||
}
|
||||
|
||||
void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) {
|
||||
|
||||
|
||||
Set<String> kws;
|
||||
|
||||
int idx=0;
|
||||
|
||||
while (builtin_func_defs[idx].name) {
|
||||
|
||||
kws.insert(builtin_func_defs[idx].name);
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
for(Set<String>::Element *E=kws.front();E;E=E->next()) {
|
||||
r_keywords->push_back(E->get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ShaderLanguage::DataType ShaderLanguage::get_scalar_type(DataType p_type) {
|
||||
|
||||
static const DataType scalar_types[]={
|
||||
|
|
@ -2342,6 +2371,12 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
|
|||
|
||||
bool ok =_parse_function_arguments(p_block,p_builtin_types,func,&carg);
|
||||
|
||||
for(int i=0;i<shader->functions.size();i++) {
|
||||
if (shader->functions[i].name==name) {
|
||||
shader->functions[i].uses_function.insert(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (carg>=0) {
|
||||
|
|
@ -3140,6 +3175,9 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
|
|||
|
||||
Token tk = _get_token();
|
||||
|
||||
int texture_uniforms = 0;
|
||||
int uniforms =0;
|
||||
|
||||
while(tk.type!=TK_EOF) {
|
||||
|
||||
switch(tk.type) {
|
||||
|
|
@ -3160,12 +3198,12 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
|
|||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
if (shader->render_modes.has(tk.text)) {
|
||||
if (shader->render_modes.find(tk.text)!=-1) {
|
||||
_set_error("Duplicate render mode: '"+String(tk.text)+"'");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
shader->render_modes.insert(tk.text);
|
||||
shader->render_modes.push_back(tk.text);
|
||||
|
||||
tk = _get_token();
|
||||
if (tk.type==TK_COMMA) {
|
||||
|
|
@ -3225,6 +3263,13 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
|
|||
|
||||
ShaderNode::Uniform uniform;
|
||||
uniform.order=shader->uniforms.size();
|
||||
if (is_sampler_type(type)) {
|
||||
uniform.texture_order=texture_uniforms++;
|
||||
uniform.order=-1;
|
||||
} else {
|
||||
uniform.texture_order=-1;
|
||||
uniform.order=uniforms++;
|
||||
}
|
||||
uniform.type=type;
|
||||
uniform.precission=precision;
|
||||
|
||||
|
|
@ -3520,9 +3565,13 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
|
|||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
current_function = name;
|
||||
|
||||
Error err = _parse_block(func_node->body,builtin_types);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
current_function=StringName();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue