1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 -class slum:
26 '''This is the base shader class. (not used directly to develop shaders)
27 This class have all the support methods that that a template needs.
28 Also have all the client support methods.
29
30 renderer code is define as a method, as in the following example:
31
32 def delight(self, parameters):
33 return ('','')
34
35 The method must have the name of one of the renderers defined in
36 the _renderers method.
37
38 The method will be called by the clients, which will pass
39 the "parameters" attribute to it.
40
41 The parameters attribute is a dictionary that contains all the
42 parameters returned by the parameters method, but already evaluated
43 by the client. This way the method can evaluate the parameters input
44 from the user to build up the shader parameters and code.
45
46 The method should return a tupple, where [0] is the shader
47 parameters and [1] is the shader code.
48 '''
49
50 @staticmethod
52 ''' slum shader template ID. This method MUST be overriden when developing a shader template. Every shader must have an unique ID. '''
53 return None
55 ''' return parameters to be exposed in the client. This method MUST be overriden when developing a shader template. '''
56 pass
58 ''' return string with MPX icon. This can be overriden in the template to define a custom icon. '''
59 return ''
61 ''' slum shader type. This method is overriden by other classes to define the slum class type '''
62 return None
64 ''' placeholder. No use for this method yet '''
65 pass
67 ''' placeholder. Clients will override this at runtime to allow template to refresh client UI '''
68 pass
70 ''' upload template to online repository. It will be called by the client when the user wants to submit a template to the online repository.'''
71 pass
72
73
74
75
77 ''' Returns supported renderers. This is used by clients so they can add support on UI for then.
78 Basically, the names here reflect the same names of the methods for each renderer.
79 so, if you add a new renderer, you must make sure to add the method with the same name for it.
80 also, the support for this new renderer need to be added in the clients.'''
81 return [
82 'delight',
83 'renderman',
84 'air',
85 'cgfx',
86 'glsl',
87 ]
89 def recursivePopulateDict( parameter ):
90 temp = {}
91 if parameter.__class__.__name__ == 'group':
92 for each in parameter.value:
93 temp.update( recursivePopulateDict( each ) )
94 elif parameter.__class__.__name__ == 'parameter':
95 if value:
96 temp[parameter.name] = parameter.value
97 else:
98 temp[parameter.name] = parameter
99 return temp
100
101 return recursivePopulateDict( self.parameters() )
102
106 ''' this class is used in a slum template when defining surface shaders.
107 this class is basically a normal slum class, with the override of the type method.
108 This classes are being defined here to make a slum template easier to read, with just the
109 methods that are really needed on it.'''
110 @staticmethod
113
115 ''' this class is used in a slum template when defining volume shaders '''
116 @staticmethod
119
121 ''' this class is used in a slum template when defining displacement shaders '''
122 @staticmethod
124 return 'displacement'
125
127 ''' this class is used in a slum template when defining light shaders '''
128 @staticmethod
131
133 ''' this class is used in a slum template when defining color utility shaders '''
134 @staticmethod
137
139 ''' this class is used in a slum template when defining float utility shaders '''
140 @staticmethod
143