Crystal Space
Welcome, Guest. Please login or register.
October 20, 2014, 10:30:44 pm

Login with username, password and session length
Search:     Advanced search
9010 Posts in 2044 Topics by 8765 Members
Latest Member: Damianwwnarta
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Game Content Creation
| | |-+  Q: multiple semi-transparent objects?
« previous next »
Pages: [1] Print
Author Topic: Q: multiple semi-transparent objects?  (Read 6320 times)
Kriss
Newbie
*
Posts: 49



View Profile
« on: October 14, 2007, 02:48:49 pm »

I'd like to ask about usage of z-buffer for semi-transparent models, because in the past I had problems placing such meshes in CS3D. Can't remember clearly, but I think I tried every option (<zuse /> <zfill /> and etc...)
Sometimes I messed with other environment (only to realize that it became partially invisible behind semi-transparent object).
By semi-transparent I mean usual object with .PNG or .DDS semi-transparent texture.
What options should I choose to see one semi-transparent object through another?
Because I fail to understand what was wrong...
CS version was/is 1.0rc1 or 2...
« Last Edit: October 15, 2007, 06:32:06 pm by Kriss » Logged
Darek
Newbie
*
Posts: 48



View Profile
« Reply #1 on: October 15, 2007, 02:38:17 pm »

make sure that you using PER VERTEX lighting for your transparent objects.
e.g.
    <material name="abc">
      <shader type="standard">std_lighting_fixed</shader>
      <shadervar name="tex diffuse" type="texture">abc</shadervar>
    </material>
Logged
Kriss
Newbie
*
Posts: 49



View Profile
« Reply #2 on: October 15, 2007, 05:47:02 pm »

Thank you! That helped me, but only partially (rough meshes, just to test it) notice how far leaves sticking out of invisible plane that still exist on some of the semi-transparent meshes. The trunk is still visible because it has higher priority (object vs. alpha) although I tried both priorities during test.

Not sure what's the problem... I'm using CELStart 1.0 version8 or something like that...
DL-ing CELStart v1.2 at the moment, but Darek, I heard that you was able to "override" that problem by creating custom renderloop. Can't you give me a sample plz?

I know about <alpha><binary/></alpha>, but still I'd like use semi-transparent meshes... Smiley

Added: Few moments ago tried same thing on CELStart v1.2 with same results...
« Last Edit: October 18, 2007, 10:29:33 am by Kriss » Logged
bookeater2
Newbie
*
Posts: 45


View Profile Email
« Reply #3 on: October 16, 2007, 06:18:51 pm »

I recently asked if full alpha face sorting features current work in CS, and am not currently sure what the answer is.
Logged
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« Reply #4 on: October 18, 2007, 09:51:24 am »

For dynamicaly generated semi-transparant meshes i used the following:

  _mesh->GetMeshObject()->SetMixMode(CS_FX_ALPHA);
  _mesh->SetZBufMode(CS_ZBUF_TEST);
  _mesh->SetRenderPriority(_engine->GetAlphaRenderPriority());

These properties can also be defined in the world file.

For the texture i set the following
txtDemo->GetTextureHandle()->SetAlphaType(csAlphaMode::alphaSmooth);

In the world file, the culler for the sector should be set to "frustvis". Don't use "dynavis" because it will cull objects that
are completely "obscured" by other meshes, no matter if they are semi-transparant or not.
 
<cullerp>crystalspace.culling.frustvis</cullerp>
Logged
Kriss
Newbie
*
Posts: 49



View Profile
« Reply #5 on: October 18, 2007, 11:23:18 am »

rvhaasen
Good to see you here Smiley
So what you're saying is I need something like
<priority>alpha</priority> (I described priorities in my previous post here)
<mixmode><alpha /></mixmode>
<ztest />
Am I correct?
I'm asking because I already tried this variant with both of possible cullers, and the result always was "back2front", in other words far meshes are covering ones that closer...
Whether I use method that Darek posted here or not.

But I don't know how to write "texture" part in XML, as for cullers, yes, dynavis will probably (look my topic about XML just below this one) cull everything behind these meshes, to avoid this you just need to write <viscull>no</viscull> to these meshes (can't remember what to do in 3ds)

P.S. If you have something new regarding 3ds exporter, can you send it on my e-mail? Or share with everyone? Smiley
« Last Edit: October 18, 2007, 11:58:11 am by Kriss » Logged
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« Reply #6 on: October 19, 2007, 11:13:25 am »

Hi Kriss,

the manual only discusses the "binary alpha" and "keycolor" modes.
I checked the source code for other modes: in plugins\csparser\services\syntaxldr.cpp you can see 3 types:

1- "smooth"
2- "binary"
3-"smooth"


So in order to alpha-blend based on an per-texel-alpha that is present in the texture, this should  be possible with.

<texture name="transparent">
    <file>mytexture.png</file>
    <alpha><smooth/></alpha>
</texture>


About the 3ds exporter:
i'm now picking up my activities on the 3dsmax exporter. The latest version has full shader-support.
I designed it in such a way that it should be convenient to use. This version is almost ready.
If you/others are interested i can send you a version as soon it is "ready to be used/tested"
Logged
Kriss
Newbie
*
Posts: 49



View Profile
« Reply #7 on: October 19, 2007, 03:42:49 pm »

rvhaasen
Works like a charm. I already posted in my 3rd post here about <alpha><binary/></alpha>, but with <alpha><smooth /></alpha> everything works with semi-transparency. But allow me to post certain parts of code to explain (just to explain everything, forgive me for being too informative, but I remember when I didn't understand a thing here Smiley ):
<textures>
  <texture name="leaves.dds"> <file>./tex/leaves.dds</file><alpha><smooth /></alpha></texture>
</textures>

...

<meshfact name="Leaves">
 <plugin>genmeshFact</plugin>
 <priority>alpha</priority>
 <ztest />
  <params>
   <mixmode><alpha /></mixmode>
   ...
  </params>
</meshfact>

And that's all. Below is an additional line I used, it creates "nothing" for collision detection (in other words disables collision detection) and for visibility culling (disables visibility culling, since I use dynavis, regrettably my previous advice aren't working). Yes, with lines below instead of 2 certain lines above, it worked on both cullers.

     </params>
  <polymesh><viscull /><colldet /></polymesh>
 </meshfact>

As an ex-FPS-gamer I prefer dynavis where it's less possible to have major slow-downs when you hastily turn your "head" to face something with too complex geometry. I just don't like this to happen so unexpectedly

OffTopic:
Regarding 3ds exporter:
Don't you want to create a topic?
There you can explain how to use this exporter, how much of the previous code and conventions (like _g_ for genmeshes and such) you used. Did you redo "particles" part, since it was outdated in PlaneShift exporter and so on...
And attach exporter itself please, since I'd like to try it and to participate a little...
BTW in recent couple of days I've added "support" for materials with just colors and without texture, they can be added like this (m - material):
format "<material name=\"%\"> <color red=\"%\" green=\"%\" blue=\"%\" /></material>\n" m.name ( m.diffuse.red / 255 ) ( m.diffuse.green / 255 ) ( m.diffuse.blue / 255 ) to:WorldFileOut
and other misc stuff, like conditions to have both colldet and viscull switched off for certain mesh (but you already saw it in this post) and so on.
Later I'd like to add "Custom Property" for mesh to be able to control whether it has (collision detection && visibility culling) mesh inside itself or not, and whether to place it on meshFact or independently for each instance.
Same for normal exporting. I added it long ago but didn't even test it, since it takes too long to export them and I'd like to be able to export normals for certain meshes (in case there will be problems otherwise).
And more (it comes)
P.S. Don't quote everything below "OffTopic" line since I'd like to delete it (or move to new topic)...
« Last Edit: October 20, 2007, 03:43:04 am by Kriss » Logged
Darek
Newbie
*
Posts: 48



View Profile
« Reply #8 on: October 19, 2007, 03:50:52 pm »

bunch of my custom renderloops:
(note that i'm not using 'diffuse' or 'standard' but 'ppl' 'pvl' 'pplshd' which stands per pixel lighted/pervertex/shadows etc)

<?xml version="1.0" encoding="UTF-8"?>
<params>
  <name>renderloop</name>
  <steps>
    <!-- ambient lighting -->
    <step plugin="crystalspace.renderloop.step.generic">
      <shadertype>ambient</shadertype>
      <zoffset>yes</zoffset>
      <portaltraversal/>
      <zuse/>
    </step>
    <!-- per pixel lighting -->
    <step plugin="crystalspace.renderloop.step.lightiter">
      <steps>
        <!-- diffuse lighting -->
        <step plugin="crystalspace.renderloop.step.generic">
          <shadertype>ppl</shadertype>
          <zoffset>no</zoffset>
          <ztest/>
        </step>
      </steps>
    </step>
    <!-- per vertex lighting -->
    <step plugin="crystalspace.renderloop.step.generic">
      <shadertype>pvl</shadertype>
      <zoffset>no</zoffset>
      <zuse/>
    </step>
  </steps>
</params>



<?xml version="1.0" encoding="utf-8" ?>
<params>
  <name>renderloop</name>
  <steps>
    <!-- ambient lighting -->
    <step plugin="crystalspace.renderloop.step.generic">
      <shadertype>ambient</shadertype>
      <zoffset>yes</zoffset>
      <portaltraversal/>
      <zmesh/>
    </step>
    <!-- terrain base -->
    <step plugin="crystalspace.renderloop.step.generic">
      <shadertype>terrain base</shadertype>
      <zoffset>no</zoffset>
      <portaltraversal/>
      <zuse/>
    </step>
    <!-- terrain splatting with shadows -->
    <step plugin="crystalspace.renderloop.step.lightiter">
      <steps>
        <!-- stencil shadows -->
        <step plugin="crystalspace.renderloop.step.shadow.stencil">
          <steps>
            <!-- diffuse lighting -->
            <step plugin="crystalspace.renderloop.step.generic">
              <shadertype>terrain splat</shadertype>
              <zoffset>no</zoffset>
              <zuse/>
            </step>
          </steps>
        </step>
      </steps>
    </step>
    <!-- per pixel lighting -->
    <step plugin="crystalspace.renderloop.step.lightiter">
      <steps>
        <!-- diffuse lighting -->
        <step plugin="crystalspace.renderloop.step.generic">
          <shadertype>ppl</shadertype>
          <zoffset>no</zoffset>
          <ztest/>
        </step>
      </steps>
    </step>
    <!-- per pixel lighting with shadows -->
    <step plugin="crystalspace.renderloop.step.lightiter">
      <steps>
        <!-- stencil shadows -->
        <step plugin="crystalspace.renderloop.step.shadow.stencil">
          <steps>
            <!-- diffuse lighting -->
            <step plugin="crystalspace.renderloop.step.generic">
              <shadertype>pplshd</shadertype>
              <zoffset>no</zoffset>
              <ztest/>
            </step>
          </steps>
        </step>
      </steps>
    </step>
    <!-- per vertex lighting -->
    <step plugin="crystalspace.renderloop.step.generic">
      <shadertype>pvl</shadertype>
      <zoffset>no</zoffset>
      <zmesh/>
    </step>
  </steps>
</params>


Logged
bookeater2
Newbie
*
Posts: 45


View Profile Email
« Reply #9 on: October 19, 2007, 08:06:55 pm »

Quote
<texture name="transparent">
    <file>mytexture.png</file>
    <alpha><smooth/></alpha>
</texture>

If that feature works somone should add it to the options in Blender2Crystal
Logged
Kriss
Newbie
*
Posts: 49



View Profile
« Reply #10 on: October 21, 2007, 04:19:58 am »

Thanks, Darek. Now I need to read more about renderloops Smiley
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 9.865 seconds with 16 queries.