[SCRIPT] DLLs pour Unity3D
Re: DLLs pour Unity3D
Après tests et analyses, Nuance RealSpeak et Acapela sont les meilleurs. AT&T est en 16khz (!) et Cepstral® n'a pas de voix Française (non Canadienne !!!).
JP
JP
Re: DLLs pour Unity3D
J'avais également jeté un coup d'oeil, je suis d'accord avec ton analyse
En tout cas la dll est vraiment géniale
En tout cas la dll est vraiment géniale
Re: DLLs pour Unity3D
Merci.
Gros bémol pour Acapela. L'achat d'un pack langage n'est pas suffisant. Il faut OBLIGATOIREMENT le logiciel INFOVOX qui (bien sur) coûte cher. Sinon, le pack langue n'est pas accessible via l'api SAPI. Je viens d'en faire l’expérience. C'est dommage car la qualité ( Claire est incroyable) est au dessus des autres.
Nuance RealSpeak est finalement le seul choix abordable.
JP
Gros bémol pour Acapela. L'achat d'un pack langage n'est pas suffisant. Il faut OBLIGATOIREMENT le logiciel INFOVOX qui (bien sur) coûte cher. Sinon, le pack langue n'est pas accessible via l'api SAPI. Je viens d'en faire l’expérience. C'est dommage car la qualité ( Claire est incroyable) est au dessus des autres.
Nuance RealSpeak est finalement le seul choix abordable.
JP
Re: DLLs pour Unity3D
Un up pour signaler qu'il maintenant possible d’accéder au pipeline de rendu d'Unity à partir de DLLs externes.
Voir ici :
Sur la scène de démo , il y a un triangle coloré effectuant un rotation.
Code du C# appelant le script :
Source C++ du plugin
Direct3D ET Opengl.
JP
Voir ici :
GéniaaaaallllllllllLow-level Native Plugin Interface
In addition to the basic script interface, Native Code Plugins in Unity can receive callbacks when certain events happen. This is mostly used to implement low-level rendering in your plugin and enable it to work with Unity's multithreaded rendering.
Sur la scène de démo , il y a un triangle coloré effectuant un rotation.
Code du C# appelant le script :
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class UseRenderingPlugin : MonoBehaviour {
// Native plugin rendering events are only called if a plugin is used
// by some script. This means we have to DllImport at least
// one function in some active script.
// For this example, we'll call into plugin's SetTimeFromUnity
// function and pass the current time so the plugin can animate.
[DllImport ("RenderingPlugin")]
private static extern void SetTimeFromUnity (float t);
IEnumerator Start () {
yield return StartCoroutine("CallPluginAtEndOfFrames");
}
private IEnumerator CallPluginAtEndOfFrames ()
{
while (true) {
// Wait until all frame rendering is done
yield return new WaitForEndOfFrame();
// Set time for the plugin
SetTimeFromUnity (Time.timeSinceLevelLoad);
// Issue a plugin event with arbitrary integer identifier.
// The plugin can distinguish between different
// things it needs to do based on this ID.
// For our simple plugin, it does not matter which ID we pass here.
GL.IssuePluginEvent (1);
}
}
}
Code : Tout sélectionner
// Example low level rendering Unity plugin
#include "UnityPluginInterface.h"
#include <math.h>
#include <stdio.h>
// --------------------------------------------------------------------------
// Include headers for the graphics APIs we support
#if SUPPORT_D3D9
#include <d3d9.h>
#endif
#if SUPPORT_OPENGL
#if UNITY_WIN
#include <gl/GL.h>
#else
#include <OpenGL/OpenGL.h>
#endif
#endif
// --------------------------------------------------------------------------
// Helper function to print a string
static void DebugLog (const char* str)
{
#if UNITY_WIN
OutputDebugStringA (str);
#else
printf ("%s", str);
#endif
}
// --------------------------------------------------------------------------
// SetTimeFromUnity, an example function we export which is called by one of the scripts.
static float g_Time;
extern "C" void EXPORT_API SetTimeFromUnity (float t) { g_Time = t; }
// --------------------------------------------------------------------------
// UnitySetGraphicsDevice
static int g_DeviceType = -1;
#if SUPPORT_D3D9
static IDirect3DDevice9* g_D3D9Device;
// In D3D9 case, we'll also create a dynamic vertex buffer just to demonstrate
// how to handle D3D9 device resets.
static IDirect3DVertexBuffer9* g_D3D9DynamicVB;
#endif
extern "C" void EXPORT_API UnitySetGraphicsDevice (void* device, int deviceType, int eventType)
{
// Set device type to -1, i.e. "not recognized by our plugin"
g_DeviceType = -1;
#if SUPPORT_D3D9
// If we've got a D3D9 device, remember device pointer and device type.
// The pointer we get is IDirect3DDevice9.
if (deviceType == kGfxRendererD3D9)
{
DebugLog ("Set D3D9 graphics device\n");
g_D3D9Device = (IDirect3DDevice9*)device;
g_DeviceType = deviceType;
// Create or release a small dynamic vertex buffer depending on the event type.
switch (eventType) {
case kGfxDeviceEventInitialize:
case kGfxDeviceEventAfterReset:
// After device is initialized or was just reset, create the VB.
if (!g_D3D9DynamicVB)
g_D3D9Device->CreateVertexBuffer (1024, D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0, D3DPOOL_DEFAULT, &g_D3D9DynamicVB, NULL);
break;
case kGfxDeviceEventBeforeReset:
case kGfxDeviceEventShutdown:
// Before device is reset or being shut down, release the VB.
if (g_D3D9DynamicVB)
{
g_D3D9DynamicVB->Release();
g_D3D9DynamicVB = NULL;
}
break;
}
}
#endif
#if SUPPORT_OPENGL
// If we've got an OpenGL device, remember device type. There's no OpenGL
// "device pointer" to remember since OpenGL always operates on a currently set
// global context.
if (deviceType == kGfxRendererOpenGL)
{
DebugLog ("Set OpenGL graphics device\n");
g_DeviceType = deviceType;
}
#endif
}
// --------------------------------------------------------------------------
// SetDefaultGraphicsState
//
// Helper function to setup some "sane" graphics state. Rendering state
// upon call into our plugin can be almost completely arbitrary depending
// on what was rendered in Unity before.
// Before calling into the plugin, Unity will set shaders to null,
// and will unbind most of "current" objects (e.g. VBOs in OpenGL case).
//
// Here, we set culling off, lighting off, alpha blend & test off, Z
// comparison to less equal, and Z writes off.
static void SetDefaultGraphicsState ()
{
#if SUPPORT_D3D9
// D3D9 case
if (g_DeviceType == kGfxRendererD3D9)
{
g_D3D9Device->SetRenderState (D3DRS_CULLMODE, D3DCULL_NONE);
g_D3D9Device->SetRenderState (D3DRS_LIGHTING, FALSE);
g_D3D9Device->SetRenderState (D3DRS_ALPHABLENDENABLE, FALSE);
g_D3D9Device->SetRenderState (D3DRS_ALPHATESTENABLE, FALSE);
g_D3D9Device->SetRenderState (D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
g_D3D9Device->SetRenderState (D3DRS_ZWRITEENABLE, FALSE);
}
#endif
#if SUPPORT_OPENGL
// OpenGL case
if (g_DeviceType == kGfxRendererOpenGL)
{
glDisable (GL_CULL_FACE);
glDisable (GL_LIGHTING);
glDisable (GL_BLEND);
glDisable (GL_ALPHA_TEST);
glDepthFunc (GL_LEQUAL);
glEnable (GL_DEPTH_TEST);
glDepthMask (GL_FALSE);
}
#endif
}
// --------------------------------------------------------------------------
// UnityRenderEvent
// This will be called for GL.IssuePluginEvent script calls; eventID will
// be the integer passed to IssuePluginEvent. In this example, we just ignore
// that value.
extern "C" void EXPORT_API UnityRenderEvent (int eventID)
{
// Unknown graphics device type? Do nothing.
if (g_DeviceType == -1)
return;
// A colored triangle. Note that colors will come out differently
// in D3D9 and OpenGL, for example, since they expect color bytes
// in different ordering.
struct MyVertex {
float x, y, z;
unsigned int color;
};
MyVertex verts[3] = {
{ -0.5f, -0.25f, 0, 0xFFff0000 },
{ 0.5f, -0.25f, 0, 0xFF00ff00 },
{ 0, 0.5f , 0, 0xFF0000ff },
};
// Some transformation matrices: rotate around Z axis for world
// matrix, identity view matrix, and identity projection matrix.
float phi = g_Time;
float cosPhi = cosf(phi);
float sinPhi = sinf(phi);
float worldMatrix[16] = {
cosPhi,-sinPhi,0,0,
sinPhi,cosPhi,0,0,
0,0,1,0,
0,0,0.7f,1,
};
float identityMatrix[16] = {
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1,
};
float projectionMatrix[16] = {
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1,
};
// Setup sane graphics state (a helper function above)
SetDefaultGraphicsState ();
// Now do actual rendering!
#if SUPPORT_D3D9
// D3D9 case
if (g_DeviceType == kGfxRendererD3D9)
{
// Transformation matrices
g_D3D9Device->SetTransform (D3DTS_WORLD, (const D3DMATRIX*)worldMatrix);
g_D3D9Device->SetTransform (D3DTS_VIEW, (const D3DMATRIX*)identityMatrix);
g_D3D9Device->SetTransform (D3DTS_PROJECTION, (const D3DMATRIX*)projectionMatrix);
// Vertex layout
g_D3D9Device->SetFVF (D3DFVF_XYZ|D3DFVF_DIFFUSE);
// Texture stage states to output vertex color
g_D3D9Device->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
g_D3D9Device->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_CURRENT);
g_D3D9Device->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_D3D9Device->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
g_D3D9Device->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_DISABLE);
g_D3D9Device->SetTextureStageState (1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
// Copy vertex data into our small dynamic vertex buffer. We could have used
// DrawPrimitiveUP just fine as well.
void* vbPtr;
g_D3D9DynamicVB->Lock (0, 0, &vbPtr, D3DLOCK_DISCARD);
memcpy (vbPtr, verts, sizeof(verts));
g_D3D9DynamicVB->Unlock ();
g_D3D9Device->SetStreamSource (0, g_D3D9DynamicVB, 0, sizeof(MyVertex));
// Draw!
g_D3D9Device->DrawPrimitive (D3DPT_TRIANGLELIST, 0, 1);
}
#endif
#if SUPPORT_OPENGL
// OpenGL case
if (g_DeviceType == kGfxRendererOpenGL)
{
// Transformation matrices
glMatrixMode (GL_MODELVIEW);
glLoadMatrixf (worldMatrix);
glMatrixMode (GL_PROJECTION);
// Tweak the projection matrix a bit to make it match what identity
// projection would do in D3D9 case.
projectionMatrix[10] = 2.0f;
projectionMatrix[14] = -1.0f;
glLoadMatrixf (projectionMatrix);
// Vertex layout
glVertexPointer (3, GL_FLOAT, sizeof(verts[0]), &verts[0].x);
glEnableClientState (GL_VERTEX_ARRAY);
glColorPointer (4, GL_UNSIGNED_BYTE, sizeof(verts[0]), &verts[0].color);
glEnableClientState (GL_COLOR_ARRAY);
// Draw!
glDrawArrays (GL_TRIANGLES, 0, 3);
}
#endif
}
JP
- leoufdetou
- Messages : 729
- Inscription : 16 Oct 2011 21:30
- Localisation : Sens
Re: DLLs pour Unity3D
OO,j'en connais qui vont être content,moi le premier
Merci encore ZJP,le lieneur fou
Merci encore ZJP,le lieneur fou
La Netiquette du forum à lire avant de poster
viewtopic.php?f=7&t=2964
Règle de base du forum "Scripting Javascript, C# et Boo:
viewtopic.php?f=7&t=3307
viewtopic.php?f=7&t=2964
Règle de base du forum "Scripting Javascript, C# et Boo:
viewtopic.php?f=7&t=3307
Re: DLLs pour Unity3D
Je suis aussi tombe dessus en parcourant le change log mais j'ai une question qui pour le moment reste sans reponse au file de mes recherches.Un up pour signaler qu'il maintenant possible d’accéder au pipeline de rendu d'Unity
Est il possible d'acceder aux textures, materials, shaders de unity dans un plugin graphique ?
Re: DLLs pour Unity3D
Là tu peux le dire. Cela ouvre un certains nombres de perspectives super intéressante, moi qui ai toujours fait du bas niveau (pour l'essentiel DX9) je vais décortiquer cela avec beaucoup d'attentionleoufdetou a écrit :OO,j'en connais qui vont être content,moi le premier
Merci encore ZJP,le lieneur fou
m'ci m'sieurs JP
Pas d'aide par MP, le forum est là pour ça.
En cas de doute sur les bonnes pratiques à adopter sur le forum, consulter la Charte et sa FAQ
Re: DLLs pour Unity3D
De rien.
JP
Pas certain. Pas encore trouvé d'infos la dessus. Mais appliquer des shaders de post-rendu ne devrait poser aucun soucis. Exploiter enfin les shaders ".FX" de nvidia, ainsi que FxComposerEst il possible d'acceder aux textures, materials, shaders de unity dans un plugin graphique ?
JP
Re: DLLs pour Unity3D
Merci !Un up pour signaler qu'il maintenant possible d’accéder au pipeline de rendu d'Unity à partir de DLLs externes.
Dernière édition par Freelax le 24 Fév 2012 04:51, édité 1 fois.
Re: DLLs pour Unity3D
Super interessant effectivement, ceci dit ca reste pour un public averti