My Account


RSS
oZone3D.Net RSS Feeds»RSS 2.0 Feeds

Blogs
»Demoniak3D Blog
»JeGX's Infamous Lab

Sponsors


Modul8: real time video mixing and compositing


Link to Us

oZone3D.Net 100% Realtime 3D

»All Links

Web Partners

www.geeks3d.com
www.benchmarkhq.ru
www.tdt3d.com
www.steph3d.net
www.g-truc.net
www.worldpcspecs.com


Banners Exchange

www.jmax-hardware.com
cgindia.blogspot.com
grapejuice.c.la
www.game-lab.com


Links Exchange

»CYGAD's 3DXtra

Search
Google
Web
oZone3D.Net
 
oZone3D.Net - Demoniak3D Developer Guide


» Back To Index

Demoniak3D/LUA API: Progammable shaders handling library

The HYP_GPUShader library ensures the management of the vertex and pixel shaders (programmable shaders).
HYP_GPUShader.Activate
HYP_GPUShader.Desactivate

HYP_GPUShader.Enable
HYP_GPUShader.Disable

HYP_GPUShader.SetConstant_1i
HYP_GPUShader.SetConstant_2i
HYP_GPUShader.SetConstant_3i
HYP_GPUShader.SetConstant_4i

HYP_GPUShader.AllocArray_1iv
HYP_GPUShader.SetArrayElement_1iv
HYP_GPUShader.AllocArray_2iv
HYP_GPUShader.SetArrayElement_2iv
HYP_GPUShader.AllocArray_3iv
HYP_GPUShader.SetArrayElement_3iv
HYP_GPUShader.AllocArray_4iv
HYP_GPUShader.SetArrayElement_4iv

HYP_GPUShader.SetConstant_1f
HYP_GPUShader.SetConstant_2f
HYP_GPUShader.SetConstant_3f
HYP_GPUShader.SetConstant_4f

HYP_GPUShader.AllocArray_1fv
HYP_GPUShader.SetArrayElement_1fv
HYP_GPUShader.AllocArray_2fv
HYP_GPUShader.SetArrayElement_2fv
HYP_GPUShader.AllocArray_3fv
HYP_GPUShader.SetArrayElement_3fv
HYP_GPUShader.AllocArray_4fv
HYP_GPUShader.SetArrayElement_4fv

HYP_GPUShader.SetConstant_4x4f

SetConstant_{1|2|3|4}i

SetConstant_{1|2|3|4}i allows to create or to update an integer {1|2|3|4}D uniform variable. The name of this varibale must exist in the source code of the shader.
Syntaxe
HYP_GPUShader.SetConstant_1i( shader_name, uniform_name, x );
HYP_GPUShader.SetConstant_2i( shader_name, uniform_name, x, y );
HYP_GPUShader.SetConstant_3i( shader_name, uniform_name, x, y, z );
HYP_GPUShader.SetConstant_4i( shader_name, uniform_name, x, y, z, w );
  • shader_name - [STR127] - shader name.
  • uniform_name - [STR64] - uniform name.
  • x, y, z, w - [INTEGER] - uniform values.
Exemple
HYP_GPUShader.SetConstant_1i( "skin_shader", "skin_type", 3 );

SetConstant_{1|2|3|4}f

SetConstant_{1|2|3|4}f allows to create or to update a real {1|2|3|4}D uniform variable. The name of this varibale must exist in the source code of the shader.
Syntaxe
HYP_GPUShader.SetConstant_1f( shader_name, uniform_name, x );
HYP_GPUShader.SetConstant_2f( shader_name, uniform_name, x, y );
HYP_GPUShader.SetConstant_3f( shader_name, uniform_name, x, y, z );
HYP_GPUShader.SetConstant_4f( shader_name, uniform_name, x, y, z, w );
  • shader_name - [STR127] - shader name.
  • uniform_name - [STR64] - uniform name.
  • x, y, z, w - [REAL] - uniform values.
Exemple
HYP_GPUShader.SetConstant_1f( "skin_shader", "opacity", 0.74 );

SetConstant_4x4f

SetConstant_4x4f allows to pass to the shader a constant of the type stamps 4x4. The name of the constant must exist in the source code of the shader. This matrix respects the OpenGL convention (column matrix - columns vectors):
|x'|   | m_0  m_4  m_8   m_12 |   |x|
|y'| = | m_1  m_5  m_9   m_13 | * |y|
|z'|   | m_2  m_6  m_10  m_14 |   |z|
|1 |   | m_3  m_7  m_11  m_15 |   |1|

		<--> <-->  <-->  <-->
		 X     Y     Z   Position
		axis  axis  axis
Syntax
HYP_GPUShader.SetConstant_4x4f( shader_name, constant_name, 
m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15 );
  • shader_name - [STR127] - character string representing the name of the shader to which the constant is passed.
  • constant_name - [STR64] - character string representing the name of the constant.
  • m0 à m15 - [REAL] - coefficients of the 4x4 matrix.

Activate

Activate allows to activate (i.e bind in OpenGL terms) a gpu shader.
Syntaxe
HYP_GPUShader.Activate( shader_name );
  • shader_name - [STR127] - shader name.
Example
-- Activate the shader.
//
HYP_GPUShader.Activate( "myShader" );

-- Set the color map.
--
HYP_GPUShader.SetConstant_1i( "myShader", "colorMap", 0 );	
-- We have finish so we can desactivate the shader.
--
HYP_GPUShader.Desactivate( "myShader" );

Desactivate

Desactivate allows to desactive (i.e bind(0) in OpenGL terms) a gpu shader previously bound with Activate.
Syntaxe
HYP_GPUShader.Desactivate( shader_name );
  • shader_name - [STR127] - shader name.

Enable

Enable allows to enable a gpu shader.
Syntaxe
HYP_GPUShader.Enable( shader_name );
  • shader_name - [STR127] - shader name.

Disable

Disable allows to disable a un gpu shader.
Syntaxe
HYP_GPUShader.Disable( shader_name );
  • shader_name - [STR127] - shader name.

AllocArray_{1|2|3|4}iv

AllocArray_{1|2|3|4}iv allows to allocate an array of {1|2|3|4}D integer in order to create an uniform array.
Syntaxe
HYP_GPUShader.AllocArray_1iv( shader_name, uniform_name, count );
HYP_GPUShader.AllocArray_2iv( shader_name, uniform_name, count );
HYP_GPUShader.AllocArray_3iv( shader_name, uniform_name, count );
HYP_GPUShader.AllocArray_4iv( shader_name, uniform_name, count );
  • shader_name - [STR127] - shader name.
  • uniform_name - [STR64] - uniform array name.
  • count - [INTEGER] - number of elements of the array.
Exemple
HYP_GPUShader.AllocArray_1iv( "convolutionShader", "kernel", 9 );

SetArrayElement_{1|2|3|4}iv

SetArrayElement_{1|2|3|4}iv allows to initialize an element of an uniform array.
Syntaxe
HYP_GPUShader.SetArrayElement_1iv( shader_name, uniform_name, index, x );
HYP_GPUShader.SetArrayElement_2iv( shader_name, uniform_name, index, x, y );
HYP_GPUShader.SetArrayElement_3iv( shader_name, uniform_name, index, x, y, z );
HYP_GPUShader.SetArrayElement_4iv( shader_name, uniform_name, index, x, y, z, w );
  • shader_name - [STR127] - shader name.
  • uniform_name - [STR64] - uniform array name.
  • index - [INTEGER] - element index.
  • x, y, z, w - [INTEGER] - element value.
Exemple
HYP_GPUShader.AllocArray_1iv( "convolutionShader", "kernel", 9 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 0, 1.0 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 1, 2.0 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 2, 1.0 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 3, 2.0 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 4, 4.0 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 5, 2.0 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 6, 1.0 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 7, 2.0 );
HYP_GPUShader.SetArrayElement_1iv( "convolutionShader", "kernel", 8, 1.0 );

AllocArray_{1|2|3|4}fv

AllocArray_{1|2|3|4}fv allows to allocate an array of {1|2|3|4}D real in order to create an uniform array.
Syntaxe
HYP_GPUShader.AllocArray_1fv( shader_name, uniform_name, count );
HYP_GPUShader.AllocArray_2fv( shader_name, uniform_name, count );
HYP_GPUShader.AllocArray_3fv( shader_name, uniform_name, count );
HYP_GPUShader.AllocArray_4fv( shader_name, uniform_name, count );
  • shader_name - [STR127] - shader name.
  • uniform_name - [STR64] - uniform array name.
  • count - [INTEGER] - number of elements of the array.
Exemple
HYP_GPUShader.AllocArray_2fv( "convolutionShader", "offset", 9 );

SetArrayElement_{1|2|3|4}fv

SetArrayElement_{1|2|3|4}fv allows to initialize an element of an uniform array.
Syntaxe
HYP_GPUShader.SetArrayElement_1fv( shader_name, uniform_name, index, x );
HYP_GPUShader.SetArrayElement_2fv( shader_name, uniform_name, index, x, y );
HYP_GPUShader.SetArrayElement_3fv( shader_name, uniform_name, index, x, y, z );
HYP_GPUShader.SetArrayElement_4fv( shader_name, uniform_name, index, x, y, z, w );
  • shader_name - [STR127] - shader name.
  • uniform_name - [STR64] - uniform array name.
  • index - [INTEGER] - element index.
  • x, y, z, w - [REAL] - element value.
Exemple
HYP_GPUShader.AllocArray_2fv( "convolutionShader", "offset", 9 );

local image_width = 0.0;
local image_height = 0.0;

image_width, image_height = HYP_Texture.GetDimensions( "wallpaper" );

local step_w = 1.0/image_width;
local step_h = 1.0/image_height;

HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 0, -step_w, -step_h);
HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 1, 0.0, -step_h);
HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 2, step_w, -step_h);
HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 3, -step_w, 0.0);
HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 4, 0.0, 0.0);
HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 5, step_w, 0.0);
HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 6, -step_w, step_h);
HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 7, 0.0, step_h);
HYP_GPUShader.SetArrayElement_2fv("convShader", "offset", 8, step_w, step_h);




Language:


Demoniak3D
Current Version: 1.23.0
»Demoniak3D
»Download
»Libraries and Plugins
»Demos
»Online Help - Reference Guide
»Codes Samples


GPU Caps Viewer
Current Version: 1.5.2
»GPU Caps Viewer
»GPU DB Submissions


FurMark
Current Version: 1.4.0
»FurMark
»Benchmark Submissions


PhysX FluidMark
Current Version: 1.0.0
»PhysX FluidMark
»Benchmark Submissions


Geeks3D News


Sponsors



Visitors Map

Page generated in 0.071670055389404 seconds.