C# Class GPUGraph.Graph

Inheritance: ISerializable
ファイルを表示 Open project: heyx3/GPUNoiseForUnity Class Usage Examples

Public Properties

Property Type Description
FilePath string
Hash1 string
NextUID int
Output NodeInput
OutputPos UnityEngine.Rect

Public Methods

Method Description
AddNode ( Node n, bool generateNewUID = true ) : void
Clone ( int idOffset ) : Graph
GenerateShader ( string shaderName, Action addToProperties, Action addToDefs, StringBuilder>.Action returnFragmentColor ) : string

Generates a shader with customized output.

GenerateShader ( string shaderName, string colorRampParamName ) : string

Generates a shader that outputs a color based on the graph's noise and a color ramp texture.

GenerateShader ( string shaderName, string outputs, float defaultVal ) : string

Generates a shader that outputs this graph's noise in the given channels.

GetNode ( int uid ) : Node

Returns "null" if the given Node uid doesn't exist in this graph.

GetObjectData ( SerializationInfo info, StreamingContext context ) : void
Graph ( ) : System
Graph ( SerializationInfo info, StreamingContext context ) : System
Graph ( string file, bool isGUID = false ) : System

Creates a graph for the given file path/GUID.

InsertShaderCode ( StringBuilder shaderProperties, StringBuilder shaderCGDefines, StringBuilder shaderBody, int idOffset, bool isFirstGraph ) : string

Inserts code for this graph into the given strings, and outputs an expression that evaluates to the output of this graph.

IsValidUID ( int uid ) : bool
Load ( ) : string

Re-loads this graph from its file-path, effectively wiping out any changes to it. Returns an error message, or an empty string if nothing went wrong.

PreProcess ( ) : void

Simplifies this graph by running its nodes through the pre-processing stage. The whole graph will be reduced to its final form (i.e. no "weird" nodes like SubGraphNode).

RemoveNode ( Node n ) : void
Save ( ) : string

Saves this graph to its file-path. Returns an error message, or an empty string if nothing went wrong.

Private Methods

Method Description
FinalizeDeserialization ( StreamingContext context ) : void
InsertShad ( StringBuilder properties, StringBuilder cgProperties, StringBuilder body, bool addDefines ) : string

Method Details

AddNode() public method

public AddNode ( Node n, bool generateNewUID = true ) : void
n Node
generateNewUID bool
return void

Clone() public method

public Clone ( int idOffset ) : Graph
idOffset int
return Graph

GenerateShader() public method

Generates a shader with customized output.
public GenerateShader ( string shaderName, Action addToProperties, Action addToDefs, StringBuilder>.Action returnFragmentColor ) : string
shaderName string The shader's name in the file.
addToProperties Action Adds any Unity Shaderlab Properties to the given string.
addToDefs Action Adds any Cg declarations to the given string.
returnFragmentColor StringBuilder>.Action /// Outupts shader instructions that return a float4 color /// given the variable holding the graph's noise output. ///
return string

GenerateShader() public method

Generates a shader that outputs a color based on the graph's noise and a color ramp texture.
public GenerateShader ( string shaderName, string colorRampParamName ) : string
shaderName string The shader's name in the file.
colorRampParamName string
return string

GenerateShader() public method

Generates a shader that outputs this graph's noise in the given channels.
public GenerateShader ( string shaderName, string outputs, float defaultVal ) : string
shaderName string The shader's name in the file.
outputs string The channels to output this graph's noise into.
defaultVal float /// The value held by channels that didn't receive this graph's noise. ///
return string

GetNode() public method

Returns "null" if the given Node uid doesn't exist in this graph.
public GetNode ( int uid ) : Node
uid int
return Node

GetObjectData() public method

public GetObjectData ( SerializationInfo info, StreamingContext context ) : void
info System.Runtime.Serialization.SerializationInfo
context System.Runtime.Serialization.StreamingContext
return void

Graph() public method

public Graph ( ) : System
return System

Graph() public method

public Graph ( SerializationInfo info, StreamingContext context ) : System
info System.Runtime.Serialization.SerializationInfo
context System.Runtime.Serialization.StreamingContext
return System

Graph() public method

Creates a graph for the given file path/GUID.
public Graph ( string file, bool isGUID = false ) : System
file string
isGUID bool
return System

InsertShaderCode() public method

Inserts code for this graph into the given strings, and outputs an expression that evaluates to the output of this graph.
public InsertShaderCode ( StringBuilder shaderProperties, StringBuilder shaderCGDefines, StringBuilder shaderBody, int idOffset, bool isFirstGraph ) : string
shaderProperties StringBuilder
shaderCGDefines StringBuilder
shaderBody StringBuilder
idOffset int /// Offsets the ids of the nodes in this graph /// so that they do not conflict with the ID's of any other nodes in other graphs used by this shader. /// This offset should be larger than any ID of a node in any other graph. ///
isFirstGraph bool /// Indicates whether this is the first time that /// generated code from a Graph is being inserted into this shader. /// If true, certain function definitions will be included into the shader code. ///
return string

IsValidUID() public static method

public static IsValidUID ( int uid ) : bool
uid int
return bool

Load() public method

Re-loads this graph from its file-path, effectively wiping out any changes to it. Returns an error message, or an empty string if nothing went wrong.
public Load ( ) : string
return string

PreProcess() public method

Simplifies this graph by running its nodes through the pre-processing stage. The whole graph will be reduced to its final form (i.e. no "weird" nodes like SubGraphNode).
public PreProcess ( ) : void
return void

RemoveNode() public method

public RemoveNode ( Node n ) : void
n Node
return void

Save() public method

Saves this graph to its file-path. Returns an error message, or an empty string if nothing went wrong.
public Save ( ) : string
return string

Property Details

FilePath public_oe property

The filepath that this graph saves to/is read from.
public string FilePath
return string

Hash1 public_oe property

The 1D, 2D, and 3D hash functions this graph is using.
public string Hash1
return string

NextUID public_oe property

The next node added to this graph will be given this ID.
public int NextUID
return int

Output public_oe property

The output of this graph.
public NodeInput,GPUGraph Output
return NodeInput

OutputPos public_oe property

The position of the "Output" node in the editor.
public Rect,UnityEngine OutputPos
return UnityEngine.Rect