Static variables

@:value("foxlite/basic")staticfinalinlineread onlyBASIC:String = "foxlite/basic"

@:value("foxlite/minimal")staticfinalinlineread onlyMINIMAL:String = "foxlite/minimal"

@:value("foxlite/sky_panorama")staticfinalinlineread onlySKY:String = "foxlite/sky_panorama"

@:value("#pragma foxflags")staticfinalinlineread onlyPRAGMA_FOXFLAGS:String = "#pragma foxflags"

@:value("#pragma shadow_program_check")staticfinalinlineread onlyPRAGMA_SHADOW_PROGRAM:String = "#pragma shadow_program_check"

@:value("#pragma opengl3")staticfinalinlineread onlyPRAGMA_OPENGL3:String = "#pragma opengl3"

@:value("#pragma opengl4")staticfinalinlineread onlyPRAGMA_OPENGL4:String = "#pragma opengl4"

@:value("#version 150")staticfinalinlineread onlyOPENGL3_VERSION:String = "#version 150"

@:value("#version 300 es")staticfinalinlineread onlyOPENGL3_VERSION_ES:String = "#version 300 es"

@:value("#version 450")staticfinalinlineread onlyOPENGL4_VERSION:String = "#version 450"

@:value([])staticGLOBAL_FLAGS:Array<String> = []

Static methods

staticstaticInit():Void

staticfromSources(vert:String, frag:String, ?flags:Array<String>, ?output:FoxShader):FoxShader

staticprocessIncludes(source:String):String

staticfromAsset(name:String, ?flagsDefs:Array<String>):FoxShader

staticdefineName(name:String):String

staticcombine(shaderA:FoxShader, shaderB:FoxShader):FoxShader

Handy little function to combine different fragment and vertex programs from two different shaders into one without recompiling sources!

Note: since this shader uses programs from other shaders, destroy() won't delete the program on the GPU and destroying shaderA or shaderB will cause issues when trying to use this shader So make sure to use it carefully.

The result object contains the frag from shaderA and the vert from shaderB.

staticsanitizeFlags(flags:Array<String>):Array<String>

Constructor

new()

Variables

privatecontext:Context3D

privategl:WebGLRenderContext

shadow:FoxShader

Version of the shader for the shadow pass only

assetsKey:String

program:Program3D

@:value(new StringMap())textureInput:Map<String, FoxShaderTextureInput> = new StringMap()

@:value(new StringMap())uniformCache:Map<String, FoxUniformCache> = new StringMap()

@:value({ position : -1, texCoord : -1, normal : -1, tangent : -1, color : -1, boneWeight : -1, boneIndex : -1, instanceData : { data0 : -1, data1 : -1, data2 : -1, color : -1 } })finalattribIdx:{texCoord:Int, tangent:Int, position:Int, normal:Int, instanceData:{data2:Int, data1:Int, data0:Int, color:Int}, color:Int, boneWeight:Int, boneIndex:Int} = { position : -1, texCoord : -1, normal : -1, tangent : -1, color : -1, boneWeight : -1, boneIndex : -1, instanceData : { data0 : -1, data1 : -1, data2 : -1, color : -1 } }

@:value(-1)__uSkinnedLocation:Int = -1

Cached skin location for fast access

@:value(-1)__bonesDataLocation:Int = -1

Cached bone data location for fast access

@:value(-1)__bonesDataSizeLocation:Int = -1

@:value(-1)__prevBonesDataLocation:Int = -1

@:value(-1)__uInstancedLocation:Int = -1

Cached instanced location for fast access

@:value(false)__hasLights:Bool = false

@:value(false)__isCombined:Bool = false

Variable to keep track of combined shaders

@:value(false)__needsCompiling:Bool = false

When loading a shader, it won't be compiled right away, instead it will be compiled when needed for rendering. This should be set only once per shader.

This is required for async/threaded resource loading, as the programs fail to link when in a separate thread (I believe there's a fix to it but I don't know).

If any uniform is set while this flag is enabled, it will be saved uploaded to the GPU once the shader been compiled.

@:value([])read onlyshaderDefines:Array<String> = []

The preprocessor flags for this shader.

private@:value(new Float32Array(16))__tmpMatrix:Float32Array = new Float32Array(16)

A temporary array to store matrix values, cached for speed

Methods

compile():Void

Compiles the shader. Used internally. Maybe one day it'll support async.

While the shader isn't compiled, no uniform should be set, else they will be lost.

initCache():Void

recompile(?flags:Array<String>):Void

Recompiles this shader using the cached vert and frag sources.

Optionally you can provide a new shader flags array.

Note: If this shader is a combined shader (check combine() for details), a new shader will be created and this will be marked as not combined.

inlinegetVertexShaderLog():String

inlinegetFragmentShaderLog():String

setFloat(name:String, value:Float):Void

setInt(name:String, value:Int):Void

inlinesetBool(name:String, value:Bool):Void

setSampler2D(name:String, value:FoxTexture):Void

setFloatArray(name:String, values:Array<Float>):Void

setIntArray(name:String, values:Array<Int>):Void

inlinesetBoolArray(name:String, values:Array<Bool>):Void

setVector2(name:String, v:Vector2):Void

setVector3(name:String, v:Vector3D):Void

setVector4(name:String, v:Dynamic):Void

setMatrix4(name:String, value:Matrix3D):Void

inlinesetMatrix4Array_Raw(name:String, value:Float32Array):Void

inlinegetGLProgram():Null<GLProgram>

inlinegetGLShadowProgram():Null<GLProgram>

destroy():Void