Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 510 511 [512] 513 514 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 908562 times)

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7665 on: August 15, 2015, 06:42:09 am »

So in Unity, I want to create a shader that behaves like an alpha mask. Suppose the scene with regular materials is rendered as one image. However, one mesh has my hypothetical shader on it. Instead of rendering the object, a hole is cut in the rendered scene, revealing a flat, unlit texture underneath the "rendered scene" layer. If you've ever seen how characters in plaid clothes were animated in old cartoons, that's the effect I'm going for.

I have the feeling I'm not going to accomplish this with any of Unity's built-in stuff or standard assets, and I don't want to go with an Asset Store solution. So, where do I start reading to figure out how to accomplish this?
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7666 on: August 15, 2015, 07:04:00 am »

Render a transparent texture that writes to the depth buffer.

Easier may be having a texture applied to the shader that's mapped to screen coordinates.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7667 on: August 15, 2015, 10:32:12 am »

Is there any sort of decent documentation anywhere about writing shaders in Unity? I looked around but can't find anything useful. Unity's own documentation is pathetic, you can find some function names and primitives mentioned some places, but no clue as to how you're meant to use them or connected them together.

 So far I'm just cutting and pasting stuff from other sources hoping it works without know what the allowed syntax even is, or how the sections work. Even the guy at the game studio where I'm helping out, who writes the Unity shaders didn't understand half the stuff in the shader I cobbled together for my terrain renderer, so I get the feeling it's hard to come by good documentation.

I couldn't understand any of the stuff in his shader, and I had a simple request: how to make the output from my shader brighter? Any sort of brightness / gamma thing I can play with, and he couldn't get it to work. It seems like a simple thing, just scaling up the colour values.
« Last Edit: August 15, 2015, 10:37:30 am by Reelya »
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7668 on: August 15, 2015, 11:19:58 am »

I just did a shitload of google searching to find out what I needed.
Logged

Moghjubar

  • Bay Watcher
  • Science gets you to space.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7669 on: August 15, 2015, 12:26:06 pm »


I couldn't understand any of the stuff in his shader, and I had a simple request: how to make the output from my shader brighter? Any sort of brightness / gamma thing I can play with, and he couldn't get it to work. It seems like a simple thing, just scaling up the colour values.

I can't believe it would be that hard... I mean, that shit is basically trivial in GLSL.

I'll help look around, be back if I find anything.

Edit: So, I don't have Unity installed to mess around with things... but looking at the docs, apparently Unity uses either CG or HLSL so those are the docs you should probably look at.  In any case, from http://docs.unity3d.com/Manual/ShaderTut2.html  I see "texture modulated by color" so that seems simple enough.
« Last Edit: August 15, 2015, 12:42:51 pm by Moghjubar »
Logged
Steam ID
Making things in Unity
Current Project: Demon Legend
Made This too (publisher abandoned ) Farworld Pioneers
Mastodon

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7670 on: August 15, 2015, 12:50:26 pm »

Oh wow. I've skimmed the ShaderLab stuff before so I knew it was pretty skimpy, but damn. It's just uncommented source and a token "Take our word for it, this is what it does" line for every function. At least I found a snippet that (apparently) maps a texture to screen space. The might as well have just said "Go read a book on OpenGL, dickhead" under every heading.

Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Scoops Novel

  • Bay Watcher
  • Talismanic
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7671 on: August 17, 2015, 02:13:42 pm »

Can anyone code a parser (config style) for this forum so i can view it in Siilihai? It's a forum client (like thunderbird for email or pidgin for messaging), and i'm itching to use it with this. There's a parser maker in the client itself, and Simplemachine forums are supported. I've appealed to Toady to take 20 minutes and install a TapaTalk plugin for the site. He's verra busy though so i hope u can take it off his hands.

He's unfamiliar with how TapaTalk works and fears security issues, so it's up to us to code a parser for Siilihai.

Wish i'd thought of this before!
« Last Edit: August 19, 2015, 09:29:09 am by Novel Scoops »
Logged
Reading a thinner book

Arcjolt (useful) Chilly The Endoplasm Jiggles

Hums with potential    a flying minotaur

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7672 on: August 17, 2015, 08:28:43 pm »

Is that a config file or do you actually need a script to pull all the data off the forum and display it in a slightly different format?
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Puzzlemaker

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7673 on: August 17, 2015, 10:01:22 pm »

Damn it took me way to long to get it to select and move a sphere around the screen.

Working on Imperium, still.

http://www.bay12forums.com/smf/index.php?topic=151256.0

Hopefully I can have a working prototype sometime this year  :P
Logged
The mark of the immature man is that he wants to die nobly for a cause, while the mark of the mature man is that he wants to live humbly for one.

Scoops Novel

  • Bay Watcher
  • Talismanic
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7674 on: August 18, 2015, 01:12:13 am »

Is that a config file or do you actually need a script to pull all the data off the forum and display it in a slightly different format?

It looks a lot like a config file, but I could be wrong.

Edit: Toady's unfamiliar with how TapaTalk works and fears security issues, so it's up to us to code a parser for Siilihai. The client itself has a parser maker.
« Last Edit: August 19, 2015, 09:28:34 am by Novel Scoops »
Logged
Reading a thinner book

Arcjolt (useful) Chilly The Endoplasm Jiggles

Hums with potential    a flying minotaur

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7675 on: August 21, 2015, 01:52:02 am »

Okay, I'm at wit's end here trying to multiply double precision floats in x86 Assembly. Our first assignment (to be due on the first day of class before we've even had a single lecture for some screwed up reason) is to write a program that calculates the surface area and volume of a sphere of a given radius. The relevant section looks a bit like this so far:
Code: (Assembly) [Select]
PI equ 0x400921fb54442d18                                   ;Represents 8-byte float Pi (NASM Manual)
;rbx = radius

mov qword   rax, PI                                         ;Set rax to Pi so we can calculate surface area 4*Pi*r*r
add         rax, rax                                        ;Pi + Pi = 2*Pi
add         rax, rax                                        ;2*Pi + 2*Pi = 4*Pi
mul         rbx                                             ;Multiply 4*Pi by r, result in rdx:rax (most significant in rdx, least significant in rax?)
;Something about storing rax to memory here?
mov qword   rcx, rdx                                        ;Save significant part into rcx
;More stuff
Once that's done, I'm going to need to multiply by r again, store that result, then multiply by r and 1/3 to get the volume.

Can I just ditch the least significant digits between multiplications or will that incur noticeable rounding errors?

Best guide I could find was this, but I'm not really sure what's going on with the saving to and retrieving from [bignum]. Maybe I'd be better off working with the SSE vector registers?
(Edit: It looks like that's for multiplying two 32-bits to make a 64-bit. I only need to multiply two 64-bits to make another 64-bit. Maybe just chopping off the end is fine? It's limited to 15 digits of accuracy with my value for Pi anyways.)
« Last Edit: August 21, 2015, 02:06:23 am by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7676 on: August 21, 2015, 01:56:56 am »

rax will have the result, rdx the overflow (as you noted yourself)

so mov rax in rcx
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7677 on: August 21, 2015, 03:09:52 am »

rax will have the result, rdx the overflow (as you noted yourself)

so mov rax in rcx
So can you help me clarify this? Suppose we have two 32-bit floats (for simplicity's sake.) In memory they are stored as 1 bit for sign, 8 bits for exponent, and the remaining bits for the mantissa:

SEEEEEEE EMMMMMMM MMMMMMMM MMMMMMMM
01000000 01001001 00001111 11011010 = 3.1415925
00111110 10101010 10101010 10101010 = 0.33333331


Suppose they are multiplied through arcane magic and you get a 64-bit float like so:

/---------------EDX---------------\ /---------------EAX---------------\
SEEEEEEE EEEEMMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM
00111111 11110000 11000001 01010010 00010110 11000001 11011000 11001100 = 1.047197426696175   
(I got the binary from the proper decimal value.)

Assuming I can just drop EAX, I'd be left with:
/---------------EDX---------------\
SEEEEEEE EEEEMMMM MMMMMMMM MMMMMMMM
00111111 11110000 11000001 01010010 = 1.8808997   
(When read as a 64-bit float.)

Which seems like unacceptable rounding error, not to mention it's not a readable 32-bit float anymore. Maybe it's better with 64-bit floats? Maybe I shouldn't assume it would switch to 64-bit exponents from the MUL instruction?

For reference, I used these to come up with the conversions:
http://babbage.cs.qc.edu/courses/cs341/IEEE-754hex64.html
http://babbage.cs.qc.edu/courses/cs341/IEEE-754.html
« Last Edit: August 21, 2015, 12:43:42 pm by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7678 on: August 21, 2015, 03:42:34 am »

no that'd be your life now, there are ops to keep working with doubles until you divide them and then you get back a normal single precision float


you could probably divide by 1 to return to single precision if you aren't allowed to touch mmx stuff

otherwise cvtsd2ss

Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7679 on: August 21, 2015, 03:50:27 am »

no that'd be your life now, there are ops to keep working with doubles until you divide them and then you get back a normal single precision float


you could probably divide by 1 to return to single precision if you aren't allowed to touch mmx stuff

otherwise cvtsd2ss
We're allowed to use it, and that's what I'll probably end up doing. It's just another set of operations I have to figure out on my own (including the 16 byte alignment it requires), with only 3 days left to finish.
« Last Edit: August 21, 2015, 03:54:30 am by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?
Pages: 1 ... 510 511 [512] 513 514 ... 796