Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 27-May-2011 07:55:39

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

conversion from blender

draw a model in blender, then export. OS3D displays it is not correct, totally different dimensions. What could be wrong?

Offline

#2 27-May-2011 09:36:42

Nodrev
Scol Language & OS3D developer
From: Nantes, France
Registered: 29-Dec-2009
Posts: 197

Re: conversion from blender

This is due to the way you edit your object:
You have sized the object while you where not in "edit mode" (edit mode is when you can move the vertex, "tab" key to switch between edit mode and object mode).
It's wrong to size an object, allways size the vertices instead; it's a good habit to allways scale/rot/move in edit mode (selecting all vertices with "A" key) instead doing those action in object mode.
To verify that your object is scaled, show the "transform property" dialog ("N" key), you will see that the "scaleX/scaleY/scaleZ" properties are not to the "1" value.
It must allways be "1" before exporting.
So, there is a way to reset the scale: in object mode, select your mesh, and go to the object menu, then clear/apply, and then "Apply scale/rotation to object data" (ctrl A 1). For 3DSMax users, it's the same thing that "Reset XForm".
You will notice that the scale parameters are now to "1".

Let me know if it solves the issue.

Last edited by Nodrev (27-May-2011 10:03:40)

Offline

#3 27-May-2011 10:18:38

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

Re: conversion from blender

did so anyway dimensions have not changed

Offline

#4 27-May-2011 10:20:35

Nodrev
Scol Language & OS3D developer
From: Nantes, France
Registered: 29-Dec-2009
Posts: 197

Re: conversion from blender

What are the "size" params of your object in the transform propety dialog (DimX/DimY/DimZ)?

Offline

#5 27-May-2011 10:33:24

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

Re: conversion from blender

8.474, 8.474, 0.129.
My object is composed of several joint projects. After the conversion OS3D displays a cube with default size

Offline

#6 27-May-2011 10:35:39

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

Re: conversion from blender

write sequence you are exporting

Offline

#7 27-May-2011 12:46:02

Nodrev
Scol Language & OS3D developer
From: Nantes, France
Registered: 29-Dec-2009
Posts: 197

Re: conversion from blender

I just upload a video on OpenSpace3D's youtube channel, explaining how to export a single mesh from blender, it's simpler and more suitable than writing how to do step by step wink:

Flash required

Last edited by Nodrev (27-May-2011 12:51:49)

Offline

#8 27-May-2011 13:26:58

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: conversion from blender

Well, who write this howto ? big_smile

Note : i move this thread to 3D forum instead ...

Offline

#9 27-May-2011 13:28:34

Nodrev
Scol Language & OS3D developer
From: Nantes, France
Registered: 29-Dec-2009
Posts: 197

Re: conversion from blender

Me big_smile, this morning, just before diner <edit>I mean lunch</edit> tongue

Last edited by Nodrev (27-May-2011 13:35:04)

Offline

#10 27-May-2011 13:31:34

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: conversion from blender

Luckily, it was before diner ! lol

[Edit] And i do a copy  silly ! [/Edit]

Offline

#11 27-May-2011 13:34:58

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

Re: conversion from blender

wow, thank you. renamed and earned ...

Offline

#12 27-May-2011 15:39:07

Nodrev
Scol Language & OS3D developer
From: Nantes, France
Registered: 29-Dec-2009
Posts: 197

Re: conversion from blender

So, did you succeed to export your mesh, or did you still have size issues?

Offline

#13 28-May-2011 19:03:35

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

Re: conversion from blender

all successfully.
you do not know how to do stuff like fur

Offline

#14 28-May-2011 21:52:16

Nodrev
Scol Language & OS3D developer
From: Nantes, France
Registered: 29-Dec-2009
Posts: 197

Re: conversion from blender

Hi,

You'll need a shader for that, I started to make one, but something is wrong in it, and got to go now.
I'll let you know i I succeed to do the effect...

Here what i have so far:

FurV.cg

struct typInput
{
  float4 Position : POSITION;
  float3 Normal   : NORMAL;
  float2 uv0      : TEXCOORD0;
};

struct typOutput
{
  float4 Position : POSITION;
  float4 light    : COLOR1;
  float2 uv0      : TEXCOORD0;
};

typOutput main(typInput inData, 
       uniform float3   lightPosition,
       uniform float    furHeight, 
       uniform float    furAmbient, 
       uniform float3x3 normalMatrix, 
       uniform float2x2 textureMatrix0, 
       uniform float4x4 modelViewMatrix,
       uniform float4x4 modelViewProjMatrix,
       uniform float multiPassNumber)
{
  typOutput outData;
  
  // Compute the size of fur for this pass iteration
  furHeight = furHeight * (1.0 / multiPassNumber);

  float3 normal        = inData.Normal;
  float3 vertex        = inData.Position.xyz + normal * furHeight;
  normal               = normalize(mul(normalMatrix, normal));
  float3 position      = float3(mul(modelViewMatrix,float4(vertex, 1.0)));
  float3 lightToVertex = normalize(lightPosition - position);
  float  diffuse       = dot(lightToVertex, normal);
  outData.light        = furAmbient + diffuse;
  outData.uv0          = mul(textureMatrix0, inData.uv0);
  outData.Position     = mul(modelViewProjMatrix, float4(vertex, 1.0));
  return outData;
}

FurF.cg:

struct typOut
{
  float4 fragColor : COLOR;
};

struct typIn
{
  float4 Position: POSITION;
  float4 light   : COLOR1;
  float2 uv0     : TEXCOORD0;
};


typOut main(typIn             inData,
            uniform sampler2D noiseTexture,
            uniform sampler2D colorTexture,
            uniform float     spacing,
            uniform float     transparency)
{
   typOut outData;

   float furValue = tex2D(noiseTexture, inData.uv0 * float2(spacing, spacing) ).x;
   outData.fragColor = float4(float3(inData.light) * tex2D(colorTexture, inData.uv0).rgb, transparency * furValue);
   return outData;
}

Fur.program:

// CG simple Fur
vertex_program OpenSpace3D/fur_vs cg 
{ 
  source fur/FurV.cg
  profiles vs_1_1 arbvp1
  entry_point main
  
  default_params
  {
    param_named_auto lightPosition light_position_object_space 0
    param_named furHeight float 0.15
    param_named furAmbient float 0.02
    param_named normalMatrix inverse_transpose_view_matrix
    param_named textureMatrix0 texture_matrix 1
    param_named modelViewMatrix view_matrix
        param_named modelViewProjMatrix viewproj_matrix  //projection_matrix
    //param_named_auto passNumber pass_number
    param_named_auto multiPassNumber pass_iteration_number
  }
} 

fragment_program OpenSpace3D/fur_ps cg
{ 
  source fur/FurF.cg
  profiles ps_2_x arbfp1
  entry_point main
    
  default_params
  {
    param_named spacing float 0.0
    param_named transparency float 0.3
  }
}

And finally, fur.material:

material OpenSpace3D/Growing_Fur
{
technique
{
pass base_coat
{
ambient 0.7 0.7 0.7
diffuse 0.5 0.8 0.5
specular 1.0 1.0 1.0 1.5

vertex_program_ref OpenSpace3D/fur_vs
{
}

fragment_program_ref OpenSpace3D/fur_ps
{
}

texture_unit
{
texture Fur/fur.tga
tex_coord_set 0
filtering trilinear
}

}

pass grow_fur
{
ambient 0.7 0.7 0.7
diffuse 0.8 1.0 0.8
specular 1.0 1.0 1.0 64
depth_write off

scene_blend src_alpha one
iteration 10

vertex_program_ref OpenSpace3D/fur_vs
{
}

fragment_program_ref OpenSpace3D/fur_ps
{
}

texture_unit
{
texture Fur/fur.tga
tex_coord_set 0
filtering trilinear
}

            texture_unit
{
texture Fur/skin.jpg
tex_coord_set 0
filtering trilinear
}

}
}
}

Shader code is adapted from the one I had found here (inspired from this article), the original zip contains the two textures.
If someone got time to fix it...

And as a side note, don't forget to create a new topic when talking about something else that your initial question smile

Offline

#15 29-May-2011 08:19:45

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

Re: conversion from blender

I do not even know how to use these code smile

I thought to create an object in a blender with fur and convert OS3D

Last edited by slavavs (29-May-2011 08:21:34)

Offline

#16 29-May-2011 23:39:13

Nodrev
Scol Language & OS3D developer
From: Nantes, France
Registered: 29-Dec-2009
Posts: 197

Re: conversion from blender

I did not have the time to check that today...
I'm sure i'm near a good solution...
Exporting an object with fur will not work, or you'll have to "draw" the "hairs" one by one, which will cause a huge number of polys even for a small object, that's certainly not what you want to do.
I'll keep you in touch.

Don't worry about the complexity, in the end, you'll just have to add a "Change material" plugIt on the object you want some fur on big_smile

Last edited by Nodrev (29-May-2011 23:40:48)

Offline

#17 30-May-2011 07:00:28

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

Re: conversion from blender

ok, thanks!

Offline

#18 14-Jun-2011 20:55:30

Nodrev
Scol Language & OS3D developer
From: Nantes, France
Registered: 29-Dec-2009
Posts: 197

Re: conversion from blender

Arkeon worked on it, and he succeed to make it work:
moitarzan.png

Here the code you'll need in your resource path:
Fur.material:

material OpenSpace3D/Growing_Fur
{
    technique
    {
        pass base_coat
        {
            ambient 0.698039 0.698039 0.698039 1
            diffuse 0.698039 0.698039 0.698039 1
            specular 0.898039 0.898039 0.898039 1 20

            vertex_program_ref ambient_vs
            {
            }

            fragment_program_ref ambient_ps
            {
            }

            texture_unit
            {
                texture Fur/skin.jpg
                filtering linear linear linear
            }

            texture_unit
            {
                texture white.jpg
                filtering linear linear linear
            }
        }

        pass grow_fur
        {
            iteration 32 per_light
            ambient 0.65098 0.65098 0.65098 1
            diffuse 0.698039 0.698039 0.698039 1
            specular 0.898039 0.898039 0.898039 1 20
            scene_blend alpha_blend
            depth_write off

            vertex_program_ref OpenSpace3D/fur_vs
            {
                param_named UVScale float4 0.8 0.8 0 0
                param_named furHeight float4 0.12 0 0 0
                param_named gravity float4 0 0.06 0 0
                param_named totalPass float4 32 0 0 0
            }

            fragment_program_ref OpenSpace3D/fur_ps
            {
            }

            texture_unit
            {
                texture Fur/Fur.tga
                filtering linear linear linear
            }

            texture_unit
            {
                texture Fur/skin.jpg
                filtering linear linear linear
            }
        }
    }
}

FurV.cg:

struct typInput {
  float4 Position : POSITION;
  float3 Normal   : NORMAL;
  float2 uv0      : TEXCOORD0;
  float4 c        : COLOR0;
};

struct typOutput {
  float4 Position : POSITION;
  float4 light    : COLOR1;
  float2 T0       : TEXCOORD0;
  float2 T1       : TEXCOORD1;
  float2 T2       : TEXCOORD2;
};

typOutput main(typInput inData, 
      uniform float3 gravity,
      uniform float furHeight,
      uniform float totalPass,
      uniform float2 UVScale,
      uniform float4x4 wvpMat,
      uniform float4x4 iwpMat,
      uniform float4x4 wpMat,
      uniform float4 eyePosition,
      uniform float3 ambientColor,
      uniform float4 lightPosition,
      uniform float4 lightAttenuation,
      uniform float3 lightDiffuseColor,
      uniform float3 Ke,
      uniform float3 Ka,
      uniform float3 Kd,
      uniform float3 Ks,
      uniform float shininess,
      uniform float multiPassIter){
  typOutput outData;

  float4 normal = mul(wpMat, float4(inData.Normal, 1.0));
  // light
  float4 tmpcolor = inData.c;
  
  furHeight = furHeight * ((1.0 / (totalPass + 1)) * (multiPassIter + 1));
  float3 vGravity = mul(wpMat, float4(gravity, 0.0)).xyz;
  
  //float pp = 3.14 * 0.5 * Layer; // depth paramete
    //float A = dot(normal, vGravity);  //A is the angle between surface normal and gravity vector
  float k = pow(((1.0 / (totalPass + 1)) * (multiPassIter + 1)), 3); // We use the pow function, so that only the tips of the hairs bend
                             // As layer goes from 0 to 1, so by using pow(..) function is still 
                             // goes form 0 to 1, but it increases faster! exponentially
  
  float3 P = inData.Position.xyz + (inData.Normal * furHeight);
  P = P + vGravity*k;
  
  float4 znormal = 1 - dot(normal, float4(0,0,1,0));
  outData.T0 = inData.uv0 * UVScale;
    outData.T1 = inData.uv0 * UVScale + znormal.xy * 0.0007;
    outData.T2 = inData.uv0;  
  
  lightPosition = mul(iwpMat, lightPosition);
  eyePosition = mul(iwpMat, eyePosition);
  
  float3 N = normalize(inData.Normal);
  float3 emissive = Ke;
  float3 ambient = Ka * ambientColor;
  float3 L = normalize(lightPosition).xyz;
  float diffuseLight = max(dot(L, N), 0);
  float3 diffuse = Kd * lightDiffuseColor * diffuseLight;
  float3 V = normalize(eyePosition).xyz;
  float3 H = normalize(L + V);
  float specularLight = pow(max(dot(H, N), 0), shininess);
  if (diffuseLight <= 0) specularLight = 0;
  float3 specular = Ks * lightDiffuseColor * specularLight;
  tmpcolor.xyz = emissive + ambient + specular + diffuse;  
  
  outData.Position     = mul(wvpMat, float4(P, 1.0));
  outData.light        = tmpcolor;
  return outData;
}

FurF.cg:

struct typOut {
  float4 fragColor : COLOR;
};

struct typIn {
  float4 Position : POSITION;
  float4 light    : COLOR1;
  float2 T0       : TEXCOORD0;
  float2 T1       : TEXCOORD1;
  float2 T2       : TEXCOORD2;
  float2 ambient  : TEXCOORD3;
};


typOut main(typIn             inData,
            uniform float3    vecLightDir,
            uniform sampler2D noiseTexture : register(s0),
            uniform sampler2D colorTexture : register(s1),
            uniform float     spacing,
            uniform float     transparency) {

   typOut outData;

  float4 furcolr        = tex2D(noiseTexture, inData.T0);
    float4 furcolr_offset = tex2D(noiseTexture, inData.T1);
  float4 texcolr        = tex2D(colorTexture, inData.T2);

  float4 color = furcolr_offset - furcolr;
    
    float4 fcolor = color;
  fcolor.a = color.a;
  
  // Y is the luma, and contains most of the information of the image
  
    fcolor = (texcolr * inData.light) + (fcolor * inData.light);
  fcolor.a = color.a;
  
  //float furValue = tex2D(noiseTexture, inData.uv0 * float2(spacing, spacing) ).x * transparency;
  //outData.fragColor = float4(float3(inData.light) * tex2D(colorTexture, inData.uv0).rgb, furValue);
  
  outData.fragColor = fcolor;
  return outData;
}

Fur.program:

// CG simple Fur
vertex_program OpenSpace3D/fur_vs cg
{
source Fur/FurV.cg
profiles vs_1_1 arbvp1
entry_point main

default_params
{
param_named furHeight float 0.15
param_named UVScale float2 1.0 1.0
param_named totalPass float 8
param_named_auto multiPassIter pass_iteration_number
param_named_auto wvpMat worldviewproj_matrix
param_named_auto wpMat world_matrix
param_named_auto iwpMat inverse_world_matrix
param_named_auto eyePosition camera_position
param_named_auto ambientColor ambient_light_colour
    param_named_auto lightPosition light_position 0
    param_named_auto lightDiffuseColor light_diffuse_colour 0
    param_named_auto shininess surface_shininess
    param_named_auto Ka surface_ambient_colour
    param_named_auto Kd surface_diffuse_colour
    param_named_auto Ke surface_emissive_colour
    param_named_auto Ks surface_specular_colour
}
}

fragment_program OpenSpace3D/fur_ps cg
{
source Fur/FurF.cg
profiles ps_2_x arbfp1
entry_point main

default_params
{
param_named spacing float 0.0
param_named transparency float 0.3
}
}

Offline

#19 15-Jun-2011 07:44:28

slavavs
Member
Registered: 9-Apr-2011
Posts: 137
Website

Re: conversion from blender

wow. I will try... thanks

Offline

Board footer

Powered by FluxBB